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

Side by Side Diff: ui/aura/window.cc

Issue 102313002: Wires up painting of layerless children (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 7 years 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 | « ui/aura/window.h ('k') | ui/aura/window_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/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/aura/window_delegate.h" 25 #include "ui/aura/window_delegate.h"
26 #include "ui/aura/window_observer.h" 26 #include "ui/aura/window_observer.h"
27 #include "ui/aura/window_tracker.h" 27 #include "ui/aura/window_tracker.h"
28 #include "ui/aura/window_tree_host.h" 28 #include "ui/aura/window_tree_host.h"
29 #include "ui/compositor/compositor.h" 29 #include "ui/compositor/compositor.h"
30 #include "ui/compositor/layer.h" 30 #include "ui/compositor/layer.h"
31 #include "ui/events/event_target_iterator.h" 31 #include "ui/events/event_target_iterator.h"
32 #include "ui/gfx/animation/multi_animation.h" 32 #include "ui/gfx/animation/multi_animation.h"
33 #include "ui/gfx/canvas.h" 33 #include "ui/gfx/canvas.h"
34 #include "ui/gfx/path.h" 34 #include "ui/gfx/path.h"
35 #include "ui/gfx/scoped_canvas.h"
35 #include "ui/gfx/screen.h" 36 #include "ui/gfx/screen.h"
36 37
37 namespace aura { 38 namespace aura {
38 39
39 namespace { 40 namespace {
40 41
41 WindowLayerType UILayerTypeToWindowLayerType(ui::LayerType layer_type) { 42 WindowLayerType UILayerTypeToWindowLayerType(ui::LayerType layer_type) {
42 switch (layer_type) { 43 switch (layer_type) {
43 case ui::LAYER_NOT_DRAWN: 44 case ui::LAYER_NOT_DRAWN:
44 return WINDOW_LAYER_NOT_DRAWN; 45 return WINDOW_LAYER_NOT_DRAWN;
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 } 823 }
823 824
824 // If we are currently not the layer's delegate, we will not get bounds 825 // If we are currently not the layer's delegate, we will not get bounds
825 // changed notification from the layer (this typically happens after animating 826 // changed notification from the layer (this typically happens after animating
826 // hidden). We must notify ourselves. 827 // hidden). We must notify ourselves.
827 if (!layer_ || layer_->delegate() != this) 828 if (!layer_ || layer_->delegate() != this)
828 OnWindowBoundsChanged(old_bounds, ContainsMouse()); 829 OnWindowBoundsChanged(old_bounds, ContainsMouse());
829 } 830 }
830 831
831 void Window::SetVisible(bool visible) { 832 void Window::SetVisible(bool visible) {
832 if (visible == layer_->GetTargetVisibility()) 833 if ((layer_ && visible == layer_->GetTargetVisibility()) ||
834 (!layer_ && visible == visible_))
833 return; // No change. 835 return; // No change.
834 836
835 FOR_EACH_OBSERVER(WindowObserver, observers_, 837 FOR_EACH_OBSERVER(WindowObserver, observers_,
836 OnWindowVisibilityChanging(this, visible)); 838 OnWindowVisibilityChanging(this, visible));
837 839
838 WindowEventDispatcher* dispatcher = GetDispatcher(); 840 WindowEventDispatcher* dispatcher = GetDispatcher();
839 if (dispatcher) 841 if (dispatcher)
840 dispatcher->DispatchMouseExitToHidingWindow(this); 842 dispatcher->DispatchMouseExitToHidingWindow(this);
841 843
842 client::VisibilityClient* visibility_client = 844 client::VisibilityClient* visibility_client =
843 client::GetVisibilityClient(this); 845 client::GetVisibilityClient(this);
844 if (visibility_client) 846 if (visibility_client)
845 visibility_client->UpdateLayerVisibility(this, visible); 847 visibility_client->UpdateLayerVisibility(this, visible);
846 else 848 else if (layer_)
847 layer_->SetVisible(visible); 849 layer_->SetVisible(visible);
848 visible_ = visible; 850 visible_ = visible;
849 SchedulePaint(); 851 SchedulePaint();
850 if (parent_ && parent_->layout_manager_) 852 if (parent_ && parent_->layout_manager_)
851 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); 853 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible);
852 854
853 if (delegate_) 855 if (delegate_)
854 delegate_->OnWindowTargetVisibilityChanged(visible); 856 delegate_->OnWindowTargetVisibilityChanged(visible);
855 857
856 NotifyWindowVisibilityChanged(this, visible); 858 NotifyWindowVisibilityChanged(this, visible);
857 859
858 if (dispatcher) 860 if (dispatcher)
859 dispatcher->OnWindowVisibilityChanged(this, visible); 861 dispatcher->OnWindowVisibilityChanged(this, visible);
860 } 862 }
861 863
862 void Window::SchedulePaint() { 864 void Window::SchedulePaint() {
863 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); 865 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height()));
864 } 866 }
865 867
868 void Window::Paint(gfx::Canvas* canvas) {
869 if (delegate_)
870 delegate_->OnPaint(canvas);
871 PaintLayerlessChildren(canvas);
872 }
873
874 void Window::PaintLayerlessChildren(gfx::Canvas* canvas) {
875 for (size_t i = 0, count = children_.size(); i < count; ++i) {
876 Window* child = children_[i];
877 if (!child->layer_ && child->visible_) {
878 gfx::ScopedCanvas scoped_canvas(canvas);
879 if (canvas->ClipRect(child->bounds())) {
880 canvas->Translate(child->bounds().OffsetFromOrigin());
881 child->Paint(canvas);
882 }
883 }
884 }
885 }
886
866 Window* Window::GetWindowForPoint(const gfx::Point& local_point, 887 Window* Window::GetWindowForPoint(const gfx::Point& local_point,
867 bool return_tightest, 888 bool return_tightest,
868 bool for_event_handling) { 889 bool for_event_handling) {
869 if (!IsVisible()) 890 if (!IsVisible())
870 return NULL; 891 return NULL;
871 892
872 if ((for_event_handling && !HitTest(local_point)) || 893 if ((for_event_handling && !HitTest(local_point)) ||
873 (!for_event_handling && !ContainsPoint(local_point))) 894 (!for_event_handling && !ContainsPoint(local_point)))
874 return NULL; 895 return NULL;
875 896
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 delegate_->OnBoundsChanged(old_bounds, bounds()); 1307 delegate_->OnBoundsChanged(old_bounds, bounds());
1287 FOR_EACH_OBSERVER(WindowObserver, 1308 FOR_EACH_OBSERVER(WindowObserver,
1288 observers_, 1309 observers_,
1289 OnWindowBoundsChanged(this, old_bounds, bounds())); 1310 OnWindowBoundsChanged(this, old_bounds, bounds()));
1290 WindowEventDispatcher* dispatcher = GetDispatcher(); 1311 WindowEventDispatcher* dispatcher = GetDispatcher();
1291 if (dispatcher) 1312 if (dispatcher)
1292 dispatcher->OnWindowBoundsChanged(this, contained_mouse); 1313 dispatcher->OnWindowBoundsChanged(this, contained_mouse);
1293 } 1314 }
1294 1315
1295 void Window::OnPaintLayer(gfx::Canvas* canvas) { 1316 void Window::OnPaintLayer(gfx::Canvas* canvas) {
1296 if (delegate_) 1317 Paint(canvas);
1297 delegate_->OnPaint(canvas);
1298 } 1318 }
1299 1319
1300 base::Closure Window::PrepareForLayerBoundsChange() { 1320 base::Closure Window::PrepareForLayerBoundsChange() {
1301 return base::Bind(&Window::OnWindowBoundsChanged, base::Unretained(this), 1321 return base::Bind(&Window::OnWindowBoundsChanged, base::Unretained(this),
1302 bounds(), ContainsMouse()); 1322 bounds(), ContainsMouse());
1303 } 1323 }
1304 1324
1305 bool Window::CanAcceptEvent(const ui::Event& event) { 1325 bool Window::CanAcceptEvent(const ui::Event& event) {
1306 // The client may forbid certain windows from receiving events at a given 1326 // The client may forbid certain windows from receiving events at a given
1307 // point in time. 1327 // point in time.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 for (const aura::Window* window = this; window; window = window->parent()) { 1403 for (const aura::Window* window = this; window; window = window->parent()) {
1384 if (window->layer_) 1404 if (window->layer_)
1385 return window; 1405 return window;
1386 *offset += window->bounds().OffsetFromOrigin(); 1406 *offset += window->bounds().OffsetFromOrigin();
1387 } 1407 }
1388 *offset = gfx::Vector2d(); 1408 *offset = gfx::Vector2d();
1389 return NULL; 1409 return NULL;
1390 } 1410 }
1391 1411
1392 } // namespace aura 1412 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698