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

Side by Side Diff: Source/core/dom/NodeRareData.h

Issue 201153006: Move element flags from ElementRareData to NodeRareData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased (another ElementFlag added upstream) Created 6 years, 9 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 | « Source/core/dom/ElementRareData.cpp ('k') | Source/core/dom/NodeRareData.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) 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> 3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 { 248 {
249 m_connectedFrameCount += amount; 249 m_connectedFrameCount += amount;
250 } 250 }
251 void decrementConnectedSubframeCount(unsigned amount) 251 void decrementConnectedSubframeCount(unsigned amount)
252 { 252 {
253 ASSERT(m_connectedFrameCount); 253 ASSERT(m_connectedFrameCount);
254 ASSERT(amount <= m_connectedFrameCount); 254 ASSERT(amount <= m_connectedFrameCount);
255 m_connectedFrameCount -= amount; 255 m_connectedFrameCount -= amount;
256 } 256 }
257 257
258 bool hasFlag(ElementFlags mask) const { return m_elementFlags & mask; }
259 void setFlag(ElementFlags mask, bool value) { m_elementFlags = (m_elementFla gs & ~mask) | (-(int32_t)value & mask); }
260 void clearFlag(ElementFlags mask) { m_elementFlags &= ~mask; }
261
262 enum {
263 ConnectedFrameCountBits = 10, // Must fit Page::maxNumberOfFrames.
264 ElementFlagsBits = 17, // Must fit the ElementFlags enumeration.
265 };
266
258 protected: 267 protected:
259 NodeRareData(RenderObject* renderer) 268 NodeRareData(RenderObject* renderer)
260 : NodeRareDataBase(renderer) 269 : NodeRareDataBase(renderer)
261 , m_connectedFrameCount(0) 270 , m_connectedFrameCount(0)
271 , m_elementFlags(0)
262 { } 272 { }
263 273
264 private: 274 private:
265 unsigned m_connectedFrameCount : 10; // Must fit Page::maxNumberOfFrames.
266
267 OwnPtr<NodeListsNodeData> m_nodeLists; 275 OwnPtr<NodeListsNodeData> m_nodeLists;
268 OwnPtr<NodeMutationObserverData> m_mutationObserverData; 276 OwnPtr<NodeMutationObserverData> m_mutationObserverData;
277
278 unsigned m_connectedFrameCount : ConnectedFrameCountBits;
279 unsigned m_elementFlags : ElementFlagsBits;
269 }; 280 };
270 281
271 inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas tList(Node& ownerNode) 282 inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas tList(Node& ownerNode)
272 { 283 {
273 ASSERT(ownerNode.nodeLists() == this); 284 ASSERT(ownerNode.nodeLists() == this);
274 if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_tagCollectionC acheNS.size() != 1) 285 if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_tagCollectionC acheNS.size() != 1)
275 return false; 286 return false;
276 ownerNode.clearNodeLists(); 287 ownerNode.clearNodeLists();
277 return true; 288 return true;
278 } 289 }
279 290
280 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow
281 COMPILE_ASSERT(Page::maxNumberOfFrames < 1024, Frame_limit_should_fit_in_rare_da ta_count);
282
283 } // namespace WebCore 291 } // namespace WebCore
284 292
285 #endif // NodeRareData_h 293 #endif // NodeRareData_h
OLDNEW
« no previous file with comments | « Source/core/dom/ElementRareData.cpp ('k') | Source/core/dom/NodeRareData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698