QLPreviewMenuItem popovers don't close when the page scrolls
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 19:43:20 +0000 (19:43 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 19:43:20 +0000 (19:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140806
<rdar://problem/19555618>

Reviewed by Beth Dakin.

Now that QLPreviewMenuItem's popover doesn't eat scrolls, we need to dismiss it if the page scrolls.

* WebView/WebHTMLView.mm:
(-[WebHTMLView scrollWheel:scrollWheel:]):
Send scrollWheel along to WebImmediateActionController.

* WebView/WebImmediateActionController.h:
* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController webView:didHandleScrollWheel:]):
(-[WebImmediateActionController _clearImmediateActionState]):
(-[WebImmediateActionController _defaultAnimationController]):
Keep track of the active QLPreviewMenuItem, and close it upon scroll.

* UIProcess/API/mac/WKView.mm:
(-[WKView _dismissContentRelativeChildWindows]):
Send _dismissContentRelativeChildWindows on to WKImmediateActionController.

* UIProcess/mac/WKImmediateActionController.h:
* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _clearImmediateActionState]):
(-[WKImmediateActionController dismissContentRelativeChildWindows]):
(-[WKImmediateActionController _defaultAnimationController]):
Keep track of the active QLPreviewMenuItem, and close it upon scroll.

* platform/spi/mac/QuickLookMacSPI.h:
Add some SPI.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/spi/mac/QuickLookMacSPI.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebImmediateActionController.h
Source/WebKit/mac/WebView/WebImmediateActionController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/mac/WKImmediateActionController.h
Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm

index 83392942d8653e6c1931f08173ec38a66a175741..c674ad5801e19ddf400b46594c0eb30903b9c0be 100644 (file)
@@ -1,3 +1,14 @@
+2015-01-23  Timothy Horton  <timothy_horton@apple.com>
+
+        QLPreviewMenuItem popovers don't close when the page scrolls
+        https://bugs.webkit.org/show_bug.cgi?id=140806
+        <rdar://problem/19555618>
+
+        Reviewed by Beth Dakin.
+
+        * platform/spi/mac/QuickLookMacSPI.h:
+        Add some SPI.
+
 2015-01-23  Andreas Kling  <akling@apple.com>
 
         Hang CSSFontSelector off Document instead of StyleResolver.
index fa5ac2caf98986beb35006f55163638a4eee3ef4..2e321f3aa0936ee0aecd3a71ad710a14aa98a0b1 100644 (file)
@@ -46,6 +46,8 @@ typedef NS_ENUM(NSInteger, QLPreviewStyle) {
     QLPreviewStylePopover
 };
 
+- (void)close;
+
 @property (assign) id<QLPreviewMenuItemDelegate> delegate;
 @property QLPreviewStyle previewStyle;
 @end
index 7d8b2350d348e4b5d46e3502e3a47d1056586644..323f194121e59a59424e5569f29a124700cae728 100644 (file)
@@ -1,3 +1,24 @@
+2015-01-23  Timothy Horton  <timothy_horton@apple.com>
+
+        QLPreviewMenuItem popovers don't close when the page scrolls
+        https://bugs.webkit.org/show_bug.cgi?id=140806
+        <rdar://problem/19555618>
+
+        Reviewed by Beth Dakin.
+
+        Now that QLPreviewMenuItem's popover doesn't eat scrolls, we need to dismiss it if the page scrolls.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView scrollWheel:scrollWheel:]):
+        Send scrollWheel along to WebImmediateActionController.
+
+        * WebView/WebImmediateActionController.h:
+        * WebView/WebImmediateActionController.mm:
+        (-[WebImmediateActionController webView:didHandleScrollWheel:]):
+        (-[WebImmediateActionController _clearImmediateActionState]):
+        (-[WebImmediateActionController _defaultAnimationController]):
+        Keep track of the active QLPreviewMenuItem, and close it upon scroll.
+
 2015-01-23  Timothy Horton  <timothy_horton@apple.com>
 
         Infinite recursion in _clearImmediateActionState
index cd551863ea8182659ecf06ae03a7e4f28a431d8a..1f1cf001dfa2430b969ee20104578cb1d119623c 100644 (file)
@@ -3711,6 +3711,7 @@ static void setMenuTargets(NSMenu* menu)
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     [[[self _webView] _actionMenuController] webView:[self _webView] didHandleScrollWheel:event];
+    [[[self _webView] _immediateActionController] webView:[self _webView] didHandleScrollWheel:event];
 #endif
 }
 
index d1688f9ab384fd0e600527d1c0a50f29be8c07d2..026eb5edac645d1e012d891a9cd6c7d19a5f1e6d 100644 (file)
@@ -31,6 +31,7 @@
 #import <wtf/RetainPtr.h>
 
 @class DDActionContext;
+@class QLPreviewMenuItem;
 @class WebView;
 
 @interface WebImmediateActionController : NSObject <NSImmediateActionGestureRecognizerDelegate> {
@@ -40,6 +41,7 @@
     WebCore::HitTestResult _hitTestResult;
     RetainPtr<NSImmediateActionGestureRecognizer> _immediateActionRecognizer;
 
+    RetainPtr<QLPreviewMenuItem> _currentQLPreviewMenuItem;
     RetainPtr<DDActionContext> _currentActionContext;
     BOOL _isShowingTextIndicator;
     BOOL _hasActivatedActionContext;
@@ -49,6 +51,7 @@
 - (void)webViewClosed;
 
 - (void)webView:(WebView *)webView willHandleMouseDown:(NSEvent *)event;
+- (void)webView:(WebView *)webView didHandleScrollWheel:(NSEvent *)event;
 
 @end
 
index 92bd692d5041d11dda1fe305d62be3b5a23d4f36..1bfab2199d9ff37ab0c158f4257a8978b2fd9186 100644 (file)
@@ -98,6 +98,12 @@ using namespace WebCore;
     [self _clearImmediateActionState];
 }
 
