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

Side by Side Diff: ui/views/controls/native/native_view_host_aura.cc

Issue 27768003: aura: Fix NativeViewHostAura non fast resize clipping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/controls/native/native_view_host_aura_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/controls/native/native_view_host_aura.h" 5 #include "ui/views/controls/native/native_view_host_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/focus_manager.h" 8 #include "ui/aura/focus_manager.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/gfx/safe_integer_conversions.h" 10 #include "ui/gfx/safe_integer_conversions.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if (host_->native_view()) { 75 if (host_->native_view()) {
76 host_->native_view()->Hide(); 76 host_->native_view()->Hide();
77 RemoveClippingWindow(); 77 RemoveClippingWindow();
78 if (host_->native_view()->parent()) 78 if (host_->native_view()->parent())
79 host_->native_view()->parent()->RemoveChild(host_->native_view()); 79 host_->native_view()->parent()->RemoveChild(host_->native_view());
80 } 80 }
81 } 81 }
82 82
83 void NativeViewHostAura::InstallClip(int x, int y, int w, int h) { 83 void NativeViewHostAura::InstallClip(int x, int y, int w, int h) {
84 installed_clip_ = true; 84 installed_clip_ = true;
85 clip_rect_ = gfx::Rect(x + orig_bounds_.origin().x(), 85 clip_rect_ = gfx::Rect(x + orig_bounds_.x(),
86 y + orig_bounds_.origin().y(), 86 y + orig_bounds_.y(),
87 w, 87 w,
88 h); 88 h);
89 UpdateClippingWindow(); 89 UpdateClippingWindow();
90 clipping_window_.layer()->SetMasksToBounds(true); 90 clipping_window_.layer()->SetMasksToBounds(true);
91 } 91 }
92 92
93 bool NativeViewHostAura::HasInstalledClip() { 93 bool NativeViewHostAura::HasInstalledClip() {
94 return installed_clip_; 94 return installed_clip_;
95 } 95 }
96 96
97 void NativeViewHostAura::UninstallClip() { 97 void NativeViewHostAura::UninstallClip() {
98 if (installed_clip_ == false) 98 if (installed_clip_ == false)
99 return; 99 return;
100 installed_clip_ = false; 100 installed_clip_ = false;
101 clipping_window_.layer()->SetMasksToBounds(false); 101 clipping_window_.layer()->SetMasksToBounds(false);
102 } 102 }
103 103
104 void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) { 104 void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) {
105 if (host_->fast_resize()) { 105 if (host_->fast_resize()) {
106 UninstallClip(); 106 gfx::Rect native_view_bounds = host_->native_view()->bounds();
107 InstallClip(x - orig_bounds_.origin().x(), 107 gfx::Point native_view_origin =
108 y - orig_bounds_.origin().y(), 108 CalculateNativeViewOrigin(clipping_window_.bounds(),
109 native_view_bounds);
110 orig_bounds_ = gfx::Rect(x + native_view_origin.x(),
111 y + native_view_origin.y(),
112 native_view_bounds.width(),
113 native_view_bounds.height());
114
115 InstallClip(x - orig_bounds_.x(),
116 y - orig_bounds_.y(),
109 w, 117 w,
110 h); 118 h);
111 } else { 119 } else {
112 clip_rect_.Offset(x - orig_bounds_.origin().x(), 120 clip_rect_.Offset(x - orig_bounds_.x(), y - orig_bounds_.y());
113 y - orig_bounds_.origin().y());
114 orig_bounds_ = gfx::Rect(x, y, w, h); 121 orig_bounds_ = gfx::Rect(x, y, w, h);
115 UpdateClippingWindow(); 122 UpdateClippingWindow();
116 } 123 }
117 host_->native_view()->Show(); 124 host_->native_view()->Show();
118 } 125 }
119 126
120 void NativeViewHostAura::HideWidget() { 127 void NativeViewHostAura::HideWidget() {
121 host_->native_view()->Hide(); 128 host_->native_view()->Hide();
122 } 129 }
123 130
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 clipping_window_.RemoveChild(host_->native_view()); 188 clipping_window_.RemoveChild(host_->native_view());
182 } 189 }
183 host_->native_view()->SetBounds(clipping_window_.bounds()); 190 host_->native_view()->SetBounds(clipping_window_.bounds());
184 } 191 }
185 clipping_window_.Hide(); 192 clipping_window_.Hide();
186 if (clipping_window_.parent()) 193 if (clipping_window_.parent())
187 clipping_window_.parent()->RemoveChild(&clipping_window_); 194 clipping_window_.parent()->RemoveChild(&clipping_window_);
188 } 195 }
189 196
190 void NativeViewHostAura::UpdateClippingWindow() { 197 void NativeViewHostAura::UpdateClippingWindow() {
191 if (installed_clip_) { 198 if (!installed_clip_)
192 clipping_window_.SetBounds(clip_rect_); 199 clip_rect_ = orig_bounds_;
193 gfx::Rect native_view_bounds = host_->native_view()->bounds();
194 gfx::Point native_view_origin =
195 CalculateNativeViewOrigin(clipping_window_.bounds(),
196 native_view_bounds);
197 200
198 native_view_bounds.set_origin(native_view_origin); 201 clipping_window_.SetBounds(clip_rect_);
199 host_->native_view()->SetBounds(native_view_bounds); 202
200 } else { 203 gfx::Rect native_view_bounds = orig_bounds_;
201 clip_rect_ = orig_bounds_; 204 native_view_bounds.Offset(-clip_rect_.x(), -clip_rect_.y());
202 clipping_window_.SetBounds(orig_bounds_); 205 host_->native_view()->SetBounds(native_view_bounds);
203 host_->native_view()->SetBounds(gfx::Rect(orig_bounds_.size()));
204 }
205 } 206 }
206 207
207 } // namespace views 208 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/native/native_view_host_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698