public String getAllStylesForElement(Element element) { if (!(element instanceof CSSStylableElement)) { return ""; } Document document = element.getOwnerDocument(); XhtmlCssEngine engine = getCssEngine(document); if (engine != null) { CSSStylableElement elt = (CSSStylableElement)element; StyleMap map = elt.getComputedStyleMap(null); if (map != null) { return map.toString(engine); } } return ""; // NOI18N }
@Override public void setComputedStyleMap(String pseudoElement, StyleMap sm) { super.setComputedStyleMap(pseudoElement, sm); if (sm == null && tbody instanceof CSSStylableElement) { // XXX #115932 Also clear the tbody element. // The issue is that the tbody might not be a child of the table element(!??) // See above insertBefore hack. ((CSSStylableElement)tbody).setComputedStyleMap(pseudoElement, sm); } }
/** * Returns the current base-url. */ public ParsedURL getCSSBaseURI() { if (cssBaseURI == null) { cssBaseURI = element.getCSSBase(); } return cssBaseURI; }
StyleMap style = elt.getComputedStyleMap(null); if (style == null) return; // Nothing to invalidate. elt.setComputedStyleMap(null, newStyle); for (int i=0; i<diffs.length; i++) { if (diffs[i]) {
/** * A property in the override style declaration has been removed. */ public void overrideStylePropertyRemoved(CSSStylableElement elt, String name) { StyleDeclarationProvider p = elt.getOverrideStyleDeclarationProvider(); StyleDeclaration declaration = p.getStyleDeclaration(); int idx = getPropertyIndex(name); int ds = declaration.size(); for (int i = 0; i < ds; i++) { if (idx == declaration.getIndex(i)) { declaration.remove(i); StyleMap style = elt.getComputedStyleMap(null); if (style != null && style.getOrigin(idx) == StyleMap.OVERRIDE_ORIGIN /* && style.isComputed(idx) */) { invalidateProperties (elt, new int[] { idx }, null, true); } break; } } }
NamedNodeMap attrs = elt.getAttributes(); int len = attrs.getLength(); for (int i = 0; i < len; i++) { String style = elt.getAttributeNS(styleNamespaceURI, styleLocalName); if (style.length() > 0) { elt.getOverrideStyleDeclarationProvider(); if (p != null) { StyleDeclaration over = p.getStyleDeclaration();
String tname = e.getTagName(); // should already be lowercase assert (tname != null) && (tname.length() > 0); org.w3c.dom.NamedNodeMap atts = e.getAttributes();
/** * Tests whether this condition matches the given element. */ public boolean match(Element e, String pseudoE) { return (e instanceof CSSStylableElement) ? ((CSSStylableElement)e).getXMLId().equals(getValue()) : false; }
/** * Tests whether this selector matches the given element. */ public boolean match(Element e, String pseudoE) { return (e instanceof CSSStylableElement) ? ((CSSStylableElement)e).isPseudoInstanceOf(getValue()) : false; }
/** * Tests whether this condition matches the given element. */ public boolean match(Element e, String pseudoE) { if (!(e instanceof CSSStylableElement)) return false; // Can't match an unstylable element. String attr = ((CSSStylableElement)e).getCSSClass(); String val = getValue(); int attrLen = attr.length(); int valLen = val.length(); int i = attr.indexOf(val); while (i != -1) { if (i == 0 || Character.isSpaceChar(attr.charAt(i - 1))) { if (i + valLen == attrLen || Character.isSpaceChar(attr.charAt(i + valLen))) { return true; } } i = attr.indexOf(val, i + valLen); } return false; }
/** * A property in the override style declaration has been changed. */ public void overrideStylePropertyChanged(CSSStylableElement elt, String name, String val, String prio) { boolean important = prio != null && prio.length() != 0; StyleDeclarationProvider p = elt.getOverrideStyleDeclarationProvider(); declaration = p.getStyleDeclaration(); setMainProperties(elt, this, name, val, important); declaration = null; invalidateProperties(elt, null, mainPropertiesChanged, true); }
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engine, int idx, StyleMap sm, Value value) { if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_PERCENTAGE) { sm.putLineHeightRelative(idx, true); int fsi = engine.getLineHeightIndex(); CSSStylableElement parent; parent = (CSSStylableElement)elt.getParentNode(); if (parent == null) { // Hmmm somthing pretty odd - can't happen accordint to spec, // should always have text parent. // http://www.w3.org/TR/SVG11/text.html#BaselineShiftProperty parent = elt; } Value fs = engine.getComputedStyle(parent, pseudo, fsi); float fsv = fs.getFloatValue(); float v = value.getFloatValue(); return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, (fsv * v) / 100f); } return super.computeValue(elt, pseudo, engine, idx, sm, value); }
StyleMap style = elt.getComputedStyleMap(null); if (style == null) return; // Nothing to invalidate. elt.setComputedStyleMap(null, newStyle); for (int i=0; i<diffs.length; i++) { if (diffs[i]) {
/** * A property in the override style declaration has been removed. */ public void overrideStylePropertyRemoved(CSSStylableElement elt, String name) { StyleDeclarationProvider p = elt.getOverrideStyleDeclarationProvider(); StyleDeclaration declaration = p.getStyleDeclaration(); int idx = getPropertyIndex(name); int ds = declaration.size(); for (int i = 0; i < ds; i++) { if (idx == declaration.getIndex(i)) { declaration.remove(i); StyleMap style = elt.getComputedStyleMap(null); if (style != null && style.getOrigin(idx) == StyleMap.OVERRIDE_ORIGIN /* && style.isComputed(idx) */) { invalidateProperties (elt, new int[] { idx }, null, true); } break; } } }
NamedNodeMap attrs = elt.getAttributes(); int len = attrs.getLength(); for (int i = 0; i < len; i++) { String style = elt.getAttributeNS(styleNamespaceURI, styleLocalName); if (style.length() > 0) { elt.getOverrideStyleDeclarationProvider(); if (p != null) { StyleDeclaration over = p.getStyleDeclaration();
/** * Tests whether this condition matches the given element. */ public boolean match(Element e, String pseudoE) { return (e instanceof CSSStylableElement) ? ((CSSStylableElement)e).getXMLId().equals(getValue()) : false; }
/** * Tests whether this selector matches the given element. */ public boolean match(Element e, String pseudoE) { return (e instanceof CSSStylableElement) ? ((CSSStylableElement)e).isPseudoInstanceOf(getValue()) : false; }
/** * Tests whether this condition matches the given element. */ public boolean match(Element e, String pseudoE) { if (!(e instanceof CSSStylableElement)) return false; // Can't match an unstylable element. String attr = ((CSSStylableElement)e).getCSSClass(); String val = getValue(); int attrLen = attr.length(); int valLen = val.length(); int i = attr.indexOf(val); while (i != -1) { if (i == 0 || Character.isSpaceChar(attr.charAt(i - 1))) { if (i + valLen == attrLen || Character.isSpaceChar(attr.charAt(i + valLen))) { return true; } } i = attr.indexOf(val, i + valLen); } return false; }
/** * A property in the override style declaration has been changed. */ public void overrideStylePropertyChanged(CSSStylableElement elt, String name, String val, String prio) { boolean important = prio != null && prio.length() != 0; StyleDeclarationProvider p = elt.getOverrideStyleDeclarationProvider(); declaration = p.getStyleDeclaration(); setMainProperties(elt, this, name, val, important); declaration = null; invalidateProperties(elt, null, mainPropertiesChanged, true); }
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engine, int idx, StyleMap sm, Value value) { if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_PERCENTAGE) { sm.putLineHeightRelative(idx, true); int fsi = engine.getLineHeightIndex(); CSSStylableElement parent; parent = (CSSStylableElement)elt.getParentNode(); if (parent == null) { // Hmmm somthing pretty odd - can't happen accordint to spec, // should always have text parent. // http://www.w3.org/TR/SVG11/text.html#BaselineShiftProperty parent = elt; } Value fs = engine.getComputedStyle(parent, pseudo, fsi); float fsv = fs.getFloatValue(); float v = value.getFloatValue(); return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, (fsv * v) / 100f); } return super.computeValue(elt, pseudo, engine, idx, sm, value); }