| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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" | |
| 66 #include "third_party/WebKit/public/web/WebNode.h" | 64 #include "third_party/WebKit/public/web/WebNode.h" |
| 67 #include "third_party/WebKit/public/web/WebPagePopup.h" | 65 #include "third_party/WebKit/public/web/WebPagePopup.h" |
| 68 #include "third_party/WebKit/public/web/WebPopupMenu.h" | 66 #include "third_party/WebKit/public/web/WebPopupMenu.h" |
| 69 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | 67 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" |
| 70 #include "third_party/WebKit/public/web/WebRange.h" | 68 #include "third_party/WebKit/public/web/WebRange.h" |
| 71 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 69 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 72 #include "third_party/WebKit/public/web/WebView.h" | |
| 73 #include "third_party/skia/include/core/SkShader.h" | 70 #include "third_party/skia/include/core/SkShader.h" |
| 74 #include "ui/base/ui_base_switches.h" | 71 #include "ui/base/ui_base_switches.h" |
| 75 #include "ui/gfx/frame_time.h" | 72 #include "ui/gfx/frame_time.h" |
| 76 #include "ui/gfx/geometry/point_conversions.h" | 73 #include "ui/gfx/geometry/point_conversions.h" |
| 77 #include "ui/gfx/geometry/rect_conversions.h" | 74 #include "ui/gfx/geometry/rect_conversions.h" |
| 78 #include "ui/gfx/geometry/size_conversions.h" | 75 #include "ui/gfx/geometry/size_conversions.h" |
| 79 #include "ui/gfx/skia_util.h" | 76 #include "ui/gfx/skia_util.h" |
| 80 #include "ui/gl/gl_switches.h" | 77 #include "ui/gl/gl_switches.h" |
| 81 #include "ui/surface/transport_dib.h" | 78 #include "ui/surface/transport_dib.h" |
| 82 | 79 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 DCHECK(opener_id != MSG_ROUTING_NONE); | 526 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 530 scoped_refptr<RenderWidget> widget( | 527 scoped_refptr<RenderWidget> widget( |
| 531 new RenderWidget(popup_type, screen_info, false, false, false)); | 528 new RenderWidget(popup_type, screen_info, false, false, false)); |
| 532 if (widget->Init(opener_id, compositor_deps)) { // adds reference on success. | 529 if (widget->Init(opener_id, compositor_deps)) { // adds reference on success. |
| 533 return widget.get(); | 530 return widget.get(); |
| 534 } | 531 } |
| 535 return NULL; | 532 return NULL; |
| 536 } | 533 } |
| 537 | 534 |
| 538 // static | 535 // static |
| 539 RenderWidget* RenderWidget::CreateForFrame( | 536 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
| 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) { | |
| 565 switch (render_widget->popup_type_) { | 537 switch (render_widget->popup_type_) { |
| 566 case blink::WebPopupTypeNone: // Nothing to create. | 538 case blink::WebPopupTypeNone: // Nothing to create. |
| 567 break; | 539 break; |
| 568 case blink::WebPopupTypeSelect: | 540 case blink::WebPopupTypeSelect: |
| 569 case blink::WebPopupTypeSuggestion: | 541 case blink::WebPopupTypeSuggestion: |
| 570 return WebPopupMenu::create(render_widget); | 542 return WebPopupMenu::create(render_widget); |
| 571 case blink::WebPopupTypePage: | 543 case blink::WebPopupTypePage: |
| 572 return WebPagePopup::create(render_widget); | 544 return WebPagePopup::create(render_widget); |
| 573 default: | 545 default: |
| 574 NOTREACHED(); | 546 NOTREACHED(); |
| 575 } | 547 } |
| 576 return NULL; | 548 return NULL; |
| 577 } | 549 } |
| 578 | 550 |
| 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 | |
| 586 bool RenderWidget::Init(int32 opener_id, | 551 bool RenderWidget::Init(int32 opener_id, |
| 587 CompositorDependencies* compositor_deps) { | 552 CompositorDependencies* compositor_deps) { |
| 588 return DoInit(opener_id, compositor_deps, RenderWidget::CreateWebWidget(this), | 553 return DoInit(opener_id, compositor_deps, RenderWidget::CreateWebWidget(this), |
| 589 new ViewHostMsg_CreateWidget(opener_id, popup_type_, | 554 new ViewHostMsg_CreateWidget(opener_id, popup_type_, |
| 590 &routing_id_, &surface_id_)); | 555 &routing_id_, &surface_id_)); |
| 591 } | 556 } |
| 592 | 557 |
| 593 bool RenderWidget::DoInit(int32 opener_id, | 558 bool RenderWidget::DoInit(int32 opener_id, |
| 594 CompositorDependencies* compositor_deps, | 559 CompositorDependencies* compositor_deps, |
| 595 WebWidget* web_widget, | 560 WebWidget* web_widget, |
| 596 IPC::SyncMessage* create_widget_message) { | 561 IPC::SyncMessage* create_widget_message) { |
| 597 DCHECK(!webwidget_); | 562 DCHECK(!webwidget_); |
| 598 | 563 |
| 599 if (opener_id != MSG_ROUTING_NONE) | 564 if (opener_id != MSG_ROUTING_NONE) |
| 600 opener_id_ = opener_id; | 565 opener_id_ = opener_id; |
| 601 | 566 |
| 602 compositor_deps_ = compositor_deps; | 567 compositor_deps_ = compositor_deps; |
| 603 webwidget_ = web_widget; | 568 webwidget_ = web_widget; |
| 604 | 569 |
| 605 bool result = true; | 570 bool result = RenderThread::Get()->Send(create_widget_message); |
| 606 if (create_widget_message) | |
| 607 result = RenderThread::Get()->Send(create_widget_message); | |
| 608 | |
| 609 if (result) { | 571 if (result) { |
| 610 RenderThread::Get()->AddRoute(routing_id_, this); | 572 RenderThread::Get()->AddRoute(routing_id_, this); |
| 611 // Take a reference on behalf of the RenderThread. This will be balanced | 573 // Take a reference on behalf of the RenderThread. This will be balanced |
| 612 // when we receive ViewMsg_Close. | 574 // when we receive ViewMsg_Close. |
| 613 AddRef(); | 575 AddRef(); |
| 614 if (RenderThreadImpl::current()) { | 576 if (RenderThreadImpl::current()) { |
| 615 RenderThreadImpl::current()->WidgetCreated(); | 577 RenderThreadImpl::current()->WidgetCreated(); |
| 616 if (is_hidden_) | 578 if (is_hidden_) |
| 617 RenderThreadImpl::current()->WidgetHidden(); | 579 RenderThreadImpl::current()->WidgetHidden(); |
| 618 } | 580 } |
| (...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2373 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2412 video_hole_frames_.AddObserver(frame); | 2374 video_hole_frames_.AddObserver(frame); |
| 2413 } | 2375 } |
| 2414 | 2376 |
| 2415 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2377 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2416 video_hole_frames_.RemoveObserver(frame); | 2378 video_hole_frames_.RemoveObserver(frame); |
| 2417 } | 2379 } |
| 2418 #endif // defined(VIDEO_HOLE) | 2380 #endif // defined(VIDEO_HOLE) |
| 2419 | 2381 |
| 2420 } // namespace content | 2382 } // namespace content |
| OLD | NEW |