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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 2425923003: Replaced is_null() with is_valid in SurfaceId and related classes. (Closed)
Patch Set: Fixed an exo compile error Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/frame_host/render_widget_host_view_child_frame.h" 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 current_surface_scale_factor_(1.f), 59 current_surface_scale_factor_(1.f),
60 ack_pending_count_(0), 60 ack_pending_count_(0),
61 frame_connector_(nullptr), 61 frame_connector_(nullptr),
62 begin_frame_source_(nullptr), 62 begin_frame_source_(nullptr),
63 weak_factory_(this) { 63 weak_factory_(this) {
64 id_allocator_.reset(new cc::SurfaceIdAllocator()); 64 id_allocator_.reset(new cc::SurfaceIdAllocator());
65 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); 65 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
66 } 66 }
67 67
68 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { 68 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
69 if (!local_frame_id_.is_null()) 69 if (local_frame_id_.is_valid())
70 surface_factory_->Destroy(local_frame_id_); 70 surface_factory_->Destroy(local_frame_id_);
71 71
72 if (GetSurfaceManager()) 72 if (GetSurfaceManager())
73 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); 73 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_);
74 } 74 }
75 75
76 void RenderWidgetHostViewChildFrame::Init() { 76 void RenderWidgetHostViewChildFrame::Init() {
77 RegisterFrameSinkId(); 77 RegisterFrameSinkId();
78 host_->SetView(this); 78 host_->SetView(this);
79 GetTextInputManager(); 79 GetTextInputManager();
80 } 80 }
81 81
82 void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector( 82 void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector(
83 CrossProcessFrameConnector* frame_connector) { 83 CrossProcessFrameConnector* frame_connector) {
84 if (frame_connector_ == frame_connector) 84 if (frame_connector_ == frame_connector)
85 return; 85 return;
86 86
87 if (frame_connector_) { 87 if (frame_connector_) {
88 if (!parent_frame_sink_id_.is_null()) { 88 if (parent_frame_sink_id_.is_valid()) {
89 GetSurfaceManager()->UnregisterFrameSinkHierarchy(parent_frame_sink_id_, 89 GetSurfaceManager()->UnregisterFrameSinkHierarchy(parent_frame_sink_id_,
90 frame_sink_id_); 90 frame_sink_id_);
91 } 91 }
92 // Unregister the client here, as it is not guaranteed in tests that the 92 // Unregister the client here, as it is not guaranteed in tests that the
93 // destructor will be called. 93 // destructor will be called.
94 GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); 94 GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_);
95 95
96 parent_frame_sink_id_ = cc::FrameSinkId(); 96 parent_frame_sink_id_ = cc::FrameSinkId();
97 97
98 // After the RenderWidgetHostViewChildFrame loses the frame_connector, it 98 // After the RenderWidgetHostViewChildFrame loses the frame_connector, it
99 // won't be able to walk up the frame tree anymore. Clean up anything that 99 // won't be able to walk up the frame tree anymore. Clean up anything that
100 // needs to be done through the CrossProcessFrameConnector before it's gone. 100 // needs to be done through the CrossProcessFrameConnector before it's gone.
101 101
102 // Unlocks the mouse if this RenderWidgetHostView holds the lock. 102 // Unlocks the mouse if this RenderWidgetHostView holds the lock.
103 UnlockMouse(); 103 UnlockMouse();
104 } 104 }
105 frame_connector_ = frame_connector; 105 frame_connector_ = frame_connector;
106 if (frame_connector_) { 106 if (frame_connector_) {
107 GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, this); 107 GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, this);
108 RenderWidgetHostViewBase* parent_view = 108 RenderWidgetHostViewBase* parent_view =
109 frame_connector_->GetParentRenderWidgetHostView(); 109 frame_connector_->GetParentRenderWidgetHostView();
110 if (parent_view) { 110 if (parent_view) {
111 parent_frame_sink_id_ = parent_view->GetFrameSinkId(); 111 parent_frame_sink_id_ = parent_view->GetFrameSinkId();
112 DCHECK(!parent_frame_sink_id_.is_null()); 112 DCHECK(parent_frame_sink_id_.is_valid());
113 GetSurfaceManager()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, 113 GetSurfaceManager()->RegisterFrameSinkHierarchy(parent_frame_sink_id_,
114 frame_sink_id_); 114 frame_sink_id_);
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 void RenderWidgetHostViewChildFrame::InitAsChild( 119 void RenderWidgetHostViewChildFrame::InitAsChild(
120 gfx::NativeView parent_view) { 120 gfx::NativeView parent_view) {
121 NOTREACHED(); 121 NOTREACHED();
122 } 122 }
(...skipping 18 matching lines...) Expand all
141 void RenderWidgetHostViewChildFrame::Focus() { 141 void RenderWidgetHostViewChildFrame::Focus() {
142 } 142 }
143 143
144 bool RenderWidgetHostViewChildFrame::HasFocus() const { 144 bool RenderWidgetHostViewChildFrame::HasFocus() const {
145 if (frame_connector_) 145 if (frame_connector_)
146 return frame_connector_->HasFocus(); 146 return frame_connector_->HasFocus();
147 return false; 147 return false;
148 } 148 }
149 149
150 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const { 150 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
151 return surface_factory_ && !local_frame_id_.is_null(); 151 return surface_factory_ && local_frame_id_.is_valid();
152 } 152 }
153 153
154 void RenderWidgetHostViewChildFrame::Show() { 154 void RenderWidgetHostViewChildFrame::Show() {
155 if (!host_->is_hidden()) 155 if (!host_->is_hidden())
156 return; 156 return;
157 host_->WasShown(ui::LatencyInfo()); 157 host_->WasShown(ui::LatencyInfo());
158 } 158 }
159 159
160 void RenderWidgetHostViewChildFrame::Hide() { 160 void RenderWidgetHostViewChildFrame::Hide() {
161 if (host_->is_hidden()) 161 if (host_->is_hidden())
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 current_surface_size_ = frame_size; 397 current_surface_size_ = frame_size;
398 current_surface_scale_factor_ = scale_factor; 398 current_surface_scale_factor_ = scale_factor;
399 } 399 }
400 400
401 if (!surface_factory_) { 401 if (!surface_factory_) {
402 cc::SurfaceManager* manager = GetSurfaceManager(); 402 cc::SurfaceManager* manager = GetSurfaceManager();
403 surface_factory_ = 403 surface_factory_ =
404 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); 404 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
405 } 405 }
406 406
407 if (local_frame_id_.is_null()) { 407 if (!local_frame_id_.is_valid()) {
408 local_frame_id_ = id_allocator_->GenerateId(); 408 local_frame_id_ = id_allocator_->GenerateId();
409 surface_factory_->Create(local_frame_id_); 409 surface_factory_->Create(local_frame_id_);
410 410
411 cc::SurfaceSequence sequence = 411 cc::SurfaceSequence sequence =
412 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 412 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
413 // The renderer process will satisfy this dependency when it creates a 413 // The renderer process will satisfy this dependency when it creates a
414 // SurfaceLayer. 414 // SurfaceLayer.
415 cc::SurfaceManager* manager = GetSurfaceManager(); 415 cc::SurfaceManager* manager = GetSurfaceManager();
416 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_)) 416 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
417 ->AddDestructionDependency(sequence); 417 ->AddDestructionDependency(sequence);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 return frame_connector_->TransformPointToRootCoordSpace( 529 return frame_connector_->TransformPointToRootCoordSpace(
530 point, cc::SurfaceId(frame_sink_id_, local_frame_id_)); 530 point, cc::SurfaceId(frame_sink_id_, local_frame_id_));
531 } 531 }
532 532
533 bool RenderWidgetHostViewChildFrame::TransformPointToLocalCoordSpace( 533 bool RenderWidgetHostViewChildFrame::TransformPointToLocalCoordSpace(
534 const gfx::Point& point, 534 const gfx::Point& point,
535 const cc::SurfaceId& original_surface, 535 const cc::SurfaceId& original_surface,
536 gfx::Point* transformed_point) { 536 gfx::Point* transformed_point) {
537 *transformed_point = point; 537 *transformed_point = point;
538 if (!frame_connector_ || local_frame_id_.is_null()) 538 if (!frame_connector_ || !local_frame_id_.is_valid())
539 return false; 539 return false;
540 540
541 return frame_connector_->TransformPointToLocalCoordSpace( 541 return frame_connector_->TransformPointToLocalCoordSpace(
542 point, original_surface, cc::SurfaceId(frame_sink_id_, local_frame_id_), 542 point, original_surface, cc::SurfaceId(frame_sink_id_, local_frame_id_),
543 transformed_point); 543 transformed_point);
544 } 544 }
545 545
546 bool RenderWidgetHostViewChildFrame::TransformPointToCoordSpaceForView( 546 bool RenderWidgetHostViewChildFrame::TransformPointToCoordSpaceForView(
547 const gfx::Point& point, 547 const gfx::Point& point,
548 RenderWidgetHostViewBase* target_view, 548 RenderWidgetHostViewBase* target_view,
549 gfx::Point* transformed_point) { 549 gfx::Point* transformed_point) {
550 if (!frame_connector_ || local_frame_id_.is_null() || target_view == this) 550 if (!frame_connector_ || !local_frame_id_.is_valid() || target_view == this)
551 return false; 551 return false;
552 552
553 return frame_connector_->TransformPointToCoordSpaceForView( 553 return frame_connector_->TransformPointToCoordSpaceForView(
554 point, target_view, cc::SurfaceId(frame_sink_id_, local_frame_id_), 554 point, target_view, cc::SurfaceId(frame_sink_id_, local_frame_id_),
555 transformed_point); 555 transformed_point);
556 } 556 }
557 557
558 bool RenderWidgetHostViewChildFrame::IsRenderWidgetHostViewChildFrame() { 558 bool RenderWidgetHostViewChildFrame::IsRenderWidgetHostViewChildFrame() {
559 return true; 559 return true;
560 } 560 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 723 }
724 724
725 BrowserAccessibilityManager* 725 BrowserAccessibilityManager*
726 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( 726 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
727 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { 727 BrowserAccessibilityDelegate* delegate, bool for_root_frame) {
728 return BrowserAccessibilityManager::Create( 728 return BrowserAccessibilityManager::Create(
729 BrowserAccessibilityManager::GetEmptyDocument(), delegate); 729 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
730 } 730 }
731 731
732 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { 732 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() {
733 if (surface_factory_ && !local_frame_id_.is_null()) 733 if (surface_factory_ && local_frame_id_.is_valid())
734 surface_factory_->Destroy(local_frame_id_); 734 surface_factory_->Destroy(local_frame_id_);
735 local_frame_id_ = cc::LocalFrameId(); 735 local_frame_id_ = cc::LocalFrameId();
736 } 736 }
737 737
738 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 738 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
739 return true; 739 return true;
740 } 740 }
741 741
742 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 742 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
743 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 743 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
744 }; 744 };
745 745
746 } // namespace content 746 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698