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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.h

Issue 2708543003: Clean up the getLayoutSVGResource*ById helpers (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | third_party/WebKit/Source/core/layout/svg/SVGLayoutTreeAsText.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // crawls. 106 // crawls.
107 unsigned m_invalidationMask : 8; 107 unsigned m_invalidationMask : 8;
108 108
109 unsigned m_registered : 1; 109 unsigned m_registered : 1;
110 unsigned m_isInvalidating : 1; 110 unsigned m_isInvalidating : 1;
111 // 22 padding bits available 111 // 22 padding bits available
112 112
113 HashSet<LayoutObject*> m_clients; 113 HashSet<LayoutObject*> m_clients;
114 }; 114 };
115 115
116 inline LayoutSVGResourceContainer* getLayoutSVGResourceContainerById(
117 TreeScope& treeScope,
118 const AtomicString& id) {
119 if (id.isEmpty())
120 return nullptr;
121
122 if (LayoutSVGResourceContainer* layoutResource =
123 treeScope.ensureSVGTreeScopedResources().resourceById(id))
124 return layoutResource;
125
126 return nullptr;
127 }
128
129 template <typename Layout> 116 template <typename Layout>
130 Layout* getLayoutSVGResourceById(TreeScope& treeScope, const AtomicString& id) { 117 Layout* getLayoutSVGResourceById(SVGTreeScopeResources& treeScopeResources,
118 const AtomicString& id) {
131 if (LayoutSVGResourceContainer* container = 119 if (LayoutSVGResourceContainer* container =
132 getLayoutSVGResourceContainerById(treeScope, id)) { 120 treeScopeResources.resourceById(id)) {
133 if (container->resourceType() == Layout::s_resourceType) 121 if (container->resourceType() == Layout::s_resourceType)
134 return static_cast<Layout*>(container); 122 return static_cast<Layout*>(container);
135 } 123 }
136 return nullptr; 124 return nullptr;
137 } 125 }
138 126
139 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGResourceContainer, 127 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGResourceContainer,
140 isSVGResourceContainer()); 128 isSVGResourceContainer());
141 129
142 #define DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ 130 #define DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \
143 DEFINE_TYPE_CASTS(thisType, LayoutSVGResourceContainer, resource, \ 131 DEFINE_TYPE_CASTS(thisType, LayoutSVGResourceContainer, resource, \
144 resource->resourceType() == typeName, \ 132 resource->resourceType() == typeName, \
145 resource.resourceType() == typeName) 133 resource.resourceType() == typeName)
146 134
147 } // namespace blink 135 } // namespace blink
148 136
149 #endif 137 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/svg/SVGLayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698