WKView being inside WKWebView leads to weird API issues
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Oct 2015 18:52:08 +0000 (18:52 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Oct 2015 18:52:08 +0000 (18:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150174

Reviewed by Anders Carlsson.

* UIProcess/API/mac/WKView.mm:
(-[WKView _wantsKeyDownForEvent:]):
(-[WKView acceptsFirstMouse:]):
(-[WKView shouldDelayWindowOrderingForEvent:]):
(-[WKView validAttributesForMarkedText]):
(-[WKView _windowResizeMouseLocationIsInVisibleScrollerThumb:]):
(-[WKView drawRect:]):
(-[WKView isOpaque]):
(-[WKView mouseDownCanMoveWindow]):
(-[WKView viewDidHide]):
(-[WKView viewDidUnhide]):
(-[WKView _activeSpaceDidChange:]):
(-[WKView hitTest:]):
(-[WKView wantsUpdateLayer]):
(-[WKView canChangeFrameLayout:]):
(-[WKView printOperationWithPrintInfo:forFrame:]):
(+[WKView hideWordDefinitionWindow]):
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::wantsUpdateLayer):
(WebKit::WebViewImpl::mouseDownCanMoveWindow):
(WebKit::WebViewImpl::wantsKeyDownForEvent):
(WebKit::WebViewImpl::layerHostingView): Deleted.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::isOpaque):
(WebKit::WebViewImpl::acceptsFirstMouse):
(WebKit::WebViewImpl::drawRect):
(WebKit::WebViewImpl::canChangeFrameLayout):
(WebKit::WebViewImpl::printOperationWithPrintInfo):
(WebKit::WebViewImpl::shouldDelayWindowOrderingForEvent):
(WebKit::WebViewImpl::windowResizeMouseLocationIsInVisibleScrollerThumb):
(WebKit::WebViewImpl::viewDidHide):
(WebKit::WebViewImpl::viewDidUnhide):
(WebKit::WebViewImpl::activeSpaceDidChange):
(WebKit::WebViewImpl::hitTest):
(WebKit::WebViewImpl::hideWordDefinitionWindow):
(WebKit::WebViewImpl::validAttributesForMarkedText):
Printing and random bits.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm

index e6b678b6cc6a6fcc11fad63c36349b6f11d4eb46..3b39ac1cb5790c1a06006dec88aa4ac76216ab79 100644 (file)
@@ -1,3 +1,48 @@
+2015-10-30  Tim Horton  <timothy_horton@apple.com>
+
+        WKView being inside WKWebView leads to weird API issues
+        https://bugs.webkit.org/show_bug.cgi?id=150174
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _wantsKeyDownForEvent:]):
+        (-[WKView acceptsFirstMouse:]):
+        (-[WKView shouldDelayWindowOrderingForEvent:]):
+        (-[WKView validAttributesForMarkedText]):
+        (-[WKView _windowResizeMouseLocationIsInVisibleScrollerThumb:]):
+        (-[WKView drawRect:]):
+        (-[WKView isOpaque]):
+        (-[WKView mouseDownCanMoveWindow]):
+        (-[WKView viewDidHide]):
+        (-[WKView viewDidUnhide]):
+        (-[WKView _activeSpaceDidChange:]):
+        (-[WKView hitTest:]):
+        (-[WKView wantsUpdateLayer]):
+        (-[WKView canChangeFrameLayout:]):
+        (-[WKView printOperationWithPrintInfo:forFrame:]):
+        (+[WKView hideWordDefinitionWindow]):
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::wantsUpdateLayer):
+        (WebKit::WebViewImpl::mouseDownCanMoveWindow):
+        (WebKit::WebViewImpl::wantsKeyDownForEvent):
+        (WebKit::WebViewImpl::layerHostingView): Deleted.
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::isOpaque):
+        (WebKit::WebViewImpl::acceptsFirstMouse):
+        (WebKit::WebViewImpl::drawRect):
+        (WebKit::WebViewImpl::canChangeFrameLayout):
+        (WebKit::WebViewImpl::printOperationWithPrintInfo):
+        (WebKit::WebViewImpl::shouldDelayWindowOrderingForEvent):
+        (WebKit::WebViewImpl::windowResizeMouseLocationIsInVisibleScrollerThumb):
+        (WebKit::WebViewImpl::viewDidHide):
+        (WebKit::WebViewImpl::viewDidUnhide):
+        (WebKit::WebViewImpl::activeSpaceDidChange):
+        (WebKit::WebViewImpl::hitTest):
+        (WebKit::WebViewImpl::hideWordDefinitionWindow):
+        (WebKit::WebViewImpl::validAttributesForMarkedText):
+        Printing and random bits.
+
 2015-10-30  Anders Carlsson  <andersca@apple.com>
 
         REGRESSION (r191691): Unexpected "Share" context menu when right clicking around inspector
index c4992bb264049ff17c198d33a29f84d96670ccd7..fb4666b70c9ecd5a694e965c184867fc2f347fe7 100644 (file)
@@ -53,7 +53,6 @@
 #import "WKAPICast.h"
 #import "WKFullScreenWindowController.h"
 #import "WKLayoutMode.h"
-#import "WKPrintingView.h"
 #import "WKProcessPoolInternal.h"
 #import "WKStringCF.h"
 #import "WKTextInputWindowController.h"
@@ -77,7 +76,6 @@
 #import <WebCore/ColorMac.h>
 #import <WebCore/CoreGraphicsSPI.h>
 #import <WebCore/DataDetectorsSPI.h>
-#import <WebCore/DictionaryLookup.h>
 #import <WebCore/DragController.h>
 #import <WebCore/DragData.h>
 #import <WebCore/FloatRect.h>
@@ -554,13 +552,9 @@ Some other editing-related methods still unimplemented:
     _data->_impl->capitalizeWord();
 }
 
-// Events
-
-// Override this so that AppKit will send us arrow keys as key down events so we can
-// support them via the key bindings mechanism.
 - (BOOL)_wantsKeyDownForEvent:(NSEvent *)event
 {
-    return YES;
+    return _data->_impl->wantsKeyDownForEvent(event);
 }
 
 #if USE(ASYNC_NSTEXTINPUTCLIENT)
@@ -704,39 +698,12 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 - (BOOL)acceptsFirstMouse:(NSEvent *)event
 {
-    // There's a chance that responding to this event will run a nested event loop, and
-    // fetching a new event might release the old one. Retaining and then autoreleasing
-    // the current event prevents that from causing a problem inside WebKit or AppKit code.
-    [[event retain] autorelease];
-    
-    if (![self hitTest:[event locationInWindow]])
-        return NO;
-    
-    _data->_impl->setLastMouseDownEvent(event);
-    bool result = _data->_page->acceptsFirstMouse([event eventNumber], WebEventFactory::createWebMouseEvent(event, _data->_impl->lastPressureEvent(), self));
-    _data->_impl->setLastMouseDownEvent(nil);
-    return result;
+    return _data->_impl->acceptsFirstMouse(event);
 }
 
 - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)event
 {
-    // If this is the active window or we don't have a range selection, there is no need to perform additional checks
-    // and we can avoid making a synchronous call to the WebProcess.
-    if ([[self window] isKeyWindow] || _data->_page->editorState().selectionIsNone || !_data->_page->editorState().selectionIsRange)
-        return NO;
-
-    // There's a chance that responding to this event will run a nested event loop, and
-    // fetching a new event might release the old one. Retaining and then autoreleasing
-    // the current event prevents that from causing a problem inside WebKit or AppKit code.
-    [[event retain] autorelease];
-    
-    if (![self hitTest:[event locationInWindow]])
-        return NO;
-    
-    _data->_impl->setLastMouseDownEvent(event);
-    bool result = _data->_page->shouldDelayWindowOrderingForEvent(WebEventFactory::createWebMouseEvent(event, _data->_impl->lastPressureEvent(), self));
-    _data->_impl->setLastMouseDownEvent(nil);
-    return result;
+    return _data->_impl->shouldDelayWindowOrderingForEvent(event);
 }
 
 - (void)doCommandBySelector:(SEL)selector
@@ -906,29 +873,14 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
     [super keyDown:event];
 }
 
