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

Unified Diff: chrome/renderer/render_view.cc

Issue 6020017: Mac: Enable "Check Spelling While Typing" in Edit menu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« chrome/renderer/render_view.h ('K') | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
===================================================================
--- chrome/renderer/render_view.cc (revision 70404)
+++ chrome/renderer/render_view.cc (working copy)
@@ -1625,18 +1625,12 @@
}
void RenderView::OnScrollFocusedEditableNodeIntoView() {
- if (!webview())
- return;
- WebFrame* focused_frame = webview()->focusedFrame();
- if (focused_frame) {
- WebDocument doc = focused_frame->document();
- if (!doc.isNull()) {
- WebNode node = doc.focusedNode();
- if (IsEditableNode(node))
- // TODO(varunjain): Change webkit API to scroll a particular node into
- // view and use that API here instead.
- webview()->scrollFocusedNodeIntoView();
- }
+ WebNode node;
+ if (GetFocusedNode(node)) {
+ if (IsEditableNode(node))
+ // TODO(varunjain): Change webkit API to scroll a particular node into
+ // view and use that API here instead.
+ webview()->scrollFocusedNodeIntoView();
}
}
@@ -2406,6 +2400,10 @@
word));
}
+void RenderView::continuousSpellCheckingEnabledStateChanged() {
+ UpdateToggleSpellCheckCommandState();
+}
+
bool RenderView::runFileChooser(
const WebKit::WebFileChooserParams& params,
WebFileChooserCompletion* chooser_completion) {
@@ -2532,6 +2530,26 @@
}
}
+void RenderView::UpdateToggleSpellCheckCommandState() {
+ bool is_enabled = false;
+ WebNode node;
+ if (GetFocusedNode(node))
+ is_enabled = IsEditableNode(node);
+
+ int checked_state = 0;
+ if (is_enabled && webview()) {
+ WebFrame* frame = webview()->focusedFrame();
+ if (frame->isContinuousSpellCheckingEnabled()) {
+ checked_state = 1;
+ }
+ }
+
+ Send(new ViewHostMsg_CommandStateChanged(routing_id_,
+ "ToggleSpellCheck",
+ is_enabled,
+ checked_state));
+}
+
void RenderView::StartNavStateSyncTimerIfNecessary() {
int delay;
if (send_content_state_immediately_)
@@ -2608,6 +2626,8 @@
webview()->accessibilityObject(),
WebKit::WebAccessibilityNotificationFocusedUIElementChanged);
}
+
+ UpdateToggleSpellCheckCommandState();
}
void RenderView::navigateBackForwardSoon(int offset) {
@@ -4572,6 +4592,21 @@
return frame;
}
+bool RenderView::GetFocusedNode(WebNode& node) const {
+ if (!webview())
+ return false;
+ WebFrame* focused_frame = webview()->focusedFrame();
+ if (focused_frame) {
+ WebDocument doc = focused_frame->document();
+ if (!doc.isNull()) {
+ node = doc.focusedNode();
+ return true;
+ }
+ }
+
+ return false;
+}
+
void RenderView::SetSuggestions(const std::vector<std::string>& suggestions) {
// Explicitly allow empty vector to be sent to the browser.
Send(new ViewHostMsg_SetSuggestions(routing_id_, page_id_, suggestions));
« chrome/renderer/render_view.h ('K') | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698