Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp

Issue 2797073002: Move WebTextCheckClient reference from WebViewImpl to WebLocalFrameImpl (Closed)
Patch Set: Spell my name correctly Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // Spellchecker adds spelling markers to misspelled words and attaches 321 // Spellchecker adds spelling markers to misspelled words and attaches
320 // suggestions to these markers in the background. Therefore, when a 322 // suggestions to these markers in the background. Therefore, when a
321 // user right-clicks a mouse on a word, Chrome just needs to find a 323 // user right-clicks a mouse on a word, Chrome just needs to find a
322 // spelling marker on the word instead of spellchecking it. 324 // spelling marker on the word instead of spellchecking it.
323 String description; 325 String description;
324 data.misspelledWord = selectMisspellingAsync(selectedFrame, description); 326 data.misspelledWord = selectMisspellingAsync(selectedFrame, description);
325 if (description.length()) { 327 if (description.length()) {
326 Vector<String> suggestions; 328 Vector<String> suggestions;
327 description.split('\n', suggestions); 329 description.split('\n', suggestions);
328 data.dictionarySuggestions = suggestions; 330 data.dictionarySuggestions = suggestions;
329 } else if (m_webView->textCheckClient()) { 331 } else if (selectedWebFrame->textCheckClient()) {
330 int misspelledOffset, misspelledLength; 332 int misspelledOffset, misspelledLength;
331 m_webView->textCheckClient()->checkSpelling( 333 selectedWebFrame->textCheckClient()->checkSpelling(
332 data.misspelledWord, misspelledOffset, misspelledLength, 334 data.misspelledWord, misspelledOffset, misspelledLength,
333 &data.dictionarySuggestions); 335 &data.dictionarySuggestions);
334 } 336 }
335 337
336 HTMLFormElement* form = selectedFrame->selection().currentForm(); 338 HTMLFormElement* form = selectedFrame->selection().currentForm();
337 if (form && isHTMLInputElement(*r.innerNode())) { 339 if (form && isHTMLInputElement(*r.innerNode())) {
338 HTMLInputElement& selectedElement = toHTMLInputElement(*r.innerNode()); 340 HTMLInputElement& selectedElement = toHTMLInputElement(*r.innerNode());
339 WebSearchableFormData ws = WebSearchableFormData( 341 WebSearchableFormData ws = WebSearchableFormData(
340 WebFormElement(form), WebInputElement(&selectedElement)); 342 WebFormElement(form), WebInputElement(&selectedElement));
341 if (ws.url().isValid()) 343 if (ws.url().isValid())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 data.inputFieldType = WebContextMenuData::InputFieldTypePlainText; 383 data.inputFieldType = WebContextMenuData::InputFieldTypePlainText;
382 else 384 else
383 data.inputFieldType = WebContextMenuData::InputFieldTypeOther; 385 data.inputFieldType = WebContextMenuData::InputFieldTypeOther;
384 } else { 386 } else {
385 data.inputFieldType = WebContextMenuData::InputFieldTypeNone; 387 data.inputFieldType = WebContextMenuData::InputFieldTypeNone;
386 } 388 }
387 389
388 if (fromTouch && !shouldShowContextMenuFromTouch(data)) 390 if (fromTouch && !shouldShowContextMenuFromTouch(data))
389 return false; 391 return false;
390 392
391 WebLocalFrameImpl* selectedWebFrame =
392 WebLocalFrameImpl::fromFrame(selectedFrame);
393 selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); 393 selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage());
394 if (!selectedWebFrame->client()) 394 if (!selectedWebFrame->client())
395 return false; 395 return false;
396 396
397 selectedWebFrame->client()->showContextMenu(data); 397 selectedWebFrame->client()->showContextMenu(data);
398 return true; 398 return true;
399 } 399 }
400 400
401 void ContextMenuClientImpl::clearContextMenu() { 401 void ContextMenuClientImpl::clearContextMenu() {
402 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult(); 402 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 subMenuItems.swap(outputItems); 450 subMenuItems.swap(outputItems);
451 } 451 }
452 452
453 void ContextMenuClientImpl::populateCustomMenuItems( 453 void ContextMenuClientImpl::populateCustomMenuItems(
454 const ContextMenu* defaultMenu, 454 const ContextMenu* defaultMenu,
455 WebContextMenuData* data) { 455 WebContextMenuData* data) {
456 populateSubMenuItems(defaultMenu->items(), data->customItems); 456 populateSubMenuItems(defaultMenu->items(), data->customItems);
457 } 457 }
458 458
459 } // namespace blink 459 } // namespace blink
OLDNEW
« no previous file with comments | « content/shell/test_runner/web_test_runner.h ('k') | third_party/WebKit/Source/web/TextCheckerClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698