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

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: Removed added printf statements; LocalFrameId::is_valid() no longer checks if nonce is 0. Created 4 years, 2 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 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 current_surface_size_ = frame_size; 398 current_surface_size_ = frame_size;
399 current_surface_scale_factor_ = scale_factor; 399 current_surface_scale_factor_ = scale_factor;
400 } 400 }
401 401
402 if (!surface_factory_) { 402 if (!surface_factory_) {
403 cc::SurfaceManager* manager = GetSurfaceManager(); 403 cc::SurfaceManager* manager = GetSurfaceManager();
404 surface_factory_ = 404 surface_factory_ =
405 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); 405 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
406 } 406 }
407 407
408 if (local_frame_id_.is_null()) { 408 if (!local_frame_id_.is_valid()) {
409 local_frame_id_ = id_allocator_->GenerateId(); 409 local_frame_id_ = id_allocator_->GenerateId();
410 surface_factory_->Create(local_frame_id_); 410 surface_factory_->Create(local_frame_id_);
411 411
412 cc::SurfaceSequence sequence = 412 cc::SurfaceSequence sequence =
413 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 413 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
414 // The renderer process will satisfy this dependency when it creates a 414 // The renderer process will satisfy this dependency when it creates a
415 // SurfaceLayer. 415 // SurfaceLayer.
416 cc::SurfaceManager* manager = GetSurfaceManager(); 416 cc::SurfaceManager* manager = GetSurfaceManager();
417 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_)) 417 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
418 ->AddDestructionDependency(sequence); 418 ->AddDestructionDependency(sequence);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 return frame_connector_->TransformPointToRootCoordSpace( 530 return frame_connector_->TransformPointToRootCoordSpace(
531 point, cc::SurfaceId(frame_sink_id_, local_frame_id_)); 531 point, cc::SurfaceId(frame_sink_id_, local_frame_id_));
532 } 532 }
533 533
534 bool RenderWidgetHostViewChildFrame::TransformPointToLocalCoordSpace( 534 bool RenderWidgetHostViewChildFrame::TransformPointToLocalCoordSpace(
535 const gfx::Point& point, 535 const gfx::Point& point,
536 const cc::SurfaceId& original_surface, 536 const cc::SurfaceId& original_surface,
537 gfx::Point* transformed_point) { 537 gfx::Point* transformed_point) {
538 *transformed_point = point; 538 *transformed_point = point;
539 if (!frame_connector_ || local_frame_id_.is_null()) 539 if (!frame_connector_ || !local_frame_id_.is_valid())
540 return false; 540 return false;
541 541
542 return frame_connector_->TransformPointToLocalCoordSpace( 542 return frame_connector_->TransformPointToLocalCoordSpace(
543 point, original_surface, cc::SurfaceId(frame_sink_id_, local_frame_id_), 543 point, original_surface, cc::SurfaceId(frame_sink_id_, local_frame_id_),
544 transformed_point); 544 transformed_point);
545 } 545 }
546 546
547 bool RenderWidgetHostViewChildFrame::TransformPointToCoordSpaceForView( 547 bool RenderWidgetHostViewChildFrame::TransformPointToCoordSpaceForView(
548 const gfx::Point& point, 548 const gfx::Point& point,
549 RenderWidgetHostViewBase* target_view, 549 RenderWidgetHostViewBase* target_view,
550 gfx::Point* transformed_point) { 550 gfx::Point* transformed_point) {
551 if (!frame_connector_ || local_frame_id_.is_null() || target_view == this) 551 if (!frame_connector_ || !local_frame_id_.is_valid() || target_view == this)
552 return false; 552 return false;
553 553
554 return frame_connector_->TransformPointToCoordSpaceForView( 554 return frame_connector_->TransformPointToCoordSpaceForView(
555 point, target_view, cc::SurfaceId(frame_sink_id_, local_frame_id_), 555 point, target_view, cc::SurfaceId(frame_sink_id_, local_frame_id_),
556 transformed_point); 556 transformed_point);
557 } 557 }
558 558
559 bool RenderWidgetHostViewChildFrame::IsRenderWidgetHostViewChildFrame() { 559 bool RenderWidgetHostViewChildFrame::IsRenderWidgetHostViewChildFrame() {
560 return true; 560 return true;
561 } 561 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } 724 }
725 725
726 BrowserAccessibilityManager* 726 BrowserAccessibilityManager*
727 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( 727 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
728 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { 728 BrowserAccessibilityDelegate* delegate, bool for_root_frame) {
729 return BrowserAccessibilityManager::Create( 729 return BrowserAccessibilityManager::Create(
730 BrowserAccessibilityManager::GetEmptyDocument(), delegate); 730 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
731 } 731 }
732 732
733 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { 733 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() {
734 if (surface_factory_ && !local_frame_id_.is_null()) 734 if (surface_factory_ && local_frame_id_.is_valid())
735 surface_factory_->Destroy(local_frame_id_); 735 surface_factory_->Destroy(local_frame_id_);
736 local_frame_id_ = cc::LocalFrameId(); 736 local_frame_id_ = cc::LocalFrameId();
737 } 737 }
738 738
739 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 739 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
740 return true; 740 return true;
741 } 741 }
742 742
743 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 743 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
744 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 744 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
745 }; 745 };
746 746
747 } // namespace content 747 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698