[librsvg: 13/26] Rename CssRules to Stylesheet



commit 5d4e309c84f2d23f694c358db7420bca5f3b174a
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Nov 8 13:32:54 2019 -0600

    Rename CssRules to Stylesheet

 rsvg_internals/src/css.rs      | 16 ++++++++--------
 rsvg_internals/src/document.rs | 14 +++++++-------
 rsvg_internals/src/node.rs     | 12 ++++++------
 3 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index fd32861d..ef36b26a 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -340,10 +340,10 @@ impl Selector {
     }
 }
 
-/// Contains all the mappings of selectors to style declarations
-/// that result from loading an SVG document.
+/// A parsed CSS stylesheet
 #[derive(Default)]
-pub struct CssRules {
+pub struct Stylesheet {
+    /// Maps a selector name to a list of property/value declarations
     selectors_to_declarations: HashMap<Selector, DeclarationList>,
 }
 
@@ -379,7 +379,7 @@ impl<'a> Iterator for DeclarationListIter<'a> {
     }
 }
 
-impl CssRules {
+impl Stylesheet {
     pub fn parse(&mut self, base_url: Option<&Url>, buf: &str) {
         if buf.is_empty() {
             return; // libcroco doesn't like empty strings :(
@@ -388,7 +388,7 @@ impl CssRules {
         unsafe {
             let mut handler_data = DocHandlerData {
                 base_url,
-                css_rules: self,
+                stylesheet: self,
                 selector: ptr::null_mut(),
             };
 
@@ -555,7 +555,7 @@ impl CssRules {
 
 struct DocHandlerData<'a> {
     base_url: Option<&'a Url>,
-    css_rules: &'a mut CssRules,
+    stylesheet: &'a mut Stylesheet,
     selector: *mut CRSelector,
 }
 
@@ -592,7 +592,7 @@ unsafe extern "C" fn css_import_style(
 
     if let Ok(aurl) = AllowedUrl::from_href(uri, handler_data.base_url) {
         // FIXME: handle CSS errors
-        let _ = handler_data.css_rules.load_css(&aurl);
+        let _ = handler_data.stylesheet.load_css(&aurl);
     } else {
         rsvg_log!("disallowed URL \"{}\" for importing CSS", uri);
     }
@@ -671,7 +671,7 @@ unsafe extern "C" fn css_property(
                         };
 
                         handler_data
-                            .css_rules
+                            .stylesheet
                             .add_declaration(Selector::new(&selector_name, specificity), declaration);
                     }
                     Err(_) => (), // invalid property name or invalid value; ignore
diff --git a/rsvg_internals/src/document.rs b/rsvg_internals/src/document.rs
index 2bfa7876..81af4708 100644
--- a/rsvg_internals/src/document.rs
+++ b/rsvg_internals/src/document.rs
@@ -8,7 +8,7 @@ use std::rc::Rc;
 
 use crate::allowed_url::{AllowedUrl, Fragment};
 use crate::create_node::create_node;
-use crate::css::CssRules;
+use crate::css::Stylesheet;
 use crate::error::LoadingError;
 use crate::handle::LoadOptions;
 use crate::io::{self, BinaryData};
@@ -212,7 +212,7 @@ pub struct DocumentBuilder {
     tree: Option<RsvgNode>,
     ids: HashMap<String, RsvgNode>,
     inline_css: String,
-    css_rules: CssRules,
+    stylesheet: Stylesheet,
 }
 
 impl DocumentBuilder {
@@ -222,7 +222,7 @@ impl DocumentBuilder {
             tree: None,
             ids: HashMap::new(),
             inline_css: String::new(),
-            css_rules: CssRules::default(),
+            stylesheet: Stylesheet::default(),
         }
     }
 
@@ -239,7 +239,7 @@ impl DocumentBuilder {
         }
 
         // FIXME: handle CSS errors
-        let _ = self.css_rules.load_css(&self.resolve_href(href)?);
+        let _ = self.stylesheet.load_css(&self.resolve_href(href)?);
 
         Ok(())
     }
@@ -318,16 +318,16 @@ impl DocumentBuilder {
     }
 
     pub fn build(mut self) -> Result<Document, LoadingError> {
-        self.css_rules.parse(self.load_options.base_url.as_ref(), &self.inline_css);
+        self.stylesheet.parse(self.load_options.base_url.as_ref(), &self.inline_css);
 
-        let DocumentBuilder { load_options, tree, ids, css_rules, .. } = self;
+        let DocumentBuilder { load_options, tree, ids, stylesheet, .. } = self;
 
         match tree {
             None => Err(LoadingError::SvgHasNoElements),
             Some(mut root) => {
                 if root.borrow().get_type() == NodeType::Svg {
                     for mut node in root.descendants() {
-                        node.borrow_mut().set_style(&css_rules);
+                        node.borrow_mut().set_style(&stylesheet);
                     }
 
                     let values = ComputedValues::default();
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index b98b8cc0..a2727f62 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -7,7 +7,7 @@ use std::fmt;
 
 use crate::bbox::BoundingBox;
 use crate::cond::{RequiredExtensions, RequiredFeatures, SystemLanguage};
-use crate::css::CssRules;
+use crate::css::Stylesheet;
 use crate::drawing_ctx::DrawingCtx;
 use crate::error::*;
 use crate::filters::FilterEffect;
@@ -210,9 +210,9 @@ impl NodeData {
     }
 
     /// Applies the CSS rules that match into the node's specified_values
-    fn set_css_styles(&mut self, css_rules: &CssRules) {
-        for selector in &css_rules.get_matches(self) {
-            if let Some(decl_list) = css_rules.get_declarations(selector) {
+    fn set_css_styles(&mut self, stylesheet: &Stylesheet) {
+        for selector in &stylesheet.get_matches(self) {
+            if let Some(decl_list) = stylesheet.get_declarations(selector) {
                 for declaration in decl_list.iter() {
                     self.specified_values
                         .set_property_from_declaration(declaration, &mut self.important_styles);
@@ -238,8 +238,8 @@ impl NodeData {
 
     // Sets the node's specified values from the style-related attributes in the pbag.
     // Also applies CSS rules in our limited way based on the node's tag/class/id.
-    pub fn set_style(&mut self, css_rules: &CssRules) {
-        self.set_css_styles(css_rules);
+    pub fn set_style(&mut self, stylesheet: &Stylesheet) {
+        self.set_css_styles(stylesheet);
         self.set_style_attribute();
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]