Changeset 221707 in webkit
- Timestamp:
- Sep 6, 2017 4:27:46 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221705 r221707 1 2017-09-06 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's pinnedStateDidChange 4 https://bugs.webkit.org/show_bug.cgi?id=176474 5 <rdar://problem/29270035> 6 7 Reviewed by Tim Horton. 8 9 Rather than telling the UIClient that the pinned state changed and having the application check 4 bools 10 like we do with WKPage, I made a KVO property on the WKWebView. I introduce _WKRectEdge for this purpose, 11 which is like UIRectEdge but unfortunately NSRectEdge and CGRectEdge cannot be used as NS_OPTIONS/flags. 12 This same structure is used for rubber band state. 13 14 Covered by a new API test. 15 16 * UIProcess/API/Cocoa/WKWebView.mm: 17 (-[WKWebView _pinnedState]): 18 (-[WKWebView _rubberBandState]): 19 (-[WKWebView _setRubberBandState:]): 20 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 21 * UIProcess/Cocoa/WebViewImpl.h: 22 * UIProcess/Cocoa/WebViewImpl.mm: 23 (WebKit::WebViewImpl::pinnedState): 24 (WebKit::WebViewImpl::rubberBandState): 25 (WebKit::WebViewImpl::setRubberBandState): 26 * UIProcess/PageClient.h: 27 (WebKit::PageClient::pinnedStateWillChange): 28 (WebKit::PageClient::pinnedStateDidChange): 29 * UIProcess/WebPageProxy.cpp: 30 (WebKit::WebPageProxy::didChangeScrollOffsetPinningForMainFrame): 31 * UIProcess/mac/PageClientImplMac.h: 32 * UIProcess/mac/PageClientImplMac.mm: 33 (WebKit::PageClientImpl::pinnedStateWillChange): 34 (WebKit::PageClientImpl::pinnedStateDidChange): 35 1 36 2017-09-06 Youenn Fablet <youenn@apple.com> 2 37 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r221702 r221707 5282 5282 } 5283 5283 5284 - (_WKRectEdge)_pinnedState 5285 { 5286 return _impl->pinnedState(); 5287 } 5288 5289 - (_WKRectEdge)_rubberBandingEnabled 5290 { 5291 return _impl->rubberBandingEnabled(); 5292 } 5293 5294 - (void)_setRubberBandingEnabled:(_WKRectEdge)state 5295 { 5296 _impl->setRubberBandingEnabled(state); 5297 } 5298 5284 5299 - (id)_immediateActionAnimationControllerForHitTestResult:(_WKHitTestResult *)hitTestResult withType:(_WKImmediateActionType)type userData:(id<NSSecureCoding>)userData 5285 5300 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
r221702 r221707 81 81 } WK_API_AVAILABLE(macosx(10.12)); 82 82 83 typedef NS_OPTIONS(NSInteger, _WKRectEdge) { 84 _WKRectEdgeNone = 0, 85 _WKRectEdgeLeft = 1 << CGRectMinXEdge, 86 _WKRectEdgeTop = 1 << CGRectMinYEdge, 87 _WKRectEdgeRight = 1 << CGRectMaxXEdge, 88 _WKRectEdgeBottom = 1 << CGRectMaxYEdge, 89 _WKRectEdgeAll = _WKRectEdgeLeft | _WKRectEdgeTop | _WKRectEdgeRight | _WKRectEdgeBottom, 90 } WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 91 83 92 #endif 84 93 … … 239 248 240 249 #else 250 251 @property (nonatomic, readonly) _WKRectEdge _pinnedState; 252 @property (nonatomic, setter=_setRubberBandingEnabled:) _WKRectEdge _rubberBandingEnabled; 253 241 254 @property (readonly) NSColor *_pageExtendedBackgroundColor; 242 255 @property (nonatomic, setter=_setDrawsBackground:) BOOL _drawsBackground; -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r221702 r221707 24 24 */ 25 25 26 #ifndef WebViewImpl_h 27 #define WebViewImpl_h 26 #pragma once 28 27 29 28 #if PLATFORM(MAC) … … 42 41 #include <wtf/WeakPtr.h> 43 42 #include <wtf/text/WTFString.h> 43 44 using _WKRectEdge = NSInteger; 44 45 45 46 OBJC_CLASS NSAccessibilityRemoteUIElement; … … 237 238 NSColor *underlayColor() const; 238 239 NSColor *pageExtendedBackgroundColor() const; 240 241 _WKRectEdge pinnedState(); 242 _WKRectEdge rubberBandingEnabled(); 243 void setRubberBandingEnabled(_WKRectEdge); 239 244 240 245 void setOverlayScrollbarStyle(std::optional<WebCore::ScrollbarOverlayStyle> scrollbarStyle); … … 733 738 734 739 #endif // PLATFORM(MAC) 735 736 #endif // WebViewImpl_h -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r221702 r221707 58 58 #import "WKTextInputWindowController.h" 59 59 #import "WKViewLayoutStrategy.h" 60 #import "WKWebView .h"60 #import "WKWebViewPrivate.h" 61 61 #import "WebBackForwardList.h" 62 62 #import "WebEditCommandProxy.h" … … 4845 4845 } 4846 4846 4847 _WKRectEdge WebViewImpl::pinnedState() 4848 { 4849 #if WK_API_ENABLED 4850 _WKRectEdge state = _WKRectEdgeNone; 4851 if (m_page->isPinnedToLeftSide()) 4852 state |= _WKRectEdgeLeft; 4853 if (m_page->isPinnedToRightSide()) 4854 state |= _WKRectEdgeRight; 4855 if (m_page->isPinnedToTopSide()) 4856 state |= _WKRectEdgeTop; 4857 if (m_page->isPinnedToBottomSide()) 4858 state |= _WKRectEdgeBottom; 4859 return state; 4860 #else 4861 return 0; 4862 #endif 4863 } 4864 4865 _WKRectEdge WebViewImpl::rubberBandingEnabled() 4866 { 4867 #if WK_API_ENABLED 4868 _WKRectEdge state = _WKRectEdgeNone; 4869 if (m_page->rubberBandsAtLeft()) 4870 state |= _WKRectEdgeLeft; 4871 if (m_page->rubberBandsAtRight()) 4872 state |= _WKRectEdgeRight; 4873 if (m_page->rubberBandsAtTop()) 4874 state |= _WKRectEdgeTop; 4875 if (m_page->rubberBandsAtBottom()) 4876 state |= _WKRectEdgeBottom; 4877 return state; 4878 #else 4879 return 0; 4880 #endif 4881 } 4882 4883 void WebViewImpl::setRubberBandingEnabled(_WKRectEdge state) 4884 { 4885 #if WK_API_ENABLED 4886 m_page->setRubberBandsAtLeft(state & _WKRectEdgeLeft); 4887 m_page->setRubberBandsAtRight(state & _WKRectEdgeRight); 4888 m_page->setRubberBandsAtTop(state & _WKRectEdgeTop); 4889 m_page->setRubberBandsAtBottom(state & _WKRectEdgeBottom); 4890 #else 4891 UNUSED_PARAM(state); 4892 #endif 4893 } 4894 4847 4895 void WebViewImpl::mouseDown(NSEvent *event) 4848 4896 { -
trunk/Source/WebKit/UIProcess/PageClient.h
r221702 r221707 347 347 virtual void isPlayingAudioWillChange() = 0; 348 348 virtual void isPlayingAudioDidChange() = 0; 349 virtual void pinnedStateWillChange() { }; 350 virtual void pinnedStateDidChange() { }; 349 351 350 352 #if PLATFORM(MAC) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r221702 r221707 5967 5967 void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide) 5968 5968 { 5969 m_pageClient.pinnedStateWillChange(); 5969 5970 m_mainFrameIsPinnedToLeftSide = pinnedToLeftSide; 5970 5971 m_mainFrameIsPinnedToRightSide = pinnedToRightSide; 5971 5972 m_mainFrameIsPinnedToTopSide = pinnedToTopSide; 5972 5973 m_mainFrameIsPinnedToBottomSide = pinnedToBottomSide; 5974 m_pageClient.pinnedStateDidChange(); 5973 5975 5974 5976 m_uiClient->pinnedStateDidChange(*this); -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r221702 r221707 118 118 #endif 119 119 120 void pinnedStateWillChange() final; 121 void pinnedStateDidChange() final; 122 120 123 CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const override; 121 124 -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r221702 r221707 403 403 } 404 404 405 void PageClientImpl::pinnedStateWillChange() 406 { 407 #if WK_API_ENABLED 408 [m_webView willChangeValueForKey:@"_pinnedState"]; 409 #endif 410 } 411 412 void PageClientImpl::pinnedStateDidChange() 413 { 414 #if WK_API_ENABLED 415 [m_webView didChangeValueForKey:@"_pinnedState"]; 416 #endif 417 } 418 405 419 IntPoint PageClientImpl::screenToRootView(const IntPoint& point) 406 420 { -
trunk/Tools/ChangeLog
r221702 r221707 1 2017-09-06 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's pinnedStateDidChange 4 https://bugs.webkit.org/show_bug.cgi?id=176474 5 <rdar://problem/29270035> 6 7 Reviewed by Tim Horton. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: 10 (-[PinnedStateObserver observeValueForKeyPath:ofObject:change:context:]): 11 (TEST): 12 1 13 2017-09-06 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
r221702 r221707 250 250 } 251 251 252 @interface PinnedStateObserver : NSObject <WKUIDelegatePrivate> 253 @end 254 255 @implementation PinnedStateObserver 256 257 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *, id> *)change context:(void *)context 258 { 259 EXPECT_TRUE([keyPath isEqualToString:NSStringFromSelector(@selector(_pinnedState))]); 260 EXPECT_TRUE([[object class] isEqual:[TestWKWebView class]]); 261 EXPECT_EQ([[change objectForKey:NSKeyValueChangeOldKey] integerValue], _WKRectEdgeAll); 262 EXPECT_EQ([[change objectForKey:NSKeyValueChangeNewKey] integerValue], _WKRectEdgeLeft | _WKRectEdgeRight); 263 EXPECT_TRUE(context == nullptr); 264 done = true; 265 } 266 267 @end 268 269 TEST(WebKit, PinnedState) 270 { 271 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]); 272 auto observer = adoptNS([[PinnedStateObserver alloc] init]); 273 [webView addObserver:observer.get() forKeyPath:@"_pinnedState" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; 274 [webView loadHTMLString:@"<body onload='scroll(100, 100)' style='height:10000vh;'/>" baseURL:[NSURL URLWithString:@"http://example.com/"]]; 275 TestWebKitAPI::Util::run(&done); 276 } 277 252 278 static NSEvent *tabEvent(NSWindow *window, NSEventType type, NSEventModifierFlags flags) 253 279 {
Note: See TracChangeset
for help on using the changeset viewer.