summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/render_view.cc53
-rw-r--r--chrome/renderer/render_view.h12
-rw-r--r--webkit/glue/editor_client_impl.cc15
-rw-r--r--webkit/glue/webview_delegate.h8
-rw-r--r--webkit/tools/test_shell/test_shell.cc8
5 files changed, 43 insertions, 53 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index b50ff26..d12fa14 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -216,8 +216,10 @@ RenderView::RenderView(RenderThreadBase* render_thread,
determine_page_text_after_loading_stops_(false),
view_type_(ViewType::INVALID),
browser_window_id_(-1),
- last_top_level_navigation_page_id_(-1),
- has_spell_checker_document_tag_(false),
+ last_top_level_navigation_page_id_(-1),
+#if defined(OS_MACOSX)
+ has_document_tag_(false),
+#endif
document_tag_(0),
webkit_preferences_(webkit_preferences) {
Singleton<RenderViewSet>()->render_view_set_.insert(this);
@@ -228,8 +230,11 @@ RenderView::~RenderView() {
if (decrement_shared_popup_at_destruction_)
shared_popup_counter_->data--;
+#if defined(OS_MACOSX)
// Tell the spellchecker that the document is closed.
- Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_));
+ if (has_document_tag_)
+ Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_));
+#endif
render_thread_->RemoveFilter(audio_message_filter_);
}
@@ -2565,22 +2570,23 @@ bool RenderView::WasOpenedByUserGesture() const {
return opened_by_user_gesture_;
}
-void RenderView::SpellCheck(const std::wstring& word, int tag,
- int* misspell_location,
- int* misspell_length) {
- Send(new ViewHostMsg_SpellCheck(routing_id_, word, tag,
- misspell_location, misspell_length));
+void RenderView::SpellCheck(const std::wstring& word,
+ int* misspell_location,
+ int* misspell_length) {
+ EnsureDocumentTag();
+ Send(new ViewHostMsg_SpellCheck(
+ routing_id_, word, document_tag_, misspell_location, misspell_length));
}
std::wstring RenderView::GetAutoCorrectWord(
- const std::wstring& misspelled_word, int tag) {
+ const std::wstring& misspelled_word) {
std::wstring autocorrect_word;
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kAutoSpellCorrect)) {
- Send(new ViewHostMsg_GetAutoCorrectWord(routing_id_, misspelled_word, tag,
- &autocorrect_word));
+ EnsureDocumentTag();
+ Send(new ViewHostMsg_GetAutoCorrectWord(
+ routing_id_, misspelled_word, document_tag_, &autocorrect_word));
}
-
return autocorrect_word;
}
@@ -2588,17 +2594,6 @@ void RenderView::ShowSpellingUI(bool show) {
Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show));
}
-int RenderView::SpellCheckerDocumentTag() {
- if (!has_spell_checker_document_tag_) {
- // Make the call to get the tag.
- int tag;
- Send(new ViewHostMsg_GetDocumentTag(routing_id_, &tag));
- document_tag_ = tag;
- has_spell_checker_document_tag_ = true;
- }
- return document_tag_;
-}
-
void RenderView::UpdateSpellingUIWithMisspelledWord(const std::wstring& word) {
Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord(
routing_id_, word));
@@ -3464,3 +3459,15 @@ bool RenderView::HandleCurrentKeyboardEvent() {
return true;
}
+
+void RenderView::EnsureDocumentTag() {
+ // TODO(darin): There's actually no reason for this to be here. We should
+ // have the browser side manage the document tag.
+#if defined(OS_MACOSX)
+ if (!has_document_tag_) {
+ // Make the call to get the tag.
+ Send(new ViewHostMsg_GetDocumentTag(routing_id_, &document_tag_));
+ has_document_tag_ = true;
+ }
+#endif
+}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 5b05c99..cac8ca8 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -251,13 +251,12 @@ class RenderView : public RenderWidget,
const WebKit::WebRect& selection);
virtual bool WasOpenedByUserGesture() const;
virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj);
- virtual void SpellCheck(const std::wstring& word, int tag,
+ virtual void SpellCheck(const std::wstring& word,
int* misspell_location,
int* misspell_length);
- virtual std::wstring GetAutoCorrectWord(const std::wstring& word, int tag);
+ virtual std::wstring GetAutoCorrectWord(const std::wstring& word);
virtual void UpdateSpellingUIWithMisspelledWord(const std::wstring& word);
virtual void ShowSpellingUI(bool show);
- virtual int SpellCheckerDocumentTag();
virtual void ScriptedPrint(WebKit::WebFrame* frame);
virtual void UserMetricsRecordAction(const std::wstring& action);
virtual void DnsPrefetch(const std::vector<std::string>& host_names);
@@ -712,6 +711,9 @@ class RenderView : public RenderWidget,
void UpdateFontRenderingFromRendererPrefs() { }
#endif
+ // Initializes the document_tag_ member if necessary.
+ void EnsureDocumentTag();
+
// Bitwise-ORed set of extra bindings that have been enabled. See
// BindingsPolicy for details.
int enabled_bindings_;
@@ -906,8 +908,10 @@ class RenderView : public RenderWidget,
// page id for the last navigation sent to the browser.
int32 last_top_level_navigation_page_id_;
+#if defined(OS_MACOSX)
// True if the current RenderView has been assigned a document tag.
- bool has_spell_checker_document_tag_;
+ bool has_document_tag_;
+#endif
// Document tag for this RenderView.
int document_tag_;
diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc
index e1187f7..1502a3c 100644
--- a/webkit/glue/editor_client_impl.cc
+++ b/webkit/glue/editor_client_impl.cc
@@ -152,14 +152,7 @@ void EditorClientImpl::toggleGrammarChecking() {
}
int EditorClientImpl::spellCheckerDocumentTag() {
-#if defined(OS_MACOSX)
- WebViewDelegate* d = web_view_->delegate();
- if (d)
- return d->SpellCheckerDocumentTag();
-#else
- // Can't use NOTIMPLEMENTED() here as it confounds the layout test output,
- // but this should eventually be implemented for ignores to work.
-#endif // OS_MACOSX
+ ASSERT_NOT_REACHED();
return 0;
}
@@ -849,8 +842,7 @@ void EditorClientImpl::checkSpellingOfString(const UChar* str, int length,
if (isContinuousSpellCheckingEnabled() && d) {
std::wstring word =
webkit_glue::StringToStdWString(WebCore::String(str, length));
- d->SpellCheck(word, spellCheckerDocumentTag(),
- &spell_location, &spell_length);
+ d->SpellCheck(word, &spell_location, &spell_length);
} else {
spell_location = 0;
spell_length = 0;
@@ -879,8 +871,7 @@ WebCore::String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(
return WebCore::String();
}
- std::wstring autocorrect_word =
- d->GetAutoCorrectWord(word, spellCheckerDocumentTag());
+ std::wstring autocorrect_word = d->GetAutoCorrectWord(word);
return webkit_glue::StdWStringToString(autocorrect_word);
}
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index f45843b..4987326 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -372,7 +372,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
// indices (inclusive) will be filled with the offsets of the boundary of the
// word within the given buffer. The out pointers must be specified. If the
// word is correctly spelled (returns true), they will be set to (0,0).
- virtual void SpellCheck(const std::wstring& word, int tag,
+ virtual void SpellCheck(const std::wstring& word,
int* misspell_location,
int* misspell_length) {
*misspell_location = *misspell_length = 0;
@@ -380,14 +380,10 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
// Computes an auto correct word for a misspelled word. If no word is found,
// empty string is computed.
- virtual std::wstring GetAutoCorrectWord(const std::wstring& misspelled_word,
- int tag) {
+ virtual std::wstring GetAutoCorrectWord(const std::wstring& misspelled_word) {
return std::wstring();
}
- // Returns the document tag for the current WebView.
- virtual int SpellCheckerDocumentTag() { return 0; }
-
// Switches the spelling panel to be displayed or not based on |show|.
virtual void ShowSpellingUI(bool show) { }
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 682b25b..6eeb4a5 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -647,14 +647,6 @@ bool GetExeDirectory(FilePath* path) {
return GetApplicationDirectory(path);
}
-bool SpellCheckWord(const wchar_t* word, int word_len,
- int* misspelling_start, int* misspelling_len) {
- // Report all words being correctly spelled.
- *misspelling_start = 0;
- *misspelling_len = 0;
- return true;
-}
-
bool IsPluginRunningInRendererProcess() {
return true;
}