Chromium Code Reviews| Index: chrome/renderer/render_view.cc |
| =================================================================== |
| --- chrome/renderer/render_view.cc (revision 71029) |
| +++ chrome/renderer/render_view.cc (working copy) |
| @@ -41,6 +41,7 @@ |
| #include "chrome/common/page_zoom.h" |
| #include "chrome/common/pepper_plugin_registry.h" |
| #include "chrome/common/render_messages.h" |
| +#include "chrome/common/render_view_commands.h" |
| #include "chrome/common/renderer_preferences.h" |
| #include "chrome/common/thumbnail_score.h" |
| #include "chrome/common/url_constants.h" |
| @@ -1633,18 +1634,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(); |
| } |
| } |
| @@ -2414,6 +2409,10 @@ |
| word)); |
| } |
| +void RenderView::continuousSpellCheckingEnabledStateChanged() { |
| + UpdateToggleSpellCheckCommandState(); |
| +} |
| + |
| bool RenderView::runFileChooser( |
| const WebKit::WebFileChooserParams& params, |
| WebFileChooserCompletion* chooser_completion) { |
| @@ -2540,6 +2539,27 @@ |
| } |
| } |
| +void RenderView::UpdateToggleSpellCheckCommandState() { |
| + bool is_enabled = false; |
| + WebNode node; |
| + if (GetFocusedNode(node)) |
| + is_enabled = IsEditableNode(node); |
| + |
| + CommandCheckedState checked_state = COMMAND_CHECKED_STATE_UNCHECKED; |
| + if (is_enabled && webview()) { |
| + WebFrame* frame = webview()->focusedFrame(); |
| + if (frame->isContinuousSpellCheckingEnabled()) { |
|
brettw
2011/01/13 05:59:55
Use {} for single-line conditionals consistently.
sail
2011/01/13 23:38:15
Done.
|
| + checked_state = COMMAND_CHECKED_STATE_CHECKED; |
| + } |
| + } |
| + |
| + Send(new ViewHostMsg_CommandStateChanged( |
| + routing_id_, |
| + RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK, |
| + is_enabled, |
| + checked_state)); |
| +} |
| + |
| void RenderView::StartNavStateSyncTimerIfNecessary() { |
| int delay; |
| if (send_content_state_immediately_) |
| @@ -2616,6 +2636,8 @@ |
| webview()->accessibilityObject(), |
| WebKit::WebAccessibilityNotificationFocusedUIElementChanged); |
| } |
| + |
| + UpdateToggleSpellCheckCommandState(); |
| } |
| void RenderView::navigateBackForwardSoon(int offset) { |
| @@ -4588,6 +4610,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)); |