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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 812033016: Add RenderFrameObserver::FocusedNodeChanged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 } 1901 }
1902 1902
1903 void RenderViewImpl::focusNext() { 1903 void RenderViewImpl::focusNext() {
1904 Send(new ViewHostMsg_TakeFocus(routing_id_, false)); 1904 Send(new ViewHostMsg_TakeFocus(routing_id_, false));
1905 } 1905 }
1906 1906
1907 void RenderViewImpl::focusPrevious() { 1907 void RenderViewImpl::focusPrevious() {
1908 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); 1908 Send(new ViewHostMsg_TakeFocus(routing_id_, true));
1909 } 1909 }
1910 1910
1911 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { 1911 void RenderViewImpl::focusedNodeChanged(const WebNode& previouslyFocusedNode,
1912 const WebNode& focusedNode) {
1912 has_scrolled_focused_editable_node_into_rect_ = false; 1913 has_scrolled_focused_editable_node_into_rect_ = false;
1913 1914
1914 gfx::Rect node_bounds; 1915 gfx::Rect node_bounds;
1915 if (!node.isNull() && node.isElementNode()) { 1916 if (!focusedNode.isNull() && focusedNode.isElementNode()) {
1916 WebNode web_node = const_cast<WebNode&>(node); 1917 WebNode web_node = const_cast<WebNode&>(focusedNode);
1917 node_bounds = gfx::Rect(web_node.to<WebElement>().boundsInViewportSpace()); 1918 node_bounds = gfx::Rect(web_node.to<WebElement>().boundsInViewportSpace());
1918 } 1919 }
1919 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node), 1920 Send(new ViewHostMsg_FocusedNodeChanged(
1920 node_bounds)); 1921 routing_id_, IsEditableNode(focusedNode), node_bounds));
1921 1922
1922 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); 1923 // TODO(estade): remove.
1924 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
1925 FocusedNodeChanged(focusedNode));
1923 1926
1924 // TODO(dmazzoni): this should be part of RenderFrameObserver. 1927 RenderFrameImpl* previous_frame = nullptr;
1925 GetMainRenderFrame()->FocusedNodeChanged(node); 1928 if (!previouslyFocusedNode.isNull()) {
1929 previous_frame =
1930 RenderFrameImpl::FromWebFrame(previouslyFocusedNode.document().frame());
1931 }
1932 RenderFrameImpl* new_frame = nullptr;
1933 if (!focusedNode.isNull()) {
nasko 2015/01/20 05:09:51 nit: no need for {}
Evan Stade 2015/01/20 22:31:01 Done.
1934 new_frame = RenderFrameImpl::FromWebFrame(focusedNode.document().frame());
1935 }
1936
1937 if (previous_frame && previous_frame != new_frame)
1938 previous_frame->FocusedNodeChanged(WebNode());
1939 if (new_frame)
1940 new_frame->FocusedNodeChanged(focusedNode);
1941
1942 // TODO(dmazzoni): remove once there's a separate a11y tree per frame.
1943 GetMainRenderFrame()->FocusedNodeChangedForAccessibility(focusedNode);
1926 } 1944 }
1927 1945
1928 void RenderViewImpl::didUpdateLayout() { 1946 void RenderViewImpl::didUpdateLayout() {
1929 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); 1947 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout());
1930 1948
1931 // We don't always want to set up a timer, only if we've been put in that 1949 // We don't always want to set up a timer, only if we've been put in that
1932 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 1950 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
1933 // message. 1951 // message.
1934 if (!send_preferred_size_changes_ || !webview()) 1952 if (!send_preferred_size_changes_ || !webview())
1935 return; 1953 return;
(...skipping 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 std::vector<gfx::Size> sizes; 4118 std::vector<gfx::Size> sizes;
4101 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4119 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4102 if (!url.isEmpty()) 4120 if (!url.isEmpty())
4103 urls.push_back( 4121 urls.push_back(
4104 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4122 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4105 } 4123 }
4106 SendUpdateFaviconURL(urls); 4124 SendUpdateFaviconURL(urls);
4107 } 4125 }
4108 4126
4109 } // namespace content 4127 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698