| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 | 8 |
| 9 MSVC_PUSH_WARNING_LEVEL(0); | 9 MSVC_PUSH_WARNING_LEVEL(0); |
| 10 #include "ContextMenu.h" | 10 #include "ContextMenu.h" |
| 11 #include "Document.h" | 11 #include "Document.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // Check for 0 words. | 50 // Check for 0 words. |
| 51 if (!word_count) | 51 if (!word_count) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 // Has a single word. | 54 // Has a single word. |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Helper function to get misspelled word on which context menu | 58 // Helper function to get misspelled word on which context menu |
| 59 // is to be evolked. This function also sets the word on which context menu | 59 // is to be evolked. This function also sets the word on which context menu |
| 60 // has been evoked to be the selected word, as required. | 60 // has been evoked to be the selected word, as required. This function changes |
| 61 // the selection only when there were no selected characters. |
| 61 std::wstring GetMisspelledWord(const WebCore::ContextMenu* default_menu, | 62 std::wstring GetMisspelledWord(const WebCore::ContextMenu* default_menu, |
| 62 WebCore::Frame* selected_frame) { | 63 WebCore::Frame* selected_frame) { |
| 63 std::wstring misspelled_word_string; | 64 std::wstring misspelled_word_string; |
| 64 | 65 |
| 65 // First select from selectedText to check for multiple word selection. | 66 // First select from selectedText to check for multiple word selection. |
| 66 misspelled_word_string = CollapseWhitespace( | 67 misspelled_word_string = CollapseWhitespace( |
| 67 webkit_glue::StringToStdWString(selected_frame->selectedText()), | 68 webkit_glue::StringToStdWString(selected_frame->selectedText()), |
| 68 false); | 69 false); |
| 69 | 70 |
| 70 // Don't provide suggestions for multiple words. | 71 // If some texts were already selected, we don't change the selection. |
| 71 if (!misspelled_word_string.empty() && | 72 if (!misspelled_word_string.empty()) { |
| 72 !IsASingleWord(misspelled_word_string)) | 73 // Don't provide suggestions for multiple words. |
| 73 return L""; | 74 if (!IsASingleWord(misspelled_word_string)) |
| 75 return L""; |
| 76 else |
| 77 return misspelled_word_string; |
| 78 } |
| 74 | 79 |
| 75 WebCore::HitTestResult hit_test_result = selected_frame->eventHandler()-> | 80 WebCore::HitTestResult hit_test_result = selected_frame->eventHandler()-> |
| 76 hitTestResultAtPoint(default_menu->hitTestResult().point(), true); | 81 hitTestResultAtPoint(default_menu->hitTestResult().point(), true); |
| 77 WebCore::Node* inner_node = hit_test_result.innerNode(); | 82 WebCore::Node* inner_node = hit_test_result.innerNode(); |
| 78 WebCore::VisiblePosition pos(inner_node->renderer()->positionForPoint( | 83 WebCore::VisiblePosition pos(inner_node->renderer()->positionForPoint( |
| 79 hit_test_result.localPoint())); | 84 hit_test_result.localPoint())); |
| 80 | 85 |
| 81 WebCore::VisibleSelection selection; | 86 WebCore::VisibleSelection selection; |
| 82 if (pos.isNotNull()) { | 87 if (pos.isNotNull()) { |
| 83 selection = WebCore::VisibleSelection(pos); | 88 selection = WebCore::VisibleSelection(pos); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 282 |
| 278 bool ContextMenuClientImpl::shouldIncludeInspectElementItem() { | 283 bool ContextMenuClientImpl::shouldIncludeInspectElementItem() { |
| 279 return false; // TODO(jackson): Eventually include the inspector context me
nu item | 284 return false; // TODO(jackson): Eventually include the inspector context me
nu item |
| 280 } | 285 } |
| 281 | 286 |
| 282 #if defined(OS_MACOSX) | 287 #if defined(OS_MACOSX) |
| 283 void ContextMenuClientImpl::searchWithSpotlight() { | 288 void ContextMenuClientImpl::searchWithSpotlight() { |
| 284 // TODO(pinkerton): write this | 289 // TODO(pinkerton): write this |
| 285 } | 290 } |
| 286 #endif | 291 #endif |
| OLD | NEW |