Going back after resizing causes scroll knob to appear in the middle of the page
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 May 2015 20:51:37 +0000 (20:51 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 May 2015 20:51:37 +0000 (20:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144968
<rdar://problem/18299827>

Reviewed by Beth Dakin.

* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
(WebCore::CachedPage::clear):
* history/CachedPage.h:
(WebCore::CachedPage::markForContentsSizeChanged):
* history/PageCache.cpp:
(WebCore::PageCache::markPagesForContentsSizeChanged):
* history/PageCache.h:
Add a flag that will cause us to call updateContentsSize() after a page
comes out of the page cache, if necessary.

* page/FrameView.cpp:
(WebCore::FrameView::setContentsSize):
* page/FrameView.h:
Mark all cached pages for this frame as needing updateContentsSize()
when setContentsSize happens. This will ensure that scrollbar layers
are repositioned when coming out of the page cache.

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

Source/WebCore/ChangeLog
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/PageCache.cpp
Source/WebCore/history/PageCache.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h

index 11a4322..d522d4c 100644 (file)
@@ -1,3 +1,29 @@
+2015-05-13  Timothy Horton  <timothy_horton@apple.com>
+
+        Going back after resizing causes scroll knob to appear in the middle of the page
+        https://bugs.webkit.org/show_bug.cgi?id=144968
+        <rdar://problem/18299827>
+
+        Reviewed by Beth Dakin.
+
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::restore):
+        (WebCore::CachedPage::clear):
+        * history/CachedPage.h:
+        (WebCore::CachedPage::markForContentsSizeChanged):
+        * history/PageCache.cpp:
+        (WebCore::PageCache::markPagesForContentsSizeChanged):
+        * history/PageCache.h:
+        Add a flag that will cause us to call updateContentsSize() after a page
+        comes out of the page cache, if necessary.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setContentsSize):
+        * page/FrameView.h:
+        Mark all cached pages for this frame as needing updateContentsSize()
+        when setContentsSize happens. This will ensure that scrollbar layers
+        are repositioned when coming out of the page cache.
+
 2015-05-13  Beth Dakin  <bdakin@apple.com>
 
         Need SPI to set the overlay scroll bar style
index ef71ee6..e30fc10 100644 (file)
@@ -116,6 +116,11 @@ void CachedPage::restore(Page& page)
         page.captionPreferencesChanged();
 #endif
 
+    if (m_needsUpdateContentsSize) {
+        if (FrameView* frameView = page.mainFrame().view())
+            frameView->updateContentsSize();
+    }
+
     clear();
 }
 
@@ -130,6 +135,7 @@ void CachedPage::clear()
     m_needsCaptionPreferencesChanged = false;
 #endif
     m_needsDeviceOrPageScaleChanged = false;
+    m_needsUpdateContentsSize = false;
 }
 
 bool CachedPage::hasExpired() const
index 9340ed2..ed58fcd 100644 (file)
@@ -57,6 +57,8 @@ public:
 
     void markForDeviceOrPageScaleChanged() { m_needsDeviceOrPageScaleChanged = true; }
 
+    void markForContentsSizeChanged() { m_needsUpdateContentsSize = true; }
+
 private:
     double m_expirationTime;
     std::unique_ptr<CachedFrame> m_cachedMainFrame;
@@ -66,6 +68,7 @@ private:
     bool m_needsCaptionPreferencesChanged { false };
 #endif
     bool m_needsDeviceOrPageScaleChanged { false };
+    bool m_needsUpdateContentsSize { false };
 };
 
 } // namespace WebCore
index bcbdef2..94eadaa 100644 (file)
@@ -399,6 +399,15 @@ void PageCache::markPagesForDeviceOrPageScaleChanged(Page& page)
     }
 }
 
+void PageCache::markPagesForContentsSizeChanged(Page& page)
+{
+    for (auto& item : m_items) {
+        CachedPage& cachedPage = *item->m_cachedPage;
+        if (&page.mainFrame() == &cachedPage.cachedMainFrame()->view()->frame())
+            cachedPage.markForContentsSizeChanged();
+    }
+}
+
 #if ENABLE(VIDEO_TRACK)
 void PageCache::markPagesForCaptionPreferencesChanged()
 {
index 9fab802..b2cefaa 100644 (file)
@@ -65,6 +65,7 @@ public:
     // Will mark all cached pages associated with the given page as needing style recalc.
     void markPagesForFullStyleRecalc(Page&);
     void markPagesForDeviceOrPageScaleChanged(Page&);
+    void markPagesForContentsSizeChanged(Page&);
 #if ENABLE(VIDEO_TRACK)
     void markPagesForCaptionPreferencesChanged();
 #endif
index 5d68406..ebf7166 100644 (file)
@@ -61,6 +61,7 @@
 #include "MemoryCache.h"
 #include "MemoryPressureHandler.h"
 #include "OverflowEvent.h"
+#include "PageCache.h"
 #include "PageOverlayController.h"
 #include "ProgressTracker.h"
 #include "RenderEmbeddedObject.h"
@@ -583,8 +584,10 @@ void FrameView::setContentsSize(const IntSize& size)
 
     page->chrome().contentsSizeChanged(&frame(), size); // Notify only.
 
-    if (frame().isMainFrame())
+    if (frame().isMainFrame()) {
         frame().mainFrame().pageOverlayController().didChangeDocumentSize();
+        PageCache::singleton().markPagesForContentsSizeChanged(*page);
+    }
 
     ASSERT(m_deferSetNeedsLayoutCount);
     m_deferSetNeedsLayoutCount--;
index 6059d36..607f40d 100644 (file)
@@ -104,6 +104,7 @@ public:
     virtual bool avoidScrollbarCreation() const override;
 
     virtual void setContentsSize(const IntSize&) override;
+    virtual void updateContentsSize() override;
 
     void layout(bool allowSubtree = true);
     WEBCORE_EXPORT bool didFirstLayout() const;
@@ -606,7 +607,6 @@ private:
     WEBCORE_EXPORT void adjustTiledBackingCoverage();
 
     virtual void repaintContentRectangle(const IntRect&) override;
-    virtual void updateContentsSize() override;
     virtual void addedOrRemovedScrollbar() override;
 
     virtual void delegatesScrollingDidChange() override;