/// <summary>Called when this element got added to the DOM.</summary> internal override void AddedToDOM() { Css.ReflowDocument doc = document as Css.ReflowDocument; if (doc != null) { if (doc.AttributeIndex != null) { // Index element if needed: AddToAttributeLookups(); } // Make sure the stylesheet is present: doc.RequireStyleSheet(this); } // Update its css by telling it the parent changed. // This affects inherit, height/width etc. Style.Computed.ParentChanged(); if (doc != null) { // Request a layout: doc.RequestLayout(); } }
public ScreenMediaType(ReflowDocument doc) { // Load all the values now: Css.Value width = new Css.Units.PxUnit(Width); Css.Value height = new Css.Units.PxUnit(Height); Css.Value aspect = new Css.Units.DecimalUnit((float)Width / (float)Height); // Pull in the default values: // Note that if any are numeric and 0, it treats it as a null. // (which in turn makes the feature unavailable, as expected by the HasFeature property). this["width"] = width; this["height"] = height; this["device-width"] = width; this["device-height"] = height; this["aspect-ratio"] = aspect; this["device-aspect-ratio"] = aspect; this["orientation"] = new Css.Units.TextUnit(Landscape?"landscape":"portrait"); this["resolution"] = new Css.Units.DecimalUnit(Resolution); this["color"] = new Css.Units.DecimalUnit(Color); this["color-index"] = new Css.Units.DecimalUnit(ColorIndex); this["monochrome"] = new Css.Units.DecimalUnit(Monochrome); this["scan"] = new Css.Units.TextUnit(Scan); this["grid"] = new Css.Units.DecimalUnit(Grid); // Ready! Ready(doc); }
public void RemoveFromDocument(ReflowDocument document) { // Contained in media rules? if (document.MediaRules == null) { return; } for (int i = 0; i < document.MediaRules.Count; i++) { if (document.MediaRules[i] == this) { // Got it! Remove now: document.MediaRules.RemoveAt(i); return; } } // Always deactivate: if (PreviousStatus) { PreviousStatus = false; Deactivate(ParentSheet.document); } }
/// <summary>Called when this element got removed from the DOM.</summary> internal override void RemovedFromDOM() { Css.ReflowDocument reflowDocument = document as Css.ReflowDocument; if (reflowDocument.AttributeIndex != null) { // Remove this from the DOM attribute cache: reflowDocument.RemoveCachedElement(this); } // Remove handler: // OnRemovedFromDOM(); // Let the style know we went offscreen: RenderableData renderable = RenderData; renderable.WentOffScreen(); // Apply to all virtual elements: VirtualElements virts = renderable.Virtuals; if (virts != null) { foreach (KeyValuePair <int, Node> kvp in virts.Elements) { // Remove it: kvp.Value.RemovedFromDOM(); } } base.RemovedFromDOM(); // Request a layout: reflowDocument.RequestLayout(); }
public void Evaluate() { ReflowDocument document = ParentSheet.document; // Test the query now: bool testQuery = Query.IsTrue(document); if (testQuery == PreviousStatus) { // Unchanged. return; } PreviousStatus = testQuery; if (testQuery) { // This query is now active. Activate(document); } else { // This query is now no longer active. Deactivate(document); } }
public void RemoveFromDocument(ReflowDocument document) { if (ImportedSheet != null) { ImportedSheet.RemoveSheet(document); } }
public override bool IsTrue(ReflowDocument document) { // Get the value: Css.Value value = document.Media[Feature]; // Match? return(Value.Equals(value)); }
public void RemoveFromDocument(ReflowDocument document) { if (document.GetAnimation(Name) == this) { // Remove it: document.Animations.Remove(Name.ToLower()); } }
/// <summary>Removes this stylesheet from the given documents fast lookups.</summary> internal void RemoveSheet(ReflowDocument document) { // For each rule.. foreach (Rule rule in cssRules) { // Add it: rule.RemoveFromDocument(document); } }
/// <summary>Called when this rule is now active.</summary> private void Activate(ReflowDocument document) { // Add selectors to documents lookups: foreach (Rule rule in Rules) { // Note that this also auto triggers the RuleAdded method, which is what we want for it to apply! rule.AddToDocument(document); } }
/// <summary>Called when this rule is no longer active.</summary> private void Deactivate(ReflowDocument document) { // Remove it: foreach (Rule rule in Rules) { // Remove the rule: rule.RemoveFromDocument(document); } }
/// <summary>Adds this stylesheet to the documents fast lookups. /// This is used by the default stylesheet.</summary> internal void ReAddSheet(ReflowDocument document) { // For each rule.. foreach (Rule rule in cssRules) { // Add it: rule.AddToDocument(document); } }
public override void AddToDocument(ReflowDocument document, StyleSheet sheet) { if (sheet != null && document != null) { // Add attribute to stylesheet: int count; document.SelectorAttributes.TryGetValue(Attribute, out count); document.SelectorAttributes[Attribute] = count++; } }
public void AddToDocument(ReflowDocument document) { // Put it into the animations set in the document: if (document.Animations == null) { // Create it: document.Animations = new Dictionary <string, KeyframesRule>(); } document.Animations[Name.ToLower()] = this; }
public override bool IsTrue(ReflowDocument document) { Css.Value v = document.Media[Feature]; if (v == null) { return(0f <= MaxValue); } return(v.GetRawDecimal() <= MaxValue); }
public void RemoveFromDocument(ReflowDocument document) { // Remove the selector (as it may need to update attribute caches): Selector.RemoveFromDocument(this, document, ParentStyleSheet); if (document.documentElement != null) { // Find all elements that matched this rule. (document.documentElement as IRenderableNode).RenderData.RuleRemoved(this); } }
/// <summary>Sets up this renderman.</summary> private void Init() { Block = new MeshBlock(this); ClippingBoundary = new BoxRegion(0, 0, UnityEngine.Screen.width, UnityEngine.Screen.height); if (RootDocument == null) { HtmlDocument hdoc = new HtmlDocument(this); hdoc.SetRawLocation(new Location("resources://", null)); RootDocument = hdoc; } }
/// <summary>Adds this rule to its parent document caches. /// This is used by the default style sheet when the document gets cleared.</summary> public void AddToDocument(ReflowDocument document) { // Add the selector (as it may need to update attribute caches): Selector.AddToDocument(this, document, ParentStyleSheet); if (document.documentElement != null) { // Is this selector already in use? // Recurse through the DOM looking for it: (document.documentElement as IRenderableNode).RenderData.RuleAdded(this); } }
/// <summary>Used by document.matchMedia.</summary> public MediaQueryList(ReflowDocument doc, MediaQuery q) { // Pull the query set from the media query, if it is a set: if (!(q is MediaQueryList)) { // Just the one query. Queries = new MediaQuery[] { q }; return; } // Pull the set out: MediaQueryList list = q as MediaQueryList; Queries = list.Queries; }
/// <summary>Used by JS.</summary> public SupportsQueryList(ReflowDocument doc, SupportsQuery q) { // Pull the query set from the supports query, if it is a set: if (!(q is SupportsQueryList)) { // Just the one query. Queries = new SupportsQuery[] { q }; return; } // Pull the set out: SupportsQueryList list = q as SupportsQueryList; Queries = list.Queries; }
public override bool IsTrue(ReflowDocument document) { // For each one.. for (int i = 0; i < Queries.Length; i++) { // Is it true? if (Queries[i].IsTrue(document)) { return(true); } } // None were true return(false); }
/// <summary>Removes this selector from its parent documents caches.</summary> public void RemoveFromDocument(StyleRule rule, ReflowDocument document, Css.StyleSheet sheet) { // Get the cached root name: string text = LastRoot.StyleText; List <StyleRule> list = null; if (text == "*") { list = document.AnySelectors; } else { // Add the rule: document.SelectorStubs.TryGetValue(text, out list); } // Remove from the set: if (list != null) { for (int i = 0; i < list.Count; i++) { if (list[i] == rule) { list.RemoveAt(i); break; } } } // For each root, remove their locals: for (int r = 0; r < RootCount; r++) { // Get locals set: LocalMatcher[] locals = Roots[r].LocalMatchers; if (locals != null) { // For each one.. for (int i = 0; i < locals.Length; i++) { // Remove it: locals[i].RemoveFromDocument(document, sheet); } } } }
public void AddToDocument(ReflowDocument document) { if (Query == null || Query.IsTrue(document)) { if (ImportedSheet == null) { DownloadNow(); // Add it: ParentSheet.document.AddStyle(ImportedSheet, null); } else { ImportedSheet.ReAddSheet(document); } } }
public void AddToDocument(ReflowDocument document) { // Require doc.Media now: document.RequireMediaType(); if (document.MediaRules == null) { // Create it: document.MediaRules = new List <MediaRule>(); } // Add to rules: document.MediaRules.Add(this); // Attempt to activate it: if (!PreviousStatus) { Evaluate(); } }
/// <summary>Adds this selector to its parent documents caches. /// This is used by the default style sheet when the document gets cleared.</summary> public void AddToDocument(StyleRule rule, ReflowDocument document, Css.StyleSheet sheet) { // Get the cached root (always the 'last' one): string text = LastRoot.StyleText; List <StyleRule> list = null; if (text == "*") { list = document.AnySelectors; } else { // Add the rule: if (!document.SelectorStubs.TryGetValue(text, out list)) { list = new List <StyleRule>(); document.SelectorStubs[text] = list; } } // Add the rule to the set: list.Add(rule); // For each root, add their locals: for (int r = 0; r < RootCount; r++) { // Get locals set: LocalMatcher[] locals = Roots[r].LocalMatchers; if (locals != null) { // For each one.. for (int i = 0; i < locals.Length; i++) { // Add it: locals[i].AddToDocument(document, sheet); } } } }
public override void RemoveFromDocument(ReflowDocument document, StyleSheet sheet) { if (sheet != null && document != null) { // Remove attribute from stylesheet: int count; if (document.SelectorAttributes.TryGetValue(Attribute, out count)) { count--; if (count <= 0) { document.SelectorAttributes.Remove(Attribute); } else { document.SelectorAttributes[Attribute] = count; } } } }
internal override void AddedToDOM() { Css.ReflowDocument doc = document as Css.ReflowDocument; if (doc != null) { if (doc.AttributeIndex != null) { // Index element if needed: AddToAttributeLookups(); } // Make sure the stylesheet is present: doc.RequireStyleSheet(this); } // Update its css by telling it the parent changed. // This affects inherit, height/width etc. Style.Computed.ParentChanged(); // Obtain the render context: SVGElement svgParent = (parentNode as SVGElement); if (svgParent != null) { if (Context == null) { // Get the context: Context = svgParent.Context; } if (Context != null) { // Request a rebuild: Context.RequestRebuild(); } } }
public override void AddToDocument(ReflowDocument document, StyleSheet sheet) { // Apply scope: Scope = sheet.ownerNode; }
public override bool IsTrue(ReflowDocument document) { return(document.Media.HasFeature(Feature)); }
public override bool IsTrue(ReflowDocument document) { return(document.Media.Is(MediaName)); }