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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (!m_webView->contextMenuAllowed()) | 188 if (!m_webView->contextMenuAllowed()) |
189 return; | 189 return; |
190 | 190 |
191 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult()
; | 191 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult()
; |
192 | 192 |
193 r.setToShadowHostIfInClosedShadowRoot(); | 193 r.setToShadowHostIfInClosedShadowRoot(); |
194 | 194 |
195 LocalFrame* selectedFrame = r.innerNodeFrame(); | 195 LocalFrame* selectedFrame = r.innerNodeFrame(); |
196 | 196 |
197 WebContextMenuData data; | 197 WebContextMenuData data; |
198 IntPoint mousePoint = selectedFrame->view()->contentsToWindow(r.roundedPoint
InInnerNodeFrame()); | 198 data.mousePosition = selectedFrame->view()->contentsToViewport(r.roundedPoin
tInInnerNodeFrame()); |
199 | |
200 // FIXME(bokan): crbug.com/371902 - We shouldn't be making these scale | |
201 // related coordinate transformatios in an ad hoc way. | |
202 PinchViewport& pinchViewport = selectedFrame->host()->pinchViewport(); | |
203 mousePoint -= flooredIntSize(pinchViewport.visibleRect().location()); | |
204 mousePoint.scale(m_webView->pageScaleFactor(), m_webView->pageScaleFactor())
; | |
205 data.mousePosition = mousePoint; | |
206 | 199 |
207 // Compute edit flags. | 200 // Compute edit flags. |
208 data.editFlags = WebContextMenuData::CanDoNone; | 201 data.editFlags = WebContextMenuData::CanDoNone; |
209 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) | 202 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) |
210 data.editFlags |= WebContextMenuData::CanUndo; | 203 data.editFlags |= WebContextMenuData::CanUndo; |
211 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo()) | 204 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo()) |
212 data.editFlags |= WebContextMenuData::CanRedo; | 205 data.editFlags |= WebContextMenuData::CanRedo; |
213 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut()) | 206 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut()) |
214 data.editFlags |= WebContextMenuData::CanCut; | 207 data.editFlags |= WebContextMenuData::CanCut; |
215 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy()) | 208 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy()) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 outputItems[i] = subItems[i]; | 435 outputItems[i] = subItems[i]; |
443 subMenuItems.swap(outputItems); | 436 subMenuItems.swap(outputItems); |
444 } | 437 } |
445 | 438 |
446 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) | 439 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) |
447 { | 440 { |
448 populateSubMenuItems(defaultMenu->items(), data->customItems); | 441 populateSubMenuItems(defaultMenu->items(), data->customItems); |
449 } | 442 } |
450 | 443 |
451 } // namespace blink | 444 } // namespace blink |
OLD | NEW |