Remove isInitialState flag from Page::setViewState
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Feb 2014 02:25:03 +0000 (02:25 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Feb 2014 02:25:03 +0000 (02:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128428

Reviewed by Sam Weinig.

Source/WebCore:

* WebCore.exp.in:
    - removed isInitialState.
* page/Page.cpp:
(WebCore::Page::setViewState):
    - removed isInitialState.
(WebCore::Page::setIsVisible):
    - removed isInitialState.
(WebCore::Page::setIsVisibleInternal):
    - removed isInitialState.
* page/Page.h:
    - removed isInitialState.

Source/WebKit/efl:

* ewk/ewk_view.cpp:
(ewk_view_visibility_state_set):
    - don't pass isInitialState to setViewState.

Source/WebKit/gtk:

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::setPageVisibility):
    - don't pass isInitialState to setViewState.

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView _updateVisibilityState]):
(-[WebView _setIsVisible:]):
(-[WebView _setVisibilityState:isInitialState:]):
(-[WebView _windowWillOrderOnScreen:]):
(-[WebView _windowWillOrderOffScreen:]):
    - don't pass isInitialState to setViewState.

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
    - don't pass isInitialState to setViewState.
(WebKit::WebPage::reinitializeWebPage):
    - if the viewState changes this should fire a visibility event.
(WebKit::WebPage::setViewState):
    - merged with setViewStateInternal.
* WebProcess/WebPage/WebPage.h:
    - removed setViewStateInternal.

LayoutTests:

* fast/events/page-visibility-iframe-delete-test.html:
* fast/events/page-visibility-iframe-move-test.html:
    - resetPageVisibility will now cause additional visibiliy events to fire;
      clean up the event listeners to avoid this affecting the test results.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/page-visibility-iframe-delete-test.html
LayoutTests/fast/events/page-visibility-iframe-move-test.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h

index ac2ea5e..3205350 100644 (file)
@@ -1,3 +1,15 @@
+2014-02-07  Gavin Barraclough  <barraclough@apple.com>
+
+        Remove isInitialState flag from Page::setViewState
+        https://bugs.webkit.org/show_bug.cgi?id=128428
+
+        Reviewed by Sam Weinig.
+
+        * fast/events/page-visibility-iframe-delete-test.html:
+        * fast/events/page-visibility-iframe-move-test.html:
+            - resetPageVisibility will now cause additional visibiliy events to fire;
+              clean up the event listeners to avoid this affecting the test results.
+
 2014-02-07  Beth Dakin  <bdakin@apple.com>
 
         Should get rid of TileController's CoverageForSlowScrolling mode
index a6d33e4..e27ab87 100644 (file)
@@ -15,6 +15,7 @@ var frame1, frame2, frame3, frame4, frame5, subframe1, subFrame2, subFrame3;
 var docsLoaded = 0;
 var mainPageVisibilityChangeDone = false;
 var frame2VisiblityChangeDone = false;
