[HtmlUnit] [htmlunit:bugs] #1997 Element height calculation ignores children if the height of the element itself is 0
RBRi via HtmlUnit-develop <[email protected]> Wed, 24 Oct 2018 18:32:41 -0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/1997/2d87bd202bf54d369e06a1a904e5ad69320cad00.bugs@htmlunit.p.sourceforge.net> |
- **status**: open --> accepted
- **assigned_to**: RBRi
---
** [bugs:#1997] Element height calculation ignores children if the height of the element itself is 0**
**Status:** accepted
**Group:** 2.33
**Created:** Thu Oct 18, 2018 09:18 AM UTC by Rural Hunter
**Last Updated:** Wed Oct 24, 2018 06:32 PM UTC
**Owner:** RBRi
The test code:
~~~
@Test
public void testMain() throws Exception
{
List<String> alerts = new ArrayList<>();
WebClient wc=new WebClient();
wc.setAlertHandler(new CollectingAlertHandler(alerts));
wc.getPage(getClass().getResource("element_size.html"));
System.out.println(alerts.toString());
}
~~~
The element_size.html page:
~~~
<html>
<head>
<title>size test</title>
</head>
<body>
<div id="div1">
<iframe height="360" src="http://www.bing.com" frameborder="0" width="410"></iframe>
</div>
<script language="JavaScript">
alert(div1.offsetHeight);
</script>
</body>
</html>
~~~
In real browser, the alert result is 360. In htmlunit, the result is 0.
If I comment out the code below in ComputedCSSStyleDeclaration.getCalculatedHeight(), the alert result is 154. Though it's still not the same as the browser, but it's much better.
~~~
private int getCalculatedHeight() {
if (height_ != null) {
return height_.intValue();
}
int height = getEmptyHeight();
// if (height == 0) {
// height_ = Integer.valueOf(0);
// return 0;
// }
if (super.getHeight().isEmpty()) {
~~~
I also noticed the logic in getCalculatedWidth() is different:
~~~
private int getCalculatedWidth() {
if (width_ != null) {
return width_.intValue();
}
final Element element = getElement();
final DomNode node = element.getDomNodeOrDie();
if (!node.mayBeDisplayed()) {
width_ = Integer.valueOf(0);
return 0;
}
~~~
---
Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop