Changeset 265091 in webkit
- Timestamp:
- Jul 30, 2020 11:25:47 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r265088 r265091 1 2020-07-30 Tim Horton <timothy_horton@apple.com> 2 3 Web content gets stuck in an inactive state (no cursor updates or text insertion caret) when activating a tab with a thumbnail visible 4 https://bugs.webkit.org/show_bug.cgi?id=214962 5 <rdar://problem/65670984> 6 7 Reviewed by Wenson Hsieh. 8 9 New API test: WebKit.WKThumbnailViewResetsViewStateWhenUnparented 10 11 * testing/Internals.cpp: 12 (WebCore::Internals::isPageActive const): 13 * testing/Internals.h: 14 * testing/Internals.idl: 15 Add a "view window is active" getter. 16 1 17 2020-07-30 Antoine Quint <graouts@webkit.org> 2 18 -
trunk/Source/WebCore/testing/Internals.cpp
r264975 r265091 5172 5172 } 5173 5173 5174 bool Internals::isPageActive() const 5175 { 5176 auto* document = contextDocument(); 5177 if (!document || !document->page()) 5178 return false; 5179 auto& page = *document->page(); 5180 return page.activityState().contains(ActivityState::WindowIsActive); 5181 } 5182 5174 5183 #if ENABLE(WEB_RTC) 5175 5184 void Internals::setH264HardwareEncoderAllowed(bool allowed) -
trunk/Source/WebCore/testing/Internals.h
r264975 r265091 773 773 void setPageVisibility(bool isVisible); 774 774 void setPageIsFocusedAndActive(bool); 775 775 bool isPageActive() const; 776 776 777 777 #if ENABLE(WEB_RTC) -
trunk/Source/WebCore/testing/Internals.idl
r264975 r265091 797 797 void setPageVisibility(boolean isVisible); 798 798 void setPageIsFocusedAndActive(boolean isFocused); 799 boolean isPageActive(); 799 800 800 801 [Conditional=WEB_RTC] void setH264HardwareEncoderAllowed(boolean allowed); -
trunk/Source/WebKit/ChangeLog
r265089 r265091 1 2020-07-30 Tim Horton <timothy_horton@apple.com> 2 3 Web content gets stuck in an inactive state (no cursor updates or text insertion caret) when activating a tab with a thumbnail visible 4 https://bugs.webkit.org/show_bug.cgi?id=214962 5 <rdar://problem/65670984> 6 7 Reviewed by Wenson Hsieh. 8 9 * UIProcess/Cocoa/WebViewImpl.mm: 10 (WebKit::WebViewImpl::setThumbnailView): 11 When WKThumbnailView is unparented, invalidate all activity state bits. 12 We do this because many of the functions that compute activity state bits 13 use the WKThumbnailView's window while it is parented. When it is unparented, 14 and we switch back to using the WKWebView's window, we mustn't get stuck 15 with activity state bits from WKThumbnailView's window. 16 17 This was particularly problematic in the case of the WKThumbnailViews 18 used for tab hover previews, because that window is not key, so we'd get 19 stuck with the inactive-window state, resulting in a lack of cursor updates, 20 a hidden text caret, the wrong selection color, etc. 21 22 * UIProcess/mac/PageClientImplMac.mm: 23 (WebKit::PageClientImpl::isViewWindowActive): 24 While writing the API test for this, I noticed that isViewWindowActive 25 returns YES if there is no key window AND WKWebView is unparented 26 ([NSApp keyWindow] == activeWindow() == nil). 27 This seems completely insane (how can the window be active if it doesn't 28 exist?), and breaks the test, so ensure that we only say YES if we actually 29 have a window. 30 1 31 2020-07-30 Peng Liu <peng.liu6@apple.com> 2 32 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r264585 r265091 3855 3855 if (thumbnailView) 3856 3856 updateThumbnailViewLayer(); 3857 else 3857 else { 3858 3858 setAcceleratedCompositingRootLayer(m_rootLayer.get()); 3859 m_page->activityStateDidChange(WebCore::ActivityState::allFlags()); 3860 } 3859 3861 } 3860 3862 -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r263825 r265091 161 161 ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 162 162 NSWindow *activeViewWindow = activeWindow(); 163 return activeViewWindow.isKeyWindow || [NSApp keyWindow] == activeViewWindow;163 return activeViewWindow.isKeyWindow || (activeViewWindow && [NSApp keyWindow] == activeViewWindow); 164 164 } 165 165 -
trunk/Tools/ChangeLog
r265082 r265091 1 2020-07-30 Tim Horton <timothy_horton@apple.com> 2 3 Web content gets stuck in an inactive state (no cursor updates or text insertion caret) when activating a tab with a thumbnail visible 4 https://bugs.webkit.org/show_bug.cgi?id=214962 5 <rdar://problem/65670984> 6 7 Reviewed by Wenson Hsieh. 8 9 * TestWebKitAPI/Tests/WebKit/WKThumbnailView.mm: 10 (TestWebKitAPI::TEST): 11 Add a test ensuring that we go back to the active-window state after 12 unparenting a WKThumbnailView that was installed in an inactive window. 13 14 (-[WKThumbnailViewDelegate webView:didFinishNavigation:]): Deleted. 15 * TestWebKitAPI/mac/OffscreenWindow.h: 16 * TestWebKitAPI/mac/OffscreenWindow.mm: 17 (-[OffscreenWindow initWithSize:]): 18 (-[OffscreenWindow initWithSize:isKeyWindow:]): 19 (-[OffscreenWindow isKeyWindow]): 20 1 21 2020-07-30 Jonathan Bedard <jbedard@apple.com> 2 22 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/WKThumbnailView.mm
r260366 r265091 29 29 30 30 #import "JavaScriptTest.h" 31 #import "OffscreenWindow.h" 31 32 #import "PlatformUtilities.h" 32 33 #import "PlatformWebView.h" 33 34 #import "TestWKWebView.h" 35 #import "WKWebViewConfigurationExtras.h" 34 36 #import <WebKit/WKViewPrivate.h> 35 37 #import <WebKit/_WKThumbnailView.h> … … 58 60 59 61 [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; 60 }61 62 @end63 64 65 @interface WKThumbnailViewDelegate : NSObject <WKNavigationDelegate>66 @end67 68 @implementation WKThumbnailViewDelegate69 70 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation71 {72 didFinishLoad = true;73 62 } 74 63 … … 200 189 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]); 201 190 WKPageSetCustomBackingScaleFactor([webView _pageForTesting], 1); 202 auto delegate = adoptNS([[WKThumbnailViewDelegate alloc] init]); 203 [webView setNavigationDelegate:delegate.get()]; 204 [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"lots-of-text" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; 205 Util::run(&didFinishLoad); 191 [webView synchronouslyLoadTestPageNamed:@"lots-of-text"]; 206 192 207 193 RetainPtr<_WKThumbnailView> thumbnailView = adoptNS([[_WKThumbnailView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) fromWKWebView:webView.get()]); … … 242 228 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]); 243 229 WKPageSetCustomBackingScaleFactor([webView _pageForTesting], 1); 244 auto delegate = adoptNS([[WKThumbnailViewDelegate alloc] init]); 245 [webView setNavigationDelegate:delegate.get()]; 246 [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"lots-of-text" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; 247 Util::run(&didFinishLoad); 230 [webView synchronouslyLoadTestPageNamed:@"lots-of-text"]; 248 231 249 232 auto thumbnailView = adoptNS([[_WKThumbnailView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) fromWKWebView:webView.get()]); … … 286 269 } 287 270 271 TEST(WebKit, WKThumbnailViewResetsViewStateWhenUnparented) 272 { 273 WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]; 274 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]); 275 [webView removeFromSuperview]; 276 [webView synchronouslyLoadTestPageNamed:@"lots-of-text"]; 277 278 auto thumbnailView = adoptNS([[_WKThumbnailView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) fromWKWebView:webView.get()]); 279 280 auto observer = adoptNS([[SnapshotSizeObserver alloc] init]); 281 282 [thumbnailView addObserver:observer.get() forKeyPath:@"snapshotSize" options:NSKeyValueObservingOptionNew context:snapshotSizeChangeKVOContext]; 283 284 RetainPtr<NSWindow> otherWindow = adoptNS([[OffscreenWindow alloc] initWithSize:CGSizeMake(100, 100) isKeyWindow:NO]); 285 [[otherWindow contentView] addSubview:thumbnailView.get()]; 286 [otherWindow orderFront:nil]; 287 [[webView hostWindow] makeKeyAndOrderFront:nil]; 288 Util::run(&didTakeSnapshot); 289 didTakeSnapshot = false; 290 EXPECT_FALSE([thumbnailView layer].contents == nil); 291 [webView waitForNextPresentationUpdate]; 292 EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"window.internals.isPageActive()"] boolValue]); 293 294 [webView addToTestWindow]; 295 [webView waitForNextPresentationUpdate]; 296 EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"window.internals.isPageActive()"] boolValue]); 297 298 [thumbnailView removeFromSuperview]; 299 [webView waitForNextPresentationUpdate]; 300 EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"window.internals.isPageActive()"] boolValue]); 301 302 [thumbnailView removeObserver:observer.get() forKeyPath:@"snapshotSize" context:snapshotSizeChangeKVOContext]; 303 } 304 305 288 306 } // namespace TestWebKitAPI 289 307 290 #endif 308 #endif // PLATFORM(MAC) -
trunk/Tools/TestWebKitAPI/mac/OffscreenWindow.h
r260366 r265091 35 35 36 36 - (instancetype)initWithSize:(CGSize)size; 37 - (instancetype)initWithSize:(CGSize)size isKeyWindow:(BOOL)isKeyWindow; 37 38 38 39 @end -
trunk/Tools/TestWebKitAPI/mac/OffscreenWindow.mm
r240010 r265091 27 27 #import "OffscreenWindow.h" 28 28 29 @implementation OffscreenWindow 29 @implementation OffscreenWindow { 30 BOOL _isKeyWindow; 31 } 30 32 31 33 - (instancetype)initWithSize:(CGSize)size 32 34 { 35 return [self initWithSize:size isKeyWindow:YES]; 36 } 37 38 - (instancetype)initWithSize:(CGSize)size isKeyWindow:(BOOL)isKeyWindow 39 { 40 _isKeyWindow = isKeyWindow; 41 33 42 NSRect rect = NSMakeRect(0, 0, size.width, size.height); 34 43 NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000); … … 47 56 - (BOOL)isKeyWindow 48 57 { 49 return YES;58 return _isKeyWindow; 50 59 } 51 60
Note: See TracChangeset
for help on using the changeset viewer.