+var finishTestDone = false;
 
 function startTest() {
     ++docsLoaded;
@@ -43,6 +44,11 @@ function startTest() {
 }
 
 function finishTest() {
+    document.removeEventListener(
+        "visibilitychange", onMainPageVisibilityChange, false);
+    frame2.contentDocument.removeEventListener(
+        "visibilitychange", onFrame2VisibilityChange, false);
+
     if (window.testRunner)
         testRunner.resetPageVisibility();
     finishJSTest();
index b58e744..1360084 100644 (file)
@@ -61,6 +61,10 @@ function startTest() {
 }
 
 function finishTest() {
+    document.removeEventListener("visibilitychange",
+                              onVisibilityChange, false);
+    window2.removeEventListener("load", window2Loaded, false);
+
     if (window.testRunner) {
         testRunner.resetPageVisibility();
     }
index 8eff3fa..3618cc4 100644 (file)
@@ -1,3 +1,22 @@
+2014-02-07  Gavin Barraclough  <barraclough@apple.com>
+
+        Remove isInitialState flag from Page::setViewState
+        https://bugs.webkit.org/show_bug.cgi?id=128428
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.exp.in:
+            - removed isInitialState.
+        * page/Page.cpp:
+        (WebCore::Page::setViewState):
+            - removed isInitialState.
+        (WebCore::Page::setIsVisible):
+            - removed isInitialState.
+        (WebCore::Page::setIsVisibleInternal):
+            - removed isInitialState.
+        * page/Page.h:
+            - removed isInitialState.
+
 2014-02-07  Simon Fraser  <simon.fraser@apple.com>
 
         Encode requestedScrollPosition on ScrollingStateScrollingNodes to send to the UI process
index 706f548..6956310 100644 (file)
@@ -992,8 +992,8 @@ __ZN7WebCore4Page10findStringERKN3WTF6StringEj
 __ZN7WebCore4Page11PageClientsC1Ev
 __ZN7WebCore4Page11PageClientsD1Ev
 __ZN7WebCore4Page12setGroupNameERKN3WTF6StringE
-__ZN7WebCore4Page12setIsVisibleEbb
-__ZN7WebCore4Page12setViewStateEjb
+__ZN7WebCore4Page12setIsVisibleEb
+__ZN7WebCore4Page12setViewStateEj
 __ZN7WebCore4Page13rangeOfStringERKN3WTF6StringEPNS_5RangeEj
 __ZN7WebCore4Page13setIsInWindowEb
 __ZN7WebCore4Page13setPaginationERKNS_10PaginationE
index 7854e5e..de9c68e 100644 (file)
@@ -1148,7 +1148,7 @@ void Page::resumeAnimatingImages()
         CachedImage::resumeAnimatingImagesForLoader(frame->document()->cachedResourceLoader());
 }
 
-void Page::setViewState(ViewState::Flags viewState, bool isInitialState)
+void Page::setViewState(ViewState::Flags viewState)
 {
     ViewState::Flags changed = m_viewState ^ viewState;
     if (!changed)
@@ -1158,19 +1158,19 @@ void Page::setViewState(ViewState::Flags viewState, bool isInitialState)
     m_focusController->setViewState(viewState);
 
     if (changed & ViewState::IsVisible)
-        setIsVisibleInternal(viewState & ViewState::IsVisible, isInitialState);
+        setIsVisibleInternal(viewState & ViewState::IsVisible);
     if (changed & ViewState::IsInWindow)
         setIsInWindowInternal(viewState & ViewState::IsInWindow);
     if (changed & ViewState::IsVisuallyIdle)
         setIsVisuallyIdleInternal(viewState & ViewState::IsVisuallyIdle);
 }
 
-void Page::setIsVisible(bool isVisible, bool isInitialState)
+void Page::setIsVisible(bool isVisible)
 {
-    setViewState(isVisible ? m_viewState | ViewState::IsVisible : m_viewState & ~ViewState::IsVisible, isInitialState);
+    setViewState(isVisible ? m_viewState | ViewState::IsVisible : m_viewState & ~ViewState::IsVisible);
 }
 
-void Page::setIsVisibleInternal(bool isVisible, bool isInitialState)
+void Page::setIsVisibleInternal(bool isVisible)
 {
     // FIXME: The visibility state should be stored on the top-level document.
     // https://bugs.webkit.org/show_bug.cgi?id=116769
@@ -1199,16 +1199,12 @@ void Page::setIsVisibleInternal(bool isVisible, bool isInitialState)
     }
 
 #if ENABLE(PAGE_VISIBILITY_API)
-    if (!isInitialState) {
-        Vector<Ref<Document>> documents;
-        for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
-            documents.append(*frame->document());
+    Vector<Ref<Document>> documents;
+    for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
+        documents.append(*frame->document());
 
-        for (size_t i = 0, size = documents.size(); i < size; ++i)
-            documents[i]->visibilityStateChanged();
-    }
-#else
-    UNUSED_PARAM(isInitialState);
+    for (size_t i = 0, size = documents.size(); i < size; ++i)
+        documents[i]->visibilityStateChanged();
 #endif
 
     if (!isVisible) {
index 6f48257..06cd7bb 100644 (file)
@@ -290,8 +290,8 @@ public:
     unsigned pageCount() const;
 
     // Notifications when the Page starts and stops being presented via a native window.
-    void setViewState(ViewState::Flags, bool isInitial = false);
-    void setIsVisible(bool isVisible, bool isInitial);
+    void setViewState(ViewState::Flags);
+    void setIsVisible(bool);
     void setIsPrerender();
     bool isVisible() const { return m_viewState & ViewState::IsVisible; }
 
@@ -419,7 +419,7 @@ private:
     void initGroup();
 
     void setIsInWindowInternal(bool);
-    void setIsVisibleInternal(bool isVisible, bool isInitial);
+    void setIsVisibleInternal(bool);
     void setIsVisuallyIdleInternal(bool);
 
 #if ASSERT_DISABLED
index 96548f5..54f631f 100644 (file)
@@ -1,3 +1,14 @@
+2014-02-07  Gavin Barraclough  <barraclough@apple.com>
+
+        Remove isInitialState flag from Page::setViewState
+        https://bugs.webkit.org/show_bug.cgi?id=128428
+
+        Reviewed by Sam Weinig.
+
+        * ewk/ewk_view.cpp:
+        (ewk_view_visibility_state_set):
+            - don't pass isInitialState to setViewState.
+
 2014-02-05  Andreas Kling  <akling@apple.com>
 
         Remove ENABLE(DIRECTORY_UPLOAD).
index 8650d72..4341eae 100644 (file)
@@ -4442,7 +4442,7 @@ void ewk_view_mixed_content_run_set(Evas_Object* ewkView, bool hasRun)
         evas_object_smart_callback_call(ewkView, "mixedcontent,run", 0);
 }
 
-Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
+Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool)
 {
 #if ENABLE(PAGE_VISIBILITY_API)
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
@@ -4452,7 +4452,7 @@ Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibilit
     if (pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_UNLOADED)
         return false;
 
-    priv->page->setIsVisible(pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_VISIBLE, initialState);
+    priv->page->setIsVisible(pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_VISIBLE);
     if (pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_PRERENDER)
         priv->page->setIsPrerender();
 
@@ -4461,7 +4461,6 @@ Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibilit
     DBG("PAGE_VISIBILITY_API is disabled.");
     UNUSED_PARAM(ewkView);
     UNUSED_PARAM(pageVisibilityState);
-    UNUSED_PARAM(initialState);
     return false;
 #endif
 }
index 1ced02c..7bfe169 100644 (file)
@@ -1,3 +1,14 @@
+2014-02-07  Gavin Barraclough  <barraclough@apple.com>
+
+        Remove isInitialState flag from Page::setViewState
+        https://bugs.webkit.org/show_bug.cgi?id=128428
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::setPageVisibility):
+            - don't pass isInitialState to setViewState.
+
 2014-02-06  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Add Console support to JSContext Inspection