+- (NSView *)_superHitTest:(NSPoint)point
+{
+    return [super hitTest:point];
+}
+
 - (NSArray *)validAttributesForMarkedText
 {
-    static NSArray *validAttributes;
-    if (!validAttributes) {
-        validAttributes = [[NSArray alloc] initWithObjects:
-                           NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
-                           NSMarkedClauseSegmentAttributeName,
-#if USE(DICTATION_ALTERNATIVES)
-                           NSTextAlternativesAttributeName,
-#endif
-#if USE(INSERTION_UNDO_GROUPING)
-                           NSTextInsertionUndoableAttributeName,
-#endif
-                           nil];
-        // NSText also supports the following attributes, but it's
-        // hard to tell which are really required for text input to
-        // work well; I have not seen any input method make use of them yet.
-        //     NSFontAttributeName, NSForegroundColorAttributeName,
-        //     NSBackgroundColorAttributeName, NSLanguageAttributeName.
-        CFRetain(validAttributes);
-    }
-    LOG(TextInput, "validAttributesForMarkedText -> (...)");
-    return validAttributes;
+    return _data->_impl->validAttributesForMarkedText();
 }
 
 #if ENABLE(DRAG_SUPPORT)
@@ -968,11 +920,9 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 }
 #endif // ENABLE(DRAG_SUPPORT)
 
-- (BOOL)_windowResizeMouseLocationIsInVisibleScrollerThumb:(NSPoint)loc
+- (BOOL)_windowResizeMouseLocationIsInVisibleScrollerThumb:(NSPoint)point
 {
-    NSPoint localPoint = [self convertPoint:loc fromView:nil];
-    NSRect visibleThumbRect = NSRect(_data->_page->visibleScrollerThumbRect());
-    return NSMouseInRect(localPoint, visibleThumbRect, [self isFlipped]);
+    return _data->_impl->windowResizeMouseLocationIsInVisibleScrollerThumb(NSPointToCGPoint(point));
 }
 
 - (void)_addFontPanelObserver
