Chromium Code Reviews| Index: chrome/renderer/render_view.cc |
| =================================================================== |
| --- chrome/renderer/render_view.cc (revision 71193) |
| +++ 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" |
| @@ -1641,18 +1642,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(); |
| - } |
| + linked_ptr<WebKit::WebNode> node = GetFocusedNode(); |
| + if (node != NULL) { |
| + if (IsEditableNode(*node)) |
| + // TODO(varunjain): Change webkit API to scroll a particular node into |
| + // view and use that API here instead. |
| + webview()->scrollFocusedNodeIntoView(); |
| } |
| } |
| @@ -2422,6 +2417,10 @@ |
| word)); |
| } |
| +void RenderView::continuousSpellCheckingEnabledStateChanged() { |
| + UpdateToggleSpellCheckCommandState(); |
| +} |
| + |
| bool RenderView::runFileChooser( |
| const WebKit::WebFileChooserParams& params, |
| WebFileChooserCompletion* chooser_completion) { |
| @@ -2548,6 +2547,27 @@ |
| } |
| } |
| +void RenderView::UpdateToggleSpellCheckCommandState() { |
| + bool is_enabled = false; |
| + linked_ptr<WebKit::WebNode> node = GetFocusedNode(); |
| + if (node != NULL) |
| + is_enabled = IsEditableNode(*node); |
| + |
| + RenderViewCommandCheckedState checked_state = |
| + RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED; |
| + if (is_enabled && webview()) { |
| + WebFrame* frame = webview()->focusedFrame(); |
| + if (frame->isContinuousSpellCheckingEnabled()) |
| + checked_state = RENDER_VIEW_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_) |
| @@ -2624,6 +2644,8 @@ |
| webview()->accessibilityObject(), |
| WebKit::WebAccessibilityNotificationFocusedUIElementChanged); |
| } |
| + |
| + UpdateToggleSpellCheckCommandState(); |
| } |
| void RenderView::navigateBackForwardSoon(int offset) { |
| @@ -4596,6 +4618,20 @@ |
| return frame; |
| } |
| +linked_ptr<WebNode> RenderView::GetFocusedNode() const { |
|
brettw
2011/01/18 18:25:43
I've never seen us use linked_ptr in this context.
sail
2011/01/18 18:41:13
Hm.. but then I wouldn't be able to indicate that
brettw
2011/01/18 18:44:17
It has an IsNull function and you can make isNull
sail
2011/01/18 19:09:17
Ahh, that's awesome. I should have seen that earli
|
| + if (!webview()) |
| + return linked_ptr<WebNode>(); |
| + WebFrame* focused_frame = webview()->focusedFrame(); |
| + if (focused_frame) { |
| + WebDocument doc = focused_frame->document(); |
| + if (!doc.isNull()) { |
| + return linked_ptr<WebNode>(new WebNode(doc.focusedNode())); |
| + } |
| + } |
| + |
| + return linked_ptr<WebNode>(); |
| +} |
| + |
| 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)); |