index f55ad43..01bb762 100644 (file)
@@ -680,14 +680,14 @@ void DumpRenderTreeSupportGtk::setAuthenticationCallback(AuthenticationCallback
     s_authenticationCallback = authenticationCallback;
 }
 
-void DumpRenderTreeSupportGtk::setPageVisibility(WebKitWebView* webView, WebCore::PageVisibilityState visibilityState, bool isInitialState)
+void DumpRenderTreeSupportGtk::setPageVisibility(WebKitWebView* webView, WebCore::PageVisibilityState visibilityState, bool)
 {
 #if ENABLE(PAGE_VISIBILITY_API)
     Page* page = core(webView);
     if (!page)
         return;
 
-    page->setIsVisible(visibilityState == PageVisibilityStateVisible, isInitialState);
+    page->setIsVisible(visibilityState == PageVisibilityStateVisible);
     if (visibilityState == PageVisibilityStatePrerender)
         page->setIsPrerender();
 #endif
index d0b50d9..1cfee0d 100644 (file)
@@ -1,3 +1,19 @@
+2014-02-07  Gavin Barraclough  <barraclough@apple.com>
+
+        Remove isInitialState flag from Page::setViewState
+        https://bugs.webkit.org/show_bug.cgi?id=128428
+
+        Reviewed by Sam Weinig.
+
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView _updateVisibilityState]):
+        (-[WebView _setIsVisible:]):
+        (-[WebView _setVisibilityState:isInitialState:]):
+        (-[WebView _windowWillOrderOnScreen:]):
+        (-[WebView _windowWillOrderOffScreen:]):
+            - don't pass isInitialState to setViewState.
+
 2014-02-06  Filip Pizlo  <fpizlo@apple.com>
 
         More FTL build scaffolding
index 6f6000e..da42e8c 100644 (file)
@@ -994,7 +994,7 @@ static bool shouldUseLegacyBackgroundSizeShorthandBehavior()
     [self _registerDraggedTypes];
 #endif
 
-    [self _setIsVisible:[self _isViewVisible] isInitialState:YES];
+    [self _setIsVisible:[self _isViewVisible]];
 
     WebPreferences *prefs = [self preferences];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
@@ -4009,7 +4009,7 @@ static inline IMP getMethod(id o, SEL s)
 - (void)_updateVisibilityState
 {
     if (_private && _private->page)
-        [self _setIsVisible:[self _isViewVisible] isInitialState:NO];
+        [self _setIsVisible:[self _isViewVisible]];
 }
 
 - (void)_updateActiveState
@@ -4374,16 +4374,18 @@ static Vector<String> toStringVector(NSArray* patterns)
     return WebPageVisibilityStateVisible;
 }
 
