public override Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { // Read a name: Css.Value nameValue = value[1]; // Get the name: string name = nameValue.Text; // Read the value (a selector block): Css.Value block = value[2]; // Grab the block: SelectorBlockUnit sBlock = block as SelectorBlockUnit; // The block should now be a set of other blocks. // This set is accessible as sBlock.Rules. if (sBlock == null || name == null) { // Broken keyframe set. return(null); } // Get the frame set: List <Rule> rules = sBlock.Rules; if (rules == null || style.document == null) { // Broken keyframe set. return(null); } // Create it: return(new KeyframesRule(style, value, name, rules)); }
public override Rule LoadRule(Css.Rule parent, StyleSheet sheet, Css.Value value) { // Grab the sheet: ParentSheet = sheet; RawValue = value; // Simply read a block like normal: Css.Value blk = value[value.Count - 1]; // Grab it as a block unit: SelectorBlockUnit block = blk as SelectorBlockUnit; if (block == null) { // Broken page :( return(null); } // Grab the style: this.style = block.Style; return(this); }
public override Rule LoadRule(Css.Rule parent, StyleSheet sheet, Css.Value value) { // Grab the sheet: ParentSheet = sheet; RawValue = value; // Read a value: Css.Value val = value[1]; // Get the value as constant text: CounterName = val.Text; // Read a block like normal: Css.Value blk = value[value.Count - 1]; // Grab it as a block unit: SelectorBlockUnit block = blk as SelectorBlockUnit; if (block == null) { // Broken :( return(null); } // Grab the style: this.style = block.Style; return(this); }
public override Rule LoadRule(Css.Rule parent, StyleSheet sheet, Css.Value value) { // Grab the sheet: ParentSheet = sheet; RawValue = value; FontFeatureValuesRule parentRule = parent as FontFeatureValuesRule; // Add to lookup: parentRule.FeatureLookup[FeatureName] = this; // Load the OpenType rules now: int count = value.Count; // Get the block: PropertyMapUnit sBlock = value[count - 1] as PropertyMapUnit; if (sBlock == null) { // Try as a set instead: ValueSet set = value[count - 1] as ValueSet; if (set == null) { // Invalid/ unrecognised block. Ignore it. return(null); } // Get last one in the set: sBlock = set[set.Count - 1] as PropertyMapUnit; // still null? if (sBlock == null) { // Invalid/ unrecognised block. Ignore it. return(null); } } // - For each CSS property (each of which is a user defined identifier).. foreach (KeyValuePair <string, Css.Value> kvp in sBlock.Properties) { // Create our feature list: List <OpenTypeFeature> features = new List <OpenTypeFeature>(); // Map to open type feature now: ToOpenTypeFeature(kvp.Value, features); // Put it into the properties set: Properties[kvp.Key] = features; } return(this); }
public override Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { // Read a value: Css.Value val = value[1]; // Get the value as constant text: CharsetName = val.Text; // Note: Charset rule is obsolete. return(null); }
public override Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { // Read a value: Css.Value val = value[1]; // Load queries: Query = MediaQuery.Load(value, 2, value.Count - 1); // Get the value as constant text: Href = val.Text; return(new ImportRule(style, value, Query, Href)); }
/// <summary>Reads a rule from this lexer.</summary> public Rule ReadRules(out Rule[] set) { // Lexer is in selector mode - this simply blocks # from being recognised as a colour. SelectorMode = true; // Read a CSS value. This includes the block itself: Css.Value value = ReadValue(); // Convert it: Rule mainRule = ConvertToRule(LatestRule, value, Sheet, out set); LatestRule = mainRule; return(mainRule); }
public override Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { RawValue = value; ParentSheet = style; // Get the count: int count = value.Count; if (count == 1) { // Invalid return(null); } // Read a value: Css.Value val = value[1]; // Got a prefix? if (count >= 3) { prefix = val.Text.ToLower(); val = value[2]; } // Get the namespace: Namespace = new CssNamespace(val.Text); if (!string.IsNullOrEmpty(prefix)) { if (ParentSheet.Namespaces == null) { // Create prefix lookup: ParentSheet.Namespaces = new Dictionary <string, CssNamespace>(); } ParentSheet.Namespaces[prefix] = Namespace; } else { // Assign NS: ParentSheet.Namespace = Namespace; } return(this); }
public override Rule LoadRule(Css.Rule parent, StyleSheet sheet, Css.Value value) { // Grab the sheet: ParentSheet = sheet; RawValue = value; // Read a value: Css.Value val = value[1]; // Get the value as constant text: FontName = val.Text; int count = value.Count; // Get the block: SelectorBlockUnit sBlock = value[count - 1] as SelectorBlockUnit; if (sBlock == null) { // Try as a set instead: ValueSet set = value[count - 1] as ValueSet; if (set == null) { // Invalid/ unrecognised block. Ignore it. return(null); } // Get last one in the set: sBlock = set[set.Count - 1] as SelectorBlockUnit; // still null? if (sBlock == null) { // Invalid/ unrecognised block. Ignore it. return(null); } } Entries = sBlock.LoadAsRules(); return(this); }
public override Rule LoadRule(Css.Rule parent,StyleSheet style,Css.Value value){ // Read a block like normal: Css.Value blk=value[1]; // Grab it as a block unit: SelectorBlockUnit block=blk as SelectorBlockUnit; if(block==null){ // Broken :( return null; } // Grab the style: this.style=block.Style; return this; }
/// <summary>Called on this instance object to load it's values from the given value object.</summary> public virtual Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { return(null); }
public override Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { // Get the count: int count = value.Count; // Get the block: SelectorBlockUnit sBlock = value[count - 1] as SelectorBlockUnit; if (sBlock == null) { // This happens when it contains a *comma* or it's actually broken. // Try as a set instead: ValueSet set = value[count - 1] as ValueSet; if (set == null) { // Invalid/ unrecognised block. Ignore it. return(null); } // Get last one in the set: sBlock = set[set.Count - 1] as SelectorBlockUnit; // still null? if (sBlock == null) { // Invalid/ unrecognised block. Ignore it. return(null); } // Clear it: set[set.Count - 1] = null; // Clear the @media part too: value[0][0] = null; // For each part, build a query: List <SupportsQuery> results = new List <SupportsQuery>(); for (int i = 0; i < value.Count; i++) { Value part = value[i]; if (part == null) { continue; } SupportsQuery q = SupportsQuery.Load(part, 0, part.Count - 1); if (q != null) { results.Add(q); } } if (results.Count == 1) { Query = results[0]; } else { Query = new SupportsQueryList(results.ToArray()); } } else { // Build the media query: Query = SupportsQuery.Load(value, 1, count - 2); } return(this); }
public override Rule LoadRule(Css.Rule parent, StyleSheet style, Css.Value value) { // Get the count: int count = value.Count; // Get the block: SelectorBlockUnit sBlock = value[count - 1] as SelectorBlockUnit; if (sBlock == null) { // This happens in the following situations: // @media screen,projection{} (when it contains a *comma*) // @media screen; (broken css without an actual block) // Try as a set instead: ValueSet set = value[count - 1] as ValueSet; if (set == null) { // Invalid/ unrecognised block. Ignore it. return(null); } // Get last one in the set: sBlock = set[set.Count - 1] as SelectorBlockUnit; // still null? if (sBlock == null) { // Invalid/ unrecognised block. Ignore it. return(null); } // Clear it: set[set.Count - 1] = null; // Clear the @media part too: value[0][0] = null; // For each part, build a query: List <MediaQuery> results = new List <MediaQuery>(); for (int i = 0; i < value.Count; i++) { Value part = value[i]; if (part == null) { continue; } MediaQuery q = MediaQuery.Load(part, 0, part.Count - 1); if (q != null) { results.Add(q); } } if (results.Count == 1) { Query = results[0]; } else { Query = new MediaQueryList(results.ToArray()); } } else { // Build the media query: Query = MediaQuery.Load(value, 1, count - 2); } // Create the rule now: return(new MediaRule(style, value, Query, sBlock)); }