Diff
Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog 2014-11-19 21:56:11 UTC (rev 176336)
@@ -1,3 +1,25 @@
+2014-11-19 Dana Burkart <[email protected]>
+
+ Merge r176220. rdar://problem/18944893
+
+ 2014-11-17 Beth Dakin <[email protected]>
+
+ Whitespace action menus should focus the HitTestResult and create an insertion
+ point
+ https://bugs.webkit.org/show_bug.cgi?id=138786
+ -and corresponding-
+ rdar://problem/18944893
+
+ Reviewed by Tim Horton.
+
+ Whitespace menus should cause the HitTestResult to be focused, and they should set
+ the selection based on the HitTest location.
+
+ * WebView/WebActionMenuController.mm:
+ (-[WebActionMenuController isMenuForTextContent]):
+ (-[WebActionMenuController focusAndSelectHitTestResult]):
+ (-[WebActionMenuController willOpenMenu:withEvent:]):
+
2014-11-18 Dana Burkart <[email protected]>
Merge r176164. rdar://problem/18953982
Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-11-19 21:56:11 UTC (rev 176336)
@@ -44,6 +44,7 @@
#import <WebCore/Editor.h>
#import <WebCore/Element.h>
#import <WebCore/EventHandler.h>
+#import <WebCore/FocusController.h>
#import <WebCore/Frame.h>
#import <WebCore/FrameView.h>
#import <WebCore/HTMLConverter.h>
@@ -151,9 +152,29 @@
- (BOOL)isMenuForTextContent
{
- return _type == WebActionMenuReadOnlyText || _type == WebActionMenuEditableText || _type == WebActionMenuEditableTextWithSuggestions || _type == WebActionMenuWhitespaceInEditableArea;
+ return _type == WebActionMenuReadOnlyText || _type == WebActionMenuEditableText || _type == WebActionMenuEditableTextWithSuggestions;
}
+- (void)focusAndSelectHitTestResult
+{
+ if (!_hitTestResult.isContentEditable())
+ return;
+
+ Element* element = _hitTestResult.innerElement();
+ if (!element)
+ return;
+
+ auto renderer = element->renderer();
+ if (!renderer)
+ return;
+
+ Frame& frame = renderer->frame();
+
+ frame.page()->focusController().setFocusedElement(element, element->document().frame());
+ VisiblePosition position = renderer->positionForPoint(_hitTestResult.localPoint(), nullptr);
+ frame.selection().setSelection(position);
+}
+
- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
{
if (menu != _webView.actionMenu)
@@ -172,6 +193,11 @@
return;
}
+ if (_type == WebActionMenuWhitespaceInEditableArea) {
+ [self focusAndSelectHitTestResult];
+ return;
+ }
+
if (![self isMenuForTextContent]) {
[[_webView _selectedOrMainFrame] _clearSelection];
return;
Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog 2014-11-19 21:56:11 UTC (rev 176336)
@@ -1,3 +1,31 @@
+2014-11-19 Dana Burkart <[email protected]>
+
+ Merge r176220. rdar://problem/18944893
+
+ 2014-11-17 Beth Dakin <[email protected]>
+
+ Whitespace action menus should focus the HitTestResult and create an insertion
+ point
+ https://bugs.webkit.org/show_bug.cgi?id=138786
+ -and corresponding-
+ rdar://problem/18944893
+
+ Reviewed by Tim Horton.
+
+ Whitespace menus should cause the HitTestResult to be focused, and they should set
+ the selection based on the HitTest location.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::focusAndSelectLastActionMenuHitTestResult):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/mac/WKActionMenuController.mm:
+ (-[WKActionMenuController isMenuForTextContent]):
+ (-[WKActionMenuController willOpenMenu:withEvent:]):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::performActionMenuHitTestAtLocation):
+ (WebKit::WebPage::focusAndSelectLastActionMenuHitTestResult):
+
2014-11-18 Dana Burkart <[email protected]>
Merge r176166. rdar://problem/18953982
Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-11-19 21:56:11 UTC (rev 176336)
@@ -5212,6 +5212,11 @@
m_process->send(Messages::WebPage::SelectLastActionMenuRange(), m_pageID);
}
+void WebPageProxy::focusAndSelectLastActionMenuHitTestResult()
+{
+ m_process->send(Messages::WebPage::FocusAndSelectLastActionMenuHitTestResult(), m_pageID);
+}
+
void WebPageProxy::didPerformActionMenuHitTest(const ActionMenuHitTestResult& result, IPC::MessageDecoder& decoder)
{
RefPtr<API::Object> userData;
Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2014-11-19 21:56:11 UTC (rev 176336)
@@ -919,6 +919,7 @@
WebHitTestResult* lastMouseMoveHitTestResult() const { return m_lastMouseMoveHitTestResult.get(); }
void performActionMenuHitTestAtLocation(WebCore::FloatPoint);
void selectLastActionMenuRange();
+ void focusAndSelectLastActionMenuHitTestResult();
#endif
#if USE(UNIFIED_TEXT_CHECKING)
Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm 2014-11-19 21:56:11 UTC (rev 176336)
@@ -184,7 +184,7 @@
- (BOOL)isMenuForTextContent
{
- return _type == kWKActionMenuReadOnlyText || _type == kWKActionMenuEditableText || _type == kWKActionMenuEditableTextWithSuggestions || _type == kWKActionMenuWhitespaceInEditableArea;
+ return _type == kWKActionMenuReadOnlyText || _type == kWKActionMenuEditableText || _type == kWKActionMenuEditableTextWithSuggestions;
}
- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
@@ -204,6 +204,11 @@
return;
}
+ if (_type == kWKActionMenuWhitespaceInEditableArea) {
+ _page->focusAndSelectLastActionMenuHitTestResult();
+ return;
+ }
+
if (![self isMenuForTextContent]) {
_page->clearSelection();
return;
Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-11-19 21:56:11 UTC (rev 176336)
@@ -48,6 +48,7 @@
#include <WebCore/DragData.h>
#include <WebCore/Editor.h>
#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/HitTestResult.h>
#include <WebCore/IntRect.h>
#include <WebCore/IntSizeHash.h>
#include <WebCore/Page.h>
@@ -1042,6 +1043,7 @@
void performActionMenuHitTestAtLocation(WebCore::FloatPoint);
PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint);
void selectLastActionMenuRange();
+ void focusAndSelectLastActionMenuHitTestResult();
void dataDetectorsDidPresentUI();
void dataDetectorsDidChangeUI();
@@ -1272,6 +1274,7 @@
#if PLATFORM(MAC)
RefPtr<WebCore::Range> m_lastActionMenuRangeForSelection;
+ WebCore::HitTestResult m_lastActionMenuHitTestResult;
RefPtr<WebPageOverlay> m_lastActionMenuHitPageOverlay;
#endif
};
Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-11-19 21:56:11 UTC (rev 176336)
@@ -390,6 +390,7 @@
#if PLATFORM(MAC)
PerformActionMenuHitTestAtLocation(WebCore::FloatPoint location)
SelectLastActionMenuRange()
+ FocusAndSelectLastActionMenuHitTestResult()
DataDetectorsDidPresentUI()
DataDetectorsDidChangeUI()
DataDetectorsDidHideUI()
Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (176335 => 176336)
--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2014-11-19 21:39:33 UTC (rev 176335)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2014-11-19 21:56:11 UTC (rev 176336)
@@ -1003,6 +1003,7 @@
RefPtr<WebCore::Range> lookupRange = lookupTextAtLocation(locationInViewCooordinates);
actionMenuResult.lookupText = lookupRange ? lookupRange->text() : String();
m_lastActionMenuRangeForSelection = lookupRange;
+ m_lastActionMenuHitTestResult = hitTestResult;
if (Image* image = hitTestResult.image()) {
actionMenuResult.image = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
@@ -1076,6 +1077,24 @@
corePage()->mainFrame().selection().setSelectedRange(m_lastActionMenuRangeForSelection.get(), DOWNSTREAM, true);
}
+void WebPage::focusAndSelectLastActionMenuHitTestResult()
+{
+ if (!m_lastActionMenuHitTestResult.isContentEditable())
+ return;
+
+ Element* element = m_lastActionMenuHitTestResult.innerElement();
+ if (!element)
+ return;
+
+ auto renderer = element->renderer();
+ if (!renderer)
+ return;
+
+ m_page->focusController().setFocusedElement(element, element->document().frame());
+ VisiblePosition position = renderer->positionForPoint(m_lastActionMenuHitTestResult.localPoint(), nullptr);
+ element->document().frame()->selection().setSelection(position);
+}
+
void WebPage::dataDetectorsDidPresentUI()
{
if (m_lastActionMenuHitPageOverlay)