From 4c72e2f59a3ef0540f9e28c3fac3e749b34bfa979a66332b390a0c3d5f95ae8d Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Thu, 7 Nov 2019 10:53:45 +0000 Subject: [PATCH 1/2] Accepting request 746056 from GNOME:Next OBS-URL: https://build.opensuse.org/request/show/746056 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/librsvg?expand=0&rev=163 --- librsvg.changes | 6 ++++++ librsvg.spec | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/librsvg.changes b/librsvg.changes index d2b8068..9805a1c 100644 --- a/librsvg.changes +++ b/librsvg.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Nov 6 01:24:01 UTC 2019 - Yifan Jiang + +- Remove BuildRequires rust-std. The replacement rust-std-static + is already required by rust. + ------------------------------------------------------------------- Wed Oct 23 14:46:43 UTC 2019 - Bjørn Lie diff --git a/librsvg.spec b/librsvg.spec index ee485b2..6281f6d 100644 --- a/librsvg.spec +++ b/librsvg.spec @@ -33,7 +33,6 @@ BuildRequires: cargo BuildRequires: gobject-introspection-devel BuildRequires: pkgconfig BuildRequires: rust >= 1.34 -BuildRequires: rust-std BuildRequires: vala BuildRequires: pkgconfig(cairo) >= 1.16.0 BuildRequires: pkgconfig(cairo-png) >= 1.2.0 From 1ccad9b44d8f6464a90478f876b66e022900231a4ba7e8a6c10197592a947a48 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Thu, 7 Nov 2019 10:54:08 +0000 Subject: [PATCH 2/2] Accepting request 746179 from home:favogt:branches:GNOME:Factory - Add patches to fix coloring of symbolic icons (glgo#GNOME/librsvg#525): * 0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch * 0002-Compute-the-specificity-of-CSS-selectors.patch * 0003-525-Consider-specificity-when-applying-CSS-selector-.patch OBS-URL: https://build.opensuse.org/request/show/746179 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/librsvg?expand=0&rev=164 --- ...dd-struct-definition-for-CRSimpleSel.patch | 60 +++++++ ...ute-the-specificity-of-CSS-selectors.patch | 166 ++++++++++++++++++ ...cificity-when-applying-CSS-selector-.patch | 81 +++++++++ librsvg.changes | 8 + librsvg.spec | 5 +- 5 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch create mode 100644 0002-Compute-the-specificity-of-CSS-selectors.patch create mode 100644 0003-525-Consider-specificity-when-applying-CSS-selector-.patch diff --git a/0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch b/0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch new file mode 100644 index 0000000..4338a00 --- /dev/null +++ b/0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch @@ -0,0 +1,60 @@ +From 00795b4d94858be229da7e47c046f9f2bf3f579c Mon Sep 17 00:00:00 2001 +From: Federico Mena Quintero +Date: Wed, 6 Nov 2019 17:13:15 -0600 +Subject: [PATCH 1/3] croco.rs: Add struct definition for CRSimpleSel + +--- + rsvg_internals/src/croco.rs | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +diff --git a/rsvg_internals/src/croco.rs b/rsvg_internals/src/croco.rs +index 892aca9b..21ac8051 100644 +--- a/rsvg_internals/src/croco.rs ++++ b/rsvg_internals/src/croco.rs +@@ -6,9 +6,9 @@ use libc; + + // Opaque types from libcroco, or those which we only manipulate through libcroco functions + pub type CRString = gpointer; +-pub type CRSimpleSel = gpointer; + pub type CRParser = gpointer; + pub type CRTerm = gpointer; ++pub type CRAdditionalSel = gpointer; + + pub type CRStatus = u32; + +@@ -22,9 +22,22 @@ pub struct CRParsingLocation { + pub byte_offset: libc::c_uint, + } + ++#[repr(C)] ++pub struct CRSimpleSel { ++ pub type_mask: libc::c_int, ++ pub is_case_sentive: gboolean, ++ pub name: CRString, ++ pub combinator: libc::c_int, ++ pub add_sel: CRAdditionalSel, ++ pub specificity: libc::c_ulong, ++ pub next: *mut CRSimpleSel, ++ pub prev: *mut CRSimpleSel, ++ pub location: CRParsingLocation, ++} ++ + #[repr(C)] + pub struct CRSelector { +- pub simple_sel: CRSimpleSel, ++ pub simple_sel: *mut CRSimpleSel, + + pub next: *mut CRSelector, + pub prev: *mut CRSelector, +@@ -91,7 +104,7 @@ extern "C" { + pub fn cr_selector_ref(a_this: *mut CRSelector); + pub fn cr_selector_unref(a_this: *mut CRSelector) -> gboolean; + +- pub fn cr_simple_sel_to_string(a_this: CRSimpleSel) -> *mut libc::c_char; ++ pub fn cr_simple_sel_to_string(a_this: *mut CRSimpleSel) -> *mut libc::c_char; + + pub fn cr_string_peek_raw_str(a_this: CRString) -> *const libc::c_char; + +-- +2.23.0 + diff --git a/0002-Compute-the-specificity-of-CSS-selectors.patch b/0002-Compute-the-specificity-of-CSS-selectors.patch new file mode 100644 index 0000000..94288a6 --- /dev/null +++ b/0002-Compute-the-specificity-of-CSS-selectors.patch @@ -0,0 +1,166 @@ +From 5796011ea5232783ee89e8467a76656873a3f7b4 Mon Sep 17 00:00:00 2001 +From: Federico Mena Quintero +Date: Wed, 6 Nov 2019 17:59:53 -0600 +Subject: [PATCH 2/3] Compute the specificity of CSS selectors + +And remove the unused function CssRules::lookup() +--- + rsvg_internals/src/croco.rs | 2 ++ + rsvg_internals/src/css.rs | 44 ++++++++++++++++++++++--------------- + 2 files changed, 28 insertions(+), 18 deletions(-) + +diff --git a/rsvg_internals/src/croco.rs b/rsvg_internals/src/croco.rs +index 21ac8051..7bee041d 100644 +--- a/rsvg_internals/src/croco.rs ++++ b/rsvg_internals/src/croco.rs +@@ -11,6 +11,7 @@ pub type CRTerm = gpointer; + pub type CRAdditionalSel = gpointer; + + pub type CRStatus = u32; ++pub const CR_OK: u32 = 0; + + pub type CREncoding = u32; + pub const CR_UTF_8: CREncoding = 5; +@@ -105,6 +106,7 @@ extern "C" { + pub fn cr_selector_unref(a_this: *mut CRSelector) -> gboolean; + + pub fn cr_simple_sel_to_string(a_this: *mut CRSimpleSel) -> *mut libc::c_char; ++ pub fn cr_simple_sel_compute_specificity(a_this: *mut CRSimpleSel) -> CRStatus; + + pub fn cr_string_peek_raw_str(a_this: CRString) -> *const libc::c_char; + +diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs +index 2bb4a3b9..c8ae072c 100644 +--- a/rsvg_internals/src/css.rs ++++ b/rsvg_internals/src/css.rs +@@ -73,11 +73,17 @@ impl<'i> AtRuleParser<'i> for DeclParser { + } + + #[derive(Clone, Hash, PartialEq, Eq)] +-pub struct Selector(String); ++pub struct Selector { ++ name: String, ++ specificity: u64, ++} + + impl Selector { +- fn new(s: &str) -> Selector { +- Selector(s.to_string()) ++ fn new(s: &str, specificity: u64) -> Selector { ++ Selector { ++ name: s.to_string(), ++ specificity, ++ } + } + } + +@@ -196,10 +202,6 @@ impl CssRules { + decl_list.add_declaration(declaration); + } + +- pub fn lookup(&self, selector: &str) -> Option<&DeclarationList> { +- self.get_declarations(&Selector::new(selector)) +- } +- + pub fn get_declarations(&self, selector: &Selector) -> Option<&DeclarationList> { + self.selectors_to_declarations.get(selector) + } +@@ -219,12 +221,12 @@ impl CssRules { + let id = node_data.get_id(); + + // * +- if *selector == Selector::new("*") { ++ if selector.name == "*" { + return true; + } + + // tag +- if *selector == Selector::new(element_name) { ++ if selector.name == element_name { + return true; + } + +@@ -234,7 +236,7 @@ impl CssRules { + // tag.class#id + if let Some(id) = id { + let target = format!("{}.{}#{}", element_name, cls, id); +- if *selector == Selector::new(&target) { ++ if selector.name == target { + return true; + } + } +@@ -242,20 +244,20 @@ impl CssRules { + // .class#id + if let Some(id) = id { + let target = format!(".{}#{}", cls, id); +- if *selector == Selector::new(&target) { ++ if selector.name == target { + return true; + } + } + + // tag.class + let target = format!("{}.{}", element_name, cls); +- if *selector == Selector::new(&target) { ++ if selector.name == target { + return true; + } + + // didn't find anything more specific, just apply the class style + let target = format!(".{}", cls); +- if *selector == Selector::new(&target) { ++ if selector.name == target { + return true; + } + } +@@ -265,13 +267,13 @@ impl CssRules { + if let Some(id) = id { + // id + let target = format!("#{}", id); +- if *selector == Selector::new(&target) { ++ if selector.name == target { + return true; + } + + // tag#id + let target = format!("{}#{}", element_name, id); +- if *selector == Selector::new(&target) { ++ if selector.name == target { + return true; + } + } +@@ -375,7 +377,15 @@ unsafe extern "C" fn css_property( + while !cur_sel.is_null() { + let simple_sel = (*cur_sel).simple_sel; + ++ cur_sel = (*cur_sel).next; ++ + if !simple_sel.is_null() { ++ if cr_simple_sel_compute_specificity(simple_sel) != CR_OK { ++ continue; ++ } ++ ++ let specificity = u64::from((*simple_sel).specificity); ++ + let raw_selector_name = cr_simple_sel_to_string(simple_sel) as *mut libc::c_char; + + if !raw_selector_name.is_null() { +@@ -405,14 +415,12 @@ unsafe extern "C" fn css_property( + + handler_data + .css_rules +- .add_declaration(Selector::new(&selector_name), declaration); ++ .add_declaration(Selector::new(&selector_name, specificity), declaration); + } + Err(_) => (), // invalid property name or invalid value; ignore + } + } + } +- +- cur_sel = (*cur_sel).next; + } + } + +-- +2.23.0 + diff --git a/0003-525-Consider-specificity-when-applying-CSS-selector-.patch b/0003-525-Consider-specificity-when-applying-CSS-selector-.patch new file mode 100644 index 0000000..b02aedf --- /dev/null +++ b/0003-525-Consider-specificity-when-applying-CSS-selector-.patch @@ -0,0 +1,81 @@ +From 657d061bf66f1b289c8f915f21da82fa5915d920 Mon Sep 17 00:00:00 2001 +From: Federico Mena Quintero +Date: Wed, 6 Nov 2019 18:03:27 -0600 +Subject: [PATCH 3/3] (#525): Consider specificity when applying CSS selector + matches + +We still don't consider ordering of rules in stylesheets, but at least +we handle specificity for conflicting matches with this. + +Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/525 + +Without tests/fixtures/reftests/525-specificity-ref.png to avoid binary diff. +--- + rsvg_internals/src/css.rs | 8 ++++-- + tests/fixtures/reftests/525-specificity.svg | 27 +++++++++++++++++++++ + 2 files changed, 33 insertions(+), 2 deletions(-) + create mode 100644 tests/fixtures/reftests/525-specificity.svg + +diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs +index c8ae072c..dee9e9ba 100644 +--- a/rsvg_internals/src/css.rs ++++ b/rsvg_internals/src/css.rs +@@ -282,7 +282,7 @@ impl CssRules { + } + + pub fn get_matches(&self, node_data: &NodeData) -> Vec { +- self.selectors_to_declarations ++ let mut matches: Vec<_> = self.selectors_to_declarations + .iter() + .filter_map(|(selector, _)| { + if self.selector_matches_node(selector, node_data) { +@@ -292,7 +292,11 @@ impl CssRules { + } + }) + .map(Selector::clone) +- .collect() ++ .collect(); ++ ++ matches.as_mut_slice().sort_by(|sel_a, sel_b| sel_a.specificity.cmp(&sel_b.specificity)); ++ ++ matches + } + } + +diff --git a/tests/fixtures/reftests/525-specificity.svg b/tests/fixtures/reftests/525-specificity.svg +new file mode 100644 +index 00000000..2fb1c525 +--- /dev/null ++++ b/tests/fixtures/reftests/525-specificity.svg +@@ -0,0 +1,27 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +\ No newline at end of file +-- +2.23.0 + diff --git a/librsvg.changes b/librsvg.changes index 9805a1c..1589ae6 100644 --- a/librsvg.changes +++ b/librsvg.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Nov 7 07:51:06 UTC 2019 - Fabian Vogt + +- Add patches to fix coloring of symbolic icons (glgo#GNOME/librsvg#525): + * 0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch + * 0002-Compute-the-specificity-of-CSS-selectors.patch + * 0003-525-Consider-specificity-when-applying-CSS-selector-.patch + ------------------------------------------------------------------- Wed Nov 6 01:24:01 UTC 2019 - Yifan Jiang diff --git a/librsvg.spec b/librsvg.spec index 6281f6d..aa8771b 100644 --- a/librsvg.spec +++ b/librsvg.spec @@ -28,7 +28,10 @@ Group: Development/Libraries/C and C++ URL: https://wiki.gnome.org/Projects/LibRsvg Source0: https://download.gnome.org/sources/librsvg/2.46/%{name}-%{version}.tar.xz Source99: baselibs.conf - +# PATCH-FIX-UPSTREAM https://gitlab.gnome.org/GNOME/librsvg/issues/525 +Patch1: 0001-croco.rs-Add-struct-definition-for-CRSimpleSel.patch +Patch2: 0002-Compute-the-specificity-of-CSS-selectors.patch +Patch3: 0003-525-Consider-specificity-when-applying-CSS-selector-.patch BuildRequires: cargo BuildRequires: gobject-introspection-devel BuildRequires: pkgconfig