コード例 #1
0
        /// <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();
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: MediaRule.cs プロジェクト: ru-ace/spark
        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);
            }
        }
コード例 #4
0
        /// <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();
        }
コード例 #5
0
ファイル: MediaRule.cs プロジェクト: ru-ace/spark
        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);
            }
        }
コード例 #6
0
 public void RemoveFromDocument(ReflowDocument document)
 {
     if (ImportedSheet != null)
     {
         ImportedSheet.RemoveSheet(document);
     }
 }
コード例 #7
0
        public override bool IsTrue(ReflowDocument document)
        {
            // Get the value:
            Css.Value value = document.Media[Feature];

            // Match?
            return(Value.Equals(value));
        }
コード例 #8
0
ファイル: KeyframesRule.cs プロジェクト: HippoAR/DemoPowerUI
 public void RemoveFromDocument(ReflowDocument document)
 {
     if (document.GetAnimation(Name) == this)
     {
         // Remove it:
         document.Animations.Remove(Name.ToLower());
     }
 }
コード例 #9
0
ファイル: StyleSheet.cs プロジェクト: HippoAR/DemoPowerUI
 /// <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);
     }
 }
コード例 #10
0
ファイル: MediaRule.cs プロジェクト: ru-ace/spark
 /// <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);
     }
 }
コード例 #11
0
ファイル: MediaRule.cs プロジェクト: ru-ace/spark
 /// <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);
     }
 }
コード例 #12
0
ファイル: StyleSheet.cs プロジェクト: HippoAR/DemoPowerUI
 /// <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);
     }
 }
コード例 #13
0
 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++;
     }
 }
コード例 #14
0
ファイル: KeyframesRule.cs プロジェクト: HippoAR/DemoPowerUI
        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;
        }
コード例 #15
0
        public override bool IsTrue(ReflowDocument document)
        {
            Css.Value v = document.Media[Feature];

            if (v == null)
            {
                return(0f <= MaxValue);
            }

            return(v.GetRawDecimal() <= MaxValue);
        }
コード例 #16
0
ファイル: StyleRule.cs プロジェクト: ru-ace/spark
        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);
            }
        }
コード例 #17
0
        /// <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;
            }
        }
コード例 #18
0
ファイル: StyleRule.cs プロジェクト: ru-ace/spark
        /// <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);
            }
        }
コード例 #19
0
        /// <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;
        }
コード例 #20
0
        /// <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;
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        /// <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);
                    }
                }
            }
        }
コード例 #23
0
        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);
                }
            }
        }
コード例 #24
0
ファイル: MediaRule.cs プロジェクト: ru-ace/spark
        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();
            }
        }
コード例 #25
0
        /// <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);
                    }
                }
            }
        }
コード例 #26
0
        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;
                    }
                }
            }
        }
コード例 #27
0
        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();
                }
            }
        }
コード例 #28
0
ファイル: IsScope.cs プロジェクト: HippoAR/DemoPowerUI
 public override void AddToDocument(ReflowDocument document, StyleSheet sheet)
 {
     // Apply scope:
     Scope = sheet.ownerNode;
 }
コード例 #29
0
 public override bool IsTrue(ReflowDocument document)
 {
     return(document.Media.HasFeature(Feature));
 }
コード例 #30
0
 public override bool IsTrue(ReflowDocument document)
 {
     return(document.Media.Is(MediaName));
 }