diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/context/StandardAttributeResolver.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/context/StandardAttributeResolver.java index 1f2d0676e..8f9b2f080 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/context/StandardAttributeResolver.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/context/StandardAttributeResolver.java @@ -20,6 +20,7 @@ package org.xhtmlrenderer.context; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.xhtmlrenderer.css.extend.AttributeResolver; import org.xhtmlrenderer.extend.NamespaceHandler; import org.xhtmlrenderer.extend.UserAgentCallback; @@ -49,12 +50,12 @@ public StandardAttributeResolver(NamespaceHandler nsh, UserAgentCallback uac, Us * Gets the attributeValue attribute of the StandardAttributeResolver object */ @Override - public String getAttributeValue(Object e, String attrName) { + public String getAttributeValue(Node e, String attrName) { return nsh.getAttributeValue((Element) e, attrName); } @Override - public String getAttributeValue(Object e, String namespaceURI, String attrName) { + public String getAttributeValue(Node e, String namespaceURI, String attrName) { return nsh.getAttributeValue((Element)e, namespaceURI, attrName); } @@ -62,7 +63,7 @@ public String getAttributeValue(Object e, String namespaceURI, String attrName) * Gets the class attribute of the StandardAttributeResolver object */ @Override - public String getClass(Object e) { + public String getClass(Node e) { return nsh.getClass((Element) e); } @@ -70,12 +71,12 @@ public String getClass(Object e) { * Gets the iD attribute of the StandardAttributeResolver object */ @Override - public String getID(Object e) { + public String getID(Node e) { return nsh.getID((Element) e); } @Override - public String getNonCssStyling(Object e) { + public String getNonCssStyling(Node e) { return nsh.getNonCssStyling((Element) e); } @@ -83,7 +84,7 @@ public String getNonCssStyling(Object e) { * Gets the elementStyling attribute of the StandardAttributeResolver object */ @Override - public String getElementStyling(Object e) { + public String getElementStyling(Node e) { return nsh.getElementStyling((Element) e); } @@ -91,7 +92,7 @@ public String getElementStyling(Object e) { * Gets the lang attribute of the StandardAttributeResolver object */ @Override - public String getLang(Object e) { + public String getLang(Node e) { return nsh.getLang((Element) e); } @@ -99,7 +100,7 @@ public String getLang(Object e) { * Gets the link attribute of the StandardAttributeResolver object */ @Override - public boolean isLink(Object e) { + public boolean isLink(Node e) { return nsh.getLinkUri((Element) e) != null; } @@ -107,7 +108,7 @@ public boolean isLink(Object e) { * Gets the visited attribute of the StandardAttributeResolver object */ @Override - public boolean isVisited(Object e) { + public boolean isVisited(Node e) { return isLink(e) && uac.isVisited(nsh.getLinkUri((Element) e)); } @@ -115,7 +116,7 @@ public boolean isVisited(Object e) { * Gets the hover attribute of the StandardAttributeResolver object */ @Override - public boolean isHover(Object e) { + public boolean isHover(Node e) { return ui.isHover((Element) e); } @@ -123,7 +124,7 @@ public boolean isHover(Object e) { * Gets the active attribute of the StandardAttributeResolver object */ @Override - public boolean isActive(Object e) { + public boolean isActive(Node e) { return ui.isActive((Element) e); } @@ -131,7 +132,7 @@ public boolean isActive(Object e) { * Gets the focus attribute of the StandardAttributeResolver object */ @Override - public boolean isFocus(Object e) { + public boolean isFocus(Node e) { return ui.isFocus((Element) e); } } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/AttributeResolver.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/AttributeResolver.java index beb1c0f5c..4a7ff7306 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/AttributeResolver.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/AttributeResolver.java @@ -19,6 +19,8 @@ */ package org.xhtmlrenderer.css.extend; +import org.w3c.dom.Node; + import javax.annotation.Nullable; /** @@ -42,61 +44,61 @@ public interface AttributeResolver { * not null if attribute exists. */ @Nullable - String getAttributeValue(Object e, String attrName); + String getAttributeValue(Node e, String attrName); /** * Required to return null if attribute does not exist and * not null if attribute exists. */ @Nullable - String getAttributeValue(Object e, String namespaceURI, String attrName); + String getAttributeValue(Node e, String namespaceURI, String attrName); @Nullable - String getClass(Object e); + String getClass(Node e); @Nullable - String getID(Object e); + String getID(Node e); /** * @return The non css styling (specificity 0,0,0,0 on author styles, according to css 2.1) */ @Nullable - String getNonCssStyling(Object e); + String getNonCssStyling(Node e); /** * @return The elementStyling value * (corresponding to xhtml style attribute, specificity 1,0,0,0 according to css 2.1) */ @Nullable - String getElementStyling(Object e); + String getElementStyling(Node e); @Nullable - String getLang(Object e); + String getLang(Node e); /** * Gets the link attribute of the AttributeResolver object */ - boolean isLink(Object e); + boolean isLink(Node e); /** * Gets the visited attribute of the AttributeResolver object */ - boolean isVisited(Object e); + boolean isVisited(Node e); /** * Gets the hover attribute of the AttributeResolver object */ - boolean isHover(Object e); + boolean isHover(Node e); /** * Gets the active attribute of the AttributeResolver object */ - boolean isActive(Object e); + boolean isActive(Node e); /** * Gets the focus attribute of the AttributeResolver object */ - boolean isFocus(Object e); + boolean isFocus(Node e); } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/lib/DOMStaticXhtmlAttributeResolver.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/lib/DOMStaticXhtmlAttributeResolver.java index 1f40b5e5f..2b85b1953 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/lib/DOMStaticXhtmlAttributeResolver.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/lib/DOMStaticXhtmlAttributeResolver.java @@ -24,6 +24,7 @@ import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; import org.xhtmlrenderer.css.extend.AttributeResolver; import org.xhtmlrenderer.css.extend.TreeResolver; @@ -32,12 +33,12 @@ */ public class DOMStaticXhtmlAttributeResolver implements AttributeResolver { @Override - public String getAttributeValue(Object e, String attrName) { + public String getAttributeValue(Node e, String attrName) { return ((Element) e).getAttribute(attrName); } @Override - public String getAttributeValue(Object o, String namespaceURI, String attrName) { + public String getAttributeValue(Node o, String namespaceURI, String attrName) { Element e = (Element)o; if (namespaceURI == TreeResolver.NO_NAMESPACE) { return e.getAttribute(attrName); @@ -62,27 +63,27 @@ public String getAttributeValue(Object o, String namespaceURI, String attrName) } @Override - public String getClass(Object e) { + public String getClass(Node e) { return ((Element) e).getAttribute("class"); } @Override - public String getID(Object e) { + public String getID(Node e) { return ((Element) e).getAttribute("id"); } @Override - public String getNonCssStyling(Object e) { + public String getNonCssStyling(Node e) { return null; } @Override - public String getLang(Object e) { + public String getLang(Node e) { return ((Element) e).getAttribute("lang"); } @Override - public String getElementStyling(Object el) { + public String getElementStyling(Node el) { Element e = ((Element) el); StringBuilder style = new StringBuilder(); if (e.getNodeName().equals("td")) { @@ -103,28 +104,28 @@ public String getElementStyling(Object el) { } @Override - public boolean isActive(Object e) { + public boolean isActive(Node e) { return false; } @Override - public boolean isFocus(Object e) { + public boolean isFocus(Node e) { return false; } @Override - public boolean isHover(Object e) { + public boolean isHover(Node e) { return false; } @Override - public boolean isLink(Object el) { + public boolean isLink(Node el) { Element e = ((Element) el); return e.getNodeName().equalsIgnoreCase("a") && !e.getAttribute("href").isEmpty(); } @Override - public boolean isVisited(Object e) { + public boolean isVisited(Node e) { return false; } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/newmatch/Matcher.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/newmatch/Matcher.java index eb3c68d94..fef875a12 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/newmatch/Matcher.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/newmatch/Matcher.java @@ -136,7 +136,7 @@ public boolean isFocusStyled(Node e) { return _focusElements.contains(e); } - protected Mapper matchElement(Node e) { + private Mapper matchElement(Node e) { synchronized (e) { Node parent = _treeRes.getParentElement(e); Mapper child; @@ -150,7 +150,7 @@ protected Mapper matchElement(Node e) { } } - Mapper createDocumentMapper(List stylesheets, String medium) { + private Mapper createDocumentMapper(List stylesheets, String medium) { Map sorter = new TreeMap<>(); addAllStylesheets(stylesheets, sorter, medium); XRLog.match("Matcher created with " + sorter.size() + " selectors");