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

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

Issue 1307013004: Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: consolidate render->browser ipcs into one Created 5 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 using blink::WebUserGestureIndicator; 239 using blink::WebUserGestureIndicator;
240 using blink::WebVector; 240 using blink::WebVector;
241 using blink::WebView; 241 using blink::WebView;
242 using base::Time; 242 using base::Time;
243 using base::TimeDelta; 243 using base::TimeDelta;
244 244
245 namespace content { 245 namespace content {
246 246
247 namespace { 247 namespace {
248 248
249 int GetRoutingIDForFrame(blink::WebFrame* child_frame) {
250 if (child_frame->isWebRemoteFrame())
251 return RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
252
253 return RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
254 }
255
249 const char kDefaultAcceptHeader[] = 256 const char kDefaultAcceptHeader[] =
250 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" 257 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/"
251 "*;q=0.8"; 258 "*;q=0.8";
252 const char kAcceptHeader[] = "Accept"; 259 const char kAcceptHeader[] = "Accept";
253 260
254 const size_t kExtraCharsBeforeAndAfterSelection = 100; 261 const size_t kExtraCharsBeforeAndAfterSelection = 100;
255 262
256 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; 263 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap;
257 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 264 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
258 LAZY_INSTANCE_INITIALIZER; 265 LAZY_INSTANCE_INITIALIZER;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 589
583 // static 590 // static
584 void RenderFrameImpl::CreateFrame( 591 void RenderFrameImpl::CreateFrame(
585 int routing_id, 592 int routing_id,
586 int proxy_routing_id, 593 int proxy_routing_id,
587 int opener_routing_id, 594 int opener_routing_id,
588 int parent_routing_id, 595 int parent_routing_id,
589 int previous_sibling_routing_id, 596 int previous_sibling_routing_id,
590 const FrameReplicationState& replicated_state, 597 const FrameReplicationState& replicated_state,
591 CompositorDependencies* compositor_deps, 598 CompositorDependencies* compositor_deps,
592 const FrameMsg_NewFrame_WidgetParams& widget_params) { 599 const FrameMsg_NewFrame_WidgetParams& widget_params,
600 const blink::WebFrameOwnerProperties& frame_owner_properties) {
593 blink::WebLocalFrame* web_frame; 601 blink::WebLocalFrame* web_frame;
594 RenderFrameImpl* render_frame; 602 RenderFrameImpl* render_frame;
595 if (proxy_routing_id == MSG_ROUTING_NONE) { 603 if (proxy_routing_id == MSG_ROUTING_NONE) {
596 RenderFrameProxy* parent_proxy = 604 RenderFrameProxy* parent_proxy =
597 RenderFrameProxy::FromRoutingID(parent_routing_id); 605 RenderFrameProxy::FromRoutingID(parent_routing_id);
598 // If the browser is sending a valid parent routing id, it should already 606 // If the browser is sending a valid parent routing id, it should already
599 // be created and registered. 607 // be created and registered.
600 CHECK(parent_proxy); 608 CHECK(parent_proxy);
601 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); 609 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame();
602 610
603 blink::WebFrame* previous_sibling_web_frame = nullptr; 611 blink::WebFrame* previous_sibling_web_frame = nullptr;
604 RenderFrameProxy* previous_sibling_proxy = 612 RenderFrameProxy* previous_sibling_proxy =
605 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); 613 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id);
606 if (previous_sibling_proxy) 614 if (previous_sibling_proxy)
607 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); 615 previous_sibling_web_frame = previous_sibling_proxy->web_frame();
608 616
609 // Create the RenderFrame and WebLocalFrame, linking the two. 617 // Create the RenderFrame and WebLocalFrame, linking the two.
610 render_frame = 618 render_frame =
611 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); 619 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
612 web_frame = parent_web_frame->createLocalChild( 620 web_frame = parent_web_frame->createLocalChild(
613 replicated_state.scope, WebString::fromUTF8(replicated_state.name), 621 replicated_state.scope, WebString::fromUTF8(replicated_state.name),
614 replicated_state.sandbox_flags, render_frame, 622 replicated_state.sandbox_flags, render_frame,
615 previous_sibling_web_frame); 623 previous_sibling_web_frame, frame_owner_properties);
616 } else { 624 } else {
617 RenderFrameProxy* proxy = 625 RenderFrameProxy* proxy =
618 RenderFrameProxy::FromRoutingID(proxy_routing_id); 626 RenderFrameProxy::FromRoutingID(proxy_routing_id);
619 CHECK(proxy); 627 CHECK(proxy);
620 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); 628 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id);
621 web_frame = 629 web_frame =
622 blink::WebLocalFrame::create(replicated_state.scope, render_frame); 630 blink::WebLocalFrame::create(replicated_state.scope, render_frame);
623 render_frame->proxy_routing_id_ = proxy_routing_id; 631 render_frame->proxy_routing_id_ = proxy_routing_id;
624 web_frame->initializeToReplaceRemoteFrame( 632 web_frame->initializeToReplaceRemoteFrame(
625 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), 633 proxy->web_frame(), WebString::fromUTF8(replicated_state.name),
626 replicated_state.sandbox_flags); 634 replicated_state.sandbox_flags, frame_owner_properties);
627 } 635 }
628 render_frame->SetWebFrame(web_frame); 636 render_frame->SetWebFrame(web_frame);
629 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); 637 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent());
630 638
631 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); 639 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr);
632 web_frame->setOpener(opener); 640 web_frame->setOpener(opener);
633 641
634 if (widget_params.routing_id != MSG_ROUTING_NONE) { 642 if (widget_params.routing_id != MSG_ROUTING_NONE) {
635 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 643 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
636 render_frame->render_widget_ = RenderWidget::CreateForFrame( 644 render_frame->render_widget_ = RenderWidget::CreateForFrame(
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) 1128 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
1121 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, 1129 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
1122 OnTextSurroundingSelectionRequest) 1130 OnTextSurroundingSelectionRequest)
1123 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, 1131 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode,
1124 OnSetAccessibilityMode) 1132 OnSetAccessibilityMode)
1125 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree, 1133 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree,
1126 OnSnapshotAccessibilityTree) 1134 OnSnapshotAccessibilityTree)
1127 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) 1135 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener)
1128 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) 1136 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation)
1129 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) 1137 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags)
1138 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties,
1139 OnSetFrameOwnerProperties)
1130 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, 1140 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings,
1131 OnTextTrackSettingsChanged) 1141 OnTextTrackSettingsChanged)
1132 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) 1142 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent)
1133 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) 1143 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation)
1134 #if defined(OS_ANDROID) 1144 #if defined(OS_ANDROID)
1135 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) 1145 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1136 #elif defined(OS_MACOSX) 1146 #elif defined(OS_MACOSX)
1137 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) 1147 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1138 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 1148 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
1139 #endif 1149 #endif
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 1681
1672 void RenderFrameImpl::OnUpdateOpener(int opener_routing_id) { 1682 void RenderFrameImpl::OnUpdateOpener(int opener_routing_id) {
1673 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); 1683 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr);
1674 frame_->setOpener(opener); 1684 frame_->setOpener(opener);
1675 } 1685 }
1676 1686
1677 void RenderFrameImpl::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) { 1687 void RenderFrameImpl::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) {
1678 frame_->setFrameOwnerSandboxFlags(flags); 1688 frame_->setFrameOwnerSandboxFlags(flags);
1679 } 1689 }
1680 1690
1691 void RenderFrameImpl::OnSetFrameOwnerProperties(
1692 const blink::WebFrameOwnerProperties& frame_owner_properties) {
1693 DCHECK(frame_);
1694 frame_->setFrameOwnerProperties(frame_owner_properties);
1695 }
1696
1681 void RenderFrameImpl::OnTextTrackSettingsChanged( 1697 void RenderFrameImpl::OnTextTrackSettingsChanged(
1682 const FrameMsg_TextTrackSettings_Params& params) { 1698 const FrameMsg_TextTrackSettings_Params& params) {
1683 DCHECK(!frame_->parent()); 1699 DCHECK(!frame_->parent());
1684 if (!render_view_->webview()) 1700 if (!render_view_->webview())
1685 return; 1701 return;
1686 1702
1687 if (params.text_tracks_enabled) { 1703 if (params.text_tracks_enabled) {
1688 render_view_->webview()->settings()->setTextTrackKindUserPreference( 1704 render_view_->webview()->settings()->setTextTrackKindUserPreference(
1689 WebSettings::TextTrackKindUserPreference::Captions); 1705 WebSettings::TextTrackKindUserPreference::Captions);
1690 } else { 1706 } else {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 if (!navigation_state->request_committed()) { 2220 if (!navigation_state->request_committed()) {
2205 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 2221 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
2206 } 2222 }
2207 } 2223 }
2208 } 2224 }
2209 2225
2210 blink::WebFrame* RenderFrameImpl::createChildFrame( 2226 blink::WebFrame* RenderFrameImpl::createChildFrame(
2211 blink::WebLocalFrame* parent, 2227 blink::WebLocalFrame* parent,
2212 blink::WebTreeScopeType scope, 2228 blink::WebTreeScopeType scope,
2213 const blink::WebString& name, 2229 const blink::WebString& name,
2214 blink::WebSandboxFlags sandbox_flags) { 2230 blink::WebSandboxFlags sandbox_flags,
2231 const blink::WebFrameOwnerProperties& frameOwnerProperties) {
2215 // Synchronously notify the browser of a child frame creation to get the 2232 // Synchronously notify the browser of a child frame creation to get the
2216 // routing_id for the RenderFrame. 2233 // routing_id for the RenderFrame.
2217 int child_routing_id = MSG_ROUTING_NONE; 2234 int child_routing_id = MSG_ROUTING_NONE;
2218 Send(new FrameHostMsg_CreateChildFrame( 2235 Send(new FrameHostMsg_CreateChildFrame(
2219 routing_id_, scope, 2236 routing_id_, scope, base::UTF16ToUTF8(base::StringPiece16(name)),
2220 base::UTF16ToUTF8(base::StringPiece16(name)), sandbox_flags, 2237 sandbox_flags, frameOwnerProperties, &child_routing_id));
2221 &child_routing_id));
2222 2238
2223 // Allocation of routing id failed, so we can't create a child frame. This can 2239 // Allocation of routing id failed, so we can't create a child frame. This can
2224 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped 2240 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped
2225 // out state or synchronous IPC message above has failed. 2241 // out state or synchronous IPC message above has failed.
2226 if (child_routing_id == MSG_ROUTING_NONE) { 2242 if (child_routing_id == MSG_ROUTING_NONE) {
2227 NOTREACHED() << "Failed to allocate routing id for child frame."; 2243 NOTREACHED() << "Failed to allocate routing id for child frame.";
2228 return nullptr; 2244 return nullptr;
2229 } 2245 }
2230 2246
2231 // Create the RenderFrame and WebLocalFrame, linking the two. 2247 // Create the RenderFrame and WebLocalFrame, linking the two.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 // updates are happening too frequently. 2350 // updates are happening too frequently.
2335 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || 2351 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() ||
2336 render_view_->renderer_preferences_.report_frame_name_changes) { 2352 render_view_->renderer_preferences_.report_frame_name_changes) {
2337 Send(new FrameHostMsg_DidChangeName( 2353 Send(new FrameHostMsg_DidChangeName(
2338 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)))); 2354 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name))));
2339 } 2355 }
2340 } 2356 }
2341 2357
2342 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, 2358 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame,
2343 blink::WebSandboxFlags flags) { 2359 blink::WebSandboxFlags flags) {
2344 int frame_routing_id = MSG_ROUTING_NONE; 2360 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2345 if (child_frame->isWebRemoteFrame()) {
2346 frame_routing_id =
2347 RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
2348 } else {
2349 frame_routing_id =
2350 RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
2351 }
2352
2353 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id, 2361 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id,
2354 flags)); 2362 flags));
2355 } 2363 }
2356 2364
2365 void RenderFrameImpl::didChangeScrollingMode(
2366 blink::WebFrame* child_frame,
2367 blink::WebFrameOwnerProperties::ScrollingMode scrolling_mode) {
2368 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2369 frame_owner_properties_.scrollingMode = scrolling_mode;
2370 DidChangeFrameOwnerProperties(frame_routing_id);
2371 }
2372
2373 void RenderFrameImpl::didChangeMarginWidth(blink::WebFrame* child_frame,
2374 int marginWidth) {
2375 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2376 frame_owner_properties_.marginWidth = marginWidth;
2377 DidChangeFrameOwnerProperties(frame_routing_id);
2378 }
2379
2380 void RenderFrameImpl::didChangeMarginHeight(blink::WebFrame* child_frame,
2381 int marginHeight) {
2382 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2383 frame_owner_properties_.marginHeight = marginHeight;
2384 DidChangeFrameOwnerProperties(frame_routing_id);
2385 }
2386
2357 void RenderFrameImpl::didMatchCSS( 2387 void RenderFrameImpl::didMatchCSS(
2358 blink::WebLocalFrame* frame, 2388 blink::WebLocalFrame* frame,
2359 const blink::WebVector<blink::WebString>& newly_matching_selectors, 2389 const blink::WebVector<blink::WebString>& newly_matching_selectors,
2360 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 2390 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
2361 DCHECK(!frame_ || frame_ == frame); 2391 DCHECK(!frame_ || frame_ == frame);
2362 2392
2363 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2393 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2364 DidMatchCSS(newly_matching_selectors, 2394 DidMatchCSS(newly_matching_selectors,
2365 stopped_matching_selectors)); 2395 stopped_matching_selectors));
2366 } 2396 }
(...skipping 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 if (!pending_navigation_params_->common_params.url.SchemeIs( 5017 if (!pending_navigation_params_->common_params.url.SchemeIs(
4988 url::kJavaScriptScheme)) { 5018 url::kJavaScriptScheme)) {
4989 return NavigationStateImpl::CreateBrowserInitiated( 5019 return NavigationStateImpl::CreateBrowserInitiated(
4990 pending_navigation_params_->common_params, 5020 pending_navigation_params_->common_params,
4991 pending_navigation_params_->start_params, 5021 pending_navigation_params_->start_params,
4992 pending_navigation_params_->request_params); 5022 pending_navigation_params_->request_params);
4993 } 5023 }
4994 return NavigationStateImpl::CreateContentInitiated(); 5024 return NavigationStateImpl::CreateContentInitiated();
4995 } 5025 }
4996 5026
5027 void RenderFrameImpl::DidChangeFrameOwnerProperties(int frame_routing_id) {
5028 Send(new FrameHostMsg_DidChangeFrameOwnerProperties(
5029 routing_id_, frame_routing_id, frame_owner_properties_));
5030 }
5031
4997 #if defined(OS_ANDROID) 5032 #if defined(OS_ANDROID)
4998 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( 5033 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer(
4999 WebMediaPlayerClient* client, 5034 WebMediaPlayerClient* client,
5000 WebMediaPlayerEncryptedMediaClient* encrypted_client, 5035 WebMediaPlayerEncryptedMediaClient* encrypted_client,
5001 const media::WebMediaPlayerParams& params) { 5036 const media::WebMediaPlayerParams& params) {
5002 scoped_refptr<StreamTextureFactory> stream_texture_factory; 5037 scoped_refptr<StreamTextureFactory> stream_texture_factory;
5003 if (SynchronousCompositorFactory* factory = 5038 if (SynchronousCompositorFactory* factory =
5004 SynchronousCompositorFactory::GetInstance()) { 5039 SynchronousCompositorFactory::GetInstance()) {
5005 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_); 5040 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_);
5006 } else { 5041 } else {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
5116 mojo::ServiceProviderPtr service_provider; 5151 mojo::ServiceProviderPtr service_provider;
5117 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5152 mojo::URLRequestPtr request(mojo::URLRequest::New());
5118 request->url = mojo::String::From(url); 5153 request->url = mojo::String::From(url);
5119 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5154 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5120 nullptr, nullptr, 5155 nullptr, nullptr,
5121 base::Bind(&OnGotContentHandlerID)); 5156 base::Bind(&OnGotContentHandlerID));
5122 return service_provider.Pass(); 5157 return service_provider.Pass();
5123 } 5158 }
5124 5159
5125 } // namespace content 5160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698