@@ -992,30 +942,27 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 - (void)drawRect:(NSRect)rect
 {
-    LOG(Printing, "drawRect: x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-    _data->_page->endPrinting();
+    _data->_impl->drawRect(NSRectToCGRect(rect));
 }
 
 - (BOOL)isOpaque
 {
-    return _data->_page->drawsBackground();
+    return _data->_impl->isOpaque();
 }
 
 - (BOOL)mouseDownCanMoveWindow
 {
-    // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent,
-    // but we don't want a drag in the NSView to move the window, even if it's transparent.
-    return NO;
+    return WebViewImpl::mouseDownCanMoveWindow();
 }
 
 - (void)viewDidHide
 {
-    _data->_page->viewStateDidChange(ViewState::IsVisible);
+    _data->_impl->viewDidHide();
 }
 
 - (void)viewDidUnhide
 {
-    _data->_page->viewStateDidChange(ViewState::IsVisible);
+    _data->_impl->viewDidUnhide();
 }
 
 - (void)viewDidChangeBackingProperties
@@ -1025,7 +972,7 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 - (void)_activeSpaceDidChange:(NSNotification *)notification
 {
-    _data->_page->viewStateDidChange(ViewState::IsVisible);
+    _data->_impl->activeSpaceDidChange();
 }
 
 - (id)accessibilityFocusedUIElement
@@ -1050,11 +997,9 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 - (NSView *)hitTest:(NSPoint)point
 {
-    NSView *hitView = [super hitTest:point];
-    if (hitView && _data && hitView == _data->_impl->layerHostingView())
-        hitView = self;
-
-    return hitView;
+    if (!_data)
+        return [super hitTest:point];
+    return _data->_impl->hitTest(NSPointToCGPoint(point));
 }
 
 - (NSInteger)conversationIdentifier
@@ -1217,7 +1162,7 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 - (BOOL)wantsUpdateLayer
 {
-    return YES;
+    return WebViewImpl::wantsUpdateLayer();
 }
 
 - (void)updateLayer
@@ -1232,23 +1177,12 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 - (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef
 {
-    // PDF documents are already paginated, so we can't change them to add headers and footers.
-    return !toImpl(frameRef)->isDisplayingPDFDocument();
+    return _data->_impl->canChangeFrameLayout(*toImpl(frameRef));
 }
 
 - (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef
 {
-    LOG(Printing, "Creating an NSPrintOperation for frame '%s'", toImpl(frameRef)->url().utf8().data());
-
-    // FIXME: If the frame cannot be printed (e.g. if it contains an encrypted PDF that disallows
-    // printing), this function should return nil.
-    RetainPtr<WKPrintingView> printingView = adoptNS([[WKPrintingView alloc] initWithFrameProxy:toImpl(frameRef) view:self]);
-    // NSPrintOperation takes ownership of the view.
-    NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printingView.get() printInfo:printInfo];
-    [printOperation setCanSpawnSeparateThread:YES];
-    [printOperation setJobTitle:toImpl(frameRef)->title()];
-    printingView->_printOperation = printOperation;
-    return printOperation;
+    return _data->_impl->printOperationWithPrintInfo(printInfo, *toImpl(frameRef));
 }
 
 - (void)setFrame:(NSRect)rect andScrollBy:(NSSize)offset
@@ -1273,7 +1207,7 @@ NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
 
 + (void)hideWordDefinitionWindow
 {
-    DictionaryLookup::hidePopup();
+    WebViewImpl::hideWordDefinitionWindow();
 }
 
 - (NSSize)minimumSizeForAutoLayout
index f45322aa9728b119f60ed16fde5fd5c841ee0fe1..7cfb1167279bb099d215a026f2b0e9ca6befe0e2 100644 (file)
@@ -61,6 +61,7 @@ OBJC_CLASS _WKThumbnailView;
 - (void)_superDoCommandBySelector:(SEL)selector;
 - (BOOL)_superPerformKeyEquivalent:(NSEvent *)event;
 - (void)_superKeyDown:(NSEvent *)event;
+- (NSView *)_superHitTest:(NSPoint)point;
 
 // This is a hack; these things live can live on a category (e.g. WKView (Private)) but WKView itself conforms to this protocol.
 // They're not actually optional.
@@ -119,7 +120,9 @@ public:
     bool drawsBackground() const;
     void setDrawsTransparentBackground(bool);
     bool drawsTransparentBackground() const;
+    bool isOpaque() const;
 
+    bool acceptsFirstMouse(NSEvent *);
     bool acceptsFirstResponder();
     bool becomeFirstResponder();
     bool resignFirstResponder();
@@ -145,6 +148,11 @@ public:
     void forceAsyncDrawingAreaSizeUpdate(CGSize);
     void waitForAsyncDrawingAreaSizeUpdate();
     void updateLayer();
+    static bool wantsUpdateLayer() { return true; }
+
+    void drawRect(CGRect);
+    bool canChangeFrameLayout(WebFrameProxy&);
+    NSPrintOperation *printOperationWithPrintInfo(NSPrintInfo *, WebFrameProxy&);
 
     void setAutomaticallyAdjustsContentInsets(bool);
     bool automaticallyAdjustsContentInsets() const { return m_automaticallyAdjustsContentInsets; }
@@ -186,10 +194,21 @@ public:
     void windowDidChangeScreen();
     void windowDidChangeLayerHosting();
     void windowDidChangeOcclusionState();
+    bool shouldDelayWindowOrderingForEvent(NSEvent *);
+    bool windowResizeMouseLocationIsInVisibleScrollerThumb(CGPoint);
+
+    // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent,
+    // but we don't want a drag in the NSView to move the window, even if it's transparent.
+    static bool mouseDownCanMoveWindow() { return false; }
 
     void viewWillMoveToWindow(NSWindow *);
     void viewDidMoveToWindow();
     void viewDidChangeBackingProperties();
+    void viewDidHide();
+    void viewDidUnhide();
+    void activeSpaceDidChange();
+
+    NSView *hitTest(CGPoint);
 
     ColorSpaceData colorSpace();
 
@@ -293,6 +312,7 @@ public:
     void dismissContentRelativeChildWindowsFromViewOnly();
     void dismissContentRelativeChildWindowsWithAnimation(bool);
     void dismissContentRelativeChildWindowsWithAnimationFromViewOnly(bool);
+    static void hideWordDefinitionWindow();
 
     void quickLookWithEvent(NSEvent *);
     void prepareForDictionaryLookup();
@@ -334,7 +354,6 @@ public:
 
     void setAcceleratedCompositingRootLayer(CALayer *);
     CALayer *acceleratedCompositingRootLayer() const { return m_rootLayer.get(); }
-    NSView *layerHostingView() const { return m_layerHostingView.get(); }
 
 #if WK_API_ENABLED
     void setThumbnailView(_WKThumbnailView *);
@@ -408,6 +427,7 @@ public:
     CGFloat totalHeightOfBanners() const { return m_totalHeightOfBanners; }
 
     void doneWithKeyEvent(NSEvent *, bool eventWasHandled);
+    NSArray *validAttributesForMarkedText();
     void doCommandBySelector(SEL);
     void insertText(id string);
     void insertText(id string, NSRange replacementRange);
@@ -425,6 +445,10 @@ public:
     void keyDown(NSEvent *);
     void flagsChanged(NSEvent *);
 
+    // Override this so that AppKit will send us arrow keys as key down events so we can
+    // support them via the key bindings mechanism.
+    static bool wantsKeyDownForEvent(NSEvent *) { return true; }
+
 #if USE(ASYNC_NSTEXTINPUTCLIENT)
     void selectedRangeWithCompletionHandler(void(^)(NSRange));
     void hasMarkedTextWithCompletionHandler(void(^)(BOOL hasMarkedText));
index 6a5449f8b9ee30dd8ed53e42b4f84376186a2947..81cf15e81538889e3dcab6df5a6d1b8befc41c9c 100644 (file)
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKFullScreenWindowController.h"
 #import "WKImmediateActionController.h"
+#import "WKPrintingView.h"
 #import "WKTextInputWindowController.h"
 #import "WKViewLayoutStrategy.h"
 #import "WKWebView.h"
 #import "WebEditCommandProxy.h"
+#import "WebEventFactory.h"
 #import "WebInspectorProxy.h"
 #import "WebPageProxy.h"
 #import "WebProcessPool.h"
@@ -513,6 +515,27 @@ bool WebViewImpl::drawsTransparentBackground() const
     return m_page.drawsTransparentBackground();
 }
 
+bool WebViewImpl::isOpaque() const
+{
+    return m_page.drawsBackground();
+}
+
+bool WebViewImpl::acceptsFirstMouse(NSEvent *event)
+{
+    // There's a chance that responding to this event will run a nested event loop, and
+    // fetching a new event might release the old one. Retaining and then autoreleasing
+    // the current event prevents that from causing a problem inside WebKit or AppKit code.
+    [[event retain] autorelease];
+
+    if (![m_view hitTest:event.locationInWindow])
+        return false;
+
+    setLastMouseDownEvent(event);
+    bool result = m_page.acceptsFirstMouse(event.eventNumber, WebEventFactory::createWebMouseEvent(event, m_lastPressureEvent.get(), m_view));
+    setLastMouseDownEvent(nil);
+    return result;
+}
+
 bool WebViewImpl::acceptsFirstResponder()
 {
     return true;
@@ -773,6 +796,33 @@ void WebViewImpl::updateLayer()
         drawingArea->waitForPossibleGeometryUpdate();
 }
 
+void WebViewImpl::drawRect(CGRect rect)
+{
+    LOG(Printing, "drawRect: x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+    m_page.endPrinting();
+}
+
+bool WebViewImpl::canChangeFrameLayout(WebFrameProxy& frame)
+{
+    // PDF documents are already paginated, so we can't change them to add headers and footers.
+    return !frame.isDisplayingPDFDocument();
+}
+
+NSPrintOperation *WebViewImpl::printOperationWithPrintInfo(NSPrintInfo *printInfo, WebFrameProxy& frame)
+{
+    LOG(Printing, "Creating an NSPrintOperation for frame '%s'", frame.url().utf8().data());
+
+    // FIXME: If the frame cannot be printed (e.g. if it contains an encrypted PDF that disallows
+    // printing), this function should return nil.
+    RetainPtr<WKPrintingView> printingView = adoptNS([[WKPrintingView alloc] initWithFrameProxy:&frame view:m_view]);
+    // NSPrintOperation takes ownership of the view.
+    NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printingView.get() printInfo:printInfo];
+    [printOperation setCanSpawnSeparateThread:YES];
+    [printOperation setJobTitle:frame.title()];
+    printingView->_printOperation = printOperation;
+    return printOperation;
+}
+
 void WebViewImpl::setAutomaticallyAdjustsContentInsets(bool automaticallyAdjustsContentInsets)
 {
     m_automaticallyAdjustsContentInsets = automaticallyAdjustsContentInsets;
@@ -1050,6 +1100,34 @@ void WebViewImpl::windowDidChangeOcclusionState()
     m_page.viewStateDidChange(WebCore::ViewState::IsVisible);
 }
 
+bool WebViewImpl::shouldDelayWindowOrderingForEvent(NSEvent *event)
+{
+    // If this is the active window or we don't have a range selection, there is no need to perform additional checks
+    // and we can avoid making a synchronous call to the WebProcess.
+    if (m_view.window.isKeyWindow || m_page.editorState().selectionIsNone || !m_page.editorState().selectionIsRange)
+        return false;
+
+    // There's a chance that responding to this event will run a nested event loop, and
+    // fetching a new event might release the old one. Retaining and then autoreleasing
+    // the current event prevents that from causing a problem inside WebKit or AppKit code.
+    [[event retain] autorelease];
+
+    if (![m_view hitTest:event.locationInWindow])
+        return false;
+
+    setLastMouseDownEvent(event);
+    bool result = m_page.shouldDelayWindowOrderingForEvent(WebEventFactory::createWebMouseEvent(event, m_lastPressureEvent.get(), m_view));
+    setLastMouseDownEvent(nil);
+    return result;
+}
+
+bool WebViewImpl::windowResizeMouseLocationIsInVisibleScrollerThumb(CGPoint point)
+{
+    NSPoint localPoint = [m_view convertPoint:NSPointFromCGPoint(point) fromView:nil];
+    NSRect visibleThumbRect = NSRect(m_page.visibleScrollerThumbRect());
+    return NSMouseInRect(localPoint, visibleThumbRect, m_view.isFlipped);
+}
+
 void WebViewImpl::viewWillMoveToWindow(NSWindow *window)
 {
     // If we're in the middle of preparing to move to a window, we should only be moved to that window.
@@ -1133,6 +1211,30 @@ void WebViewImpl::viewDidChangeBackingProperties()
         drawingArea->colorSpaceDidChange();
 }
 
+void WebViewImpl::viewDidHide()
+{
+    m_page.viewStateDidChange(WebCore::ViewState::IsVisible);
+}
+
+void WebViewImpl::viewDidUnhide()
+{
+    m_page.viewStateDidChange(WebCore::ViewState::IsVisible);
+}
+
+void WebViewImpl::activeSpaceDidChange()
+{
+    m_page.viewStateDidChange(WebCore::ViewState::IsVisible);
+}
+
+NSView *WebViewImpl::hitTest(CGPoint point)
+{
+    NSView *hitView = [m_view _superHitTest:NSPointFromCGPoint(point)];
+    if (hitView && hitView == m_layerHostingView)
+        hitView = m_view;
+
+    return hitView;
+}
+
 void WebViewImpl::postFakeMouseMovedEventForFlagsChangedEvent(NSEvent *flagsChangedEvent)
 {
     NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved location:flagsChangedEvent.window.mouseLocationOutsideOfEventStream
@@ -2072,6 +2174,11 @@ void WebViewImpl::dismissContentRelativeChildWindowsFromViewOnly()
     m_pageClient.dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeTextIgnored);
 }
 
