Merge PageVisibilityState & ViewState::IsVisible in WebKit2
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Dec 2013 19:46:00 +0000 (19:46 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Dec 2013 19:46:00 +0000 (19:46 +0000)
commitfdb2769f5e73be2931f3a12a921c0580d7e406a8
treed4f9bdbe7a85cdb2eab71c627a0d0bc372dbba17
parent3ae9db0808bcce79afa75c10e18e73e510670049
Merge PageVisibilityState & ViewState::IsVisible in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=126214

Reviewed by Alexey Proskuryakov.

WebKit2 redundantly tracks the visibility of the view through two mechanisms - the visibility
state, and the view state. Remove visibility state from the WebKit2 layer. The visibility
state also tracks the prerender state - so split this out and handle it separately (a change
we should make in WebCore, too).

Source/WebCore:

WebCore - changes the API tests exposed a bug, a view should only ever come out of the
prerender state when it becomes visible - redundant notifications that the view is still
hidden should be ignored.

* page/Page.cpp:
(WebCore::Page::setVisibilityState):
    - ignore visibility state change to hidden, if the current state is prerender.

Source/WebKit2:

Removing the redundancy also removes the ability from the API to set a fake visibility state
(IsVisible tracks the actual visibility of the view). Through private API
(WKPageSetVisibilityState) a client could previously request the view be reported as hidden or
visible, but this didn't really work - the override was not enforced and the API may reset the
state at an arbitrary point. The mechanism is only used by testing code, which instead should
actually update the view visibility (this tests more of the actual visibility mechanisms used
by the browser). The one aspect of the API relied on by existing clients is the ability to
initialize a hidden view as prerender - continue to support this specific functionality via
WKPageSetVisibilityState, to maintain backwards compatibility.

- WebKit2 - remove internal state that tracks page visibility separately from the view state
visibility. For backwards compatibility continue to support the WKPageSetVisibilityState API,
but only to initialize the state to prerender.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetVisibilityState):
    - only support initializing the visibility state to prerender.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
    - remove m_visibilityState
(WebKit::WebPageProxy::initializeWebPage):
    - no need to send initial visibility state (this is sent as a part of the creation parameters).
(WebKit::WebPageProxy::viewStateDidChange):
    - no need to send visibility state change (this is sent as a part of view state).
(WebKit::WebPageProxy::setVisibilityStatePrerender):
    - setVisibilityState -> setVisibilityStatePrerender.
* UIProcess/WebPageProxy.h:
    - remove m_visibilityState, setVisibilityState -> setVisibilityStatePrerender.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
    - added call to updateVisibilityState.
(WebKit::WebPage::setViewIsVisible):
    - added call to updateVisibilityState.
(WebKit::WebPage::updateVisibilityState):
    - previously setVisibilityState, updates the page visibility state according to the view state.
(WebKit::WebPage::setVisibilityStatePrerender):
    - set visibility state to prerender.
* WebProcess/WebPage/WebPage.h:
    - remove m_visibilityState, setVisibilityState -> setVisibilityStatePrerender.
* WebProcess/WebPage/WebPage.messages.in:
    - SetVisibilityState -> SetVisibilityStatePrerender.

Tools:

Tools - WebKit2 no longer (poorly) supports a fake visibility state, so to test the page
visibility mechanisms we should actually be changing characteristics of the view that will
be detected by WebKit2 as a visibility change. This affects three things:
    1) On setVisibilityState WebKitTestRunner must actually change visibility of the view.
    2) The 'PageVisibilityState' test in the API tests is useless (as evidenced by the fact
       that page visibility has been broken in WebKit2 for a couple of months, and didn't
       catch this fact). Removed in favour of:
    3) 'PageVisibilityStateWithWindowChanges' - this is the good stuff. This actually tests
       the visibility mechanism. Beef this test up by adding coverage for: a) the prerender
    state, b) document.hidden, and c) too many state change notifications (it already looks
    for too few).

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp: Removed.
    - Removed PageVisibilityState - this test was ineffective, API no longer supports this
      test, and behaviour is covered by PageVisibilityStateWithWindowChanges.
* TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm:
(-[PageVisibilityStateDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
(runJavaScriptAlert):
    - Add checking for too many calls to the alert.
(TestWebKitAPI::PageVisibilityStateWithWindowChanges::setPrerender):
    - Added methods to set visibility to prerender.
(TestWebKitAPI::PageVisibilityStateWithWindowChanges::runTest):
    - Added checking of 'document.hidden'.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setVisibilityState):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/efl/TestControllerEfl.cpp:
(WTR::TestController::setHidden):
* WebKitTestRunner/gtk/TestControllerGtk.cpp:
(WTR::TestController::setHidden):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::setHidden):
    - Add setHidden method; call this from setVisibilityState.

LayoutTests:

LayoutTests - remove test for notification on visibility state change to preerender. This test
was covering something nonsensical, and not supported by the spec - the page should never see
a visibility change to prerender, this should only be an initial state. WebKit2 API now only
allows the client to change the state to prerender without sending a notification, and there
is no sense in continuing to support the current test case, since the behaviour is neither
allowed by API nor available in web content.

The prerender state is now properly covered by API tests.

* fast/events/page-visibility-transition-test-expected.txt:
* fast/events/page-visibility-transition-test.html:
    - remove test for notification on visibility state change to preerender.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/page-visibility-transition-test-expected.txt
LayoutTests/fast/events/page-visibility-transition-test.html
Source/WebCore/ChangeLog
Source/WebCore/page/Page.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/GNUmakefile.am
Tools/TestWebKitAPI/PlatformEfl.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp [deleted file]
Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/efl/TestControllerEfl.cpp
Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp
Tools/WebKitTestRunner/mac/TestControllerMac.mm