-- (void)_setIsVisible:(BOOL)isVisible isInitialState:(BOOL)isInitialState
+- (void)_setIsVisible:(BOOL)isVisible
 {
     if (_private->page)
-        _private->page->setIsVisible(isVisible, isInitialState);
+        _private->page->setIsVisible(isVisible);
 }
 
 - (void)_setVisibilityState:(WebPageVisibilityState)visibilityState isInitialState:(BOOL)isInitialState
 {
+    UNUSED_PARAM(isInitialState);
+
     if (_private->page) {
-        _private->page->setIsVisible(visibilityState == WebPageVisibilityStateVisible, isInitialState);
+        _private->page->setIsVisible(visibilityState == WebPageVisibilityStateVisible);
         if (visibilityState == WebPageVisibilityStatePrerender)
             _private->page->setIsPrerender();
     }
@@ -5352,7 +5354,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 
     if (_private && _private->page) {
         _private->page->resumeScriptedAnimations();
-        _private->page->setIsVisible(true, false);
+        _private->page->setIsVisible(true);
     }
 }
 
@@ -5365,7 +5367,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 {
     if (_private && _private->page) {
         _private->page->suspendScriptedAnimations();
-        _private->page->setIsVisible(false, false);
+        _private->page->setIsVisible(false);
     }
 }
 
index 19dfae5..aefb37a 100644 (file)
@@ -1,3 +1,20 @@
+2014-02-07  Gavin Barraclough  <barraclough@apple.com>
+
+        Remove isInitialState flag from Page::setViewState
+        https://bugs.webkit.org/show_bug.cgi?id=128428
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+            - don't pass isInitialState to setViewState.
+        (WebKit::WebPage::reinitializeWebPage):
+            - if the viewState changes this should fire a visibility event.
+        (WebKit::WebPage::setViewState):
+            - merged with setViewStateInternal.
+        * WebProcess/WebPage/WebPage.h:
+            - removed setViewStateInternal.
+
 2014-02-07  Simon Fraser  <simon.fraser@apple.com>
 
         Encode requestedScrollPosition on ScrollingStateScrollingNodes to send to the UI process
index b19b709..cf2c3db 100644 (file)
@@ -384,7 +384,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 
     setMemoryCacheMessagesEnabled(parameters.areMemoryCacheClientCallsEnabled);
 
-    m_page->setViewState(m_viewState, true);
+    m_page->setViewState(m_viewState);
     updateIsInWindow(true);
 
     setMinimumLayoutSize(parameters.minimumLayoutSize);
@@ -434,7 +434,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 void WebPage::reinitializeWebPage(const WebPageCreationParameters& parameters)
 {
     if (m_viewState != parameters.viewState)
-        setViewStateInternal(parameters.viewState, true);
+        setViewState(parameters.viewState);
     if (m_layerHostingMode != parameters.layerHostingMode)
         setLayerHostingMode(static_cast<unsigned>(parameters.layerHostingMode));
 }
@@ -2069,24 +2069,19 @@ void WebPage::updateIsInWindow(bool isInitialState)
 
 void WebPage::setViewState(ViewState::Flags viewState, bool wantsDidUpdateViewState)
 {
-    setViewStateInternal(viewState, false);
-
-    if (wantsDidUpdateViewState)
-        m_sendDidUpdateViewStateTimer.startOneShot(0);
-}
-
-void WebPage::setViewStateInternal(ViewState::Flags viewState, bool isInitialState)
-{
     ViewState::Flags changed = m_viewState ^ viewState;
     m_viewState = viewState;
 
     m_drawingArea->viewStateDidChange(changed);
-    m_page->setViewState(viewState, isInitialState);
+    m_page->setViewState(viewState);
     for (auto* pluginView : m_pluginViews)
         pluginView->viewStateDidChange(changed);
 
     if (changed & ViewState::IsInWindow)
         updateIsInWindow();
+
+    if (wantsDidUpdateViewState)
+        m_sendDidUpdateViewStateTimer.startOneShot(0);
 }
 
 void WebPage::setLayerHostingMode(unsigned layerHostingMode)
index 2178a28..a0a456e 100644 (file)
@@ -760,8 +760,7 @@ private:
     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
     void setWindowResizerSize(const WebCore::IntSize&);
     void updateIsInWindow(bool isInitialState = false);
-    void setViewState(WebCore::ViewState::Flags, bool wantsDidUpdateViewState);
-    void setViewStateInternal(WebCore::ViewState::Flags, bool isInitialState);
+    void setViewState(WebCore::ViewState::Flags, bool wantsDidUpdateViewState = false);
     void validateCommand(const String&, uint64_t);
     void executeEditCommand(const String&);