https://bugs.webkit.org/show_bug.cgi?id=66244
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2011 00:29:27 +0000 (00:29 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2011 00:29:27 +0000 (00:29 +0000)
Cached pages don't fully update when going back after changing the display scale
factor
-and corresponding-
<rdar://problem/9955656>

Reviewed by Darin Adler.

This patch adds a generalized concept of needing a full style recalc to the
BackForwardController. So when the display scale factor is changed, the
BackForwardController can be informed that all pages will need a full style recalc
when they come out of the cache. This same mechanism is also used to fix a long-
standing bug with full-page/text zoom.

Iterate through the HistoryItems and mark all CachedPages as needing a full style
recalc.
* history/BackForwardController.cpp:
(WebCore::BackForwardController::markPagesForFullStyleRecalc):
* history/BackForwardController.h:

ChachedPage has a new bool -- m_needsFullStyleRecalc -- to track whether a full
style recalc is needed when the CachedPage is restored.
* history/CachedPage.cpp:
(WebCore::CachedPage::CachedPage):
(WebCore::CachedPage::restore):
(WebCore::CachedPage::clear):
* history/CachedPage.h:
(WebCore::CachedPage::markForFullStyleRecalc):

HistoryItem actually takes care of calling into CachedPage.
* history/HistoryItem.cpp:
(WebCore::HistoryItem::markForFullStyleRecalc):
* history/HistoryItem.h:

Fix style recalc issues for full-page/text zoom by calling our new function on
PageCache.
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):

Fix style recalc issues for display scale factor changes by calling our new
function on PageCache.
* page/Page.cpp:
(WebCore::Page::setDeviceScaleFactor):

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

Source/WebCore/ChangeLog
Source/WebCore/history/BackForwardController.cpp
Source/WebCore/history/BackForwardController.h
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/history/HistoryItem.h
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Page.cpp

index d299f9c..bbc2646 100644 (file)
@@ -1,3 +1,49 @@
+2011-08-23  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=66244
+        Cached pages don't fully update when going back after changing the display scale 
+        factor
+        -and corresponding-
+        <rdar://problem/9955656>
+
+        Reviewed by Darin Adler.
+
+        This patch adds a generalized concept of needing a full style recalc to the 
+        BackForwardController. So when the display scale factor is changed, the 
+        BackForwardController can be informed that all pages will need a full style recalc 
+        when they come out of the cache. This same mechanism is also used to fix a long-
+        standing bug with full-page/text zoom.
+
+        Iterate through the HistoryItems and mark all CachedPages as needing a full style 
+        recalc.
+        * history/BackForwardController.cpp:
+        (WebCore::BackForwardController::markPagesForFullStyleRecalc):
+        * history/BackForwardController.h:
+
+        ChachedPage has a new bool -- m_needsFullStyleRecalc -- to track whether a full 
+        style recalc is needed when the CachedPage is restored.
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::CachedPage):
+        (WebCore::CachedPage::restore):
+        (WebCore::CachedPage::clear):
+        * history/CachedPage.h:
+        (WebCore::CachedPage::markForFullStyleRecalc):
+
+        HistoryItem actually takes care of calling into CachedPage.
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::markForFullStyleRecalc):
+        * history/HistoryItem.h:
+
+        Fix style recalc issues for full-page/text zoom by calling our new function on 
+        PageCache.
+        * page/Frame.cpp:
+        (WebCore::Frame::setPageAndTextZoomFactors):
+
+        Fix style recalc issues for display scale factor changes by calling our new 
+        function on PageCache.
+        * page/Page.cpp:
+        (WebCore::Page::setDeviceScaleFactor):
+
 2011-08-23  Anders Carlsson  <andersca@apple.com>
 
         Fix build.
index d388f19..a9abb10 100644 (file)
@@ -104,4 +104,15 @@ void BackForwardController::close()
     m_client->close();
 }
 
+void BackForwardController::markPagesForFullStyleRecalc()
+{
+    int first = -backCount();
+    int last = forwardCount();
+    for (int i = first; i <= last; i++) {
+        if (!i)
+            continue;
+        itemAtIndex(i)->markForFullStyleRecalc();
+    }
+}
+
 } // namespace WebCore
