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

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: Address comments for tests + merge blink/cr changes. Created 5 years, 2 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 using blink::WebUserGestureIndicator; 244 using blink::WebUserGestureIndicator;
245 using blink::WebVector; 245 using blink::WebVector;
246 using blink::WebView; 246 using blink::WebView;
247 using base::Time; 247 using base::Time;
248 using base::TimeDelta; 248 using base::TimeDelta;
249 249
250 namespace content { 250 namespace content {
251 251
252 namespace { 252 namespace {
253 253
254 int GetRoutingIDForFrame(blink::WebFrame* child_frame) {
alexmos 2015/10/02 21:24:20 I don't think this has to be specific to child fra
lazyboy 2015/10/05 22:16:08 Done.
255 if (child_frame->isWebRemoteFrame())
256 return RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
257
258 return RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
259 }
260
254 const char kDefaultAcceptHeader[] = 261 const char kDefaultAcceptHeader[] =
255 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" 262 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/"
256 "*;q=0.8"; 263 "*;q=0.8";
257 const char kAcceptHeader[] = "Accept"; 264 const char kAcceptHeader[] = "Accept";
258 265
259 const size_t kExtraCharsBeforeAndAfterSelection = 100; 266 const size_t kExtraCharsBeforeAndAfterSelection = 100;
260 267
261 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; 268 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap;
262 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 269 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
263 LAZY_INSTANCE_INITIALIZER; 270 LAZY_INSTANCE_INITIALIZER;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 567
561 // static 568 // static
562 void RenderFrameImpl::CreateFrame( 569 void RenderFrameImpl::CreateFrame(
563 int routing_id, 570 int routing_id,
564 int proxy_routing_id, 571 int proxy_routing_id,
565 int opener_routing_id, 572 int opener_routing_id,
566 int parent_routing_id, 573 int parent_routing_id,
567 int previous_sibling_routing_id, 574 int previous_sibling_routing_id,
568 const FrameReplicationState& replicated_state, 575 const FrameReplicationState& replicated_state,
569 CompositorDependencies* compositor_deps, 576 CompositorDependencies* compositor_deps,
570 const FrameMsg_NewFrame_WidgetParams& widget_params) { 577 const FrameMsg_NewFrame_WidgetParams& widget_params,
578 const blink::WebFrameOwnerProperties& frame_owner_properties) {
571 blink::WebLocalFrame* web_frame; 579 blink::WebLocalFrame* web_frame;
572 RenderFrameImpl* render_frame; 580 RenderFrameImpl* render_frame;
573 if (proxy_routing_id == MSG_ROUTING_NONE) { 581 if (proxy_routing_id == MSG_ROUTING_NONE) {
574 RenderFrameProxy* parent_proxy = 582 RenderFrameProxy* parent_proxy =
575 RenderFrameProxy::FromRoutingID(parent_routing_id); 583 RenderFrameProxy::FromRoutingID(parent_routing_id);
576 // If the browser is sending a valid parent routing id, it should already 584 // If the browser is sending a valid parent routing id, it should already
577 // be created and registered. 585 // be created and registered.
578 CHECK(parent_proxy); 586 CHECK(parent_proxy);
579 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); 587 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame();
580 588
581 blink::WebFrame* previous_sibling_web_frame = nullptr; 589 blink::WebFrame* previous_sibling_web_frame = nullptr;
582 RenderFrameProxy* previous_sibling_proxy = 590 RenderFrameProxy* previous_sibling_proxy =
583 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); 591 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id);
584 if (previous_sibling_proxy) 592 if (previous_sibling_proxy)
585 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); 593 previous_sibling_web_frame = previous_sibling_proxy->web_frame();
586 594
587 // Create the RenderFrame and WebLocalFrame, linking the two. 595 // Create the RenderFrame and WebLocalFrame, linking the two.
588 render_frame = 596 render_frame =
589 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); 597 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
590 web_frame = parent_web_frame->createLocalChild( 598 web_frame = parent_web_frame->createLocalChild(
591 replicated_state.scope, WebString::fromUTF8(replicated_state.name), 599 replicated_state.scope, WebString::fromUTF8(replicated_state.name),
592 replicated_state.sandbox_flags, render_frame, 600 replicated_state.sandbox_flags, render_frame,
593 previous_sibling_web_frame); 601 previous_sibling_web_frame, frame_owner_properties);
594 } else { 602 } else {
595 RenderFrameProxy* proxy = 603 RenderFrameProxy* proxy =
596 RenderFrameProxy::FromRoutingID(proxy_routing_id); 604 RenderFrameProxy::FromRoutingID(proxy_routing_id);
597 CHECK(proxy); 605 CHECK(proxy);
598 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); 606 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id);
599 web_frame = 607 web_frame =
600 blink::WebLocalFrame::create(replicated_state.scope, render_frame); 608 blink::WebLocalFrame::create(replicated_state.scope, render_frame);
601 render_frame->proxy_routing_id_ = proxy_routing_id; 609 render_frame->proxy_routing_id_ = proxy_routing_id;
602 web_frame->initializeToReplaceRemoteFrame( 610 web_frame->initializeToReplaceRemoteFrame(
603 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), 611 proxy->web_frame(), WebString::fromUTF8(replicated_state.name),
604 replicated_state.sandbox_flags); 612 replicated_state.sandbox_flags, frame_owner_properties);
605 } 613 }
606 render_frame->SetWebFrame(web_frame); 614 render_frame->SetWebFrame(web_frame);
607 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); 615 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent());
608 616
609 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); 617 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr);
610 web_frame->setOpener(opener); 618 web_frame->setOpener(opener);
611 619
612 if (widget_params.routing_id != MSG_ROUTING_NONE) { 620 if (widget_params.routing_id != MSG_ROUTING_NONE) {
613 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 621 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
614 render_frame->render_widget_ = RenderWidget::CreateForFrame( 622 render_frame->render_widget_ = RenderWidget::CreateForFrame(
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) 1127 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
1120 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, 1128 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
1121 OnTextSurroundingSelectionRequest) 1129 OnTextSurroundingSelectionRequest)
1122 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, 1130 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode,
1123 OnSetAccessibilityMode) 1131 OnSetAccessibilityMode)
1124 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree, 1132 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree,
1125 OnSnapshotAccessibilityTree) 1133 OnSnapshotAccessibilityTree)
1126 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) 1134 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener)
1127 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) 1135 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation)
1128 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) 1136 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags)
1137 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties,
1138 OnSetFrameOwnerProperties)
1129 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, 1139 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings,
1130 OnTextTrackSettingsChanged) 1140 OnTextTrackSettingsChanged)
1131 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) 1141 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent)
1132 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) 1142 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation)
1133 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, 1143 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks,
1134 OnGetSavableResourceLinks) 1144 OnGetSavableResourceLinks)
1135 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, 1145 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks,
1136 OnGetSerializedHtmlWithLocalLinks) 1146 OnGetSerializedHtmlWithLocalLinks)
1137 #if defined(OS_ANDROID) 1147 #if defined(OS_ANDROID)
1138 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) 1148 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 1685
1676 void RenderFrameImpl::OnUpdateOpener(int opener_routing_id) { 1686 void RenderFrameImpl::OnUpdateOpener(int opener_routing_id) {
1677 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); 1687 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr);
1678 frame_->setOpener(opener); 1688 frame_->setOpener(opener);
1679 } 1689 }
1680 1690
1681 void RenderFrameImpl::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) { 1691 void RenderFrameImpl::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) {
1682 frame_->setFrameOwnerSandboxFlags(flags); 1692 frame_->setFrameOwnerSandboxFlags(flags);
1683 } 1693 }
1684 1694
1695 void RenderFrameImpl::OnSetFrameOwnerProperties(
1696 const blink::WebFrameOwnerProperties& frame_owner_properties) {
1697 DCHECK(frame_);
1698 frame_->setFrameOwnerProperties(frame_owner_properties);
1699 }
1700
1685 void RenderFrameImpl::OnTextTrackSettingsChanged( 1701 void RenderFrameImpl::OnTextTrackSettingsChanged(
1686 const FrameMsg_TextTrackSettings_Params& params) { 1702 const FrameMsg_TextTrackSettings_Params& params) {
1687 DCHECK(!frame_->parent()); 1703 DCHECK(!frame_->parent());
1688 if (!render_view_->webview()) 1704 if (!render_view_->webview())
1689 return; 1705 return;
1690 1706
1691 if (params.text_tracks_enabled) { 1707 if (params.text_tracks_enabled) {
1692 render_view_->webview()->settings()->setTextTrackKindUserPreference( 1708 render_view_->webview()->settings()->setTextTrackKindUserPreference(
1693 WebSettings::TextTrackKindUserPreference::Captions); 1709 WebSettings::TextTrackKindUserPreference::Captions);
1694 } else { 1710 } else {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 if (!navigation_state->request_committed()) { 2219 if (!navigation_state->request_committed()) {
2204 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 2220 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
2205 } 2221 }
2206 } 2222 }
2207 } 2223 }
2208 2224
2209 blink::WebFrame* RenderFrameImpl::createChildFrame( 2225 blink::WebFrame* RenderFrameImpl::createChildFrame(
2210 blink::WebLocalFrame* parent, 2226 blink::WebLocalFrame* parent,
2211 blink::WebTreeScopeType scope, 2227 blink::WebTreeScopeType scope,
2212 const blink::WebString& name, 2228 const blink::WebString& name,
2213 blink::WebSandboxFlags sandbox_flags) { 2229 blink::WebSandboxFlags sandbox_flags,
2230 const blink::WebFrameOwnerProperties& frameOwnerProperties) {
2214 // Synchronously notify the browser of a child frame creation to get the 2231 // Synchronously notify the browser of a child frame creation to get the
2215 // routing_id for the RenderFrame. 2232 // routing_id for the RenderFrame.
2216 int child_routing_id = MSG_ROUTING_NONE; 2233 int child_routing_id = MSG_ROUTING_NONE;
2217 Send(new FrameHostMsg_CreateChildFrame( 2234 Send(new FrameHostMsg_CreateChildFrame(
2218 routing_id_, scope, 2235 routing_id_, scope, base::UTF16ToUTF8(base::StringPiece16(name)),
2219 base::UTF16ToUTF8(base::StringPiece16(name)), sandbox_flags, 2236 sandbox_flags, frameOwnerProperties, &child_routing_id));
2220 &child_routing_id));
2221 2237
2222 // Allocation of routing id failed, so we can't create a child frame. This can 2238 // Allocation of routing id failed, so we can't create a child frame. This can
2223 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped 2239 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped
2224 // out state or synchronous IPC message above has failed. 2240 // out state or synchronous IPC message above has failed.
2225 if (child_routing_id == MSG_ROUTING_NONE) { 2241 if (child_routing_id == MSG_ROUTING_NONE) {
2226 NOTREACHED() << "Failed to allocate routing id for child frame."; 2242 NOTREACHED() << "Failed to allocate routing id for child frame.";
2227 return nullptr; 2243 return nullptr;
2228 } 2244 }
2229 2245
2230 // This method is always called by local frames, never remote frames. 2246 // This method is always called by local frames, never remote frames.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 // updates are happening too frequently. 2357 // updates are happening too frequently.
2342 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || 2358 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() ||
2343 render_view_->renderer_preferences_.report_frame_name_changes) { 2359 render_view_->renderer_preferences_.report_frame_name_changes) {
2344 Send(new FrameHostMsg_DidChangeName( 2360 Send(new FrameHostMsg_DidChangeName(
2345 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)))); 2361 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name))));
2346 } 2362 }
2347 } 2363 }
2348 2364
2349 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, 2365 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame,
2350 blink::WebSandboxFlags flags) { 2366 blink::WebSandboxFlags flags) {
2351 int frame_routing_id = MSG_ROUTING_NONE; 2367 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2352 if (child_frame->isWebRemoteFrame()) {
2353 frame_routing_id =
2354 RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
2355 } else {
2356 frame_routing_id =
2357 RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
2358 }
2359
2360 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id, 2368 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id,
2361 flags)); 2369 flags));
2362 } 2370 }
2363 2371
2372 void RenderFrameImpl::didChangeFrameOwnerProperties(
2373 blink::WebFrame* child_frame,
2374 const blink::WebFrameOwnerProperties& frame_owner_properties) {
2375 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2376 Send(new FrameHostMsg_DidChangeFrameOwnerProperties(
2377 routing_id_, frame_routing_id, frame_owner_properties));
2378 }
2379
2364 void RenderFrameImpl::didMatchCSS( 2380 void RenderFrameImpl::didMatchCSS(
2365 blink::WebLocalFrame* frame, 2381 blink::WebLocalFrame* frame,
2366 const blink::WebVector<blink::WebString>& newly_matching_selectors, 2382 const blink::WebVector<blink::WebString>& newly_matching_selectors,
2367 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 2383 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
2368 DCHECK(!frame_ || frame_ == frame); 2384 DCHECK(!frame_ || frame_ == frame);
2369 2385
2370 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2386 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2371 DidMatchCSS(newly_matching_selectors, 2387 DidMatchCSS(newly_matching_selectors,
2372 stopped_matching_selectors)); 2388 stopped_matching_selectors));
2373 } 2389 }
(...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5173 mojo::ServiceProviderPtr service_provider; 5189 mojo::ServiceProviderPtr service_provider;
5174 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5190 mojo::URLRequestPtr request(mojo::URLRequest::New());
5175 request->url = mojo::String::From(url); 5191 request->url = mojo::String::From(url);
5176 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5192 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5177 nullptr, nullptr, 5193 nullptr, nullptr,
5178 base::Bind(&OnGotContentHandlerID)); 5194 base::Bind(&OnGotContentHandlerID));
5179 return service_provider.Pass(); 5195 return service_provider.Pass();
5180 } 5196 }
5181 5197
5182 } // namespace content 5198 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698