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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "ContextMenuClientImpl.h" | 32 #include "ContextMenuClientImpl.h" |
33 | 33 |
34 #include "CSSPropertyNames.h" | 34 #include "CSSPropertyNames.h" |
35 #include "HTMLNames.h" | 35 #include "HTMLNames.h" |
36 #include "WebContextMenuData.h" | 36 #include "WebContextMenuData.h" |
37 #include "WebDataSourceImpl.h" | 37 #include "WebDataSourceImpl.h" |
38 #include "WebFormElement.h" | 38 #include "WebFormElement.h" |
39 #include "WebFrameClient.h" | 39 #include "WebFrameClient.h" |
40 #include "WebFrameImpl.h" | 40 #include "WebLocalFrameImpl.h" |
41 #include "WebMenuItemInfo.h" | 41 #include "WebMenuItemInfo.h" |
42 #include "WebPlugin.h" | 42 #include "WebPlugin.h" |
43 #include "WebPluginContainerImpl.h" | 43 #include "WebPluginContainerImpl.h" |
44 #include "WebSearchableFormData.h" | 44 #include "WebSearchableFormData.h" |
45 #include "WebSpellCheckClient.h" | 45 #include "WebSpellCheckClient.h" |
46 #include "WebViewClient.h" | 46 #include "WebViewClient.h" |
47 #include "WebViewImpl.h" | 47 #include "WebViewImpl.h" |
48 #include "bindings/v8/ExceptionStatePlaceholder.h" | 48 #include "bindings/v8/ExceptionStatePlaceholder.h" |
49 #include "core/css/CSSStyleDeclaration.h" | 49 #include "core/css/CSSStyleDeclaration.h" |
50 #include "core/dom/Document.h" | 50 #include "core/dom/Document.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Selection is empty, so change the selection to the word under the cursor. | 124 // Selection is empty, so change the selection to the word under the cursor. |
125 HitTestResult hitTestResult = selectedFrame->eventHandler(). | 125 HitTestResult hitTestResult = selectedFrame->eventHandler(). |
126 hitTestResultAtPoint(selectedFrame->page()->contextMenuController().hitT
estResult().pointInInnerNodeFrame()); | 126 hitTestResultAtPoint(selectedFrame->page()->contextMenuController().hitT
estResult().pointInInnerNodeFrame()); |
127 Node* innerNode = hitTestResult.innerNode(); | 127 Node* innerNode = hitTestResult.innerNode(); |
128 VisiblePosition pos(innerNode->renderer()->positionForPoint( | 128 VisiblePosition pos(innerNode->renderer()->positionForPoint( |
129 hitTestResult.localPoint())); | 129 hitTestResult.localPoint())); |
130 | 130 |
131 if (pos.isNull()) | 131 if (pos.isNull()) |
132 return misspelledWord; // It is empty. | 132 return misspelledWord; // It is empty. |
133 | 133 |
134 WebFrameImpl::selectWordAroundPosition(selectedFrame, pos); | 134 WebLocalFrameImpl::selectWordAroundPosition(selectedFrame, pos); |
135 misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); | 135 misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); |
136 | 136 |
137 #if OS(MACOSX) | 137 #if OS(MACOSX) |
138 // If misspelled word is still empty, then that portion should not be | 138 // If misspelled word is still empty, then that portion should not be |
139 // selected. Set the selection to that position only, and do not expand. | 139 // selected. Set the selection to that position only, and do not expand. |
140 if (misspelledWord.isEmpty()) | 140 if (misspelledWord.isEmpty()) |
141 selectedFrame->selection().setSelection(VisibleSelection(pos)); | 141 selectedFrame->selection().setSelection(VisibleSelection(pos)); |
142 #else | 142 #else |
143 // On non-Mac, right-click should not make a range selection in any case. | 143 // On non-Mac, right-click should not make a range selection in any case. |
144 selectedFrame->selection().setSelection(VisibleSelection(pos)); | 144 selectedFrame->selection().setSelection(VisibleSelection(pos)); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 if (ds) | 360 if (ds) |
361 data.securityInfo = ds->response().securityInfo(); | 361 data.securityInfo = ds->response().securityInfo(); |
362 | 362 |
363 data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document
()->referrerPolicy()); | 363 data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document
()->referrerPolicy()); |
364 | 364 |
365 // Filter out custom menu elements and add them into the data. | 365 // Filter out custom menu elements and add them into the data. |
366 populateCustomMenuItems(defaultMenu, &data); | 366 populateCustomMenuItems(defaultMenu, &data); |
367 | 367 |
368 data.node = r.innerNonSharedNode(); | 368 data.node = r.innerNonSharedNode(); |
369 | 369 |
370 WebFrameImpl* selectedWebFrame = WebFrameImpl::fromFrame(selectedFrame); | 370 WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedF
rame); |
371 if (selectedWebFrame->client()) | 371 if (selectedWebFrame->client()) |
372 selectedWebFrame->client()->showContextMenu(data); | 372 selectedWebFrame->client()->showContextMenu(data); |
373 } | 373 } |
374 | 374 |
375 void ContextMenuClientImpl::clearContextMenu() | 375 void ContextMenuClientImpl::clearContextMenu() |
376 { | 376 { |
377 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult()
; | 377 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult()
; |
378 LocalFrame* selectedFrame = r.innerNodeFrame(); | 378 LocalFrame* selectedFrame = r.innerNodeFrame(); |
379 if (!selectedFrame) | 379 if (!selectedFrame) |
380 return; | 380 return; |
381 | 381 |
382 WebFrameImpl* selectedWebFrame = WebFrameImpl::fromFrame(selectedFrame); | 382 WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedF
rame); |
383 if (selectedWebFrame->client()) | 383 if (selectedWebFrame->client()) |
384 selectedWebFrame->client()->clearContextMenu(); | 384 selectedWebFrame->client()->clearContextMenu(); |
385 } | 385 } |
386 | 386 |
387 static void populateSubMenuItems(const Vector<ContextMenuItem>& inputMenu, WebVe
ctor<WebMenuItemInfo>& subMenuItems) | 387 static void populateSubMenuItems(const Vector<ContextMenuItem>& inputMenu, WebVe
ctor<WebMenuItemInfo>& subMenuItems) |
388 { | 388 { |
389 Vector<WebMenuItemInfo> subItems; | 389 Vector<WebMenuItemInfo> subItems; |
390 for (size_t i = 0; i < inputMenu.size(); ++i) { | 390 for (size_t i = 0; i < inputMenu.size(); ++i) { |
391 const ContextMenuItem* inputItem = &inputMenu.at(i); | 391 const ContextMenuItem* inputItem = &inputMenu.at(i); |
392 if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->act
ion() > ContextMenuItemLastCustomTag) | 392 if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->act
ion() > ContextMenuItemLastCustomTag) |
(...skipping 27 matching lines...) Expand all Loading... |
420 outputItems[i] = subItems[i]; | 420 outputItems[i] = subItems[i]; |
421 subMenuItems.swap(outputItems); | 421 subMenuItems.swap(outputItems); |
422 } | 422 } |
423 | 423 |
424 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu*
defaultMenu, WebContextMenuData* data) | 424 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu*
defaultMenu, WebContextMenuData* data) |
425 { | 425 { |
426 populateSubMenuItems(defaultMenu->items(), data->customItems); | 426 populateSubMenuItems(defaultMenu->items(), data->customItems); |
427 } | 427 } |
428 | 428 |
429 } // namespace blink | 429 } // namespace blink |
OLD | NEW |