Diff
Modified: trunk/Source/WebKit2/ChangeLog (191801 => 191802)
--- trunk/Source/WebKit2/ChangeLog 2015-10-30 18:42:39 UTC (rev 191801)
+++ trunk/Source/WebKit2/ChangeLog 2015-10-30 18:52:08 UTC (rev 191802)
@@ -1,3 +1,48 @@
+2015-10-30 Tim Horton <[email protected]>
+
+ 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 <[email protected]>
REGRESSION (r191691): Unexpected "Share" context menu when right clicking around inspector
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (191801 => 191802)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-10-30 18:42:39 UTC (rev 191801)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-10-30 18:52:08 UTC (rev 191802)
@@ -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 @@
_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 @@
- (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 @@
[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 @@
}
#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 @@
- (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 @@
- (void)_activeSpaceDidChange:(NSNotification *)notification
{
- _data->_page->viewStateDidChange(ViewState::IsVisible);
+ _data->_impl->activeSpaceDidChange();
}
- (id)accessibilityFocusedUIElement
@@ -1050,11 +997,9 @@
- (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 @@
- (BOOL)wantsUpdateLayer
{
- return YES;
+ return WebViewImpl::wantsUpdateLayer();
}
- (void)updateLayer
@@ -1232,23 +1177,12 @@
- (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 @@
+ (void)hideWordDefinitionWindow
{
- DictionaryLookup::hidePopup();
+ WebViewImpl::hideWordDefinitionWindow();
}
- (NSSize)minimumSizeForAutoLayout
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (191801 => 191802)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2015-10-30 18:42:39 UTC (rev 191801)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2015-10-30 18:52:08 UTC (rev 191802)
@@ -61,6 +61,7 @@
- (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 @@
bool drawsBackground() const;
void setDrawsTransparentBackground(bool);
bool drawsTransparentBackground() const;
+ bool isOpaque() const;
+ bool acceptsFirstMouse(NSEvent *);
bool acceptsFirstResponder();
bool becomeFirstResponder();
bool resignFirstResponder();
@@ -145,7 +148,12 @@
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; }
void updateContentInsetsIfAutomatic();
@@ -186,11 +194,22 @@
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();
void setUnderlayColor(NSColor *);
@@ -293,6 +312,7 @@
void dismissContentRelativeChildWindowsFromViewOnly();
void dismissContentRelativeChildWindowsWithAnimation(bool);
void dismissContentRelativeChildWindowsWithAnimationFromViewOnly(bool);
+ static void hideWordDefinitionWindow();
void quickLookWithEvent(NSEvent *);
void prepareForDictionaryLookup();
@@ -334,7 +354,6 @@
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 @@
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 @@
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));
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (191801 => 191802)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2015-10-30 18:42:39 UTC (rev 191801)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2015-10-30 18:52:08 UTC (rev 191802)
@@ -49,10 +49,12 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
m_pageClient.dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeTextIgnored);
}
+void WebViewImpl::hideWordDefinitionWindow()
+{
+ WebCore::DictionaryLookup::hidePopup();
+}
+
void WebViewImpl::quickLookWithEvent(NSEvent *event)
{
if (ignoresNonWheelEvents())
@@ -3103,6 +3210,29 @@
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;