Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 Range* markerRange = selectionRange->cloneRange(); | 124 Range* markerRange = selectionRange->cloneRange(); |
| 125 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset ()); | 125 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset ()); |
| 126 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); | 126 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); |
| 127 | 127 |
| 128 if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selec tionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) | 128 if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selec tionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) |
| 129 return String(); | 129 return String(); |
| 130 | 130 |
| 131 return markerRange->text(); | 131 return markerRange->text(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) | 134 bool ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) |
| 135 { | 135 { |
| 136 // Displaying the context menu in this function is a big hack as we don't | 136 // Displaying the context menu in this function is a big hack as we don't |
| 137 // have context, i.e. whether this is being invoked via a script or in | 137 // have context, i.e. whether this is being invoked via a script or in |
| 138 // response to user input (Mouse event WM_RBUTTONDOWN, | 138 // response to user input (Mouse event WM_RBUTTONDOWN, |
| 139 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked | 139 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked |
| 140 // in response to the above input events before popping up the context menu. | 140 // in response to the above input events before popping up the context menu. |
| 141 if (!ContextMenuAllowedScope::isContextMenuAllowed()) | 141 if (!ContextMenuAllowedScope::isContextMenuAllowed()) |
| 142 return; | 142 return true; |
|
aelias_OOO_until_Jul13
2016/05/18 01:22:32
As discussed offline, it should be fine for this t
amaralp
2016/05/18 22:16:18
Done.
| |
| 143 | 143 |
| 144 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; | 144 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; |
| 145 | 145 |
| 146 r.setToShadowHostIfInUserAgentShadowRoot(); | 146 r.setToShadowHostIfInUserAgentShadowRoot(); |
| 147 | 147 |
| 148 LocalFrame* selectedFrame = r.innerNodeFrame(); | 148 LocalFrame* selectedFrame = r.innerNodeFrame(); |
| 149 | 149 |
| 150 WebContextMenuData data; | 150 WebContextMenuData data; |
| 151 data.mousePosition = selectedFrame->view()->contentsToViewport(r.roundedPoin tInInnerNodeFrame()); | 151 data.mousePosition = selectedFrame->view()->contentsToViewport(r.roundedPoin tInInnerNodeFrame()); |
| 152 | 152 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 else | 355 else |
| 356 data.inputFieldType = WebContextMenuData::InputFieldTypeOther; | 356 data.inputFieldType = WebContextMenuData::InputFieldTypeOther; |
| 357 } else { | 357 } else { |
| 358 data.inputFieldType = WebContextMenuData::InputFieldTypeNone; | 358 data.inputFieldType = WebContextMenuData::InputFieldTypeNone; |
| 359 } | 359 } |
| 360 | 360 |
| 361 WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedF rame); | 361 WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedF rame); |
| 362 selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); | 362 selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); |
| 363 if (selectedWebFrame->client()) | 363 if (selectedWebFrame->client()) |
| 364 selectedWebFrame->client()->showContextMenu(data); | 364 selectedWebFrame->client()->showContextMenu(data); |
| 365 | |
| 366 #if OS(ANDROID) | |
|
aelias_OOO_until_Jul13
2016/05/18 01:22:33
Instead of #if OS(ANDROID), let's make this logic
amaralp
2016/05/18 22:16:18
Done.
| |
| 367 if (!data.linkURL.isEmpty() | |
| 368 || data.mediaType == WebContextMenuData::MediaTypeImage | |
| 369 || data.mediaType == WebContextMenuData::MediaTypeVideo) | |
| 370 return true; | |
|
aelias_OOO_until_Jul13
2016/05/18 01:22:33
I think this should be an early-return above the s
amaralp
2016/05/18 22:16:18
I rely on the data variable being populated so I c
| |
| 371 return false; | |
| 372 #endif | |
| 373 return true; | |
| 365 } | 374 } |
| 366 | 375 |
| 367 void ContextMenuClientImpl::clearContextMenu() | 376 void ContextMenuClientImpl::clearContextMenu() |
| 368 { | 377 { |
| 369 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; | 378 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; |
| 370 LocalFrame* selectedFrame = r.innerNodeFrame(); | 379 LocalFrame* selectedFrame = r.innerNodeFrame(); |
| 371 if (!selectedFrame) | 380 if (!selectedFrame) |
| 372 return; | 381 return; |
| 373 | 382 |
| 374 WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedF rame); | 383 WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedF rame); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 outputItems[i] = subItems[i]; | 421 outputItems[i] = subItems[i]; |
| 413 subMenuItems.swap(outputItems); | 422 subMenuItems.swap(outputItems); |
| 414 } | 423 } |
| 415 | 424 |
| 416 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe nu, WebContextMenuData* data) | 425 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe nu, WebContextMenuData* data) |
| 417 { | 426 { |
| 418 populateSubMenuItems(defaultMenu->items(), data->customItems); | 427 populateSubMenuItems(defaultMenu->items(), data->customItems); |
| 419 } | 428 } |
| 420 | 429 |
| 421 } // namespace blink | 430 } // namespace blink |
| OLD | NEW |