Commit 57f29d1c authored by barraclough@apple.com's avatar barraclough@apple.com

Move ViewStateFlags out of WebPageProxy

https://bugs.webkit.org/show_bug.cgi?id=123323

Reviewed by Sam Weinig.

WebPageProxy contains an enum and typedef that provide a bitfield
of flags describing the visibility of the view containing the page.
We're going to want to use this bitfield in a message to the
WebProcess, so moving out from the UIProcess to shared code.
Creating struct 'ViewState' to scope the enum and typedef.
Renamed ViewStateFlags to ViewState::Flags, and removed redundant
'View' from enum entries.

* Shared/ViewState.h: Added.
* UIProcess/API/mac/WKView.mm:
(-[WKView becomeFirstResponder]):
(-[WKView resignFirstResponder]):
(-[WKView viewDidMoveToWindow]):
(-[WKView _windowDidBecomeKey:]):
(-[WKView _windowDidResignKey:]):
(-[WKView _windowDidMiniaturize:]):
(-[WKView _windowDidDeminiaturize:]):
(-[WKView _windowDidOrderOffScreen:]):
(-[WKView _windowDidOrderOnScreen:]):
(-[WKView _windowDidChangeOcclusionState:]):
(-[WKView viewDidHide]):
(-[WKView viewDidUnhide]):
(-[WKView _activeSpaceDidChange:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::viewStateDidChange):
* UIProcess/WebPageProxy.h:
* WebKit2.xcodeproj/project.pbxproj:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158028 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d9a55c0a
2013-10-25 Gavin Barraclough <barraclough@apple.com>
Move ViewStateFlags out of WebPageProxy
https://bugs.webkit.org/show_bug.cgi?id=123323
Reviewed by Sam Weinig.
WebPageProxy contains an enum and typedef that provide a bitfield
of flags describing the visibility of the view containing the page.
We're going to want to use this bitfield in a message to the
WebProcess, so moving out from the UIProcess to shared code.
Creating struct 'ViewState' to scope the enum and typedef.
Renamed ViewStateFlags to ViewState::Flags, and removed redundant
'View' from enum entries.
* Shared/ViewState.h: Added.
* UIProcess/API/mac/WKView.mm:
(-[WKView becomeFirstResponder]):
(-[WKView resignFirstResponder]):
(-[WKView viewDidMoveToWindow]):
(-[WKView _windowDidBecomeKey:]):
(-[WKView _windowDidResignKey:]):
(-[WKView _windowDidMiniaturize:]):
(-[WKView _windowDidDeminiaturize:]):
(-[WKView _windowDidOrderOffScreen:]):
(-[WKView _windowDidOrderOnScreen:]):
(-[WKView _windowDidChangeOcclusionState:]):
(-[WKView viewDidHide]):
(-[WKView viewDidUnhide]):
(-[WKView _activeSpaceDidChange:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::viewStateDidChange):
* UIProcess/WebPageProxy.h:
* WebKit2.xcodeproj/project.pbxproj:
2013-10-25 Gavin Barraclough <barraclough@apple.com>
Move ViewStateFlags out of WebPageProxy
......
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ViewState_h
#define ViewState_h
namespace WebKit {
struct ViewState {
enum {
WindowIsActive = 1 << 0,
IsFocused = 1 << 1,
IsVisible = 1 << 2,
IsInWindow = 1 << 3,
WindowIsVisible = 1 << 4
};
typedef unsigned Flags;
};
} // namespace WebKit
#endif // ViewState_h
......@@ -330,7 +330,7 @@ struct WKViewInterpretKeyEventsParameters {
_data->_inBecomeFirstResponder = true;
[self _updateSecureInputState];
_data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
_data->_page->viewStateDidChange(ViewState::IsFocused);
_data->_inBecomeFirstResponder = false;
......@@ -358,7 +358,7 @@ struct WKViewInterpretKeyEventsParameters {
if (!_data->_page->maintainsInactiveSelection())
_data->_page->clearSelection();
_data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
_data->_page->viewStateDidChange(ViewState::IsFocused);
_data->_inResignFirstResponder = false;
......@@ -1927,11 +1927,11 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
_data->_windowHasValidBackingStore = NO;
[self doWindowDidChangeScreen];
WebPageProxy::ViewStateFlags viewStateChanges = WebPageProxy::WindowIsVisible | WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsVisible;
ViewState::Flags viewStateChanges = ViewState::WindowIsVisible | ViewState::WindowIsActive | ViewState::IsVisible;
if ([self isDeferringViewInWindowChanges])
_data->_viewInWindowChangeWasDeferred = YES;
else
viewStateChanges |= WebPageProxy::ViewIsInWindow;
viewStateChanges |= ViewState::IsInWindow;
_data->_page->viewStateDidChange(viewStateChanges);
[self _updateWindowAndViewFrames];
......@@ -1945,11 +1945,11 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
[self _accessibilityRegisterUIProcessTokens];
} else {
WebPageProxy::ViewStateFlags viewStateChanges = WebPageProxy::WindowIsVisible | WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsVisible;
ViewState::Flags viewStateChanges = ViewState::WindowIsVisible | ViewState::WindowIsActive | ViewState::IsVisible;
if ([self isDeferringViewInWindowChanges])
_data->_viewInWindowChangeWasDeferred = YES;
else
viewStateChanges |= WebPageProxy::ViewIsInWindow;
viewStateChanges |= ViewState::IsInWindow;
_data->_page->viewStateDidChange(viewStateChanges);
[NSEvent removeMonitor:_data->_flagsChangedEventMonitor];
......@@ -1971,7 +1971,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
NSWindow *keyWindow = [notification object];
if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet]) {
[self _updateSecureInputState];
_data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
_data->_page->viewStateDidChange(ViewState::WindowIsActive);
}
}
......@@ -1985,19 +1985,19 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
NSWindow *formerKeyWindow = [notification object];
if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) {
[self _updateSecureInputState];
_data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
_data->_page->viewStateDidChange(ViewState::WindowIsActive);
}
}
- (void)_windowDidMiniaturize:(NSNotification *)notification
{
_data->_windowHasValidBackingStore = NO;
_data->_page->viewStateDidChange(WebPageProxy::WindowIsVisible);
_data->_page->viewStateDidChange(ViewState::WindowIsVisible);
}
- (void)_windowDidDeminiaturize:(NSNotification *)notification
{
_data->_page->viewStateDidChange(WebPageProxy::WindowIsVisible);
_data->_page->viewStateDidChange(ViewState::WindowIsVisible);
}
- (void)_windowDidMove:(NSNotification *)notification
......@@ -2014,12 +2014,12 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
- (void)_windowDidOrderOffScreen:(NSNotification *)notification
{
_data->_page->viewStateDidChange(WebPageProxy::WindowIsVisible | WebPageProxy::ViewIsVisible | WebPageProxy::ViewWindowIsActive);
_data->_page->viewStateDidChange(ViewState::WindowIsVisible | ViewState::IsVisible | ViewState::WindowIsActive);
}
- (void)_windowDidOrderOnScreen:(NSNotification *)notification
{
_data->_page->viewStateDidChange(WebPageProxy::WindowIsVisible | WebPageProxy::ViewIsVisible | WebPageProxy::ViewWindowIsActive);
_data->_page->viewStateDidChange(ViewState::WindowIsVisible | ViewState::IsVisible | ViewState::WindowIsActive);
}
- (void)_windowDidChangeBackingProperties:(NSNotification *)notification
......@@ -2036,7 +2036,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- (void)_windowDidChangeOcclusionState:(NSNotification *)notification
{
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
_data->_page->viewStateDidChange(ViewState::IsVisible);
}
#endif
......@@ -2060,12 +2060,12 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
- (void)viewDidHide
{
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
_data->_page->viewStateDidChange(ViewState::IsVisible);
}
- (void)viewDidUnhide
{
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
_data->_page->viewStateDidChange(ViewState::IsVisible);
}
- (void)viewDidChangeBackingProperties
......@@ -2081,7 +2081,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
- (void)_activeSpaceDidChange:(NSNotification *)notification
{
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
_data->_page->viewStateDidChange(ViewState::IsVisible);
}
- (void)_accessibilityRegisterUIProcessTokens
......
......@@ -991,25 +991,25 @@ void WebPageProxy::viewInWindowStateDidChange(WantsReplyOrNot wantsReply)
#endif
}
void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
void WebPageProxy::viewStateDidChange(ViewState::Flags flags)
{
if (!isValid())
return;
if (flags & WindowIsVisible)
if (flags & ViewState::WindowIsVisible)
process()->send(Messages::WebPage::SetWindowIsVisible(m_pageClient->isWindowVisible()), m_pageID);
if (flags & ViewIsFocused)
if (flags & ViewState::IsFocused)
m_process->send(Messages::WebPage::SetFocused(m_pageClient->isViewFocused()), m_pageID);
// We want to make sure to update the active state while hidden, so if the view is hidden then update the active state
// early (in case it becomes visible), and if the view was visible then update active state later (in case it hides).
bool viewWasVisible = m_isVisible;
if (flags & ViewWindowIsActive && !viewWasVisible)
if (flags & ViewState::WindowIsActive && !viewWasVisible)
m_process->send(Messages::WebPage::SetActive(m_pageClient->isViewWindowActive()), m_pageID);
if (flags & ViewIsVisible) {
if (flags & ViewState::IsVisible) {
bool isVisible = m_pageClient->isViewVisible();
if (isVisible != m_isVisible) {
m_isVisible = isVisible;
......@@ -1030,10 +1030,10 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
}
}
if (flags & ViewWindowIsActive && viewWasVisible)
if (flags & ViewState::WindowIsActive && viewWasVisible)
m_process->send(Messages::WebPage::SetActive(m_pageClient->isViewWindowActive()), m_pageID);
if (flags & ViewIsInWindow)
if (flags & ViewState::IsInWindow)
viewInWindowStateDidChange();
#if ENABLE(PAGE_VISIBILITY_API)
......
......@@ -37,6 +37,7 @@
#include "PlatformProcessIdentifier.h"
#include "SandboxExtension.h"
#include "ShareableBitmap.h"
#include "ViewState.h"
#include "WKBase.h"
#include "WKPagePrivate.h"
#include "WebColorPicker.h"
......@@ -323,15 +324,7 @@ public:
bool canScrollView();
void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
enum {
ViewWindowIsActive = 1 << 0,
ViewIsFocused = 1 << 1,
ViewIsVisible = 1 << 2,
ViewIsInWindow = 1 << 3,
WindowIsVisible = 1 << 4
};
typedef unsigned ViewStateFlags;
void viewStateDidChange(ViewStateFlags flags);
void viewStateDidChange(ViewState::Flags);
enum class WantsReplyOrNot { DoesNotWantReply, DoesWantReply };
void viewInWindowStateDidChange(WantsReplyOrNot = WantsReplyOrNot::DoesNotWantReply);
bool isInWindow() const { return m_isInWindow; }
......
......@@ -656,6 +656,7 @@
7CF47FFE17276AE3008ACB91 /* WKBundlePageBannerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */; };
7CF47FFF17276AE3008ACB91 /* WKBundlePageBannerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
84477853176FCC0800CDC7BB /* InjectedBundleHitTestResultMediaType.h in Headers */ = {isa = PBXBuildFile; fileRef = 84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */; };
865E0485181A094A001F72F2 /* ViewState.h in Headers */ = {isa = PBXBuildFile; fileRef = 865E0484181A090D001F72F2 /* ViewState.h */; };
8CFECE941490F140002AAA32 /* EditorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CFECE931490F140002AAA32 /* EditorState.cpp */; };
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
909854EC12BC4E17000AD080 /* WebMemorySampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905620E812BC248B000799B6 /* WebMemorySampler.cpp */; };
......@@ -2157,6 +2158,7 @@
7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBundlePageBannerMac.mm; sourceTree = "<group>"; };
7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePageBannerMac.h; sourceTree = "<group>"; };
84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleHitTestResultMediaType.h; sourceTree = "<group>"; };
865E0484181A090D001F72F2 /* ViewState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewState.h; sourceTree = "<group>"; };
8CFECE931490F140002AAA32 /* EditorState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditorState.cpp; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* WebKit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -3330,6 +3332,7 @@
1A64245D12DE29A100CAAE2C /* UpdateInfo.cpp */,
1A64245C12DE29A100CAAE2C /* UpdateInfo.h */,
BCB0B0DF12305AB100B1341E /* UserMessageCoders.h */,
865E0484181A090D001F72F2 /* ViewState.h */,
1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */,
1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */,
BC329D9916ACCE9900316DE2 /* WebArchive.cpp */,
......@@ -5396,6 +5399,7 @@
CDC3830C17212282008A2FC3 /* CookieStorageShimLibrary.h in Headers */,
B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
2989A414167D184B004F96D2 /* CustomProtocolManager.h in Headers */,
865E0485181A094A001F72F2 /* ViewState.h in Headers */,
2984F589164BA095004BC0C6 /* CustomProtocolManagerMessages.h in Headers */,
29AD3093164B4C5D0072DEA9 /* CustomProtocolManagerProxy.h in Headers */,
2984F57D164B915F004BC0C6 /* CustomProtocolManagerProxyMessages.h in Headers */,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment