REGRESSION(r106232): The resize handler is always called after loading.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 04:03:24 +0000 (04:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 04:03:24 +0000 (04:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80242

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-03-15
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Ensure resize-events are not emitted when layout-size changes due to added
scrollbars. For fixed layout, scrollbars are never subtracted or added, so
we can compare fixedLayoutSize directly. For normal layout, use the full
visible rect size which is the same as layout size plus scrollbars.

Test: fast/events/resize-events.html

* page/FrameView.cpp:
(WebCore::FrameView::reset):
(WebCore::FrameView::layout):
(WebCore::FrameView::performPostLayoutTasks):
* page/FrameView.h:
(FrameView):

LayoutTests:

Tests that no resize events are emitted during page creation,
even if the page overflows and adds a scrollbar.

* fast/events/resize-events-expected.txt: Added.
* fast/events/resize-events.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/resize-events-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/resize-events.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h

index 5b0a3fa..09a73d1 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-15  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
+
+        REGRESSION(r106232): The resize handler is always called after loading.
+        https://bugs.webkit.org/show_bug.cgi?id=80242
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Tests that no resize events are emitted during page creation,
+        even if the page overflows and adds a scrollbar.
+
+        * fast/events/resize-events-expected.txt: Added.
+        * fast/events/resize-events.html: Added.
+
 2012-03-15  Matt Falkenhagen  <falken@chromium.org>
 
         Add layout tests for font selection based on lang/xml:lang
diff --git a/LayoutTests/fast/events/resize-events-expected.txt b/LayoutTests/fast/events/resize-events-expected.txt
new file mode 100644 (file)
index 0000000..84058b9
--- /dev/null
@@ -0,0 +1,20 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x582
+      RenderBlock {DIV} at (0,0) size 784x79
+        RenderBlock (anonymous) at (0,0) size 784x42
+          RenderText {#text} at (0,0) size 772x42
+            text run at (0,0) width 652: "Test how many resize events are emitted during page load and dynamic content generation. "
+            text run at (652,0) width 120: "Do not resize the"
+            text run at (0,21) width 192: "page. It invalidates the test."
+        RenderBlock {P} at (0,58) size 784x21
+          RenderText {#text} at (10,0) size 206x21
+            text run at (10,0) width 206: "Resize events (should be 0): "
+          RenderInline {SPAN} at (0,0) size 9x21
+            RenderText {#text} at (216,0) size 9x21
+              text run at (216,0) width 9: "0"
+          RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,95) size 784x402
+        RenderBlock {DIV} at (10,0) size 764x402 [border: (1px solid #000000)]
diff --git a/LayoutTests/fast/events/resize-events.html b/LayoutTests/fast/events/resize-events.html
new file mode 100644 (file)
index 0000000..fbf5c2e
--- /dev/null
@@ -0,0 +1,54 @@
+<html>
+<head>
+    <style>
+        div.block { height: 400px; border: 1px solid black; margin:10px; }
+    </style>
+    <script>
+        var resizecount = 0;
+        var loaded = false;
+        window.onresize = function() {
+            resizecount++;
+            document.getElementById('count1').innerHTML = resizecount;
+        }
+    </script>
+</head>
+<body>
+    <div>
+        Test how many resize events are emitted during page load and dynamic content generation.
+
+        Do not resize the page. It invalidates the test.
+        <p style="text-indent: 10px" id=result1>
+        Resize events (should be 0): <span id=count1>0</span>
+    </div>
+    <div id=expandingblock>
+    </div>
+    <script>
+        if (window.layoutTestController) {
+            layoutTestController.waitUntilDone();
+        }
+
+        var blockcount = 0;
+        function addBlock() {
+            var el = document.createElement('div');
+            el.setAttribute('class','block');
+            document.getElementById('expandingblock').appendChild(el);
+            if (++blockcount < 10)
+                setTimeout(addBlock, 20);
+            else
+                finish();
+        }
+        function finish() {
+            var result;
+            // No resize events are acceptable.
+            if (resizecount < 1)
+                result = '<p style="color: green">PASS';
+            else
+                result = '<p style="color: red">FAIL';
+            var resultElement = document.getElementById('result1')
+            resultElement.innerHTML += result;
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+        onload = addBlock;
+    </script>
+</body>
\ No newline at end of file
index 0c9c77d..b199659 100644 (file)
@@ -1,3 +1,24 @@
+2012-03-15  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
+
+        REGRESSION(r106232): The resize handler is always called after loading.
+        https://bugs.webkit.org/show_bug.cgi?id=80242
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Ensure resize-events are not emitted when layout-size changes due to added
+        scrollbars. For fixed layout, scrollbars are never subtracted or added, so
+        we can compare fixedLayoutSize directly. For normal layout, use the full
+        visible rect size which is the same as layout size plus scrollbars.
+
+        Test: fast/events/resize-events.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::reset):
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::performPostLayoutTasks):
+        * page/FrameView.h:
+        (FrameView):
+
 2012-03-15  Tommy Widenflycht  <tommyw@google.com>
 
         MediaStream API (JSEP): Introducing MediaHints and IceOptions
index 9365812..423b996 100644 (file)
@@ -228,7 +228,7 @@ void FrameView::reset()
     m_firstLayout = true;
     m_firstLayoutCallbackPending = false;
     m_wasScrolledByUser = false;
-    m_lastLayoutSize = LayoutSize();
+    m_lastViewportSize = IntSize();
     m_lastZoomFactor = 1.0f;
     m_deferringRepaints = 0;
     m_repaintCount = 0;
@@ -1022,7 +1022,10 @@ void FrameView::layout(bool allowSubtree)
 
                     m_firstLayout = false;
                     m_firstLayoutCallbackPending = true;
-                    m_lastLayoutSize = LayoutSize(layoutWidth(), layoutHeight());
+                    if (useFixedLayout() && !fixedLayoutSize().isEmpty() && delegatesScrolling())
+                        m_lastViewportSize = fixedLayoutSize();
+                    else
+                        m_lastViewportSize = visibleContentRect(true /*includeScrollbars*/).size();
                     m_lastZoomFactor = root->style()->zoom();
 
                     // Set the initial vMode to AlwaysOn if we're auto.
@@ -2306,10 +2309,14 @@ void FrameView::performPostLayoutTasks()
     m_actionScheduler->resume();
 
     if (!root->printing()) {
-        LayoutSize currentSize = LayoutSize(layoutWidth(), layoutHeight());
+        IntSize currentSize;
+        if (useFixedLayout() && !fixedLayoutSize().isEmpty() && delegatesScrolling())
+            currentSize = fixedLayoutSize();
+        else
+            currentSize = visibleContentRect(true /*includeScrollbars*/).size();
         float currentZoomFactor = root->style()->zoom();
-        bool resized = !m_firstLayout && (currentSize != m_lastLayoutSize || currentZoomFactor != m_lastZoomFactor);
-        m_lastLayoutSize = currentSize;
+        bool resized = !m_firstLayout && (currentSize != m_lastViewportSize || currentZoomFactor != m_lastZoomFactor);
+        m_lastViewportSize = currentSize;
         m_lastZoomFactor = currentZoomFactor;
         if (resized) {
             m_frame->eventHandler()->sendResizeEvent();
index f14a213..cb34a17 100644 (file)
@@ -446,7 +446,7 @@ private:
     bool m_firstLayout;
     bool m_isTransparent;
     Color m_baseBackgroundColor;
-    LayoutSize m_lastLayoutSize;
+    IntSize m_lastViewportSize;
     float m_lastZoomFactor;
 
     String m_mediaType;