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

Side by Side Diff: ui/views/attributes.cc

Issue 2230913003: Experimental alignment layout manager using a property on the views Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed AlignAttribute and associated types to FillAttribute Created 4 years, 2 months 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
« no previous file with comments | « ui/views/attributes.h ('k') | ui/views/attributes_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
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/views/attributes.h"
6
7 namespace views {
8
9 AttributeId Attribute::Identity() const {
10 return GetAttributeId<Attribute>();
11 }
12
13 AttributeContainer::AttributeContainer(View* view) : view_(view) {}
14
15 AttributeContainer::AttributeContainer() : view_(nullptr) {}
16
17 AttributeContainer::~AttributeContainer() {}
18
19 bool AttributeContainer::Remove(const AttributeId attributeId) {
20 AttributeMap::const_iterator it = map_.find(attributeId);
21 bool canRemove = it != map_.cend();
22 if (canRemove) {
23 Notification(Attribute::NotifyType::AttributeRemoved, it->second.get());
24 it->second.get()->RemovedFromView();
25 map_.erase(it);
26 }
27 return canRemove;
28 }
29
30 void AttributeContainer::Notification(Attribute::NotifyType type,
31 Attribute* attribute) {
32 for (AttributeMap::const_iterator a = map_.cbegin(); a != map_.cend(); a++) {
33 Attribute* attr = a->second.get();
34 if (attr != attribute)
35 attr->Notification(type, attribute);
36 }
37 }
38
39 void AttributeContainer::ViewNotification(View* view) {
40 for (AttributeMap::const_iterator a = map_.cbegin(); a != map_.cend(); a++)
41 a->second.get()->ViewNotification(view);
42 }
43
44 AttributeIdFactory::AttributeIdMap AttributeIdFactory::map_;
45
46 AttributeId AttributeIdFactory::GetAttributeId(const char* typeName) {
47 std::string type_name = typeName;
48 AttributeIdMap::const_iterator it = map_.find(type_name);
49 if (it == map_.cend()) {
50 std::unique_ptr<AttributeIdHolder> holder =
51 base::WrapUnique(new AttributeIdHolder());
52 it = map_.insert(AttributeIdMap::value_type(type_name, std::move(holder)))
53 .first;
54 }
55 return it->second.get()->GetAttributeId();
56 }
57
58 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/attributes.h ('k') | ui/views/attributes_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698