| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked | 150 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked |
| 151 // in response to the above input events before popping up the context menu. | 151 // in response to the above input events before popping up the context menu. |
| 152 if (!ContextMenuAllowedScope::isContextMenuAllowed()) | 152 if (!ContextMenuAllowedScope::isContextMenuAllowed()) |
| 153 return false; | 153 return false; |
| 154 | 154 |
| 155 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); | 155 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); |
| 156 | 156 |
| 157 r.setToShadowHostIfInRestrictedShadowRoot(); | 157 r.setToShadowHostIfInRestrictedShadowRoot(); |
| 158 | 158 |
| 159 LocalFrame* selectedFrame = r.innerNodeFrame(); | 159 LocalFrame* selectedFrame = r.innerNodeFrame(); |
| 160 WebLocalFrameImpl* selectedWebFrame = |
| 161 WebLocalFrameImpl::fromFrame(selectedFrame); |
| 160 | 162 |
| 161 WebContextMenuData data; | 163 WebContextMenuData data; |
| 162 data.mousePosition = selectedFrame->view()->contentsToViewport( | 164 data.mousePosition = selectedFrame->view()->contentsToViewport( |
| 163 r.roundedPointInInnerNodeFrame()); | 165 r.roundedPointInInnerNodeFrame()); |
| 164 | 166 |
| 165 // Compute edit flags. | 167 // Compute edit flags. |
| 166 data.editFlags = WebContextMenuData::CanDoNone; | 168 data.editFlags = WebContextMenuData::CanDoNone; |
| 167 if (selectedFrame->document()->isHTMLDocument() || | 169 if (selectedFrame->document()->isHTMLDocument() || |
| 168 selectedFrame->document()->isXHTMLDocument()) { | 170 selectedFrame->document()->isXHTMLDocument()) { |
| 169 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) | 171 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // Spellchecker adds spelling markers to misspelled words and attaches | 322 // Spellchecker adds spelling markers to misspelled words and attaches |
| 321 // suggestions to these markers in the background. Therefore, when a | 323 // suggestions to these markers in the background. Therefore, when a |
| 322 // user right-clicks a mouse on a word, Chrome just needs to find a | 324 // user right-clicks a mouse on a word, Chrome just needs to find a |
| 323 // spelling marker on the word instead of spellchecking it. | 325 // spelling marker on the word instead of spellchecking it. |
| 324 String description; | 326 String description; |
| 325 data.misspelledWord = selectMisspellingAsync(selectedFrame, description); | 327 data.misspelledWord = selectMisspellingAsync(selectedFrame, description); |
| 326 if (description.length()) { | 328 if (description.length()) { |
| 327 Vector<String> suggestions; | 329 Vector<String> suggestions; |
| 328 description.split('\n', suggestions); | 330 description.split('\n', suggestions); |
| 329 data.dictionarySuggestions = suggestions; | 331 data.dictionarySuggestions = suggestions; |
| 330 } else if (m_webView->textCheckClient()) { | 332 } else if (selectedWebFrame->textCheckClient()) { |
| 331 int misspelledOffset, misspelledLength; | 333 int misspelledOffset, misspelledLength; |
| 332 m_webView->textCheckClient()->checkSpelling( | 334 selectedWebFrame->textCheckClient()->checkSpelling( |
| 333 data.misspelledWord, misspelledOffset, misspelledLength, | 335 data.misspelledWord, misspelledOffset, misspelledLength, |
| 334 &data.dictionarySuggestions); | 336 &data.dictionarySuggestions); |
| 335 } | 337 } |
| 336 | 338 |
| 337 HTMLFormElement* form = selectedFrame->selection().currentForm(); | 339 HTMLFormElement* form = selectedFrame->selection().currentForm(); |
| 338 if (form && isHTMLInputElement(*r.innerNode())) { | 340 if (form && isHTMLInputElement(*r.innerNode())) { |
| 339 HTMLInputElement& selectedElement = toHTMLInputElement(*r.innerNode()); | 341 HTMLInputElement& selectedElement = toHTMLInputElement(*r.innerNode()); |
| 340 WebSearchableFormData ws = WebSearchableFormData( | 342 WebSearchableFormData ws = WebSearchableFormData( |
| 341 WebFormElement(form), WebInputElement(&selectedElement)); | 343 WebFormElement(form), WebInputElement(&selectedElement)); |
| 342 if (ws.url().isValid()) | 344 if (ws.url().isValid()) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 data.inputFieldType = WebContextMenuData::InputFieldTypePlainText; | 384 data.inputFieldType = WebContextMenuData::InputFieldTypePlainText; |
| 383 else | 385 else |
| 384 data.inputFieldType = WebContextMenuData::InputFieldTypeOther; | 386 data.inputFieldType = WebContextMenuData::InputFieldTypeOther; |
| 385 } else { | 387 } else { |
| 386 data.inputFieldType = WebContextMenuData::InputFieldTypeNone; | 388 data.inputFieldType = WebContextMenuData::InputFieldTypeNone; |
| 387 } | 389 } |
| 388 | 390 |
| 389 if (fromTouch && !shouldShowContextMenuFromTouch(data)) | 391 if (fromTouch && !shouldShowContextMenuFromTouch(data)) |
| 390 return false; | 392 return false; |
| 391 | 393 |
| 392 WebLocalFrameImpl* selectedWebFrame = | |
| 393 WebLocalFrameImpl::fromFrame(selectedFrame); | |
| 394 selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); | 394 selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); |
| 395 if (!selectedWebFrame->client()) | 395 if (!selectedWebFrame->client()) |
| 396 return false; | 396 return false; |
| 397 | 397 |
| 398 selectedWebFrame->client()->showContextMenu(data); | 398 selectedWebFrame->client()->showContextMenu(data); |
| 399 return true; | 399 return true; |
| 400 } | 400 } |
| 401 | 401 |
| 402 void ContextMenuClientImpl::clearContextMenu() { | 402 void ContextMenuClientImpl::clearContextMenu() { |
| 403 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); | 403 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 subMenuItems.swap(outputItems); | 451 subMenuItems.swap(outputItems); |
| 452 } | 452 } |
| 453 | 453 |
| 454 void ContextMenuClientImpl::populateCustomMenuItems( | 454 void ContextMenuClientImpl::populateCustomMenuItems( |
| 455 const ContextMenu* defaultMenu, | 455 const ContextMenu* defaultMenu, |
| 456 WebContextMenuData* data) { | 456 WebContextMenuData* data) { |
| 457 populateSubMenuItems(defaultMenu->items(), data->customItems); | 457 populateSubMenuItems(defaultMenu->items(), data->customItems); |
| 458 } | 458 } |
| 459 | 459 |
| 460 } // namespace blink | 460 } // namespace blink |
| OLD | NEW |