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

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

Issue 616133002: Make RenderFrame(Host) own a RenderWidget(Host). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-applying same patch 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_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "ipc/ipc_sync_message.h" 54 #include "ipc/ipc_sync_message.h"
55 #include "skia/ext/platform_canvas.h" 55 #include "skia/ext/platform_canvas.h"
56 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 56 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
57 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 57 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
58 #include "third_party/WebKit/public/platform/WebPoint.h" 58 #include "third_party/WebKit/public/platform/WebPoint.h"
59 #include "third_party/WebKit/public/platform/WebRect.h" 59 #include "third_party/WebKit/public/platform/WebRect.h"
60 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 60 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
61 #include "third_party/WebKit/public/platform/WebSize.h" 61 #include "third_party/WebKit/public/platform/WebSize.h"
62 #include "third_party/WebKit/public/platform/WebString.h" 62 #include "third_party/WebKit/public/platform/WebString.h"
63 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 63 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
64 #include "third_party/WebKit/public/web/WebFrameWidget.h"
65 #include "third_party/WebKit/public/web/WebLocalFrame.h"
64 #include "third_party/WebKit/public/web/WebNode.h" 66 #include "third_party/WebKit/public/web/WebNode.h"
65 #include "third_party/WebKit/public/web/WebPagePopup.h" 67 #include "third_party/WebKit/public/web/WebPagePopup.h"
66 #include "third_party/WebKit/public/web/WebPopupMenu.h" 68 #include "third_party/WebKit/public/web/WebPopupMenu.h"
67 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" 69 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
68 #include "third_party/WebKit/public/web/WebRange.h" 70 #include "third_party/WebKit/public/web/WebRange.h"
69 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 71 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
72 #include "third_party/WebKit/public/web/WebView.h"
70 #include "third_party/skia/include/core/SkShader.h" 73 #include "third_party/skia/include/core/SkShader.h"
71 #include "ui/base/ui_base_switches.h" 74 #include "ui/base/ui_base_switches.h"
72 #include "ui/gfx/frame_time.h" 75 #include "ui/gfx/frame_time.h"
73 #include "ui/gfx/geometry/point_conversions.h" 76 #include "ui/gfx/geometry/point_conversions.h"
74 #include "ui/gfx/geometry/rect_conversions.h" 77 #include "ui/gfx/geometry/rect_conversions.h"
75 #include "ui/gfx/geometry/size_conversions.h" 78 #include "ui/gfx/geometry/size_conversions.h"
76 #include "ui/gfx/skia_util.h" 79 #include "ui/gfx/skia_util.h"
77 #include "ui/gl/gl_switches.h" 80 #include "ui/gl/gl_switches.h"
78 #include "ui/surface/transport_dib.h" 81 #include "ui/surface/transport_dib.h"
79 82
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 DCHECK(opener_id != MSG_ROUTING_NONE); 529 DCHECK(opener_id != MSG_ROUTING_NONE);
527 scoped_refptr<RenderWidget> widget( 530 scoped_refptr<RenderWidget> widget(
528 new RenderWidget(popup_type, screen_info, false, false, false)); 531 new RenderWidget(popup_type, screen_info, false, false, false));
529 if (widget->Init(opener_id, compositor_deps)) { // adds reference on success. 532 if (widget->Init(opener_id, compositor_deps)) { // adds reference on success.
530 return widget.get(); 533 return widget.get();
531 } 534 }
532 return NULL; 535 return NULL;
533 } 536 }
534 537
535 // static 538 // static
536 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { 539 RenderWidget* RenderWidget::CreateForFrame(
540 int routing_id,
541 int surface_id,
542 bool hidden,
543 const blink::WebScreenInfo& screen_info,
544 CompositorDependencies* compositor_deps,
545 blink::WebLocalFrame* frame) {
546 CHECK_NE(routing_id, MSG_ROUTING_NONE);
547 scoped_refptr<RenderWidget> widget(new RenderWidget(
548 blink::WebPopupTypeNone, screen_info, false, hidden, false));
549 widget->routing_id_ = routing_id;
550 widget->surface_id_ = surface_id;
551 widget->compositor_deps_ = compositor_deps;
552 // DoInit increments the reference count on |widget|, keeping it alive after
553 // this function returns.
554 if (widget->DoInit(MSG_ROUTING_NONE, compositor_deps,
555 RenderWidget::CreateWebFrameWidget(widget.get(), frame),
556 nullptr)) {
557 widget->CompleteInit();
558 return widget.get();
559 }
560 return nullptr;
561 }
562
563 // static
564 blink::WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
537 switch (render_widget->popup_type_) { 565 switch (render_widget->popup_type_) {
538 case blink::WebPopupTypeNone: // Nothing to create. 566 case blink::WebPopupTypeNone: // Nothing to create.
539 break; 567 break;
540 case blink::WebPopupTypeSelect: 568 case blink::WebPopupTypeSelect:
541 case blink::WebPopupTypeSuggestion: 569 case blink::WebPopupTypeSuggestion:
542 return WebPopupMenu::create(render_widget); 570 return WebPopupMenu::create(render_widget);
543 case blink::WebPopupTypePage: 571 case blink::WebPopupTypePage:
544 return WebPagePopup::create(render_widget); 572 return WebPagePopup::create(render_widget);
545 default: 573 default:
546 NOTREACHED(); 574 NOTREACHED();
547 } 575 }
548 return NULL; 576 return NULL;
549 } 577 }
550 578
579 // static
580 blink::WebWidget* RenderWidget::CreateWebFrameWidget(
581 RenderWidget* render_widget,
582 blink::WebLocalFrame* frame) {
583 return blink::WebFrameWidget::create(render_widget, frame);
584 }
585
551 bool RenderWidget::Init(int32 opener_id, 586 bool RenderWidget::Init(int32 opener_id,
552 CompositorDependencies* compositor_deps) { 587 CompositorDependencies* compositor_deps) {
553 return DoInit(opener_id, compositor_deps, RenderWidget::CreateWebWidget(this), 588 return DoInit(opener_id, compositor_deps, RenderWidget::CreateWebWidget(this),
554 new ViewHostMsg_CreateWidget(opener_id, popup_type_, 589 new ViewHostMsg_CreateWidget(opener_id, popup_type_,
555 &routing_id_, &surface_id_)); 590 &routing_id_, &surface_id_));
556 } 591 }
557 592
558 bool RenderWidget::DoInit(int32 opener_id, 593 bool RenderWidget::DoInit(int32 opener_id,
559 CompositorDependencies* compositor_deps, 594 CompositorDependencies* compositor_deps,
560 WebWidget* web_widget, 595 WebWidget* web_widget,
561 IPC::SyncMessage* create_widget_message) { 596 IPC::SyncMessage* create_widget_message) {
562 DCHECK(!webwidget_); 597 DCHECK(!webwidget_);
563 598
564 if (opener_id != MSG_ROUTING_NONE) 599 if (opener_id != MSG_ROUTING_NONE)
565 opener_id_ = opener_id; 600 opener_id_ = opener_id;
566 601
567 compositor_deps_ = compositor_deps; 602 compositor_deps_ = compositor_deps;
568 webwidget_ = web_widget; 603 webwidget_ = web_widget;
569 604
570 bool result = RenderThread::Get()->Send(create_widget_message); 605 bool result = true;
606 if (create_widget_message)
607 result = RenderThread::Get()->Send(create_widget_message);
608
571 if (result) { 609 if (result) {
572 RenderThread::Get()->AddRoute(routing_id_, this); 610 RenderThread::Get()->AddRoute(routing_id_, this);
573 // Take a reference on behalf of the RenderThread. This will be balanced 611 // Take a reference on behalf of the RenderThread. This will be balanced
574 // when we receive ViewMsg_Close. 612 // when we receive ViewMsg_Close.
575 AddRef(); 613 AddRef();
576 if (RenderThreadImpl::current()) { 614 if (RenderThreadImpl::current()) {
577 RenderThreadImpl::current()->WidgetCreated(); 615 RenderThreadImpl::current()->WidgetCreated();
578 if (is_hidden_) 616 if (is_hidden_)
579 RenderThreadImpl::current()->WidgetHidden(); 617 RenderThreadImpl::current()->WidgetHidden();
580 } 618 }
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2411 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2374 video_hole_frames_.AddObserver(frame); 2412 video_hole_frames_.AddObserver(frame);
2375 } 2413 }
2376 2414
2377 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2415 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2378 video_hole_frames_.RemoveObserver(frame); 2416 video_hole_frames_.RemoveObserver(frame);
2379 } 2417 }
2380 #endif // defined(VIDEO_HOLE) 2418 #endif // defined(VIDEO_HOLE)
2381 2419
2382 } // namespace content 2420 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698