<!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  &lt;andersca@apple.com&gt;
+
+        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  &lt;mitz@webkit.org&gt;
</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>+&lt;html&gt;
+&lt;head&gt;
+    &lt;script&gt;
+        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(&quot;FAILURE!&quot;)
+                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 &gt;= window.innerWidth ||
+                document.body.clientHeight &gt;= window.innerHeight) {
+                debug(&quot;FAILURE!&quot;)
+                return;
+            }
+                
+            debug(&quot;SUCCESS!&quot;);
+        }
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTests()&quot;&gt;
+    This tests that clientWidth/clientHeight on the body element in quirks mode returns the visible size of the frame.
+    &lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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"> &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
</span><del>-        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
</del><ins>+    &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
</ins><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;head&gt;
</span><span class="cx">     &lt;script&gt;
</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 &amp;&amp;
-                document.documentElement.clientHeight == window.innerHeight)
-                debug(&quot;SUCCESS!&quot;);
-            else
-                debug(&quot;FAILURE!&quot;);
</del><ins>+            if (document.documentElement.clientWidth != window.innerWidth ||
+                document.documentElement.clientHeight != window.innerHeight) {
+                debug(&quot;FAILURE!&quot;)
+                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 &gt;= window.innerWidth ||
+                document.documentElement.clientHeight &gt;= window.innerHeight) {
+                debug(&quot;FAILURE!&quot;)
+                return;
+            }
+                
+            debug(&quot;SUCCESS!&quot;);
</ins><span class="cx">         }
</span><span class="cx">     &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</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>+&lt;html&gt;
+&lt;head&gt;
+    &lt;script&gt;
+        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(&quot;FAILURE!&quot;)
+                return;
+            }
+                
+            debug(&quot;SUCCESS!&quot;);
+        }
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTests()&quot;&gt;
+    This tests that window.innerWidth/innerHeight does not include the size of the scrollbars.
+    &lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</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  &lt;andersca@apple.com&gt;
+
+        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  &lt;adele@apple.com&gt;
</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-&gt;view())
</span><span class="cx">         return jsUndefined();
</span><del>-      return jsNumber(m_frame-&gt;view()-&gt;visibleHeight());
</del><ins>+      return jsNumber(m_frame-&gt;view()-&gt;height());
</ins><span class="cx">     case InnerWidth:
</span><span class="cx">       if (!m_frame-&gt;view())
</span><span class="cx">         return jsUndefined();
</span><del>-      return jsNumber(m_frame-&gt;view()-&gt;visibleWidth());
</del><ins>+      return jsNumber(m_frame-&gt;view()-&gt;width());
</ins><span class="cx">     case Length:
</span><span class="cx">       return jsNumber(m_frame-&gt;tree()-&gt;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 &quot;FocusController.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;FrameView.h&quot;
</span><ins>+#include &quot;HTMLElement.h&quot;
</ins><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;KURL.h&quot;
</span><span class="cx"> #include &quot;NamedAttrMap.h&quot;
</span><span class="lines">@@ -254,12 +255,16 @@
</span><span class="cx"> {
</span><span class="cx">     document()-&gt;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()-&gt;inCompatMode() &amp;&amp; document()-&gt;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()-&gt;inCompatMode();
+    if ((!inCompatMode &amp;&amp; document()-&gt;documentElement() == this) ||
+        (inCompatMode &amp;&amp; isHTMLElement() &amp;&amp; document()-&gt;body() == this)) {
</ins><span class="cx">         if (FrameView* view = document()-&gt;view())
</span><span class="cx">             return view-&gt;visibleWidth();
</span><ins>+    }
</ins><span class="cx">     
</span><ins>+
</ins><span class="cx">     if (RenderObject* rend = renderer())
</span><span class="cx">         return rend-&gt;clientWidth();
</span><span class="cx">     return 0;
</span><span class="lines">@@ -269,11 +274,15 @@
</span><span class="cx"> {
</span><span class="cx">     document()-&gt;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()-&gt;inCompatMode() &amp;&amp; document()-&gt;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()-&gt;inCompatMode();     
+
+    if ((!inCompatMode &amp;&amp; document()-&gt;documentElement() == this) ||
+        (inCompatMode &amp;&amp; isHTMLElement() &amp;&amp; document()-&gt;body() == this)) {
</ins><span class="cx">         if (FrameView* view = document()-&gt;view())
</span><span class="cx">             return view-&gt;visibleHeight();
</span><ins>+    }
</ins><span class="cx">     
</span><span class="cx">     if (RenderObject* rend = renderer())
</span><span class="cx">         return rend-&gt;clientHeight();
</span></span></pre>
</div>
</div>

</body>
</html>