Slight CachedPage class clean up
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Feb 2015 23:06:22 +0000 (23:06 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Feb 2015 23:06:22 +0000 (23:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141693

Reviewed by Andreas Kling.

Slight CachedPage class clean up:
- Drop unnecessary m_timeStamp data member
- Protect m_needsCaptionPreferencesChanged data member with
  #if ENABLE(VIDEO_TRACK)
- Merge destroy() method into the destructor as this is the
  only caller
- Update clear() to reset 2 data members that were missing

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

Source/WebCore/ChangeLog
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h

index c2795fa..3c654b0 100644 (file)
@@ -1,3 +1,18 @@
+2015-02-17  Chris Dumez  <cdumez@apple.com>
+
+        Slight CachedPage class clean up
+        https://bugs.webkit.org/show_bug.cgi?id=141693
+
+        Reviewed by Andreas Kling.
+
+        Slight CachedPage class clean up:
+        - Drop unnecessary m_timeStamp data member
+        - Protect m_needsCaptionPreferencesChanged data member with
+          #if ENABLE(VIDEO_TRACK)
+        - Merge destroy() method into the destructor as this is the
+          only caller
+        - Update clear() to reset 2 data members that were missing
+
 2015-02-17  Anders Carlsson  <andersca@apple.com>
 
         Silence two -Wcast-qual warnings.
index af06f58..84aa030 100644 (file)
@@ -50,12 +50,13 @@ namespace WebCore {
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, cachedPageCounter, ("CachedPage"));
 
 CachedPage::CachedPage(Page& page)
-    : m_timeStamp(monotonicallyIncreasingTime())
-    , m_expirationTime(m_timeStamp + page.settings().backForwardCacheExpirationInterval())
+    : m_expirationTime(monotonicallyIncreasingTime() + page.settings().backForwardCacheExpirationInterval())
     , m_cachedMainFrame(std::make_unique<CachedFrame>(page.mainFrame()))
     , m_needStyleRecalcForVisitedLinks(false)
     , m_needsFullStyleRecalc(false)
+#if ENABLE(VIDEO_TRACK)
     , m_needsCaptionPreferencesChanged(false)
+#endif
     , m_needsDeviceScaleChanged(false)
 {
 #ifndef NDEBUG
@@ -69,8 +70,8 @@ CachedPage::~CachedPage()
     cachedPageCounter.decrement();
 #endif
 
-    destroy();
-    ASSERT(!m_cachedMainFrame);
+    if (m_cachedMainFrame)
+        m_cachedMainFrame->destroy();
 }
 
 void CachedPage::restore(Page& page)
@@ -110,9 +111,8 @@ void CachedPage::restore(Page& page)
             frame->document()->visitedLinkState().invalidateStyleForAllLinks();
     }
 
-    if (m_needsDeviceScaleChanged) {
+    if (m_needsDeviceScaleChanged)
         page.mainFrame().deviceOrPageScaleFactorChanged();
-    }
 
     if (m_needsFullStyleRecalc)
         page.setNeedsRecalcStyleInAllFrames();
@@ -129,17 +129,13 @@ void CachedPage::clear()
 {
     ASSERT(m_cachedMainFrame);
     m_cachedMainFrame->clear();
-    m_cachedMainFrame = 0;
+    m_cachedMainFrame = nullptr;
     m_needStyleRecalcForVisitedLinks = false;
     m_needsFullStyleRecalc = false;
-}
-
-void CachedPage::destroy()
-{
-    if (m_cachedMainFrame)
-        m_cachedMainFrame->destroy();
-
-    m_cachedMainFrame = 0;
+#if ENABLE(VIDEO_TRACK)
+    m_needsCaptionPreferencesChanged = false;
+#endif
+    m_needsDeviceScaleChanged = false;
 }
 
 bool CachedPage::hasExpired() const
index fd9f218..5636de1 100644 (file)
@@ -29,7 +29,7 @@
 #include "CachedFrame.h"
 
 namespace WebCore {
-    
+
 class Document;
 class DocumentLoader;
 class Page;
@@ -45,7 +45,6 @@ public:
     Document* document() const { return m_cachedMainFrame->document(); }
     DocumentLoader* documentLoader() const { return m_cachedMainFrame->documentLoader(); }
 
-    double timeStamp() const { return m_timeStamp; }
     bool hasExpired() const;
     
     CachedFrame* cachedMainFrame() { return m_cachedMainFrame.get(); }
@@ -59,14 +58,13 @@ public:
     void markForDeviceScaleChanged() { m_needsDeviceScaleChanged = true; }
 
 private:
-    void destroy();
-
-    double m_timeStamp;
     double m_expirationTime;
     std::unique_ptr<CachedFrame> m_cachedMainFrame;
     bool m_needStyleRecalcForVisitedLinks;
     bool m_needsFullStyleRecalc;
+#if ENABLE(VIDEO_TRACK)
     bool m_needsCaptionPreferencesChanged;
+#endif
     bool m_needsDeviceScaleChanged;
 };