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) { |
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); - } } } |
From: <rb...@us...> - 2013-04-17 17:38:38
|
Revision: 8227 http://sourceforge.net/p/htmlunit/code/8227 Author: rbri Date: 2013-04-17 17:38:32 +0000 (Wed, 17 Apr 2013) Log Message: ----------- minor code 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-04-15 17:49:15 UTC (rev 8226) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-04-17 17:38:32 UTC (rev 8227) @@ -1357,33 +1357,37 @@ * @return the computed top (Y coordinate), relative to the node's parent's top edge */ public int getTop(final boolean includeMargin, final boolean includeBorder, final boolean includePadding) { - int top; + int top = 0; if (null == top_) { final String p = getPositionWithInheritance(); - final String t = getTopWithInheritance(); - final String b = getBottomWithInheritance(); + if ("absolute".equals(p)) { + final String t = getTopWithInheritance(); - if ("absolute".equals(p) && !"auto".equals(t)) { - // No need to calculate displacement caused by sibling nodes. - top = pixelValue(t); - } - else if ("absolute".equals(p) && !"auto".equals(b)) { - // Estimate the vertical displacement caused by *all* siblings. - // This is very rough, and doesn't even take position or display types into account. - // It also doesn't take into account the fact that the parent's height may be hardcoded in CSS. - top = 0; - DomNode child = getElement().getDomNodeOrDie().getParentNode().getFirstChild(); - while (child != null) { - if (child instanceof HtmlElement && child.mayBeDisplayed()) { - top += 20; + if (!"auto".equals(t)) { + // No need to calculate displacement caused by sibling nodes. + top = pixelValue(t); + } + else { + final String b = getBottomWithInheritance(); + + if (!"auto".equals(b)) { + // Estimate the vertical displacement caused by *all* siblings. + // This is very rough, and doesn't even take position or display types into account. + // It also doesn't take into account the fact that the parent's height may be hardcoded in CSS. + top = 0; + DomNode child = getElement().getDomNodeOrDie().getParentNode().getFirstChild(); + while (child != null) { + if (child instanceof HtmlElement && child.mayBeDisplayed()) { + top += 20; + } + child = child.getNextSibling(); + } + top -= pixelValue(b); } - child = child.getNextSibling(); } - top -= pixelValue(b); } else { // Calculate the vertical displacement caused by *previous* siblings. - top = 0; DomNode prev = getElement().getDomNodeOrDie().getPreviousSibling(); while (prev != null && !(prev instanceof HtmlElement)) { prev = prev.getPreviousSibling(); @@ -1395,6 +1399,7 @@ } // If the position is relative, we also need to add the specified "top" displacement. if ("relative".equals(p)) { + final String t = getTopWithInheritance(); top += pixelValue(t); } } |
From: <rb...@us...> - 2013-06-14 17:39:51
|
Revision: 8343 http://sourceforge.net/p/htmlunit/code/8343 Author: rbri Date: 2013-06-14 17:39:48 +0000 (Fri, 14 Jun 2013) Log Message: ----------- static maps are factored out 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-06-14 07:22:00 UTC (rev 8342) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-06-14 17:39:48 UTC (rev 8343) @@ -113,15 +113,38 @@ "widows", "word-spacing")); + /** Maps element types to custom display types (display types that are not "block". */ + private static final Map<String, String> DEFAULT_DISPLAYS; + private static final Map<String, String> DEFAULT_DISPLAYS_CSS; + + static { + HashMap<String, String> map = new HashMap<String, String>(); + map.put("A", "inline"); + map.put("CODE", "inline"); + map.put("SPAN", "inline"); + DEFAULT_DISPLAYS = Collections.unmodifiableMap(map); + + map = new HashMap<String, String>(); + map.put("A", "inline"); + map.put("CODE", "inline"); + map.put("SPAN", "inline"); + + map.put("LI", "list-item"); + map.put("TABLE", "table"); + map.put("TBODY", "table-row-group"); + map.put("TD", "table-cell"); + map.put("TH", "table-cell"); + map.put("THEAD", "table-header-group"); + map.put("TR", "table-row"); + DEFAULT_DISPLAYS_CSS = Collections.unmodifiableMap(map); + } + /** * Local modifications maintained here rather than in the element. We use a sorted * map so that results are deterministic and thus easily testable. */ private final SortedMap<String, StyleElement> localModifications_ = new TreeMap<String, StyleElement>(); - /** Maps element types to custom display types (display types that are not "block". */ - private Map<String, String> defaultDisplays_; - /** The computed, cached width of the element to which this computed style belongs (no padding, borders, etc). */ private Integer width_; @@ -553,23 +576,12 @@ } private String getDefaultStyleDisplay() { - if (defaultDisplays_ == null) { - final Map<String, String> map = new HashMap<String, String>(); - map.put("A", "inline"); - map.put("CODE", "inline"); - map.put("SPAN", "inline"); - if (getBrowserVersion().hasFeature(CSS_DISPLAY_DEFAULT)) { - map.put("LI", "list-item"); - map.put("TABLE", "table"); - map.put("TBODY", "table-row-group"); - map.put("TD", "table-cell"); - map.put("TH", "table-cell"); - map.put("THEAD", "table-header-group"); - map.put("TR", "table-row"); - } - defaultDisplays_ = Collections.unmodifiableMap(map); + Map<String, String> map = DEFAULT_DISPLAYS; + if (getBrowserVersion().hasFeature(CSS_DISPLAY_DEFAULT)) { + map = DEFAULT_DISPLAYS_CSS; } - final String defaultValue = defaultDisplays_.get(getElement().getTagName()); + + final String defaultValue = map.get(getElement().getTagName()); if (defaultValue == null) { return "block"; } |
From: <rb...@us...> - 2013-07-01 20:30:46
|
Revision: 8365 http://sourceforge.net/p/htmlunit/code/8365 Author: rbri Date: 2013-07-01 20:30:43 +0000 (Mon, 01 Jul 2013) Log Message: ----------- next try to fix the build 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-06-30 20:32:19 UTC (rev 8364) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-07-01 20:30:43 UTC (rev 8365) @@ -149,7 +149,7 @@ map.put("I", "inline"); // map.put("IFRAME", "inline"); map.put("IMG", "inline"); - map.put("INPUT", "inline-block"); + // map.put("INPUT", "inline-block"); map.put("INS", "inline"); map.put("KBD", "inline"); map.put("KEYGEN", "inline"); @@ -180,7 +180,7 @@ map.put("FIGURE", "block"); map.put("FOOTER", "block"); map.put("HEADER", "block"); - map.put("INPUT", "inline"); + // map.put("INPUT", "inline"); map.put("LEGEND", "block"); map.put("METER", "inline-block"); |
From: <rb...@us...> - 2013-07-04 19:58:20
|
Revision: 8366 http://sourceforge.net/p/htmlunit/code/8366 Author: rbri Date: 2013-07-04 19:58:13 +0000 (Thu, 04 Jul 2013) Log Message: ----------- fix contentWidth calculation for iframes 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-07-01 20:30:43 UTC (rev 8365) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-07-04 19:58:13 UTC (rev 8366) @@ -42,8 +42,11 @@ import org.apache.commons.lang3.StringUtils; import org.w3c.css.sac.Selector; +import com.gargoylesoftware.htmlunit.Page; +import com.gargoylesoftware.htmlunit.html.BaseFrameElement; import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.html.HtmlElement; +import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlTableRow; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.host.Element; @@ -147,7 +150,7 @@ map.put("FOOTER", "inline"); map.put("HEADER", "inline"); map.put("I", "inline"); - // map.put("IFRAME", "inline"); + map.put("IFRAME", "inline"); map.put("IMG", "inline"); // map.put("INPUT", "inline-block"); map.put("INS", "inline"); @@ -1202,14 +1205,14 @@ public int getContentWidth() { int width = 0; final DomNode domNode = getDomNodeOrDie(); - final Iterable<DomNode> childs = domNode.getChildren(); -// if (domNode instanceof BaseFrameElement) { -// final Page enclosedPage = ((BaseFrameElement) domNode).getEnclosedPage(); -// if (enclosedPage instanceof HtmlPage) { -// final HtmlPage htmlPage = (HtmlPage) enclosedPage; -// childs = htmlPage.getChildren(); -// } -// } + Iterable<DomNode> childs = domNode.getChildren(); + if (domNode instanceof BaseFrameElement) { + final Page enclosedPage = ((BaseFrameElement) domNode).getEnclosedPage(); + if (enclosedPage instanceof HtmlPage) { + final HtmlPage htmlPage = (HtmlPage) enclosedPage; + childs = htmlPage.getChildren(); + } + } for (final DomNode child : childs) { if (child.getScriptObject() instanceof HTMLElement) { final HTMLElement e = (HTMLElement) child.getScriptObject(); |
From: <asa...@us...> - 2016-02-27 22:12:24
|
Revision: 11927 http://sourceforge.net/p/htmlunit/code/11927 Author: asashour Date: 2016-02-27 22:12:21 +0000 (Sat, 27 Feb 2016) Log Message: ----------- Fixing build 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 2016-02-27 21:12:00 UTC (rev 11926) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2016-02-27 22:12:21 UTC (rev 11927) @@ -1976,7 +1976,8 @@ if (includeBorder) { width += getBorderHorizontal(); } - else if (isScrollable(true, true) && getElement().getDomNodeOrDie().isDirectlyAttachedToPage()) { + else if (isScrollable(true, true) && !(getElement() instanceof HTMLBodyElement) + && getElement().getDomNodeOrDie().isDirectlyAttachedToPage()) { width -= 17; } if (includePadding) { @@ -2104,7 +2105,8 @@ if (includeBorder) { height += getBorderVertical(); } - else if (isScrollable(false, true) && getElement().getDomNodeOrDie().isDirectlyAttachedToPage()) { + else if (isScrollable(false, true) && !(getElement() instanceof HTMLBodyElement) + && getElement().getDomNodeOrDie().isDirectlyAttachedToPage()) { height -= 17; } if (includePadding) { |
From: <asa...@us...> - 2016-04-11 11:30:50
|
Revision: 12384 http://sourceforge.net/p/htmlunit/code/12384 Author: asashour Date: 2016-04-11 11:30:47 +0000 (Mon, 11 Apr 2016) Log Message: ----------- simplify 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 2016-04-11 11:21:57 UTC (rev 12383) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2016-04-11 11:30:47 UTC (rev 12384) @@ -602,7 +602,11 @@ */ @Override public String getFontSize() { - return defaultIfEmpty(super.getFontSize(), FONT_SIZE); + String value = super.getFontSize(); + if (!value.isEmpty()) { + value = pixelValue(value) + "px"; + } + return value; } /** |
From: <asa...@us...> - 2016-04-13 14:42:11
|
Revision: 12413 http://sourceforge.net/p/htmlunit/code/12413 Author: asashour Date: 2016-04-13 14:42:09 +0000 (Wed, 13 Apr 2016) Log Message: ----------- Fixing build 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 2016-04-13 12:18:40 UTC (rev 12412) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2016-04-13 14:42:09 UTC (rev 12413) @@ -696,6 +696,10 @@ */ @Override public String getMarginLeft() { + final String superMarginLeft = super.getMarginLeft(); + if (!superMarginLeft.endsWith("%")) { + return pixelString(defaultIfEmpty(superMarginLeft, "0px")); + } final Element elem = getElement(); if (!elem.getDomNodeOrDie().isAttachedToPage()) { if (getBrowserVersion().hasFeature(CSS_COMPUTED_NO_Z_INDEX)) { @@ -720,6 +724,10 @@ */ @Override public String getMarginRight() { + final String superMarginRight = super.getMarginRight(); + if (!superMarginRight.endsWith("%")) { + return pixelString(defaultIfEmpty(superMarginRight, "0px")); + } final Element elem = getElement(); if (!elem.getDomNodeOrDie().isAttachedToPage()) { if (getBrowserVersion().hasFeature(CSS_COMPUTED_NO_Z_INDEX)) { |
From: <rb...@us...> - 2018-08-28 17:32:29
|
Revision: 15546 http://sourceforge.net/p/htmlunit/code/15546 Author: rbri Date: 2018-08-28 17:32:26 +0000 (Tue, 28 Aug 2018) Log Message: ----------- fix test 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 2018-08-27 18:41:21 UTC (rev 15545) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-08-28 17:32:26 UTC (rev 15546) @@ -1506,7 +1506,7 @@ // We need to calculate the horizontal displacement caused by *previous* siblings. left = 0; DomNode prev = getElement().getDomNodeOrDie().getPreviousSibling(); - while (prev != null) { + while (prev != null && !(prev instanceof HtmlTableRow)) { final Scriptable prevScriptable = prev.getScriptableObject(); if (prevScriptable instanceof HTMLElement) { final HTMLElement e = (HTMLElement) prevScriptable; @@ -1525,9 +1525,6 @@ left += content.trim().length() * getBrowserVersion().getPixesPerChar(); } } - if (prev instanceof HtmlTableRow) { - break; - } prev = prev.getPreviousSibling(); } } |
From: <rb...@us...> - 2018-08-28 17:44:34
|
Revision: 15555 http://sourceforge.net/p/htmlunit/code/15555 Author: rbri Date: 2018-08-28 17:44:31 +0000 (Tue, 28 Aug 2018) Log Message: ----------- fix test 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 2018-08-28 17:43:17 UTC (rev 15554) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-08-28 17:44:31 UTC (rev 15555) @@ -1506,7 +1506,11 @@ // We need to calculate the horizontal displacement caused by *previous* siblings. left = 0; DomNode prev = getElement().getDomNodeOrDie().getPreviousSibling(); - while (prev != null && !(prev instanceof HtmlTableRow)) { + while (prev != null) { + if (prev instanceof HtmlTableRow) { + break; + } + final Scriptable prevScriptable = prev.getScriptableObject(); if (prevScriptable instanceof HTMLElement) { final HTMLElement e = (HTMLElement) prevScriptable; |
From: <mgu...@us...> - 2013-07-11 13:28:44
|
Revision: 8389 http://sourceforge.net/p/htmlunit/code/8389 Author: mguillem Date: 2013-07-11 13:28:40 +0000 (Thu, 11 Jul 2013) Log Message: ----------- removed duplication 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-07-11 08:59:48 UTC (rev 8388) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2013-07-11 13:28:40 UTC (rev 8389) @@ -207,7 +207,6 @@ map.put("TFOOT", "table-footer-group"); map.put("TH", "table-cell"); map.put("THEAD", "table-header-group"); - map.put("THEAD", "table-header-group"); map.put("TIME", "inline"); map.put("TR", "table-row"); map.put("TRACK", "inline"); |
From: <rb...@us...> - 2014-07-04 10:33:29
|
Revision: 9492 http://sourceforge.net/p/htmlunit/code/9492 Author: rbri Date: 2014-07-04 10:33:24 +0000 (Fri, 04 Jul 2014) Log Message: ----------- duplicate code removed 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 2014-07-03 19:35:28 UTC (rev 9491) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2014-07-04 10:33:24 UTC (rev 9492) @@ -1152,9 +1152,6 @@ else if (node instanceof HtmlRadioButtonInput || node instanceof HtmlCheckBoxInput) { width = 20; // wild guess } - else if (node instanceof HtmlTextInput || node instanceof HtmlPasswordInput) { - width = 50; // wild guess - } else if (node instanceof HtmlTextArea) { width = 100; // wild guess } |
From: <asa...@us...> - 2015-03-09 02:09:51
|
Revision: 10129 http://sourceforge.net/p/htmlunit/code/10129 Author: asashour Date: 2015-03-09 02:09:48 +0000 (Mon, 09 Mar 2015) Log Message: ----------- ComputedCSSStyleDeclaration is not a JavaScript object. 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 2015-03-09 01:57:18 UTC (rev 10128) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2015-03-09 02:09:48 UTC (rev 10129) @@ -25,9 +25,6 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_GET_BACKGROUND_COLOR_FOR_COMPUTED_STYLE_AS_RGB; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_LENGTH_WITHOUT_PX; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.TREATS_POSITION_FIXED_LIKE_POSITION_STATIC; -import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; -import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; -import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import static org.apache.commons.lang3.StringUtils.defaultIfEmpty; import java.util.Arrays; @@ -63,8 +60,6 @@ import com.gargoylesoftware.htmlunit.html.HtmlTableRow; import com.gargoylesoftware.htmlunit.html.HtmlTextArea; import com.gargoylesoftware.htmlunit.html.HtmlTextInput; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; import com.gargoylesoftware.htmlunit.javascript.host.Element; import com.gargoylesoftware.htmlunit.javascript.host.Text; import com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition; @@ -73,16 +68,16 @@ import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement; /** - * A JavaScript object for a ComputedCSSStyleDeclaration. + * An object for a CSSStyleDeclaration, which is computed. * + * @see com.gargoylesoftware.htmlunit.javascript.host.Window#getComputedStyle(Element, String) + * * @version $Revision$ * @author Ahmed Ashour * @author Marc Guillemot * @author Ronald Brill * @author Frank Danek */ -@JsxClass(isJSObject = false, - browsers = { @WebBrowser(CHROME), @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 11) }) public class ComputedCSSStyleDeclaration extends CSSStyleDeclaration { /** The number of (horizontal) pixels to assume that each character occupies. */ |
From: <asa...@us...> - 2015-03-09 03:24:07
|
Revision: 10132 http://sourceforge.net/p/htmlunit/code/10132 Author: asashour Date: 2015-03-09 03:24:04 +0000 (Mon, 09 Mar 2015) Log Message: ----------- Fixing build 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 2015-03-09 03:17:34 UTC (rev 10131) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2015-03-09 03:24:04 UTC (rev 10132) @@ -25,6 +25,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_GET_BACKGROUND_COLOR_FOR_COMPUTED_STYLE_AS_RGB; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_LENGTH_WITHOUT_PX; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.TREATS_POSITION_FIXED_LIKE_POSITION_STATIC; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static org.apache.commons.lang3.StringUtils.defaultIfEmpty; import java.util.Arrays; @@ -60,6 +61,8 @@ import com.gargoylesoftware.htmlunit.html.HtmlTableRow; import com.gargoylesoftware.htmlunit.html.HtmlTextArea; import com.gargoylesoftware.htmlunit.html.HtmlTextInput; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; import com.gargoylesoftware.htmlunit.javascript.host.Element; import com.gargoylesoftware.htmlunit.javascript.host.Text; import com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition; @@ -78,6 +81,7 @@ * @author Ronald Brill * @author Frank Danek */ +@JsxClass(isJSObject = false, isDefinedInStandardsMode = false, browsers = @WebBrowser(FF)) public class ComputedCSSStyleDeclaration extends CSSStyleDeclaration { /** The number of (horizontal) pixels to assume that each character occupies. */ |
From: <asa...@us...> - 2016-04-11 15:02:57
|
Revision: 12387 http://sourceforge.net/p/htmlunit/code/12387 Author: asashour Date: 2016-04-11 15:02:54 +0000 (Mon, 11 Apr 2016) Log Message: ----------- checkstyle 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 2016-04-11 13:10:19 UTC (rev 12386) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2016-04-11 15:02:54 UTC (rev 12387) @@ -545,7 +545,7 @@ /** * Returns the {@code display} attribute. - * @param ignoreBlockIfNotAttached is {@link BrowserVersionFeatures#CSS_COMPUTED_BLOCK_IF_NOT_ATTACHED} ignored + * @param ignoreBlockIfNotAttached is {@link BrowserVersionFeatures#CSS_COMPUTED_BLOCK_IF_NOT_ATTACHED} ignored * @return the {@code display} attribute */ public String getDisplay(final boolean ignoreBlockIfNotAttached) { |
From: <asa...@us...> - 2016-07-27 11:37:29
|
Revision: 12879 http://sourceforge.net/p/htmlunit/code/12879 Author: asashour Date: 2016-07-27 11:37:26 +0000 (Wed, 27 Jul 2016) Log Message: ----------- javadoc 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 2016-07-27 11:17:05 UTC (rev 12878) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2016-07-27 11:37:26 UTC (rev 12879) @@ -130,7 +130,7 @@ /** * An object for a CSSStyleDeclaration, which is computed. * - * @see com.gargoylesoftware.htmlunit.javascript.host.Window#getComputedStyle(Element, String) + * @see com.gargoylesoftware.htmlunit.javascript.host.Window#getComputedStyle(Object, String) * * @author Ahmed Ashour * @author Marc Guillemot |
From: <rb...@us...> - 2016-08-16 16:38:10
|
Revision: 12918 http://sourceforge.net/p/htmlunit/code/12918 Author: rbri Date: 2016-08-16 16:38:08 +0000 (Tue, 16 Aug 2016) Log Message: ----------- simplify a bit 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 2016-08-16 13:30:27 UTC (rev 12917) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2016-08-16 16:38:08 UTC (rev 12918) @@ -1062,8 +1062,7 @@ } else if ("block".equals(display)) { if (element instanceof HTMLBodyElement) { - final String widthString = element.getWindow().getComputedStyle(element, null).getWidth(); - width = Integer.parseInt(widthString.substring(0, widthString.length() - 2)); + width = windowWidth - 16; } else { // Block elements take up 100% of the parent's width. |
From: <rb...@us...> - 2017-08-28 16:52:38
|
Revision: 14798 http://sourceforge.net/p/htmlunit/code/14798 Author: rbri Date: 2017-08-28 16:52:35 +0000 (Mon, 28 Aug 2017) Log Message: ----------- some micro 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 2017-08-25 15:23:39 UTC (rev 14797) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2017-08-28 16:52:35 UTC (rev 14798) @@ -266,11 +266,11 @@ public void applyStyleFromSelector(final org.w3c.dom.css.CSSStyleDeclaration declaration, final Selector selector) { final BrowserVersion browserVersion = getBrowserVersion(); final SelectorSpecificity specificity = new SelectorSpecificity(selector); - for (int k = 0; k < declaration.getLength(); k++) { - final String name = declaration.item(k); - final String value = declaration.getPropertyValue(name); - final String priority = declaration.getPropertyPriority(name); - if (!"z-index".equals(name) || !browserVersion.hasFeature(CSS_COMPUTED_NO_Z_INDEX)) { + for (int i = 0; i < declaration.getLength(); i++) { + final String name = declaration.item(i); + if (!browserVersion.hasFeature(CSS_COMPUTED_NO_Z_INDEX) || !"z-index".equals(name)) { + final String value = declaration.getPropertyValue(name); + final String priority = declaration.getPropertyPriority(name); applyLocalStyleAttribute(name, value, priority, specificity); } } |
From: <rb...@us...> - 2017-12-13 21:33:11
|
Revision: 15007 http://sourceforge.net/p/htmlunit/code/15007 Author: rbri Date: 2017-12-13 21:33:09 +0000 (Wed, 13 Dec 2017) Log Message: ----------- fixes for chrome 63 (wip) 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 2017-12-13 21:19:00 UTC (rev 15006) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2017-12-13 21:33:09 UTC (rev 15007) @@ -46,7 +46,6 @@ import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT; import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT_FAMILY; import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT_SIZE; -import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT_STRETCH; import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT_STYLE; import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT_VARIANT; import static com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes.Definition.FONT_WEIGHT; @@ -610,10 +609,7 @@ public String getFont() { if (getBrowserVersion().hasFeature(CSS_COMPUTED_NO_Z_INDEX) && getElement().getDomNodeOrDie().isAttachedToPage()) { - return getStyleAttribute(FONT_STYLE, true) + ' ' + getStyleAttribute(FONT_VARIANT, true) + ' ' - + getStyleAttribute(FONT_WEIGHT, true) + ' ' + getStyleAttribute(FONT_STRETCH, true) + ' ' - + getFontSize() + ' ' + '/' + ' ' + getStyleAttribute(LINE_HEIGHT, true) + ' ' - + getStyleAttribute(FONT_FAMILY, true); + return super.getFont(); } return ""; } |
From: <rb...@us...> - 2018-04-22 18:18:52
|
Revision: 15255 http://sourceforge.net/p/htmlunit/code/15255 Author: rbri Date: 2018-04-22 18:16:57 +0000 (Sun, 22 Apr 2018) Log Message: ----------- try to make calculation faster 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 2018-04-22 16:05:38 UTC (rev 15254) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-04-22 18:16:57 UTC (rev 15255) @@ -1169,22 +1169,18 @@ return height_.intValue(); } - final int elementHeight = getEmptyHeight(); - if (elementHeight == 0) { - height_ = Integer.valueOf(elementHeight); - return elementHeight; + int height = getEmptyHeight(); + if (height == 0) { + height_ = Integer.valueOf(0); + return 0; } - final int contentHeight = getContentHeight(); - final boolean explicitHeightSpecified = !super.getHeight().isEmpty(); - - final int height; - if (contentHeight > 0 && !explicitHeightSpecified) { - height = contentHeight; + if (super.getHeight().isEmpty()) { + final int contentHeight = getContentHeight(); + if (contentHeight > 0) { + height = contentHeight; + } } - else { - height = elementHeight; - } height_ = Integer.valueOf(height); return height; |
From: <rb...@us...> - 2018-06-29 17:34:09
|
Revision: 15417 http://sourceforge.net/p/htmlunit/code/15417 Author: rbri Date: 2018-06-29 17:33:58 +0000 (Fri, 29 Jun 2018) Log Message: ----------- ff60 support (wip) 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 2018-06-29 17:10:26 UTC (rev 15416) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2018-06-29 17:33:58 UTC (rev 15417) @@ -16,6 +16,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CSS_COMPUTED_BLOCK_IF_NOT_ATTACHED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CSS_COMPUTED_NO_Z_INDEX; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDEFINITION_INLINE_IN_QUIRKS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_CLIENTHIGHT_INPUT_17; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_CLIENTWIDTH_INPUT_TEXT_143; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_CLIENTWIDTH_INPUT_TEXT_169; @@ -105,6 +106,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlButton; import com.gargoylesoftware.htmlunit.html.HtmlButtonInput; import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput; +import com.gargoylesoftware.htmlunit.html.HtmlDefinitionDescription; import com.gargoylesoftware.htmlunit.html.HtmlDivision; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlFileInput; @@ -568,7 +570,10 @@ if (browserVersion.hasFeature(CSS_COMPUTED_NO_Z_INDEX)) { return ""; } - if (!ignoreBlockIfNotAttached && browserVersion.hasFeature(CSS_COMPUTED_BLOCK_IF_NOT_ATTACHED)) { + if (!ignoreBlockIfNotAttached + && (browserVersion.hasFeature(CSS_COMPUTED_BLOCK_IF_NOT_ATTACHED) + || (domElem instanceof HtmlDefinitionDescription + && browserVersion.hasFeature(HTMLDEFINITION_INLINE_IN_QUIRKS)))) { changeValueIfEmpty = true; } } @@ -1830,7 +1835,7 @@ * @see #pixelString(Element, CSSStyleDeclaration.CssValue) */ protected String pixelString(final String value) { - if (value == EMPTY_FINAL || value.endsWith("px")) { + if (EMPTY_FINAL == value || value.endsWith("px")) { return value; } return pixelValue(value) + "px"; |