| Index: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
|
| diff --git a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
|
| index 3dce1b80e9cae8f2f4388c85828b84897346037a..cfbaeeb72daf7195c4599eafc98afc22b3a90e4e 100644
|
| --- a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
|
| @@ -131,43 +131,8 @@ static String selectMisspellingAsync(LocalFrame* selectedFrame, String& descript
|
| return markerRange->text();
|
| }
|
|
|
| -void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu)
|
| +void ContextMenuClientImpl::setupContextMenuData(HitTestResult& r, WebContextMenuData& data, const Event* event)
|
| {
|
| - // Displaying the context menu in this function is a big hack as we don't
|
| - // have context, i.e. whether this is being invoked via a script or in
|
| - // response to user input (Mouse event WM_RBUTTONDOWN,
|
| - // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked
|
| - // in response to the above input events before popping up the context menu.
|
| - if (!ContextMenuAllowedScope::isContextMenuAllowed())
|
| - return;
|
| -
|
| - HitTestResult r = m_webView->page()->contextMenuController().hitTestResult();
|
| -
|
| - r.setToShadowHostIfInUserAgentShadowRoot();
|
| -
|
| - LocalFrame* selectedFrame = r.innerNodeFrame();
|
| -
|
| - WebContextMenuData data;
|
| - data.mousePosition = selectedFrame->view()->contentsToViewport(r.roundedPointInInnerNodeFrame());
|
| -
|
| - // Compute edit flags.
|
| - data.editFlags = WebContextMenuData::CanDoNone;
|
| - if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo())
|
| - data.editFlags |= WebContextMenuData::CanUndo;
|
| - if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo())
|
| - data.editFlags |= WebContextMenuData::CanRedo;
|
| - if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut())
|
| - data.editFlags |= WebContextMenuData::CanCut;
|
| - if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy())
|
| - data.editFlags |= WebContextMenuData::CanCopy;
|
| - if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste())
|
| - data.editFlags |= WebContextMenuData::CanPaste;
|
| - if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete())
|
| - data.editFlags |= WebContextMenuData::CanDelete;
|
| - // We can always select all...
|
| - data.editFlags |= WebContextMenuData::CanSelectAll;
|
| - data.editFlags |= WebContextMenuData::CanTranslate;
|
| -
|
| // Links, Images, Media tags, and Image/Media-Links take preference over
|
| // all else.
|
| data.linkURL = r.absoluteLinkURL();
|
| @@ -193,6 +158,15 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu)
|
| // data received from server yet.
|
| data.hasImageContents = r.image() && !r.image()->isNull();
|
| if (data.hasImageContents && isHTMLImageElement(r.innerNodeOrImageMapImage())) {
|
| + // An imageMap get mouse location as parameters.
|
| + StringBuilder url;
|
| + IntPoint clampedPoint;
|
| + bool success = HTMLAnchorElement::getClampedPointFromEvent(clampedPoint, event);
|
| + if (success) {
|
| + HTMLAnchorElement::appendServerMapMousePosition(url, clampedPoint);
|
| + data.linkURL = KURL(data.linkURL, url.toString());
|
| + }
|
| +
|
| HTMLImageElement* imageElement = toHTMLImageElement(r.innerNodeOrImageMapImage());
|
| if (imageElement && imageElement->cachedImage())
|
| data.imageResponse = WrappedResourceResponse(imageElement->cachedImage()->response());
|
| @@ -255,6 +229,47 @@ void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu)
|
| }
|
| }
|
| }
|
| +}
|
| +
|
| +void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu, const Event* event)
|
| +{
|
| + // Displaying the context menu in this function is a big hack as we don't
|
| + // have context, i.e. whether this is being invoked via a script or in
|
| + // response to user input (Mouse event WM_RBUTTONDOWN,
|
| + // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked
|
| + // in response to the above input events before popping up the context menu.
|
| + if (!ContextMenuAllowedScope::isContextMenuAllowed())
|
| + return;
|
| +
|
| + HitTestResult r = m_webView->page()->contextMenuController().hitTestResult();
|
| +
|
| + r.setToShadowHostIfInUserAgentShadowRoot();
|
| +
|
| + LocalFrame* selectedFrame = r.innerNodeFrame();
|
| +
|
| + WebContextMenuData data;
|
| + data.mousePosition = selectedFrame->view()->contentsToViewport(r.roundedPointInInnerNodeFrame());
|
| +
|
| + // Compute edit flags.
|
| + data.editFlags = WebContextMenuData::CanDoNone;
|
| + if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo())
|
| + data.editFlags |= WebContextMenuData::CanUndo;
|
| + if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo())
|
| + data.editFlags |= WebContextMenuData::CanRedo;
|
| + if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut())
|
| + data.editFlags |= WebContextMenuData::CanCut;
|
| + if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy())
|
| + data.editFlags |= WebContextMenuData::CanCopy;
|
| + if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste())
|
| + data.editFlags |= WebContextMenuData::CanPaste;
|
| + if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete())
|
| + data.editFlags |= WebContextMenuData::CanDelete;
|
| + // We can always select all...
|
| + data.editFlags |= WebContextMenuData::CanSelectAll;
|
| + data.editFlags |= WebContextMenuData::CanTranslate;
|
| +
|
| + // setup WebContextMenuData from HitTestResult and Event
|
| + setupContextMenuData(r, data, event);
|
|
|
| // If it's not a link, an image, a media element, or an image/media link,
|
| // show a selection menu or a more generic page menu.
|
|
|