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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Don't provide suggestions for multiple words. | 120 // Don't provide suggestions for multiple words. |
121 if (!isASingleWord(misspelledWord)) | 121 if (!isASingleWord(misspelledWord)) |
122 return String(); | 122 return String(); |
123 return misspelledWord; | 123 return misspelledWord; |
124 } | 124 } |
125 | 125 |
126 // Selection is empty, so change the selection to the word under the cursor. | 126 // Selection is empty, so change the selection to the word under the cursor. |
127 HitTestResult hitTestResult = selectedFrame->eventHandler(). | 127 HitTestResult hitTestResult = selectedFrame->eventHandler(). |
128 hitTestResultAtPoint(selectedFrame->page()->contextMenuController().hitT
estResult().pointInInnerNodeFrame()); | 128 hitTestResultAtPoint(selectedFrame->page()->contextMenuController().hitT
estResult().pointInInnerNodeFrame()); |
129 Node* innerNode = hitTestResult.innerNode(); | 129 Node* innerNode = hitTestResult.innerNode(); |
130 VisiblePosition pos(innerNode->renderer()->positionForPoint( | 130 VisiblePosition pos(innerNode->layoutObject()->positionForPoint( |
131 hitTestResult.localPoint())); | 131 hitTestResult.localPoint())); |
132 | 132 |
133 if (pos.isNull()) | 133 if (pos.isNull()) |
134 return misspelledWord; // It is empty. | 134 return misspelledWord; // It is empty. |
135 | 135 |
136 WebLocalFrameImpl::selectWordAroundPosition(selectedFrame, pos); | 136 WebLocalFrameImpl::selectWordAroundPosition(selectedFrame, pos); |
137 misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); | 137 misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); |
138 | 138 |
139 #if OS(MACOSX) | 139 #if OS(MACOSX) |
140 // If misspelled word is still empty, then that portion should not be | 140 // If misspelled word is still empty, then that portion should not be |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 data.mediaFlags |= WebContextMenuData::MediaHasAudio; | 262 data.mediaFlags |= WebContextMenuData::MediaHasAudio; |
263 // Media controls can be toggled only for video player. If we toggle | 263 // Media controls can be toggled only for video player. If we toggle |
264 // controls for audio then the player disappears, and there is no way to | 264 // controls for audio then the player disappears, and there is no way to |
265 // return it back. Don't set this bit for fullscreen video, since | 265 // return it back. Don't set this bit for fullscreen video, since |
266 // toggling is ignored in that case. | 266 // toggling is ignored in that case. |
267 if (mediaElement->hasVideo() && !mediaElement->isFullscreen()) | 267 if (mediaElement->hasVideo() && !mediaElement->isFullscreen()) |
268 data.mediaFlags |= WebContextMenuData::MediaCanToggleControls; | 268 data.mediaFlags |= WebContextMenuData::MediaCanToggleControls; |
269 if (mediaElement->shouldShowControls()) | 269 if (mediaElement->shouldShowControls()) |
270 data.mediaFlags |= WebContextMenuData::MediaControls; | 270 data.mediaFlags |= WebContextMenuData::MediaControls; |
271 } else if (isHTMLObjectElement(*r.innerNonSharedNode()) || isHTMLEmbedElemen
t(*r.innerNonSharedNode())) { | 271 } else if (isHTMLObjectElement(*r.innerNonSharedNode()) || isHTMLEmbedElemen
t(*r.innerNonSharedNode())) { |
272 LayoutObject* object = r.innerNonSharedNode()->renderer(); | 272 LayoutObject* object = r.innerNonSharedNode()->layoutObject(); |
273 if (object && object->isLayoutPart()) { | 273 if (object && object->isLayoutPart()) { |
274 Widget* widget = toLayoutPart(object)->widget(); | 274 Widget* widget = toLayoutPart(object)->widget(); |
275 if (widget && widget->isPluginContainer()) { | 275 if (widget && widget->isPluginContainer()) { |
276 data.mediaType = WebContextMenuData::MediaTypePlugin; | 276 data.mediaType = WebContextMenuData::MediaTypePlugin; |
277 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget
); | 277 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget
); |
278 WebString text = plugin->plugin()->selectionAsText(); | 278 WebString text = plugin->plugin()->selectionAsText(); |
279 if (!text.isEmpty()) { | 279 if (!text.isEmpty()) { |
280 data.selectedText = text; | 280 data.selectedText = text; |
281 data.editFlags |= WebContextMenuData::CanCopy; | 281 data.editFlags |= WebContextMenuData::CanCopy; |
282 } | 282 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 outputItems[i] = subItems[i]; | 442 outputItems[i] = subItems[i]; |
443 subMenuItems.swap(outputItems); | 443 subMenuItems.swap(outputItems); |
444 } | 444 } |
445 | 445 |
446 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) | 446 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) |
447 { | 447 { |
448 populateSubMenuItems(defaultMenu->items(), data->customItems); | 448 populateSubMenuItems(defaultMenu->items(), data->customItems); |
449 } | 449 } |
450 | 450 |
451 } // namespace blink | 451 } // namespace blink |
OLD | NEW |