index 12884ea..ac57fb9 100644 (file)
@@ -67,6 +67,8 @@ public:
     HistoryItem* currentItem() { return itemAtIndex(0); }
     HistoryItem* forwardItem() { return itemAtIndex(1); }
 
+    void markPagesForFullStyleRecalc();
+
 private:
     Page* m_page;
     RefPtr<BackForwardList> m_client;
index 0860a96..deecd46 100644 (file)
@@ -54,6 +54,7 @@ CachedPage::CachedPage(Page* page)
     : m_timeStamp(currentTime())
     , m_cachedMainFrame(CachedFrame::create(page->mainFrame()))
     , m_needStyleRecalcForVisitedLinks(false)
+    , m_needsFullStyleRecalc(false)
 {
 #ifndef NDEBUG
     cachedPageCounter.increment();
@@ -93,6 +94,9 @@ void CachedPage::restore(Page* page)
         }
     }
 
+    if (m_needsFullStyleRecalc)
+        page->setNeedsRecalcStyleInAllFrames();
+
     clear();
 }
 
@@ -102,6 +106,7 @@ void CachedPage::clear()
     m_cachedMainFrame->clear();
     m_cachedMainFrame = 0;
     m_needStyleRecalcForVisitedLinks = false;
+    m_needsFullStyleRecalc = false;
 }
 
 void CachedPage::destroy()
index 8a226be..4a578ea 100644 (file)
@@ -51,6 +51,7 @@ public:
     CachedFrame* cachedMainFrame() { return m_cachedMainFrame.get(); }
 
     void markForVistedLinkStyleRecalc() { m_needStyleRecalcForVisitedLinks = true; }
+    void markForFullStyleRecalc() { m_needsFullStyleRecalc = true; }
 
 private:
     CachedPage(Page*);
@@ -58,6 +59,7 @@ private:
     double m_timeStamp;
     RefPtr<CachedFrame> m_cachedMainFrame;
     bool m_needStyleRecalcForVisitedLinks;
+    bool m_needsFullStyleRecalc;
 };
 
 } // namespace WebCore
index 38cd626..21c81ed 100644 (file)
@@ -845,6 +845,13 @@ resume:
     return node.release();
 }
 
+void HistoryItem::markForFullStyleRecalc()
+{
+    // Children are guaranteed not to have CachedPages.
+    if (m_cachedPage)
+        m_cachedPage->markForFullStyleRecalc();
+}
+
 #ifndef NDEBUG
 
 int HistoryItem::showTree() const
index 4cd289b..292942b 100644 (file)
@@ -207,6 +207,8 @@ public:
     const Vector<int>& dailyVisitCounts() const { return m_dailyVisitCounts; }
     const Vector<int>& weeklyVisitCounts() const { return m_weeklyVisitCounts; }
 
+    void markForFullStyleRecalc();
+
 private:
     HistoryItem();
     HistoryItem(const String& urlString, const String& title, double lastVisited);
index abbe9b9..5978cd9 100644 (file)
@@ -30,6 +30,7 @@
 #include "Frame.h"
 
 #include "ApplyStyleCommand.h"
+#include "BackForwardController.h"
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSMutableStyleDeclaration.h"
 #include "CSSProperty.h"
@@ -1069,6 +1070,9 @@ void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor
         if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
             view->layout();
     }
+
+    if (page->mainFrame() == this)
+        page->backForward()->markPagesForFullStyleRecalc();
 }
 
 #if USE(ACCELERATED_COMPOSITING)
index ef8d50e..da3a246 100644 (file)
@@ -596,6 +596,8 @@ void Page::setDeviceScaleFactor(float scaleFactor)
 #if USE(ACCELERATED_COMPOSITING)
     m_mainFrame->deviceOrPageScaleFactorChanged();
 #endif
+
+    backForward()->markPagesForFullStyleRecalc();
 }
 
 void Page::didMoveOnscreen()