Exemple #1
0
        /// <summary>Adds the given css style to the document. Used by style tags.</summary>
        /// <param name="ele">The scope element to use.</param>
        /// <param name="css">The css to add to the document.</param>
        /// <param name="index">The index in the style buffer to add the css into.</param>
        public Css.StyleSheet AddStyle(Node ele, string css)
        {
            // Create a style sheet:
            Css.StyleSheet sheet = new Css.StyleSheet(ele);

            // Add it:
            AddStyle(sheet, css);

            return(sheet);
        }
Exemple #2
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);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>Adds the given css style to the document. Used by style tags.</summary>
        /// <param name="ele">The scope element to use.</param>
        /// <param name="css">The css to add to the document.</param>
        /// <param name="index">The index in the style buffer to add the css into.</param>
        public void AddStyle(Css.StyleSheet sheet, string css)
        {
            // Create if needed:
            if (styleSheets == null)
            {
                styleSheets = new List <Css.StyleSheet>();
            }

            // Add it:
            styleSheets.Add(sheet);

            // Set the priority (Priority 0 is the UA sheet):
            sheet.Priority = styleSheets.Count;

            if (css != null)
            {
                // Parse the CSS now!
                sheet.ParseCss(css);
            }
        }
Exemple #4
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);
                    }
                }
            }
        }
		/// <summary>Clears all css style definitions from this document.</summary>
		public void ClearStyle(){
			Style=new Css.StyleSheet(this);
			StyleBuffer=null;
		}
		/// <summary>Creates a new document which will be rendered with the given renderer.</summary>
		/// <param name="renderer">The renderer to use when rendering this document.</param>
		/// <param name="parentWindow">The window that will become the parent window. Used in e.g. iframes.</param>
		/// <param name="aot">True if this is a Nitro AOT document (used in the Editor only).</param>
		public Document(Renderman renderer,Window parentWindow,bool aot):base(){
			AotDocument=aot;
			
			if(!aot && DefaultStyleSheet==null){
				// No default styles loaded yet. Load them now.
				string styleText=((TextAsset)Resources.Load("style")).text;
				// Have they applied any overrides?
				TextAsset extraStyle=Resources.Load("customStyle") as TextAsset;
				if(extraStyle!=null && extraStyle.text!=null){
					styleText+="\n\n"+extraStyle.text;
				}
				DefaultStyleSheet=new Css.StyleSheet(this);
				DefaultStyleSheet.ParseCss(styleText);
			}
			
			#if !NoNitroRuntime
			// Get the default security domain:
			SecurityDomain=UI.DefaultSecurityDomain;
			#endif
			
			Renderer=renderer;
			
			window=new Window();
			window.document=this;
			window.parent=parentWindow;
			if(parentWindow!=null){
				window.top=parentWindow.top;
			}else{
				window.top=window;
			}
			
			ActiveFonts=new Dictionary<string,DynamicFont>();
			Style=new Css.StyleSheet(this);
			html=new Element(this,null);
			html.SetTag("html");
			string ddbox="";
			
			if(parentWindow==null){
				// Dropdown box belongs to the top window only:
				ddbox="<ddbox></ddbox>";
			}
			
			html.innerHTML="<body></body>"+ddbox;
		}
Exemple #7
0
 /// <summary>Adds this matcher to its parent documents caches.
 /// This is used by the default style sheet when the document gets cleared.</summary>
 public virtual void AddToDocument(ReflowDocument document, Css.StyleSheet sheet)
 {
 }
Exemple #8
0
 /// <summary>Removes this matcher from any document caches.</summary>
 public virtual void RemoveFromDocument(ReflowDocument document, Css.StyleSheet sheet)
 {
 }