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

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: remove dep patch 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 using blink::WebUserGestureIndicator; 238 using blink::WebUserGestureIndicator;
239 using blink::WebVector; 239 using blink::WebVector;
240 using blink::WebView; 240 using blink::WebView;
241 using base::Time; 241 using base::Time;
242 using base::TimeDelta; 242 using base::TimeDelta;
243 243
244 namespace content { 244 namespace content {
245 245
246 namespace { 246 namespace {
247 247
248 int GetRoutingIDForFrame(blink::WebFrame* child_frame) {
249 if (child_frame->isWebRemoteFrame())
250 return RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
251
252 return RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
253 }
254
248 const char kDefaultAcceptHeader[] = 255 const char kDefaultAcceptHeader[] =
249 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" 256 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/"
250 "*;q=0.8"; 257 "*;q=0.8";
251 const char kAcceptHeader[] = "Accept"; 258 const char kAcceptHeader[] = "Accept";
252 259
253 const size_t kExtraCharsBeforeAndAfterSelection = 100; 260 const size_t kExtraCharsBeforeAndAfterSelection = 100;
254 261
255 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; 262 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap;
256 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 263 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
257 LAZY_INSTANCE_INITIALIZER; 264 LAZY_INSTANCE_INITIALIZER;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 585 }
579 586
580 // static 587 // static
581 void RenderFrameImpl::CreateFrame( 588 void RenderFrameImpl::CreateFrame(
582 int routing_id, 589 int routing_id,
583 int parent_routing_id, 590 int parent_routing_id,
584 int previous_sibling_routing_id, 591 int previous_sibling_routing_id,
585 int proxy_routing_id, 592 int proxy_routing_id,
586 const FrameReplicationState& replicated_state, 593 const FrameReplicationState& replicated_state,
587 CompositorDependencies* compositor_deps, 594 CompositorDependencies* compositor_deps,
588 const FrameMsg_NewFrame_WidgetParams& widget_params) { 595 const FrameMsg_NewFrame_WidgetParams& widget_params,
596 const blink::WebFrameOwnerProperties& frame_owner_properties) {
589 blink::WebLocalFrame* web_frame; 597 blink::WebLocalFrame* web_frame;
590 RenderFrameImpl* render_frame; 598 RenderFrameImpl* render_frame;
591 if (proxy_routing_id == MSG_ROUTING_NONE) { 599 if (proxy_routing_id == MSG_ROUTING_NONE) {
592 RenderFrameProxy* parent_proxy = 600 RenderFrameProxy* parent_proxy =
593 RenderFrameProxy::FromRoutingID(parent_routing_id); 601 RenderFrameProxy::FromRoutingID(parent_routing_id);
594 // If the browser is sending a valid parent routing id, it should already 602 // If the browser is sending a valid parent routing id, it should already
595 // be created and registered. 603 // be created and registered.
596 CHECK(parent_proxy); 604 CHECK(parent_proxy);
597 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); 605 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame();
598 606
599 blink::WebFrame* previous_sibling_web_frame = nullptr; 607 blink::WebFrame* previous_sibling_web_frame = nullptr;
600 RenderFrameProxy* previous_sibling_proxy = 608 RenderFrameProxy* previous_sibling_proxy =
601 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); 609 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id);
602 if (previous_sibling_proxy) 610 if (previous_sibling_proxy)
603 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); 611 previous_sibling_web_frame = previous_sibling_proxy->web_frame();
604 612
605 // Create the RenderFrame and WebLocalFrame, linking the two. 613 // Create the RenderFrame and WebLocalFrame, linking the two.
606 render_frame = 614 render_frame =
607 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); 615 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id);
608 web_frame = parent_web_frame->createLocalChild( 616 web_frame = parent_web_frame->createLocalChild(
609 replicated_state.scope, WebString::fromUTF8(replicated_state.name), 617 replicated_state.scope, WebString::fromUTF8(replicated_state.name),
610 replicated_state.sandbox_flags, render_frame, 618 replicated_state.sandbox_flags, render_frame,
611 previous_sibling_web_frame); 619 previous_sibling_web_frame);
620 web_frame->setFrameOwnerProperties(frame_owner_properties);
alexmos 2015/09/02 21:42:09 This will transfer updated properties for cross-si
lazyboy 2015/09/15 19:30:56 You're right, this case didn't use to work. since
612 } else { 621 } else {
613 RenderFrameProxy* proxy = 622 RenderFrameProxy* proxy =
614 RenderFrameProxy::FromRoutingID(proxy_routing_id); 623 RenderFrameProxy::FromRoutingID(proxy_routing_id);
615 CHECK(proxy); 624 CHECK(proxy);
616 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); 625 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id);
617 web_frame = 626 web_frame =
618 blink::WebLocalFrame::create(replicated_state.scope, render_frame); 627 blink::WebLocalFrame::create(replicated_state.scope, render_frame);
619 render_frame->proxy_routing_id_ = proxy_routing_id; 628 render_frame->proxy_routing_id_ = proxy_routing_id;
620 web_frame->initializeToReplaceRemoteFrame( 629 web_frame->initializeToReplaceRemoteFrame(
alexmos 2015/09/02 21:42:09 This remote-to-local path might need to call setFr
lazyboy 2015/09/15 19:30:56 Done.
621 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), 630 proxy->web_frame(), WebString::fromUTF8(replicated_state.name),
622 replicated_state.sandbox_flags); 631 replicated_state.sandbox_flags);
623 } 632 }
624 render_frame->SetWebFrame(web_frame); 633 render_frame->SetWebFrame(web_frame);
625 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); 634 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent());
626 635
627 if (widget_params.routing_id != MSG_ROUTING_NONE) { 636 if (widget_params.routing_id != MSG_ROUTING_NONE) {
628 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 637 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
629 render_frame->render_widget_ = RenderWidget::CreateForFrame( 638 render_frame->render_widget_ = RenderWidget::CreateForFrame(
630 widget_params.routing_id, widget_params.surface_id, 639 widget_params.routing_id, widget_params.surface_id,
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 if (!navigation_state->request_committed()) { 2199 if (!navigation_state->request_committed()) {
2191 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 2200 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
2192 } 2201 }
2193 } 2202 }
2194 } 2203 }
2195 2204
2196 blink::WebFrame* RenderFrameImpl::createChildFrame( 2205 blink::WebFrame* RenderFrameImpl::createChildFrame(
2197 blink::WebLocalFrame* parent, 2206 blink::WebLocalFrame* parent,
2198 blink::WebTreeScopeType scope, 2207 blink::WebTreeScopeType scope,
2199 const blink::WebString& name, 2208 const blink::WebString& name,
2200 blink::WebSandboxFlags sandbox_flags) { 2209 blink::WebSandboxFlags sandbox_flags,
2210 const blink::WebFrameOwnerProperties& frameOwnerProperties) {
2201 // Synchronously notify the browser of a child frame creation to get the 2211 // Synchronously notify the browser of a child frame creation to get the
2202 // routing_id for the RenderFrame. 2212 // routing_id for the RenderFrame.
2203 int child_routing_id = MSG_ROUTING_NONE; 2213 int child_routing_id = MSG_ROUTING_NONE;
2204 Send(new FrameHostMsg_CreateChildFrame( 2214 Send(new FrameHostMsg_CreateChildFrame(
2205 routing_id_, scope, 2215 routing_id_, scope, base::UTF16ToUTF8(base::StringPiece16(name)),
2206 base::UTF16ToUTF8(base::StringPiece16(name)), sandbox_flags, 2216 sandbox_flags, frameOwnerProperties, &child_routing_id));
2207 &child_routing_id));
2208 2217
2209 // Allocation of routing id failed, so we can't create a child frame. This can 2218 // Allocation of routing id failed, so we can't create a child frame. This can
2210 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped 2219 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped
2211 // out state or synchronous IPC message above has failed. 2220 // out state or synchronous IPC message above has failed.
2212 if (child_routing_id == MSG_ROUTING_NONE) { 2221 if (child_routing_id == MSG_ROUTING_NONE) {
2213 NOTREACHED() << "Failed to allocate routing id for child frame."; 2222 NOTREACHED() << "Failed to allocate routing id for child frame.";
2214 return nullptr; 2223 return nullptr;
2215 } 2224 }
2216 2225
2217 // Create the RenderFrame and WebLocalFrame, linking the two. 2226 // Create the RenderFrame and WebLocalFrame, linking the two.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 // updates are happening too frequently. 2329 // updates are happening too frequently.
2321 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || 2330 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() ||
2322 render_view_->renderer_preferences_.report_frame_name_changes) { 2331 render_view_->renderer_preferences_.report_frame_name_changes) {
2323 Send(new FrameHostMsg_DidChangeName( 2332 Send(new FrameHostMsg_DidChangeName(
2324 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)))); 2333 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name))));
2325 } 2334 }
2326 } 2335 }
2327 2336
2328 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, 2337 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame,
2329 blink::WebSandboxFlags flags) { 2338 blink::WebSandboxFlags flags) {
2330 int frame_routing_id = MSG_ROUTING_NONE; 2339 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2331 if (child_frame->isWebRemoteFrame()) {
2332 frame_routing_id =
2333 RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
2334 } else {
2335 frame_routing_id =
2336 RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
2337 }
2338
2339 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id, 2340 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id,
2340 flags)); 2341 flags));
2341 } 2342 }
2342 2343
2344 void RenderFrameImpl::didChangeScrollingMode(
2345 blink::WebFrame* child_frame,
2346 blink::WebFrameOwnerProperties::ScrollingMode scrolling_mode) {
2347 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2348 Send(new FrameHostMsg_DidChangeScrollingMode(routing_id_, frame_routing_id,
2349 scrolling_mode));
2350 }
2351
2352 void RenderFrameImpl::didChangeMarginWidth(blink::WebFrame* child_frame,
2353 int marginWidth) {
2354 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2355 Send(new FrameHostMsg_DidChangeMarginWidth(routing_id_, frame_routing_id,
2356 marginWidth));
2357 }
2358
2359 void RenderFrameImpl::didChangeMarginHeight(blink::WebFrame* child_frame,
2360 int marginHeight) {
2361 int frame_routing_id = GetRoutingIDForFrame(child_frame);
2362 Send(new FrameHostMsg_DidChangeMarginHeight(routing_id_, frame_routing_id,
2363 marginHeight));
2364 }
2365
2343 void RenderFrameImpl::didMatchCSS( 2366 void RenderFrameImpl::didMatchCSS(
2344 blink::WebLocalFrame* frame, 2367 blink::WebLocalFrame* frame,
2345 const blink::WebVector<blink::WebString>& newly_matching_selectors, 2368 const blink::WebVector<blink::WebString>& newly_matching_selectors,
2346 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 2369 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
2347 DCHECK(!frame_ || frame_ == frame); 2370 DCHECK(!frame_ || frame_ == frame);
2348 2371
2349 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2372 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2350 DidMatchCSS(newly_matching_selectors, 2373 DidMatchCSS(newly_matching_selectors,
2351 stopped_matching_selectors)); 2374 stopped_matching_selectors));
2352 } 2375 }
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after
5108 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_)); 5131 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_));
5109 mojo::ServiceProviderPtr service_provider; 5132 mojo::ServiceProviderPtr service_provider;
5110 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5133 mojo::URLRequestPtr request(mojo::URLRequest::New());
5111 request->url = mojo::String::From(url); 5134 request->url = mojo::String::From(url);
5112 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5135 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5113 nullptr, nullptr); 5136 nullptr, nullptr);
5114 return service_provider.Pass(); 5137 return service_provider.Pass();
5115 } 5138 }
5116 5139
5117 } // namespace content 5140 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698