Index: ui/aura/window.cc |
diff --git a/ui/aura/window.cc b/ui/aura/window.cc |
index 3fe502797e0ccf5d30fda8393f2b91c4d6605f63..43d5955d4ab8e1833af88082647cf2851b4def3e 100644 |
--- a/ui/aura/window.cc |
+++ b/ui/aura/window.cc |
@@ -40,21 +40,6 @@ namespace aura { |
namespace { |
-ui::LayerType WindowLayerTypeToUILayerType(WindowLayerType window_layer_type) { |
- switch (window_layer_type) { |
- case WINDOW_LAYER_NONE: |
- break; |
- case WINDOW_LAYER_NOT_DRAWN: |
- return ui::LAYER_NOT_DRAWN; |
- case WINDOW_LAYER_TEXTURED: |
- return ui::LAYER_TEXTURED; |
- case WINDOW_LAYER_SOLID_COLOR: |
- return ui::LAYER_SOLID_COLOR; |
- } |
- NOTREACHED(); |
- return ui::LAYER_NOT_DRAWN; |
-} |
- |
// Used when searching for a Window to stack relative to. |
template <class T> |
T IteratorForDirectionBegin(aura::Window* window); |
@@ -217,12 +202,9 @@ Window::Window(WindowDelegate* delegate) |
} |
Window::~Window() { |
- // |layer()| can be NULL during tests, or if this Window is layerless. |
- if (layer()) { |
- if (layer()->owner() == this) |
- layer()->CompleteAllAnimations(); |
- layer()->SuppressPaint(); |
- } |
+ if (layer()->owner() == this) |
+ layer()->CompleteAllAnimations(); |
+ layer()->SuppressPaint(); |
// Let the delegate know we're in the processing of destroying. |
if (delegate_) |
@@ -278,23 +260,18 @@ Window::~Window() { |
} |
prop_map_.clear(); |
- // If we have layer it will either be destroyed by |layer_owner_|'s dtor, or |
- // by whoever acquired it. We don't have a layer if Init() wasn't invoked or |
- // we are layerless. |
- if (layer()) |
- layer()->set_delegate(NULL); |
+ // The layer will either be destroyed by |layer_owner_|'s dtor, or by whoever |
+ // acquired it. |
+ layer()->set_delegate(NULL); |
DestroyLayer(); |
} |
-void Window::Init(WindowLayerType window_layer_type) { |
- if (window_layer_type != WINDOW_LAYER_NONE) { |
- SetLayer(new ui::Layer(WindowLayerTypeToUILayerType(window_layer_type))); |
- layer()->SetVisible(false); |
- layer()->set_delegate(this); |
- UpdateLayerName(); |
- layer()->SetFillsBoundsOpaquely(!transparent_); |
- } |
- |
+void Window::Init(ui::LayerType layer_type) { |
+ SetLayer(new ui::Layer(layer_type)); |
+ layer()->SetVisible(false); |
+ layer()->set_delegate(this); |
+ UpdateLayerName(); |
+ layer()->SetFillsBoundsOpaquely(!transparent_); |
Env::GetInstance()->NotifyWindowInitialized(this); |
} |
@@ -306,7 +283,6 @@ void Window::SetType(ui::wm::WindowType type) { |
void Window::SetName(const std::string& name) { |
name_ = name; |
- |
if (layer()) |
UpdateLayerName(); |
} |
@@ -325,8 +301,7 @@ void Window::SetTransparent(bool transparent) { |
} |
void Window::SetFillsBoundsCompletely(bool fills_bounds) { |
- if (layer()) |
- layer()->SetFillsBoundsCompletely(fills_bounds); |
+ layer()->SetFillsBoundsCompletely(fills_bounds); |
} |
Window* Window::GetRootWindow() { |
@@ -349,13 +324,11 @@ const WindowTreeHost* Window::GetHost() const { |
} |
void Window::Show() { |
- if (layer()) { |
- DCHECK_EQ(visible_, layer()->GetTargetVisibility()); |
- // It is not allowed that a window is visible but the layers alpha is fully |
- // transparent since the window would still be considered to be active but |
- // could not be seen. |
- DCHECK(!(visible_ && layer()->GetTargetOpacity() == 0.0f)); |
- } |
+ DCHECK_EQ(visible_, layer()->GetTargetVisibility()); |
+ // It is not allowed that a window is visible but the layers alpha is fully |
+ // transparent since the window would still be considered to be active but |
+ // could not be seen. |
+ DCHECK_IMPLIES(visible_, layer()->GetTargetOpacity() > 0.0f); |
SetVisible(true); |
} |
@@ -490,17 +463,7 @@ gfx::Rect Window::GetTargetBounds() const { |
} |
void Window::SchedulePaintInRect(const gfx::Rect& rect) { |
- if (!layer() && parent_) { |
- // Notification of paint scheduled happens for the window with a layer. |
- gfx::Rect parent_rect(bounds().size()); |
- parent_rect.Intersect(rect); |
- if (!parent_rect.IsEmpty()) { |
- parent_rect.Offset(bounds().origin().OffsetFromOrigin()); |
- parent_->SchedulePaintInRect(parent_rect); |
- } |
- } else if (layer()) { |
- layer()->SchedulePaint(rect); |
- } |
+ layer()->SchedulePaint(rect); |
} |
void Window::StackChildAtTop(Window* child) { |
@@ -788,8 +751,7 @@ bool Window::HasCapture() { |
} |
void Window::SuppressPaint() { |
- if (layer()) |
- layer()->SuppressPaint(); |
+ layer()->SuppressPaint(); |
} |
// {Set,Get,Clear}Property are implemented in window_property.h. |
@@ -942,7 +904,7 @@ void Window::SetVisible(bool visible) { |
client::GetVisibilityClient(this); |
if (visibility_client) |
visibility_client->UpdateLayerVisibility(this, visible); |
- else if (layer()) |
+ else |
layer()->SetVisible(visible); |
visible_ = visible; |
SchedulePaint(); |
@@ -962,21 +924,6 @@ void Window::SchedulePaint() { |
void Window::Paint(gfx::Canvas* canvas) { |
if (delegate_) |
delegate_->OnPaint(canvas); |
- PaintLayerlessChildren(canvas); |
-} |
- |
-void Window::PaintLayerlessChildren(gfx::Canvas* canvas) { |
- for (size_t i = 0, count = children_.size(); i < count; ++i) { |
- Window* child = children_[i]; |
- if (!child->layer() && child->visible_) { |
- gfx::ScopedCanvas scoped_canvas(canvas); |
- canvas->ClipRect(child->bounds()); |
- if (!canvas->IsClipEmpty()) { |
- canvas->Translate(child->bounds().OffsetFromOrigin()); |
- child->Paint(canvas); |
- } |
- } |
- } |
} |
Window* Window::GetWindowForPoint(const gfx::Point& local_point, |
@@ -1344,15 +1291,12 @@ void Window::NotifyAncestorWindowTransformed(Window* source) { |
} |
void Window::OnWindowBoundsChanged(const gfx::Rect& old_bounds) { |
- if (layer()) { |
- bounds_ = layer()->bounds(); |
- if (parent_ && !parent_->layer()) { |
- gfx::Vector2d offset; |
- aura::Window* ancestor_with_layer = |
- parent_->GetAncestorWithLayer(&offset); |
- if (ancestor_with_layer) |
- bounds_.Offset(-offset); |
- } |
+ bounds_ = layer()->bounds(); |
+ if (parent_ && !parent_->layer()) { |
+ gfx::Vector2d offset; |
+ aura::Window* ancestor_with_layer = parent_->GetAncestorWithLayer(&offset); |
+ if (ancestor_with_layer) |
+ bounds_.Offset(-offset); |
} |
if (layout_manager_) |