Chromium Code Reviews| 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 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; | 188 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult() ; |
| 189 LocalFrame* selectedFrame = r.innerNodeFrame(); | 189 LocalFrame* selectedFrame = r.innerNodeFrame(); |
| 190 | 190 |
| 191 WebContextMenuData data; | 191 WebContextMenuData data; |
| 192 IntPoint mousePoint = selectedFrame->view()->contentsToWindow(r.roundedPoint InInnerNodeFrame()); | 192 IntPoint mousePoint = selectedFrame->view()->contentsToWindow(r.roundedPoint InInnerNodeFrame()); |
| 193 mousePoint.scale(m_webView->pageScaleFactor(), m_webView->pageScaleFactor()) ; | 193 mousePoint.scale(m_webView->pageScaleFactor(), m_webView->pageScaleFactor()) ; |
| 194 data.mousePosition = mousePoint; | 194 data.mousePosition = mousePoint; |
| 195 | 195 |
| 196 // Compute edit flags. | 196 // Compute edit flags. |
| 197 data.editFlags = WebContextMenuData::CanDoNone; | 197 data.editFlags = WebContextMenuData::CanDoNone; |
| 198 if (m_webView->focusedWebCoreFrame()->editor().canUndo()) | 198 if (toLocalFrame(m_webView->focusedWebCoreFrame())->editor().canUndo()) |
|
dcheng
2014/03/17 18:17:44
Hm... what guarantees that these are always focuse
kenrb
2014/03/18 20:01:19
The downcast macro already contains an ASSERT. I t
| |
| 199 data.editFlags |= WebContextMenuData::CanUndo; | 199 data.editFlags |= WebContextMenuData::CanUndo; |
| 200 if (m_webView->focusedWebCoreFrame()->editor().canRedo()) | 200 if (toLocalFrame(m_webView->focusedWebCoreFrame())->editor().canRedo()) |
| 201 data.editFlags |= WebContextMenuData::CanRedo; | 201 data.editFlags |= WebContextMenuData::CanRedo; |
| 202 if (m_webView->focusedWebCoreFrame()->editor().canCut()) | 202 if (toLocalFrame(m_webView->focusedWebCoreFrame())->editor().canCut()) |
| 203 data.editFlags |= WebContextMenuData::CanCut; | 203 data.editFlags |= WebContextMenuData::CanCut; |
| 204 if (m_webView->focusedWebCoreFrame()->editor().canCopy()) | 204 if (toLocalFrame(m_webView->focusedWebCoreFrame())->editor().canCopy()) |
| 205 data.editFlags |= WebContextMenuData::CanCopy; | 205 data.editFlags |= WebContextMenuData::CanCopy; |
| 206 if (m_webView->focusedWebCoreFrame()->editor().canPaste()) | 206 if (toLocalFrame(m_webView->focusedWebCoreFrame())->editor().canPaste()) |
| 207 data.editFlags |= WebContextMenuData::CanPaste; | 207 data.editFlags |= WebContextMenuData::CanPaste; |
| 208 if (m_webView->focusedWebCoreFrame()->editor().canDelete()) | 208 if (toLocalFrame(m_webView->focusedWebCoreFrame())->editor().canDelete()) |
| 209 data.editFlags |= WebContextMenuData::CanDelete; | 209 data.editFlags |= WebContextMenuData::CanDelete; |
| 210 // We can always select all... | 210 // We can always select all... |
| 211 data.editFlags |= WebContextMenuData::CanSelectAll; | 211 data.editFlags |= WebContextMenuData::CanSelectAll; |
| 212 data.editFlags |= WebContextMenuData::CanTranslate; | 212 data.editFlags |= WebContextMenuData::CanTranslate; |
| 213 | 213 |
| 214 // Links, Images, Media tags, and Image/Media-Links take preference over | 214 // Links, Images, Media tags, and Image/Media-Links take preference over |
| 215 // all else. | 215 // all else. |
| 216 data.linkURL = r.absoluteLinkURL(); | 216 data.linkURL = r.absoluteLinkURL(); |
| 217 | 217 |
| 218 if (!r.absoluteImageURL().isEmpty()) { | 218 if (!r.absoluteImageURL().isEmpty()) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 if (marker.description().length()) { | 316 if (marker.description().length()) { |
| 317 Vector<String> suggestions; | 317 Vector<String> suggestions; |
| 318 marker.description().split('\n', suggestions); | 318 marker.description().split('\n', suggestions); |
| 319 data.dictionarySuggestions = suggestions; | 319 data.dictionarySuggestions = suggestions; |
| 320 } else if (m_webView->spellCheckClient()) { | 320 } else if (m_webView->spellCheckClient()) { |
| 321 int misspelledOffset, misspelledLength; | 321 int misspelledOffset, misspelledLength; |
| 322 m_webView->spellCheckClient()->spellCheck(data.misspelledWord, m isspelledOffset, misspelledLength, &data.dictionarySuggestions); | 322 m_webView->spellCheckClient()->spellCheck(data.misspelledWord, m isspelledOffset, misspelledLength, &data.dictionarySuggestions); |
| 323 } | 323 } |
| 324 } else { | 324 } else { |
| 325 data.isSpellCheckingEnabled = | 325 data.isSpellCheckingEnabled = |
| 326 m_webView->focusedWebCoreFrame()->spellChecker().isContinuousSpe llCheckingEnabled(); | 326 toLocalFrame(m_webView->focusedWebCoreFrame())->spellChecker().i sContinuousSpellCheckingEnabled(); |
| 327 // Spellchecking might be enabled for the field, but could be disabl ed on the node. | 327 // Spellchecking might be enabled for the field, but could be disabl ed on the node. |
| 328 if (m_webView->focusedWebCoreFrame()->spellChecker().isSpellChecking EnabledInFocusedNode()) { | 328 if (toLocalFrame(m_webView->focusedWebCoreFrame())->spellChecker().i sSpellCheckingEnabledInFocusedNode()) { |
| 329 data.misspelledWord = selectMisspelledWord(selectedFrame); | 329 data.misspelledWord = selectMisspelledWord(selectedFrame); |
| 330 if (m_webView->spellCheckClient()) { | 330 if (m_webView->spellCheckClient()) { |
| 331 int misspelledOffset, misspelledLength; | 331 int misspelledOffset, misspelledLength; |
| 332 m_webView->spellCheckClient()->spellCheck( | 332 m_webView->spellCheckClient()->spellCheck( |
| 333 data.misspelledWord, misspelledOffset, misspelledLength, | 333 data.misspelledWord, misspelledOffset, misspelledLength, |
| 334 &data.dictionarySuggestions); | 334 &data.dictionarySuggestions); |
| 335 if (!misspelledLength) | 335 if (!misspelledLength) |
| 336 data.misspelledWord.reset(); | 336 data.misspelledWord.reset(); |
| 337 } | 337 } |
| 338 } | 338 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 outputItems[i] = subItems[i]; | 413 outputItems[i] = subItems[i]; |
| 414 subMenuItems.swap(outputItems); | 414 subMenuItems.swap(outputItems); |
| 415 } | 415 } |
| 416 | 416 |
| 417 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) | 417 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) |
| 418 { | 418 { |
| 419 populateSubMenuItems(defaultMenu->items(), data->customItems); | 419 populateSubMenuItems(defaultMenu->items(), data->customItems); |
| 420 } | 420 } |
| 421 | 421 |
| 422 } // namespace blink | 422 } // namespace blink |
| OLD | NEW |