summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/glue/context_menu_client_impl.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/webkit/glue/context_menu_client_impl.cc b/webkit/glue/context_menu_client_impl.cc
index ddde662..37323b0 100644
--- a/webkit/glue/context_menu_client_impl.cc
+++ b/webkit/glue/context_menu_client_impl.cc
@@ -11,6 +11,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "Document.h"
#include "DocumentLoader.h"
#include "Editor.h"
+#include "EventHandler.h"
#include "FrameLoader.h"
#include "FrameView.h"
#include "HitTestResult.h"
@@ -29,8 +30,10 @@ MSVC_POP_WARNING();
#include "base/word_iterator.h"
+namespace {
+
// Helper function to determine whether text is a single word or a sentence.
-static bool IsASingleWord(const std::wstring& text) {
+bool IsASingleWord(const std::wstring& text) {
WordIterator iter(text, WordIterator::BREAK_WORD);
int word_count = 0;
if (!iter.Init()) return false;
@@ -53,8 +56,8 @@ static bool IsASingleWord(const std::wstring& text) {
// Helper function to get misspelled word on which context menu
// is to be evolked. This function also sets the word on which context menu
// has been evoked to be the selected word, as required.
-static std::wstring GetMisspelledWord(WebCore::ContextMenu* default_menu,
- WebCore::Frame* selected_frame) {
+std::wstring GetMisspelledWord(const WebCore::ContextMenu* default_menu,
+ WebCore::Frame* selected_frame) {
std::wstring misspelled_word_string;
// First select from selectedText to check for multiple word selection.
@@ -68,11 +71,17 @@ static std::wstring GetMisspelledWord(WebCore::ContextMenu* default_menu,
return L"";
// Expand around the click to see if we clicked a word.
- WebCore::Selection selection;
- WebCore::VisiblePosition pos(default_menu->hitTestResult().innerNode()->
- renderer()->positionForPoint(default_menu->hitTestResult().
- localPoint()));
+ WebCore::Node* inner_node = default_menu->hitTestResult().innerNode();
+ if (inner_node->renderer()->isTextArea()) {
+ WebCore::HitTestResult real_result = selected_frame->eventHandler()->
+ hitTestResultAtPoint(default_menu->hitTestResult().localPoint(), true);
+ inner_node = real_result.innerNode();
+ }
+ WebCore::VisiblePosition pos(inner_node->renderer()->
+ positionForPoint(default_menu->hitTestResult().localPoint()));
+
+ WebCore::Selection selection;
if (pos.isNotNull()) {
selection = WebCore::Selection(pos);
selection.expandUsingGranularity(WebCore::WordGranularity);
@@ -92,6 +101,8 @@ static std::wstring GetMisspelledWord(WebCore::ContextMenu* default_menu,
return misspelled_word_string;
}
+} // namespace
+
ContextMenuClientImpl::~ContextMenuClientImpl() {
}
@@ -179,7 +190,7 @@ WebCore::PlatformMenuDescription
if (r.isContentEditable()) {
type = ContextNode::EDITABLE;
if (webview_->FocusedFrameNeedsSpellchecking()) {
- misspelled_word_string = GetMisspelledWord(default_menu,
+ misspelled_word_string = GetMisspelledWord(default_menu,
selected_frame);
}
} else if (r.isSelected()) {