Index: views/view.cc |
=================================================================== |
--- views/view.cc (revision 86084) |
+++ views/view.cc (working copy) |
@@ -99,9 +99,9 @@ |
group_(-1), |
focusable_(false), |
accessibility_focusable_(false), |
- is_parent_owned_(true), |
+ parent_owned_(true), |
parent_(NULL), |
- is_visible_(true), |
+ visible_(true), |
registered_for_visible_bounds_notification_(false), |
clip_x_(0.0), |
clip_y_(0.0), |
@@ -126,8 +126,8 @@ |
int c = static_cast<int>(children_.size()); |
while (--c >= 0) { |
- children_[c]->SetParent(NULL); |
- if (children_[c]->IsParentOwned()) |
+ children_[c]->parent_ = NULL; |
+ if (children_[c]->parent_owned()) |
delete children_[c]; |
} |
@@ -148,6 +148,15 @@ |
return const_cast<Widget*>(const_cast<const View*>(this)->GetWidget()); |
} |
+const Window* View::GetWindow() const { |
+ const Widget* widget = GetWidget(); |
+ return widget ? widget->GetContainingWindow() : NULL; |
+} |
+ |
+Window* View::GetWindow() { |
+ return const_cast<Window*>(const_cast<const View*>(this)->GetWindow()); |
+} |
+ |
void View::AddChildView(View* view) { |
AddChildViewAt(view, child_count()); |
} |
@@ -164,7 +173,7 @@ |
// Let's insert the view. |
children_.insert(children_.begin() + index, view); |
- view->SetParent(this); |
+ view->parent_ = this; |
for (View* p = this; p; p = p->parent()) |
p->ViewHierarchyChangedImpl(false, true, this, view); |
@@ -213,17 +222,6 @@ |
} |
// TODO(beng): remove |
-const Window* View::GetWindow() const { |
- const Widget* widget = GetWidget(); |
- return widget ? widget->GetContainingWindow() : NULL; |
-} |
- |
-// TODO(beng): remove |
-Window* View::GetWindow() { |
- return const_cast<Window*>(const_cast<const View*>(this)->GetWindow()); |
-} |
- |
-// TODO(beng): remove |
bool View::ContainsNativeView(gfx::NativeView native_view) const { |
for (int i = 0, count = child_count(); i < count; ++i) { |
if (GetChildViewAt(i)->ContainsNativeView(native_view)) |
@@ -352,45 +350,6 @@ |
return GetPreferredSize().height(); |
} |
-void View::SetVisible(bool flag) { |
- if (flag != is_visible_) { |
- // If the tab is currently visible, schedule paint to |
- // refresh parent |
- if (IsVisible()) |
- SchedulePaint(); |
- else |
- ResetTexture(); |
- |
- is_visible_ = flag; |
- |
- // This notifies all sub-views recursively. |
- PropagateVisibilityNotifications(this, flag); |
- |
- // If we are newly visible, schedule paint. |
- if (IsVisible()) |
- SchedulePaint(); |
- } |
-} |
- |
-bool View::IsVisible() const { |
- return is_visible_; |
-} |
- |
-bool View::IsVisibleInRootView() const { |
- return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false; |
-} |
- |
-void View::SetEnabled(bool state) { |
- if (enabled_ != state) { |
- enabled_ = state; |
- SchedulePaint(); |
- } |
-} |
- |
-bool View::IsEnabled() const { |
- return enabled_; |
-} |
- |
// Transformations ------------------------------------------------------------- |
const ui::Transform& View::GetTransform() const { |
@@ -494,6 +453,41 @@ |
// Attributes ------------------------------------------------------------------ |
+void View::SetVisible(bool flag) { |
+ if (flag != visible_) { |
+ // If the tab is currently visible, schedule paint to |
+ // refresh parent |
+ if (visible()) |
+ SchedulePaint(); |
+ else |
+ ResetTexture(); |
+ |
+ visible_ = flag; |
+ |
+ // This notifies all sub-views recursively. |
+ PropagateVisibilityNotifications(this, flag); |
+ |
+ // If we are newly visible, schedule paint. |
+ if (visible()) |
+ SchedulePaint(); |
+ } |
+} |
+ |
+bool View::IsVisibleInRootView() const { |
+ return visible() && parent() ? parent()->IsVisibleInRootView() : false; |
+} |
+ |
+bool View::IsEnabled() const { |
+ return enabled_; |
+} |
+ |
+void View::SetEnabled(bool enabled) { |
+ if (enabled_ != enabled) { |
+ enabled_ = enabled; |
+ SchedulePaint(); |
+ } |
+} |
+ |
std::string View::GetClassName() const { |
return kViewClassName; |
} |
@@ -522,39 +516,26 @@ |
return const_cast<View*>(const_cast<const View*>(this)->GetViewByID(id)); |
} |
-void View::SetID(int id) { |
- id_ = id; |
+void View::set_group(int group) { |
+ DCHECK(group_ == -1 || group_ == group); |
+ group_ = group; |
} |
-int View::GetID() const { |
- return id_; |
-} |
- |
-void View::SetGroup(int gid) { |
- // Don't change the group id once it's set. |
- DCHECK(group_ == -1 || group_ == gid); |
- group_ = gid; |
-} |
- |
-int View::GetGroup() const { |
- return group_; |
-} |
- |
bool View::IsGroupFocusTraversable() const { |
return true; |
} |
-void View::GetViewsWithGroup(int group_id, std::vector<View*>* out) { |
- if (group_ == group_id) |
+void View::GetViewsInGroup(int group, std::vector<View*>* out) { |
+ if (group_ == group) |
out->push_back(this); |
for (int i = 0, count = child_count(); i < count; ++i) |
- GetChildViewAt(i)->GetViewsWithGroup(group_id, out); |
+ GetChildViewAt(i)->GetViewsInGroup(group, out); |
} |
-View* View::GetSelectedViewForGroup(int group_id) { |
+View* View::GetSelectedViewForGroup(int group) { |
std::vector<View*> views; |
- GetWidget()->GetRootView()->GetViewsWithGroup(group_id, &views); |
+ GetWidget()->GetRootView()->GetViewsInGroup(group, &views); |
return views.empty() ? NULL : views[0]; |
} |
@@ -612,7 +593,7 @@ |
} |
void View::SchedulePaintInRect(const gfx::Rect& rect) { |
- if (!IsVisible()) |
+ if (!visible()) |
return; |
if (parent_) { |
@@ -625,7 +606,7 @@ |
} |
void View::Paint(gfx::Canvas* canvas) { |
- if (!IsVisible()) |
+ if (!visible()) |
return; |
ScopedCanvas scoped_canvas(NULL); |
@@ -746,7 +727,7 @@ |
// tightly encloses the specified point. |
for (int i = child_count() - 1; i >= 0; --i) { |
View* child = GetChildViewAt(i); |
- if (!child->IsVisible()) |
+ if (!child->visible()) |
continue; |
gfx::Point point_in_child_coords(point); |
@@ -917,10 +898,6 @@ |
next_focusable_view_ = view; |
} |
-void View::SetFocusable(bool focusable) { |
- focusable_ = focusable; |
-} |
- |
bool View::IsFocusableInRootView() const { |
return IsFocusable() && IsVisibleInRootView(); |
} |
@@ -1150,7 +1127,7 @@ |
} |
#else |
void View::PaintComposite() { |
- if (!IsVisible()) |
+ if (!visible()) |
return; |
if (texture_.get()) { |
@@ -1165,7 +1142,7 @@ |
} |
void View::PaintToTexture(const gfx::Rect& dirty_region) { |
- if (!IsVisible()) |
+ if (!visible()) |
return; |
if (ShouldPaintToTexture() && texture_needs_updating_) { |
@@ -1212,7 +1189,7 @@ |
// Focus ----------------------------------------------------------------------- |
bool View::IsFocusable() const { |
- return focusable_ && IsEnabled() && IsVisible(); |
+ return focusable_ && IsEnabled() && visible(); |
} |
void View::OnFocus() { |
@@ -1319,9 +1296,9 @@ |
UnregisterChildrenForVisibleBoundsNotification(view); |
view->ResetTexture(); |
view->PropagateRemoveNotifications(this); |
- view->SetParent(NULL); |
+ view->parent_ = NULL; |
- if (delete_removed_view && view->IsParentOwned()) |
+ if (delete_removed_view && view->parent_owned()) |
view_to_be_deleted.reset(view); |
children_.erase(i); |
@@ -1334,11 +1311,6 @@ |
layout_manager_->ViewRemoved(this, view); |
} |
-void View::SetParent(View* parent) { |
- if (parent != parent_) |
- parent_ = parent; |
-} |
- |
void View::PropagateRemoveNotifications(View* parent) { |
for (int i = 0, count = child_count(); i < count; ++i) |
GetChildViewAt(i)->PropagateRemoveNotifications(parent); |
@@ -1410,7 +1382,7 @@ |
canvas_.reset(gfx::Canvas::CreateCanvas(width(), height(), false)); |
#endif |
- if (IsVisible()) { |
+ if (visible()) { |
if (parent_) { |
// Paint the old bounds. |
if (base::i18n::IsRTL()) { |