+void WebViewImpl::hideWordDefinitionWindow()
+{
+    WebCore::DictionaryLookup::hidePopup();
+}
+
 void WebViewImpl::quickLookWithEvent(NSEvent *event)
 {
     if (ignoresNonWheelEvents())
@@ -3103,6 +3210,29 @@ void WebViewImpl::doneWithKeyEvent(NSEvent *event, bool eventWasHandled)
     m_keyDownEventBeingResent = nullptr;
 }
 
+NSArray *WebViewImpl::validAttributesForMarkedText()
+{
+    static NSArray *validAttributes;
+    if (!validAttributes) {
+        validAttributes = @[ NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName, NSMarkedClauseSegmentAttributeName,
+#if USE(DICTATION_ALTERNATIVES)
+            NSTextAlternativesAttributeName,
+#endif
+#if USE(INSERTION_UNDO_GROUPING)
+            NSTextInsertionUndoableAttributeName,
+#endif
+        ];
+        // NSText also supports the following attributes, but it's
+        // hard to tell which are really required for text input to
+        // work well; I have not seen any input method make use of them yet.
+        //     NSFontAttributeName, NSForegroundColorAttributeName,
+        //     NSBackgroundColorAttributeName, NSLanguageAttributeName.
+        CFRetain(validAttributes);
+    }
+    LOG(TextInput, "validAttributesForMarkedText -> (...)");
+    return validAttributes;
+}
+
 static Vector<WebCore::CompositionUnderline> extractUnderlines(NSAttributedString *string)
 {
     Vector<WebCore::CompositionUnderline> result;