WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jun 2006 18:26:12 +0000 (18:26 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jun 2006 18:26:12 +0000 (18:26 +0000)
2006-06-06  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9325
        clientWidth/clientHeight on document element in strict mode should return visible frame size

        * dom/Element.cpp:
        (WebCore::Element::clientWidth):
        (WebCore::Element::clientHeight):
        If we're the document element, and in strict mode, return the visible size of the frame.

LayoutTests:

2006-06-06  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=9325
        clientWidth/clientHeight on document element in strict mode should return visible frame size

        * fast/dom/client-width-height-expected.txt: Added.
        * fast/dom/client-width-height.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14744 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/client-width-height-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/client-width-height.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Element.cpp

index 7f688061866afd568a80d0ea1a043a2b3dc07686..bf73a1c4fbea2a2ab01f26858d5645404f00aeb2 100644 (file)
@@ -1,3 +1,13 @@
+2006-06-06  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9325
+        clientWidth/clientHeight on document element in strict mode should return visible frame size
+
+        * fast/dom/client-width-height-expected.txt: Added.
+        * fast/dom/client-width-height.html: Added.
+
 2006-06-05  Rob Buis  <buis@kde.org>
 
         Reviewed by mjs.
diff --git a/LayoutTests/fast/dom/client-width-height-expected.txt b/LayoutTests/fast/dom/client-width-height-expected.txt
new file mode 100644 (file)
index 0000000..0450ee4
--- /dev/null
@@ -0,0 +1,3 @@
+This tests that clientWidth/clientHeight on the document element in strict mode returns the visible size of the frame.
+SUCCESS!
+
diff --git a/LayoutTests/fast/dom/client-width-height.html b/LayoutTests/fast/dom/client-width-height.html
new file mode 100644 (file)
index 0000000..68f3a70
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<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.documentElement.clientWidth == window.innerWidth &&
+                document.documentElement.clientHeight == window.innerHeight)
+                debug("SUCCESS!");
+            else
+                debug("FAILURE!");
+        }
+    </script>
+</head>
+<body onload="runTests()">
+    This tests that clientWidth/clientHeight on the document element in strict mode returns the visible size of the frame.
+    <pre id="console"></pre>
+</body>
+</html>
index 2c094ae967d5ed4ee249c8a5e876d42eca28c5bd..e2a38998c942ce42136207cfe96471a6854b9b03 100644 (file)
@@ -1,3 +1,15 @@
+2006-06-06  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9325
+        clientWidth/clientHeight on document element in strict mode should return visible frame size
+        
+        * dom/Element.cpp:
+        (WebCore::Element::clientWidth):
+        (WebCore::Element::clientHeight):
+        If we're the document element, and in strict mode, return the visible size of the frame.
+        
 2006-06-06  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by John.
index 2c6ffd043d9011929214fb70c2d85b716ed8cff6..19df05e7e70ee6e86d31233c5df42f191ddf2684 100644 (file)
@@ -223,6 +223,12 @@ Element* Element::offsetParent()
 int Element::clientWidth()
 {
     document()->updateLayoutIgnorePendingStylesheets();
+
+    // When in strict mode, clientWidth for the document
+    // element should return the width of the containing frame.
+    if (!document()->inCompatMode() && document()->documentElement() == this)
+        return document()->frame()->view()->visibleWidth();
+    
     if (RenderObject* rend = renderer())
         return rend->clientWidth();
     return 0;
@@ -231,6 +237,12 @@ int Element::clientWidth()
 int Element::clientHeight()
 {
     document()->updateLayoutIgnorePendingStylesheets();
+
+    // When in strict mode, clientHeight for the document
+    // element should return the height of the containing frame.
+    if (!document()->inCompatMode() && document()->documentElement() == this)
+        return document()->frame()->view()->visibleHeight();
+    
     if (RenderObject* rend = renderer())
         return rend->clientHeight();
     return 0;