/** * An auxiliary method for getStyleSheets(). */ protected void findStyleSheetNodes(Node n) { if (n instanceof CSSStyleSheetNode) { styleSheetNodes.add(n); } for (Node nd = getCSSFirstChild(n); nd != null; nd = getCSSNextSibling(nd)) { findStyleSheetNodes(nd); } }
/** * An auxiliary method for getStyleSheets(). */ protected void findStyleSheetNodes(Node n) { if (n instanceof CSSStyleSheetNode) { styleSheetNodes.add(n); } for (Node nd = getCSSFirstChild(n); nd != null; nd = getCSSNextSibling(nd)) { findStyleSheetNodes(nd); } }
/** * An auxiliary method for getStyleSheets(). */ protected void findStyleSheetNodes(Node n) { if (n instanceof CSSStyleSheetNode) { styleSheetNodes.add(n); } for (Node nd = getCSSFirstChild(n); nd != null; nd = getCSSNextSibling(nd)) { findStyleSheetNodes(nd); } }
/** * Handles a node insertion in the document. */ protected void handleNodeInserted(Node n) { if (hasStyleSheetNode(n)) { // Invalidate all the CSSStylableElements in the document. styleSheetNodes = null; invalidateProperties(document.getDocumentElement(), null, null, true); } else if (n instanceof CSSStylableElement) { // Invalidate the CSSStylableElement siblings, to correctly // match the adjacent selectors and first-child pseudo-class. n = getCSSNextSibling(n); while (n != null) { invalidateProperties(n, null, null, true); n = getCSSNextSibling(n); } } }
/** * Handles a node insertion in the document. */ protected void handleNodeInserted(Node n) { if (hasStyleSheetNode(n)) { // Invalidate all the CSSStylableElements in the document. styleSheetNodes = null; invalidateProperties(document.getDocumentElement(), null, null, true); } else if (n instanceof CSSStylableElement) { // Invalidate the CSSStylableElement siblings, to correctly // match the adjacent selectors and first-child pseudo-class. n = getCSSNextSibling(n); while (n != null) { invalidateProperties(n, null, null, true); n = getCSSNextSibling(n); } } }
/** * Handles a node insertion in the document. */ protected void handleNodeInserted(Node n) { if (hasStyleSheetNode(n)) { // Invalidate all the CSSStylableElements in the document. styleSheetNodes = null; invalidateProperties(document.getDocumentElement(), null, null, true); } else if (n instanceof CSSStylableElement) { // Invalidate the CSSStylableElement siblings, to correctly // match the adjacent selectors and first-child pseudo-class. n = getCSSNextSibling(n); while (n != null) { invalidateProperties(n, null, null, true); n = getCSSNextSibling(n); } } }
/** * Handles a node removal from the document. */ protected void handleNodeRemoved(Node n) { if (hasStyleSheetNode(n)) { // Wait for the DOMSubtreeModified to do the invalidations // because at this time the node is in the tree. styleSheetRemoved = true; } else if (n instanceof CSSStylableElement) { // Wait for the DOMSubtreeModified to do the invalidations // because at this time the node is in the tree. removedStylableElementSibling = getCSSNextSibling(n); } // Clears the computed styles in the removed tree. disposeStyleMaps(n); }
/** * Handles a node removal from the document. */ protected void handleNodeRemoved(Node n) { if (hasStyleSheetNode(n)) { // Wait for the DOMSubtreeModified to do the invalidations // because at this time the node is in the tree. styleSheetRemoved = true; } else if (n instanceof CSSStylableElement) { // Wait for the DOMSubtreeModified to do the invalidations // because at this time the node is in the tree. removedStylableElementSibling = getCSSNextSibling(n); } // Clears the computed styles in the removed tree. disposeStyleMaps(n); }
/** * Handles a node removal from the document. */ protected void handleNodeRemoved(Node n) { if (hasStyleSheetNode(n)) { // Wait for the DOMSubtreeModified to do the invalidations // because at this time the node is in the tree. styleSheetRemoved = true; } else if (n instanceof CSSStylableElement) { // Wait for the DOMSubtreeModified to do the invalidations // because at this time the node is in the tree. removedStylableElementSibling = getCSSNextSibling(n); } // Clears the computed styles in the removed tree. disposeStyleMaps(n); }
/** * Returns whether the DOM subtree rooted at the specified node * contains a {@link CSSStyleSheetNode}. */ protected boolean hasStyleSheetNode(Node n) { if (n instanceof CSSStyleSheetNode) { return true; } n = getCSSFirstChild(n); while (n != null) { if (hasStyleSheetNode(n)) { return true; } n = getCSSNextSibling(n); } return false; }
/** * Returns whether the DOM subtree rooted at the specified node * contains a {@link CSSStyleSheetNode}. */ protected boolean hasStyleSheetNode(Node n) { if (n instanceof CSSStyleSheetNode) { return true; } n = getCSSFirstChild(n); while (n != null) { if (hasStyleSheetNode(n)) { return true; } n = getCSSNextSibling(n); } return false; }
/** * Handles a subtree modification in the document. * todo the incoming Node is actually ignored (not used) here, * but it seems caller-sites assume that it is used - is this done right?? */ protected void handleSubtreeModified(Node ignored) { if (styleSheetRemoved) { // Invalidate all the CSSStylableElements in the document. styleSheetRemoved = false; styleSheetNodes = null; invalidateProperties(document.getDocumentElement(), null, null, true); } else if (removedStylableElementSibling != null) { // Invalidate the CSSStylableElement siblings, to // correctly match the adjacent selectors and // first-child pseudo-class. Node n = removedStylableElementSibling; while (n != null) { invalidateProperties(n, null, null, true); n = getCSSNextSibling(n); } removedStylableElementSibling = null; } }
/** * Handles a subtree modification in the document. * todo the incoming Node is actually ignored (not used) here, * but it seems caller-sites assume that it is used - is this done right?? */ protected void handleSubtreeModified(Node ignored) { if (styleSheetRemoved) { // Invalidate all the CSSStylableElements in the document. styleSheetRemoved = false; styleSheetNodes = null; invalidateProperties(document.getDocumentElement(), null, null, true); } else if (removedStylableElementSibling != null) { // Invalidate the CSSStylableElement siblings, to // correctly match the adjacent selectors and // first-child pseudo-class. Node n = removedStylableElementSibling; while (n != null) { invalidateProperties(n, null, null, true); n = getCSSNextSibling(n); } removedStylableElementSibling = null; } }
/** * Returns whether the DOM subtree rooted at the specified node * contains a {@link CSSStyleSheetNode}. */ protected boolean hasStyleSheetNode(Node n) { if (n instanceof CSSStyleSheetNode) { return true; } n = getCSSFirstChild(n); while (n != null) { if (hasStyleSheetNode(n)) { return true; } n = getCSSNextSibling(n); } return false; }
/** * Handles a subtree modification in the document. * todo the incoming Node is actually ignored (not used) here, * but it seems caller-sites assume that it is used - is this done right?? */ protected void handleSubtreeModified(Node ignored) { if (styleSheetRemoved) { // Invalidate all the CSSStylableElements in the document. styleSheetRemoved = false; styleSheetNodes = null; invalidateProperties(document.getDocumentElement(), null, null, true); } else if (removedStylableElementSibling != null) { // Invalidate the CSSStylableElement siblings, to // correctly match the adjacent selectors and // first-child pseudo-class. Node n = removedStylableElementSibling; while (n != null) { invalidateProperties(n, null, null, true); n = getCSSNextSibling(n); } removedStylableElementSibling = null; } }
/** * Removes the style maps from each CSSStylableElement in the document. */ protected void disposeStyleMaps(Node node) { if (node instanceof CSSStylableElement) { ((CSSStylableElement)node).setComputedStyleMap(null, null); } for (Node n = getCSSFirstChild(node); n != null; n = getCSSNextSibling(n)) { if (n.getNodeType() == Node.ELEMENT_NODE) { disposeStyleMaps(n); } } }
/** * Removes the style maps from each CSSStylableElement in the document. */ protected void disposeStyleMaps(Node node) { if (node instanceof CSSStylableElement) { ((CSSStylableElement)node).setComputedStyleMap(null, null); } for (Node n = getCSSFirstChild(node); n != null; n = getCSSNextSibling(n)) { if (n.getNodeType() == Node.ELEMENT_NODE) { disposeStyleMaps(n); } } }
/** * Removes the style maps from each CSSStylableElement in the document. */ protected void disposeStyleMaps(Node node) { if (node instanceof CSSStylableElement) { ((CSSStylableElement)node).setComputedStyleMap(null, null); } for (Node n = getCSSFirstChild(node); n != null; n = getCSSNextSibling(n)) { if (n.getNodeType() == Node.ELEMENT_NODE) { disposeStyleMaps(n); } } }
/** * Recursively imports the cascaded style from a source element * to an element of the current document. */ public void importCascadedStyleMaps(Element src, CSSEngine srceng, Element dest) { if (src instanceof CSSStylableElement) { CSSStylableElement csrc = (CSSStylableElement)src; CSSStylableElement cdest = (CSSStylableElement)dest; StyleMap sm = srceng.getCascadedStyleMap(csrc, null); sm.setFixedCascadedStyle(true); cdest.setComputedStyleMap(null, sm); if (pseudoElementNames != null) { int len = pseudoElementNames.length; for (String pe : pseudoElementNames) { sm = srceng.getCascadedStyleMap(csrc, pe); cdest.setComputedStyleMap(pe, sm); } } } for (Node dn = getCSSFirstChild(dest), sn = getCSSFirstChild(src); dn != null; dn = getCSSNextSibling(dn), sn = getCSSNextSibling(sn)) { if (sn.getNodeType() == Node.ELEMENT_NODE) { importCascadedStyleMaps((Element)sn, srceng, (Element)dn); } } }
/** * Recursively imports the cascaded style from a source element * to an element of the current document. */ public void importCascadedStyleMaps(Element src, CSSEngine srceng, Element dest) { if (src instanceof CSSStylableElement) { CSSStylableElement csrc = (CSSStylableElement)src; CSSStylableElement cdest = (CSSStylableElement)dest; StyleMap sm = srceng.getCascadedStyleMap(csrc, null); sm.setFixedCascadedStyle(true); cdest.setComputedStyleMap(null, sm); if (pseudoElementNames != null) { int len = pseudoElementNames.length; for (int i = 0; i < len; i++) { String pe = pseudoElementNames[i]; sm = srceng.getCascadedStyleMap(csrc, pe); cdest.setComputedStyleMap(pe, sm); } } } for (Node dn = getCSSFirstChild(dest), sn = getCSSFirstChild(src); dn != null; dn = getCSSNextSibling(dn), sn = getCSSNextSibling(sn)) { if (sn.getNodeType() == Node.ELEMENT_NODE) { importCascadedStyleMaps((Element)sn, srceng, (Element)dn); } } }