<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[20688] trunk</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20688">20688</a></dd>
<dt>Author</dt> <dd>andersca</dd>
<dt>Date</dt> <dd>2007-04-03 14:39:53 -0700 (Tue, 03 Apr 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>LayoutTests:
Reviewed by Mitz.
Add tests for innerWidth/innerHeight and clientWidth/clientHeight in quirks mode.
Modify the strict clientWidth/clientHeight test to test the behavior with scrollbars visible.
* fast/dom/client-width-height-quirks-expected.txt: Added.
* fast/dom/client-width-height-quirks.html: Added.
* fast/dom/client-width-height.html:
* fast/dom/inner-width-height-expected.txt: Added.
* fast/dom/inner-width-height.html: Added.
WebCore:
Reviewed by Mitz.
Make window.innerWidth/innerHeight include the size of any present scrollbar to match Firefox.
Make document.body.clientWidth/clientHeight return the width/height of the visible content when in
quirks mode to match WinIE.
* bindings/js/kjs_window.cpp:
(KJS::Window::getValueProperty):
Return the width and height of the scroll view, not the visible width and height.
* dom/Element.cpp:
(WebCore::Element::clientWidth):
(WebCore::Element::clientHeight):
Return the visible size if the element is the body element and we're in quirks mode.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomclientwidthheighthtml">trunk/LayoutTests/fast/dom/client-width-height.html</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorebindingsjskjs_windowcpp">trunk/WebCore/bindings/js/kjs_window.cpp</a></li>
<li><a href="#trunkWebCoredomElementcpp">trunk/WebCore/dom/Element.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomclientwidthheightquirksexpectedtxt">trunk/LayoutTests/fast/dom/client-width-height-quirks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomclientwidthheightquirkshtml">trunk/LayoutTests/fast/dom/client-width-height-quirks.html</a></li>
<li><a href="#trunkLayoutTestsfastdominnerwidthheightexpectedtxt">trunk/LayoutTests/fast/dom/inner-width-height-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdominnerwidthheighthtml">trunk/LayoutTests/fast/dom/inner-width-height.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (20687 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-04-03 20:51:55 UTC (rev 20687)
+++ trunk/LayoutTests/ChangeLog        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2007-04-03 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Mitz.
+
+ Add tests for innerWidth/innerHeight and clientWidth/clientHeight in quirks mode.
+
+ Modify the strict clientWidth/clientHeight test to test the behavior with scrollbars visible.
+
+ * fast/dom/client-width-height-quirks-expected.txt: Added.
+ * fast/dom/client-width-height-quirks.html: Added.
+ * fast/dom/client-width-height.html:
+ * fast/dom/inner-width-height-expected.txt: Added.
+ * fast/dom/inner-width-height.html: Added.
+
</ins><span class="cx"> 2007-04-03 Mitz Pettel <mitz@webkit.org>
</span><span class="cx">
</span><span class="cx"> Reviewed by Darin.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomclientwidthheightquirksexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/client-width-height-quirks-expected.txt (0 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/client-width-height-quirks-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/client-width-height-quirks-expected.txt        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that clientWidth/clientHeight on the body element in quirks mode returns the visible size of the frame.
+SUCCESS!
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomclientwidthheightquirkshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/client-width-height-quirks.html (0 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/client-width-height-quirks.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/client-width-height-quirks.html        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+<html>
+<head>
+ <script>
+ function debug(str) {
+ pre = document.getElementById('console');
+ pre.appendChild(document.createTextNode(str + '\n'));
+ }
+
+ function runTests() {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ if (document.body.clientWidth != window.innerWidth ||
+ document.body.clientHeight != window.innerHeight) {
+ debug("FAILURE!")
+ return;
+ }
+
+ // Now force scroll bars. innerWidth and innerHeight should not take the scroll bar into account
+ // but clientWidth and clientHeight should.
+ document.body.style.overflow = 'scroll';
+ document.body.offsetTop;
+
+ if (document.body.clientWidth >= window.innerWidth ||
+ document.body.clientHeight >= window.innerHeight) {
+ debug("FAILURE!")
+ return;
+ }
+
+ debug("SUCCESS!");
+ }
+ </script>
+</head>
+<body onload="runTests()">
+ This tests that clientWidth/clientHeight on the body element in quirks mode returns the visible size of the frame.
+ <pre id="console"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomclientwidthheighthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/client-width-height.html (20687 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/client-width-height.html        2007-04-03 20:51:55 UTC (rev 20687)
+++ trunk/LayoutTests/fast/dom/client-width-height.html        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -1,22 +1,35 @@
</span><span class="cx"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
</span><del>-        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</del><ins>+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</ins><span class="cx"> <html>
</span><span class="cx"> <head>
</span><span class="cx"> <script>
</span><span class="cx"> function debug(str) {
</span><del>-          pre = document.getElementById('console');
-          pre.appendChild(document.createTextNode(str + '\n'));
</del><ins>+ pre = document.getElementById('console');
+ pre.appendChild(document.createTextNode(str + '\n'));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function runTests() {
</span><span class="cx"> if (window.layoutTestController)
</span><span class="cx"> layoutTestController.dumpAsText();
</span><span class="cx">
</span><del>- if (document.documentElement.clientWidth == window.innerWidth &&
- document.documentElement.clientHeight == window.innerHeight)
- debug("SUCCESS!");
- else
- debug("FAILURE!");
</del><ins>+ if (document.documentElement.clientWidth != window.innerWidth ||
+ document.documentElement.clientHeight != window.innerHeight) {
+ debug("FAILURE!")
+ return;
+ }
+
+ // Now force scroll bars. innerWidth and innerHeight should not take the scroll bar into account
+ // but clientWidth and clientHeight should.
+ document.documentElement.style.overflow = 'scroll';
+ document.body.offsetTop;
+
+ if (document.documentElement.clientWidth >= window.innerWidth ||
+ document.documentElement.clientHeight >= window.innerHeight) {
+ debug("FAILURE!")
+ return;
+ }
+
+ debug("SUCCESS!");
</ins><span class="cx"> }
</span><span class="cx"> </script>
</span><span class="cx"> </head>
</span></span></pre></div>
<a id="trunkLayoutTestsfastdominnerwidthheightexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/inner-width-height-expected.txt (0 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/inner-width-height-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/inner-width-height-expected.txt        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that window.innerWidth/innerHeight does not include the size of the scrollbars.
+SUCCESS!
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdominnerwidthheighthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/inner-width-height.html (0 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/inner-width-height.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/inner-width-height.html        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+<html>
+<head>
+ <script>
+ function debug(str) {
+ pre = document.getElementById('console');
+ pre.appendChild(document.createTextNode(str + '\n'));
+ }
+
+ function runTests() {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var width = window.innerWidth;
+ var height = window.innerHeight;
+
+ // Now force scroll bars. innerWidth and innerHeight should not take the scroll bar into account
+ document.body.style.overflow = 'scroll';
+ document.body.offsetTop;
+
+ if (width != window.innerWidth || height != window.innerHeight) {
+ debug("FAILURE!")
+ return;
+ }
+
+ debug("SUCCESS!");
+ }
+ </script>
+</head>
+<body onload="runTests()">
+ This tests that window.innerWidth/innerHeight does not include the size of the scrollbars.
+ <pre id="console"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (20687 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-04-03 20:51:55 UTC (rev 20687)
+++ trunk/WebCore/ChangeLog        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2007-04-03 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Mitz.
+
+ Make window.innerWidth/innerHeight include the size of any present scrollbar to match Firefox.
+
+ Make document.body.clientWidth/clientHeight return the width/height of the visible content when in
+ quirks mode to match WinIE.
+
+ * bindings/js/kjs_window.cpp:
+ (KJS::Window::getValueProperty):
+ Return the width and height of the scroll view, not the visible width and height.
+
+ * dom/Element.cpp:
+ (WebCore::Element::clientWidth):
+ (WebCore::Element::clientHeight):
+ Return the visible size if the element is the body element and we're in quirks mode.
+
</ins><span class="cx"> 2007-04-03 Adele Peterson <adele@apple.com>
</span><span class="cx">
</span><span class="cx"> Reviewed by Darin.
</span></span></pre></div>
<a id="trunkWebCorebindingsjskjs_windowcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/js/kjs_window.cpp (20687 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/js/kjs_window.cpp        2007-04-03 20:51:55 UTC (rev 20687)
+++ trunk/WebCore/bindings/js/kjs_window.cpp        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -726,11 +726,11 @@
</span><span class="cx"> case InnerHeight:
</span><span class="cx"> if (!m_frame->view())
</span><span class="cx"> return jsUndefined();
</span><del>- return jsNumber(m_frame->view()->visibleHeight());
</del><ins>+ return jsNumber(m_frame->view()->height());
</ins><span class="cx"> case InnerWidth:
</span><span class="cx"> if (!m_frame->view())
</span><span class="cx"> return jsUndefined();
</span><del>- return jsNumber(m_frame->view()->visibleWidth());
</del><ins>+ return jsNumber(m_frame->view()->width());
</ins><span class="cx"> case Length:
</span><span class="cx"> return jsNumber(m_frame->tree()->childCount());
</span><span class="cx"> case Location_:
</span></span></pre></div>
<a id="trunkWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Element.cpp (20687 => 20688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Element.cpp        2007-04-03 20:51:55 UTC (rev 20687)
+++ trunk/WebCore/dom/Element.cpp        2007-04-03 21:39:53 UTC (rev 20688)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "FocusController.h"
</span><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "FrameView.h"
</span><ins>+#include "HTMLElement.h"
</ins><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "KURL.h"
</span><span class="cx"> #include "NamedAttrMap.h"
</span><span class="lines">@@ -254,12 +255,16 @@
</span><span class="cx"> {
</span><span class="cx"> document()->updateLayoutIgnorePendingStylesheets();
</span><span class="cx">
</span><del>- // When in strict mode, clientWidth for the document
- // element should return the width of the containing frame.
- if (!document()->inCompatMode() && document()->documentElement() == this)
</del><ins>+ // When in strict mode, clientWidth for the document element should return the width of the containing frame.
+ // When in quirks mode, clientWidth for the body element should return the width of the containing frame.
+ bool inCompatMode = document()->inCompatMode();
+ if ((!inCompatMode && document()->documentElement() == this) ||
+ (inCompatMode && isHTMLElement() && document()->body() == this)) {
</ins><span class="cx"> if (FrameView* view = document()->view())
</span><span class="cx"> return view->visibleWidth();
</span><ins>+ }
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> if (RenderObject* rend = renderer())
</span><span class="cx"> return rend->clientWidth();
</span><span class="cx"> return 0;
</span><span class="lines">@@ -269,11 +274,15 @@
</span><span class="cx"> {
</span><span class="cx"> document()->updateLayoutIgnorePendingStylesheets();
</span><span class="cx">
</span><del>- // When in strict mode, clientHeight for the document
- // element should return the height of the containing frame.
- if (!document()->inCompatMode() && document()->documentElement() == this)
</del><ins>+ // When in strict mode, clientHeight for the document element should return the height of the containing frame.
+ // When in quirks mode, clientHeight for the body element should return the height of the containing frame.
+ bool inCompatMode = document()->inCompatMode();
+
+ if ((!inCompatMode && document()->documentElement() == this) ||
+ (inCompatMode && isHTMLElement() && document()->body() == this)) {
</ins><span class="cx"> if (FrameView* view = document()->view())
</span><span class="cx"> return view->visibleHeight();
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> if (RenderObject* rend = renderer())
</span><span class="cx"> return rend->clientHeight();
</span></span></pre>
</div>
</div>
</body>
</html>