| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 bool RootView::IsVisibleInRootView() const { | 149 bool RootView::IsVisibleInRootView() const { |
| 150 return IsVisible(); | 150 return IsVisible(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 std::string RootView::GetClassName() const { | 153 std::string RootView::GetClassName() const { |
| 154 return kViewClassName; | 154 return kViewClassName; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void RootView::SchedulePaintInRect(const gfx::Rect& rect) { | 157 void RootView::SchedulePaintInRect(const gfx::Rect& rect) { |
| 158 MarkLayerDirty(); | |
| 159 SchedulePaintInternal(rect); | |
| 160 } | |
| 161 | |
| 162 void RootView::SchedulePaintInternal(const gfx::Rect& rect) { | |
| 163 gfx::Rect xrect = ConvertRectToParent(rect); | 158 gfx::Rect xrect = ConvertRectToParent(rect); |
| 164 gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); | 159 gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); |
| 165 if (!invalid_rect.IsEmpty()) | 160 if (!invalid_rect.IsEmpty()) |
| 166 widget_->SchedulePaintInRect(invalid_rect); | 161 widget_->SchedulePaintInRect(invalid_rect); |
| 167 } | 162 } |
| 168 | 163 |
| 169 bool RootView::OnMousePressed(const MouseEvent& event) { | 164 bool RootView::OnMousePressed(const MouseEvent& event) { |
| 170 MouseEvent e(event, this); | 165 MouseEvent e(event, this); |
| 171 UpdateCursor(e); | 166 UpdateCursor(e); |
| 172 SetMouseLocationAndFlags(e); | 167 SetMouseLocationAndFlags(e); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 418 } |
| 424 | 419 |
| 425 const ui::Compositor* RootView::GetCompositor() const { | 420 const ui::Compositor* RootView::GetCompositor() const { |
| 426 return widget_->GetCompositor(); | 421 return widget_->GetCompositor(); |
| 427 } | 422 } |
| 428 | 423 |
| 429 ui::Compositor* RootView::GetCompositor() { | 424 ui::Compositor* RootView::GetCompositor() { |
| 430 return widget_->GetCompositor(); | 425 return widget_->GetCompositor(); |
| 431 } | 426 } |
| 432 | 427 |
| 433 void RootView::MarkLayerDirty() { | 428 void RootView::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, |
| 434 View::MarkLayerDirty(); | 429 ui::Layer** layer_parent) { |
| 430 View::CalculateOffsetToAncestorWithLayer(offset, layer_parent); |
| 435 if (!layer()) | 431 if (!layer()) |
| 436 widget_->MarkLayerDirty(); | 432 widget_->CalculateOffsetToAncestorWithLayer(offset, layer_parent); |
| 437 } | |
| 438 | |
| 439 void RootView::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, | |
| 440 View** ancestor) { | |
| 441 View::CalculateOffsetToAncestorWithLayer(offset, ancestor); | |
| 442 if (!layer()) | |
| 443 widget_->CalculateOffsetToAncestorWithLayer(offset, ancestor); | |
| 444 } | 433 } |
| 445 | 434 |
| 446 //////////////////////////////////////////////////////////////////////////////// | 435 //////////////////////////////////////////////////////////////////////////////// |
| 447 // RootView, private: | 436 // RootView, private: |
| 448 | 437 |
| 449 // Input ----------------------------------------------------------------------- | 438 // Input ----------------------------------------------------------------------- |
| 450 | 439 |
| 451 void RootView::UpdateCursor(const MouseEvent& event) { | 440 void RootView::UpdateCursor(const MouseEvent& event) { |
| 452 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) { | 441 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) { |
| 453 View* v = GetEventHandlerForPoint(event.location()); | 442 View* v = GetEventHandlerForPoint(event.location()); |
| 454 widget_->SetCursor(v->GetCursor(MouseEvent(event, this, v))); | 443 widget_->SetCursor(v->GetCursor(MouseEvent(event, this, v))); |
| 455 } | 444 } |
| 456 } | 445 } |
| 457 | 446 |
| 458 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { | 447 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { |
| 459 last_mouse_event_flags_ = event.flags(); | 448 last_mouse_event_flags_ = event.flags(); |
| 460 last_mouse_event_x_ = event.x(); | 449 last_mouse_event_x_ = event.x(); |
| 461 last_mouse_event_y_ = event.y(); | 450 last_mouse_event_y_ = event.y(); |
| 462 } | 451 } |
| 463 | 452 |
| 464 } // namespace internal | 453 } // namespace internal |
| 465 } // namespace views | 454 } // namespace views |
| OLD | NEW |