From: <rb...@us...> - 2013-02-11 16:23:29
|
Revision: 8105 http://sourceforge.net/p/htmlunit/code/8105 Author: rbri Date: 2013-02-11 16:23:26 +0000 (Mon, 11 Feb 2013) Log Message: ----------- next 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 15:42:42 UTC (rev 8104) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-02-11 16:23:26 UTC (rev 8105) @@ -1292,31 +1292,28 @@ return 0; } - HTMLElement lastFlowing = null; - final Set<HTMLElement> independent = new HashSet<HTMLElement>(); + 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 = e; + lastFlowing = style; } else if ("absolute".equals(pos)) { - independent.add(e); + styles.add(style); } } } - final Set<HTMLElement> relevant = new HashSet<HTMLElement>(); - relevant.addAll(independent); if (lastFlowing != null) { - relevant.add(lastFlowing); + styles.add(lastFlowing); } int max = 0; - for (final HTMLElement e : relevant) { - final ComputedCSSStyleDeclaration style = e.getCurrentStyle(); + for (final ComputedCSSStyleDeclaration style : styles) { final int h = style.getTop(true, false, false) + style.getCalculatedHeight(true, true); if (h > max) { max = h; @@ -1459,12 +1456,13 @@ for (DomNode n = getDomNodeOrDie(); n != null; n = n.getPreviousSibling()) { if (n.getScriptObject() instanceof HTMLElement) { final HTMLElement e = (HTMLElement) n.getScriptObject(); - final String d = e.getCurrentStyle().getDisplay(); + final ComputedCSSStyleDeclaration style = e.getCurrentStyle(); + final String d = style.getDisplay(); if ("block".equals(d)) { break; } else if (!"none".equals(d)) { - left += e.getCurrentStyle().getCalculatedWidth(true, true); + left += style.getCalculatedWidth(true, true); } } else if (n.getScriptObject() instanceof Text) { |