// Please see ASURT 144034 for this device-specific issue. // Internal-only utility to return name of an XhtmlFormatStyleClass that represents the (format) diff of the // parameter from the current style. This does not push the style stack -it is used only for tags with // small content models such as <a>. internal String GetCssFormatClassName(Style style) { if (!_cachingRendering) { Debug.Fail("Only call when caching rendering"); return(null); } if (style == null) { return(null); // caller should check for this return value. } // We need to write all non-default properties, so get the filter from the _defaultStyleClass. StyleFilter filter = _defaultStyleClass.GetFilter(style); filter &= XhtmlConstants.Format; if (filter == StyleFilter.None) { return(null); } XhtmlFormatStyleClass styleClass = new XhtmlFormatStyleClass(style, filter); // Value returned is a valid styleClass which can be added to the attributes of, e.g., an <a> element // to cause character formatting. Please see 144034 for the device specific issue. XhtmlStyleClass hashStyleClass = EnsureXhtmlStyleClassInHashtable(styleClass); if (hashStyleClass == null) { return(null); } return(hashStyleClass.StyleClassName); }
/// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.SetBodyStyle"]/*' /> public virtual void SetBodyStyle(Style style) { // Filter is not strictly needed here, since default property values are not written anyway // but it is a good practice to provide a meaningful filter. StyleFilter filter = _defaultStyleClass.GetFilter(style); _bodyStyle = new XhtmlStyleClass(style, filter); _isStyleSheetEmpty = filter == 0; }
// This internal overload can be used to enter style by setting the class element // on a caller-specified tag, such as <body> or <table>. internal void EnterStyle(XhtmlStyleClass styleClass, String styleTag) { if (styleClass.Filter == StyleFilter.None) { WriteFullBeginTag(styleTag); _styleStack.Push(new StylePair(styleTag, styleClass)); return; } EnterStyleInternal(styleClass, styleTag, null); }
private XhtmlStyleClass EnsureXhtmlStyleClassInHashtable(XhtmlStyleClass styleClass) { if (styleClass.Filter == StyleFilter.None) { return(CurrentStyleClass); } // We hash the style classes by the class definition. String classKey = styleClass.GetClassDefinition(); XhtmlStyleClass existingClass = (XhtmlStyleClass)_styleHash [classKey]; string className = existingClass == null ? "s" + _styleCount++ : existingClass.StyleClassName; if (existingClass == null) { // Used to retrieve style classes in order from the hash table. _orderedStyleClassKeys.Add(classKey); styleClass.StyleClassName = className; _styleHash [classKey] = styleClass; _isStyleSheetEmpty = false; } return(existingClass == null ? styleClass : existingClass); }
internal void EnterStyleInternal(XhtmlStyleClass styleClass, String styleTag, NameValueCollection additionalAttributes, bool forceTag) { // EnterStyle is only expected to be called when _cachingRendering is true. // Specifically, the active form is rendered to the markup cache, then the cached // markup is later rendered to the page. This allows efficient use of CSS. // The if clause exits gracefully if the expected precondition is not met. if (!_cachingRendering) { Debug.Fail("Only call EnterStyleInternal when caching rendering"); _styleStack.Push(new StylePair(String.Empty, styleClass)); return; } if (styleClass.Filter == StyleFilter.None && !forceTag) // value comparison { WritePendingBreak(); // Push a placeholder for this style with Tag == "", indicating no // tag was written. _styleStack.Push(new StylePair(String.Empty, styleClass)); return; } // Swap styleClass for an equivalent style class already in the hashtable, if there is one. styleClass = EnsureXhtmlStyleClassInHashtable(styleClass); WriteBeginTag(styleTag); if (styleClass != null && styleClass != CurrentStyleClass && styleClass.Filter != StyleFilter.None) { WriteAttribute("class", styleClass.StyleClassName); } if (additionalAttributes != null) { foreach (String key in additionalAttributes.Keys) { WriteAttribute(key, additionalAttributes[key], true /* encode */); } } Write(">"); _styleStack.Push(new StylePair(styleTag, styleClass)); }
internal StylePair (String styleTag, Style style, StyleFilter filter) { Tag = styleTag; Class = new XhtmlStyleClass (style, filter); }
internal StylePair (String styleTag, XhtmlStyleClass styleClass) { Tag = styleTag; Class = styleClass; }
/// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.SetBodyStyle"]/*' /> public virtual void SetBodyStyle (Style style) { // Filter is not strictly needed here, since default property values are not written anyway // but it is a good practice to provide a meaningful filter. StyleFilter filter = _defaultStyleClass.GetFilter(style); _bodyStyle = new XhtmlStyleClass (style, filter); _isStyleSheetEmpty = filter == 0; }
internal void EnterStyleInternal (XhtmlStyleClass styleClass, String styleTag, NameValueCollection additionalAttributes, bool forceTag) { // EnterStyle is only expected to be called when _cachingRendering is true. // Specifically, the active form is rendered to the markup cache, then the cached // markup is later rendered to the page. This allows efficient use of CSS. // The if clause exits gracefully if the expected precondition is not met. if (!_cachingRendering) { Debug.Fail ("Only call EnterStyleInternal when caching rendering"); _styleStack.Push (new StylePair (String.Empty, styleClass)); return; } if (styleClass.Filter == StyleFilter.None && !forceTag) { // value comparison WritePendingBreak(); // Push a placeholder for this style with Tag == "", indicating no // tag was written. _styleStack.Push (new StylePair (String.Empty, styleClass)); return; } // Swap styleClass for an equivalent style class already in the hashtable, if there is one. styleClass = EnsureXhtmlStyleClassInHashtable (styleClass); WriteBeginTag (styleTag); if (styleClass != null && styleClass != CurrentStyleClass && styleClass.Filter != StyleFilter.None) { WriteAttribute ("class", styleClass.StyleClassName); } if (additionalAttributes != null) { foreach (String key in additionalAttributes.Keys) { WriteAttribute (key, additionalAttributes[key], true /* encode */); } } Write (">"); _styleStack.Push (new StylePair (styleTag, styleClass)); }
internal void EnterStyleInternal (XhtmlStyleClass styleClass, String styleTag, NameValueCollection additionalAttributes) { EnterStyleInternal(styleClass, styleTag, additionalAttributes, false /* force tag to be written */); }
// This internal overload can be used to enter style by setting the class element // on a caller-specified tag, such as <body> or <table>. internal void EnterStyle(XhtmlStyleClass styleClass, String styleTag) { if (styleClass.Filter == StyleFilter.None) { WriteFullBeginTag(styleTag); _styleStack.Push(new StylePair(styleTag, styleClass)); return; } EnterStyleInternal (styleClass, styleTag, null); }
private XhtmlStyleClass EnsureXhtmlStyleClassInHashtable (XhtmlStyleClass styleClass) { if (styleClass.Filter == StyleFilter.None) { return CurrentStyleClass; } // We hash the style classes by the class definition. String classKey = styleClass.GetClassDefinition (); XhtmlStyleClass existingClass = (XhtmlStyleClass) _styleHash [classKey]; string className = existingClass == null ? "s" + _styleCount++ : existingClass.StyleClassName; if (existingClass == null) { // Used to retrieve style classes in order from the hash table. _orderedStyleClassKeys.Add (classKey); styleClass.StyleClassName = className; _styleHash [classKey] = styleClass; _isStyleSheetEmpty = false; } return existingClass == null ? styleClass : existingClass; }
internal StylePair(String styleTag, Style style, StyleFilter filter) { Tag = styleTag; Class = new XhtmlStyleClass(style, filter); }
internal StylePair(String styleTag, XhtmlStyleClass styleClass) { Tag = styleTag; Class = styleClass; }
internal void EnterStyleInternal(XhtmlStyleClass styleClass, String styleTag, NameValueCollection additionalAttributes) { EnterStyleInternal(styleClass, styleTag, additionalAttributes, false /* force tag to be written */); }