From: <rb...@us...> - 2013-02-11 19:08:14
|
Revision: 8106 http://sourceforge.net/p/htmlunit/code/8106 Author: rbri Date: 2013-02-11 19:08:09 +0000 (Mon, 11 Feb 2013) Log Message: ----------- another minor optimization Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-02-11 16:23:26 UTC (rev 8105) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-02-11 19:08:09 UTC (rev 8106) @@ -37,6 +37,7 @@ import java.util.TreeMap; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import org.apache.commons.lang3.StringUtils; import org.w3c.css.sac.Selector; @@ -1295,16 +1296,19 @@ ComputedCSSStyleDeclaration lastFlowing = null; final Set<ComputedCSSStyleDeclaration> styles = new HashSet<ComputedCSSStyleDeclaration>(); for (final DomNode child : node.getChildren()) { - if (child.mayBeDisplayed() && child.getScriptObject() instanceof HTMLElement) { - final HTMLElement e = (HTMLElement) child.getScriptObject(); - final ComputedCSSStyleDeclaration style = e.getCurrentStyle(); - final String pos = style.getPositionWithInheritance(); - if ("static".equals(pos) || "relative".equals(pos)) { - lastFlowing = style; + if (child.mayBeDisplayed()) { + final ScriptableObject scriptObj = child.getScriptObject(); + if (scriptObj instanceof HTMLElement) { + final HTMLElement e = (HTMLElement) scriptObj; + final ComputedCSSStyleDeclaration style = e.getCurrentStyle(); + final String pos = style.getPositionWithInheritance(); + if ("static".equals(pos) || "relative".equals(pos)) { + lastFlowing = style; + } + else if ("absolute".equals(pos)) { + styles.add(style); + } } - else if ("absolute".equals(pos)) { - styles.add(style); - } } } |