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

Side by Side Diff: third_party/WebKit/Source/core/dom/NodeRareData.cpp

Issue 1962953002: Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs to remove redundant ComputedStyle members Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/dom/NodeRareData.h" 31 #include "core/dom/NodeRareData.h"
32 32
33 #include "bindings/core/v8/ScriptWrappableVisitor.h" 33 #include "bindings/core/v8/ScriptWrappableVisitor.h"
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 #include "core/dom/ElementRareData.h" 35 #include "core/dom/ElementRareData.h"
36 #include "core/frame/FrameHost.h" 36 #include "core/frame/FrameHost.h"
37 #include "core/layout/LayoutObject.h"
37 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 struct SameSizeAsNodeRareData { 42 struct SameSizeAsNodeRareData {
42 void* m_pointer; 43 void* m_pointer;
44 RefPtr<void*> m_refPtr;
43 Member<void*> m_willbeMember[2]; 45 Member<void*> m_willbeMember[2];
44 unsigned m_bitfields; 46 unsigned m_bitfields;
45 }; 47 };
46 48
47 static_assert(sizeof(NodeRareData) == sizeof(SameSizeAsNodeRareData), "NodeRareD ata should stay small"); 49 static_assert(sizeof(NodeRareData) == sizeof(SameSizeAsNodeRareData), "NodeRareD ata should stay small");
48 50
49 DEFINE_TRACE_AFTER_DISPATCH(NodeRareData) 51 DEFINE_TRACE_AFTER_DISPATCH(NodeRareData)
50 { 52 {
51 visitor->trace(m_mutationObserverData); 53 visitor->trace(m_mutationObserverData);
52 // Do not keep empty NodeListsNodeData objects around. 54 // Do not keep empty NodeListsNodeData objects around.
(...skipping 18 matching lines...) Expand all
71 else 73 else
72 traceWrappersAfterDispatch(visitor); 74 traceWrappersAfterDispatch(visitor);
73 } 75 }
74 76
75 DEFINE_TRACE_WRAPPERS_AFTER_DISPATCH(NodeRareData) 77 DEFINE_TRACE_WRAPPERS_AFTER_DISPATCH(NodeRareData)
76 { 78 {
77 visitor->traceWrappers(m_nodeLists); 79 visitor->traceWrappers(m_nodeLists);
78 visitor->traceWrappers(m_mutationObserverData); 80 visitor->traceWrappers(m_mutationObserverData);
79 } 81 }
80 82
83 ComputedStyle* NodeRareData::computedStyle() const
84 {
85 if (m_layoutObject)
86 return m_layoutObject->mutableStyle();
87 return m_computedStyle.get();
88 }
89
90 void NodeRareData::setComputedStyle(PassRefPtr<ComputedStyle> computedStyle)
91 {
92 if (m_layoutObject)
93 m_layoutObject->setStyleInternal(computedStyle);
94 else
95 m_computedStyle = computedStyle;
96 }
97
81 void NodeRareData::finalizeGarbageCollectedObject() 98 void NodeRareData::finalizeGarbageCollectedObject()
82 { 99 {
83 RELEASE_ASSERT(!layoutObject()); 100 RELEASE_ASSERT(!layoutObject());
101 CHECK(!computedStyle());
84 if (m_isElementRareData) 102 if (m_isElementRareData)
85 static_cast<ElementRareData*>(this)->~ElementRareData(); 103 static_cast<ElementRareData*>(this)->~ElementRareData();
86 else 104 else
87 this->~NodeRareData(); 105 this->~NodeRareData();
88 } 106 }
89 107
90 void NodeRareData::incrementConnectedSubframeCount() 108 void NodeRareData::incrementConnectedSubframeCount()
91 { 109 {
92 SECURITY_CHECK((m_connectedFrameCount + 1) <= FrameHost::maxNumberOfFrames); 110 SECURITY_CHECK((m_connectedFrameCount + 1) <= FrameHost::maxNumberOfFrames);
93 ++m_connectedFrameCount; 111 ++m_connectedFrameCount;
94 } 112 }
95 113
96 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow 114 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow
97 static_assert(FrameHost::maxNumberOfFrames < (1 << NodeRareData::ConnectedFrameC ountBits), "Frame limit should fit in rare data count"); 115 static_assert(FrameHost::maxNumberOfFrames < (1 << NodeRareData::ConnectedFrameC ountBits), "Frame limit should fit in rare data count");
98 116
99 } // namespace blink 117 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698