/// <summary>True if this element matches the given selector.</summary> public bool matches(string selectorText) { // Create the lexer: Css.CssLexer lexer = new Css.CssLexer(selectorText, this); // Read a value: Css.Value value = lexer.ReadValue(); // Read the selectors from the value: List <Css.Selector> selectors = new List <Css.Selector>(); Css.CssLexer.ReadSelectors(null, value, selectors); if (selectors.Count == 0) { return(false); } // Get renderable node: Css.IRenderableNode irn = (this as Css.IRenderableNode); if (irn == null) { // Can't select this element. return(false); } // Get the computed style: Css.ComputedStyle cs = irn.ComputedStyle; // Try and match it! return(selectors[0].StructureMatch(cs, new Css.CssEvent())); }
/// <summary>Gets the most suitable mapping to use for the given computed style if one has already been set.</summary> public void UpdateMap(Css.ComputedStyle style) { // Get the map value: Css.Value v; style.Properties.TryGetValue(GlobalProperty, out v); if (v != null) { // Update it: (v as Css.Units.WritingSystemMap).Map = GetMap(style); } }
/// <summary>Requires a writing system mapping for the given computed style.</summary> public int[] RequireMap(Css.ComputedStyle style) { // Get the map value: Css.Value v; style.Properties.TryGetValue(GlobalProperty, out v); if (v == null) { // Get it now: int[] mapValue = GetMap(style); // Cache it: v = new Css.Units.WritingSystemMap(mapValue); style.Properties[GlobalProperty] = v; return(mapValue); } // Get from the cached value: return((v as Css.Units.WritingSystemMap).Map); }