| Index: ui/views/anchor_attribute.h | 
| diff --git a/ui/views/anchor_attribute.h b/ui/views/anchor_attribute.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..1e690b1f4880d105f1f6cf12f95f706ff9a8d103 | 
| --- /dev/null | 
| +++ b/ui/views/anchor_attribute.h | 
| @@ -0,0 +1,67 @@ | 
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef UI_VIEWS_ANCHOR_ATTRIBUTE_H_ | 
| +#define UI_VIEWS_ANCHOR_ATTRIBUTE_H_ | 
| + | 
| +#include "base/macros.h" | 
| +#include "base/set_template.h" | 
| +#include "ui/gfx/geometry/point.h" | 
| +#include "ui/gfx/geometry/rect.h" | 
| +#include "ui/gfx/geometry/size.h" | 
| +#include "ui/views/attributes.h" | 
| +#include "ui/views/fill_attribute.h" | 
| +#include "ui/views/view.h" | 
| + | 
| +namespace views { | 
| + | 
| +enum class Anchor { | 
| +  // Anchor view's left side to the parent's left side of its content bounds. | 
| +  Left, | 
| +  // Anchor view's top side to the parent's top side of its content bounds. | 
| +  Top, | 
| +  // Anchor view's right side to the parent's right side of its content | 
| +  // bounds. | 
| +  Right, | 
| +  // Anchor view's bottom side to the parent's bottom side of its content | 
| +  // bounds. | 
| +  Bottom, | 
| +}; | 
| + | 
| +using Anchors = base::SetOf<Anchor, Anchor::Bottom>; | 
| + | 
| +struct VIEWS_EXPORT AnchorContent { | 
| +  AnchorContent(); | 
| +  AnchorContent(Anchors anchors); | 
| +  AnchorContent(const AnchorContent& content); | 
| +  static Anchors AnchorFill(Fill fill); | 
| +  gfx::Point& anchorBasis() { return anchor_basis_; } | 
| +  Anchors& anchors() { return anchors_; } | 
| +  gfx::Size& LastParentSize() { return last_parent_size_; } | 
| +  void SetAnchors(Anchors anchors); | 
| +  void SetAttribute(Attribute *attribute) { attribute_ = attribute; } | 
| +  void UpdateAnchorBasis(View *view); | 
| + private: | 
| +  Attribute *attribute_; | 
| +  Anchors anchors_; | 
| +  gfx::Point anchor_basis_; | 
| +  gfx::Size last_parent_size_; | 
| +}; | 
| + | 
| +class VIEWS_EXPORT AnchorAttribute : public CustomAttribute<AnchorContent> { | 
| + public: | 
| +  AnchorAttribute(); | 
| +  AnchorAttribute(Anchors anchors); | 
| +  AnchorAttribute(AnchorContent& content); | 
| +  AttributeId Identity() const override; | 
| +  void Notification(Attribute::NotifyType type, Attribute* attribute) override; | 
| +  void ViewNotification(View *view) override; | 
| +}; | 
| + | 
| +REGISTER_ATTRIBUTE_ID(CustomAttribute<AnchorContent>); | 
| +REGISTER_ATTRIBUTE_ID(AnchorAttribute); | 
| + | 
| +} // namespace views | 
| + | 
| +#endif // UI_VIEWS_ANCHOR_ATTRIBUTE_H_ | 
|  |