Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 #include "content/renderer/resizing_mode_selector.h" | 53 #include "content/renderer/resizing_mode_selector.h" |
| 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/WebRect.h" | 58 #include "third_party/WebKit/public/platform/WebRect.h" |
| 59 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 59 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
| 60 #include "third_party/WebKit/public/platform/WebSize.h" | 60 #include "third_party/WebKit/public/platform/WebSize.h" |
| 61 #include "third_party/WebKit/public/platform/WebString.h" | 61 #include "third_party/WebKit/public/platform/WebString.h" |
| 62 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 62 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 63 #include "third_party/WebKit/public/web/WebFrameWidget.h" | |
| 64 #include "third_party/WebKit/public/web/WebLocalFrame.h" | |
| 63 #include "third_party/WebKit/public/web/WebPagePopup.h" | 65 #include "third_party/WebKit/public/web/WebPagePopup.h" |
| 64 #include "third_party/WebKit/public/web/WebPopupMenu.h" | 66 #include "third_party/WebKit/public/web/WebPopupMenu.h" |
| 65 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | 67 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" |
| 66 #include "third_party/WebKit/public/web/WebRange.h" | 68 #include "third_party/WebKit/public/web/WebRange.h" |
| 67 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 69 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 70 #include "third_party/WebKit/public/web/WebView.h" | |
| 68 #include "third_party/skia/include/core/SkShader.h" | 71 #include "third_party/skia/include/core/SkShader.h" |
| 69 #include "ui/base/ui_base_switches.h" | 72 #include "ui/base/ui_base_switches.h" |
| 70 #include "ui/gfx/frame_time.h" | 73 #include "ui/gfx/frame_time.h" |
| 71 #include "ui/gfx/geometry/point_conversions.h" | 74 #include "ui/gfx/geometry/point_conversions.h" |
| 72 #include "ui/gfx/geometry/rect_conversions.h" | 75 #include "ui/gfx/geometry/rect_conversions.h" |
| 73 #include "ui/gfx/geometry/size_conversions.h" | 76 #include "ui/gfx/geometry/size_conversions.h" |
| 74 #include "ui/gfx/skia_util.h" | 77 #include "ui/gfx/skia_util.h" |
| 75 #include "ui/gl/gl_switches.h" | 78 #include "ui/gl/gl_switches.h" |
| 76 #include "ui/surface/transport_dib.h" | 79 #include "ui/surface/transport_dib.h" |
| 77 | 80 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 DCHECK(opener_id != MSG_ROUTING_NONE); | 525 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 523 scoped_refptr<RenderWidget> widget( | 526 scoped_refptr<RenderWidget> widget( |
| 524 new RenderWidget(popup_type, screen_info, false, false, false)); | 527 new RenderWidget(popup_type, screen_info, false, false, false)); |
| 525 if (widget->Init(opener_id, compositor_deps)) { // adds reference on success. | 528 if (widget->Init(opener_id, compositor_deps)) { // adds reference on success. |
| 526 return widget.get(); | 529 return widget.get(); |
| 527 } | 530 } |
| 528 return NULL; | 531 return NULL; |
| 529 } | 532 } |
| 530 | 533 |
| 531 // static | 534 // static |
| 532 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 535 RenderWidget* RenderWidget::CreateForFrame( |
| 536 int routing_id, | |
| 537 int surface_id, | |
| 538 bool hidden, | |
| 539 const blink::WebScreenInfo& screen_info, | |
| 540 CompositorDependencies* compositor_deps, | |
| 541 blink::WebLocalFrame* frame) { | |
| 542 DCHECK_NE(routing_id, MSG_ROUTING_NONE); | |
|
nasko
2015/01/14 20:08:05
Should we be braver and use CHECK_NE? Especially s
kenrb
2015/01/16 17:44:00
Done.
| |
| 543 scoped_refptr<RenderWidget> widget(new RenderWidget( | |
| 544 blink::WebPopupTypeNone, screen_info, false, hidden, false)); | |
| 545 widget->routing_id_ = routing_id; | |
| 546 widget->surface_id_ = surface_id; | |
| 547 widget->compositor_deps_ = compositor_deps; | |
| 548 if (widget->DoInit(MSG_ROUTING_NONE, compositor_deps, | |
| 549 RenderWidget::CreateWebFrameWidget(widget.get(), frame), | |
| 550 nullptr)) { | |
| 551 widget->CompleteInit(); | |
| 552 return widget.get(); | |
|
nasko
2015/01/14 20:08:05
Does DoInit take a RefCount on the widget? Otherwi
kenrb
2015/01/16 17:44:00
Yes, but that is certainly worthy of a comment.
| |
| 553 } | |
| 554 return nullptr; | |
| 555 } | |
| 556 | |
| 557 // static | |
| 558 blink::WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | |
| 533 switch (render_widget->popup_type_) { | 559 switch (render_widget->popup_type_) { |
| 534 case blink::WebPopupTypeNone: // Nothing to create. | 560 case blink::WebPopupTypeNone: // Nothing to create. |
| 535 break; | 561 break; |
| 536 case blink::WebPopupTypeSelect: | 562 case blink::WebPopupTypeSelect: |
| 537 case blink::WebPopupTypeSuggestion: | 563 case blink::WebPopupTypeSuggestion: |
| 538 return WebPopupMenu::create(render_widget); | 564 return WebPopupMenu::create(render_widget); |
| 539 case blink::WebPopupTypePage: | 565 case blink::WebPopupTypePage: |
| 540 return WebPagePopup::create(render_widget); | 566 return WebPagePopup::create(render_widget); |
| 541 default: | 567 default: |
| 542 NOTREACHED(); | 568 NOTREACHED(); |
| 543 } | 569 } |
| 544 return NULL; | 570 return NULL; |
| 545 } | 571 } |
| 546 | 572 |
| 573 // static | |
| 574 blink::WebWidget* RenderWidget::CreateWebFrameWidget( | |
| 575 RenderWidget* render_widget, | |
| 576 blink::WebLocalFrame* frame) { | |
| 577 return blink::WebFrameWidget::create(render_widget, frame); | |
| 578 } | |
| 579 | |
| 547 bool RenderWidget::Init(int32 opener_id, | 580 bool RenderWidget::Init(int32 opener_id, |
| 548 CompositorDependencies* compositor_deps) { | 581 CompositorDependencies* compositor_deps) { |
| 549 return DoInit(opener_id, compositor_deps, RenderWidget::CreateWebWidget(this), | 582 return DoInit(opener_id, compositor_deps, RenderWidget::CreateWebWidget(this), |
| 550 new ViewHostMsg_CreateWidget(opener_id, popup_type_, | 583 new ViewHostMsg_CreateWidget(opener_id, popup_type_, |
| 551 &routing_id_, &surface_id_)); | 584 &routing_id_, &surface_id_)); |
| 552 } | 585 } |
| 553 | 586 |
| 554 bool RenderWidget::DoInit(int32 opener_id, | 587 bool RenderWidget::DoInit(int32 opener_id, |
| 555 CompositorDependencies* compositor_deps, | 588 CompositorDependencies* compositor_deps, |
| 556 WebWidget* web_widget, | 589 WebWidget* web_widget, |
| 557 IPC::SyncMessage* create_widget_message) { | 590 IPC::SyncMessage* create_widget_message) { |
| 558 DCHECK(!webwidget_); | 591 DCHECK(!webwidget_); |
| 559 | 592 |
| 560 if (opener_id != MSG_ROUTING_NONE) | 593 if (opener_id != MSG_ROUTING_NONE) |
| 561 opener_id_ = opener_id; | 594 opener_id_ = opener_id; |
| 562 | 595 |
| 563 compositor_deps_ = compositor_deps; | 596 compositor_deps_ = compositor_deps; |
| 564 webwidget_ = web_widget; | 597 webwidget_ = web_widget; |
| 565 | 598 |
| 566 bool result = RenderThread::Get()->Send(create_widget_message); | 599 bool result = true; |
| 600 if (create_widget_message) | |
| 601 result = RenderThread::Get()->Send(create_widget_message); | |
| 602 | |
| 567 if (result) { | 603 if (result) { |
| 568 RenderThread::Get()->AddRoute(routing_id_, this); | 604 RenderThread::Get()->AddRoute(routing_id_, this); |
| 569 // Take a reference on behalf of the RenderThread. This will be balanced | 605 // Take a reference on behalf of the RenderThread. This will be balanced |
| 570 // when we receive ViewMsg_Close. | 606 // when we receive ViewMsg_Close. |
| 571 AddRef(); | 607 AddRef(); |
| 572 if (RenderThreadImpl::current()) { | 608 if (RenderThreadImpl::current()) { |
| 573 RenderThreadImpl::current()->WidgetCreated(); | 609 RenderThreadImpl::current()->WidgetCreated(); |
| 574 if (is_hidden_) | 610 if (is_hidden_) |
| 575 RenderThreadImpl::current()->WidgetHidden(); | 611 RenderThreadImpl::current()->WidgetHidden(); |
| 576 } | 612 } |
| (...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2365 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2401 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2366 video_hole_frames_.AddObserver(frame); | 2402 video_hole_frames_.AddObserver(frame); |
| 2367 } | 2403 } |
| 2368 | 2404 |
| 2369 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2405 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2370 video_hole_frames_.RemoveObserver(frame); | 2406 video_hole_frames_.RemoveObserver(frame); |
| 2371 } | 2407 } |
| 2372 #endif // defined(VIDEO_HOLE) | 2408 #endif // defined(VIDEO_HOLE) |
| 2373 | 2409 |
| 2374 } // namespace content | 2410 } // namespace content |
| OLD | NEW |