+- (void)webView:(WebView *)webView didHandleScrollWheel:(NSEvent *)event
+{
+    [_currentQLPreviewMenuItem close];
+    [self _clearImmediateActionState];
+}
+
 - (void)_cancelImmediateAction
 {
     // Reset the recognizer by turning it off and on again.
@@ -121,6 +127,7 @@ using namespace WebCore;
 
     _type = WebImmediateActionNone;
     _currentActionContext = nil;
+    _currentQLPreviewMenuItem = nil;
 }
 
 - (void)performHitTestAtPoint:(NSPoint)viewPoint
@@ -211,6 +218,7 @@ using namespace WebCore;
         RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
         [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
         [qlPreviewLinkItem setDelegate:self];
+        _currentQLPreviewMenuItem = qlPreviewLinkItem.get();
         return (id <NSImmediateActionAnimationController>)qlPreviewLinkItem.get();
     }
 
index d83b7a97627876fcdabfaa37722f0ade705654b8..3d8fb73c0941cc4e84d17180a7c9521cd647b729 100644 (file)
@@ -1,3 +1,24 @@
+2015-01-23  Timothy Horton  <timothy_horton@apple.com>
+
+        QLPreviewMenuItem popovers don't close when the page scrolls
+        https://bugs.webkit.org/show_bug.cgi?id=140806
+        <rdar://problem/19555618>
+
+        Reviewed by Beth Dakin.
+
+        Now that QLPreviewMenuItem's popover doesn't eat scrolls, we need to dismiss it if the page scrolls.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _dismissContentRelativeChildWindows]):
+        Send _dismissContentRelativeChildWindows on to WKImmediateActionController.
+
+        * UIProcess/mac/WKImmediateActionController.h:
+        * UIProcess/mac/WKImmediateActionController.mm:
+        (-[WKImmediateActionController _clearImmediateActionState]):
+        (-[WKImmediateActionController dismissContentRelativeChildWindows]):
+        (-[WKImmediateActionController _defaultAnimationController]):
+        Keep track of the active QLPreviewMenuItem, and close it upon scroll.
+
 2015-01-23  Timothy Horton  <timothy_horton@apple.com>
 
         Infinite recursion in _clearImmediateActionState
index 051a0167b1cb2b6130d971d0abfe8bc42df58ca9..bd7de42f452b856cf3e37314683b4e7290d58f63 100644 (file)
@@ -4354,6 +4354,8 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
 
     [self _setTextIndicator:nullptr fadeOut:NO];
 
+    [_data->_immediateActionController dismissContentRelativeChildWindows];
+
     static_cast<PageClient&>(*_data->_pageClient).dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
 }
 
index 1543d67f12b4caab89f14d0c0ba85e816b887017..bcee5a9aa78f45534d2bed6b2967b9a236d427f5 100644 (file)
@@ -45,6 +45,7 @@ enum class ImmediateActionState {
 }
 
 @class DDActionContext;
+@class QLPreviewMenuItem;
 @class WKView;
 
 @interface WKImmediateActionController : NSObject <NSImmediateActionGestureRecognizerDelegate> {
@@ -60,12 +61,14 @@ enum class ImmediateActionState {
 
     BOOL _hasActivatedActionContext;
     RetainPtr<DDActionContext> _currentActionContext;
+    RetainPtr<QLPreviewMenuItem> _currentQLPreviewMenuItem;
 }
 
 - (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView recognizer:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer;
 - (void)willDestroyView:(WKView *)view;
 - (void)didPerformActionMenuHitTest:(const WebKit::ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData;
 - (void)wkView:(WKView *)wkView willHandleMouseDown:(NSEvent *)event;
+- (void)dismissContentRelativeChildWindows;
 
 @end
 
index 8ac5ab0f61b273be98a185fc97cfc028bead6da7..4195ee71b8da621dcba104c44e692fbb041af66a 100644 (file)
@@ -126,6 +126,7 @@ using namespace WebKit;
     _type = kWKImmediateActionNone;
     _currentActionContext = nil;
     _userData = nil;
+    _currentQLPreviewMenuItem = nil;
 }
 
 - (void)didPerformActionMenuHitTest:(const ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData
@@ -139,6 +140,11 @@ using namespace WebKit;
     [self _cancelImmediateActionIfNeeded];
 }
 
+- (void)dismissContentRelativeChildWindows
+{
+    [_currentQLPreviewMenuItem close];
+}
+
 #pragma mark NSImmediateActionGestureRecognizerDelegate
 
 - (void)immediateActionRecognizerWillPrepare:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
@@ -237,6 +243,7 @@ using namespace WebKit;
         RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
         [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
         [qlPreviewLinkItem setDelegate:self];
+        _currentQLPreviewMenuItem = qlPreviewLinkItem.get();
         return (id<NSImmediateActionAnimationController>)qlPreviewLinkItem.get();
     }