| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 return m_computedStyle.get(); |
| 86 } |
| 87 |
| 88 void NodeRareData::setComputedStyle(PassRefPtr<ComputedStyle> computedStyle) |
| 89 { |
| 90 m_computedStyle = computedStyle; |
| 91 } |
| 92 |
| 81 void NodeRareData::finalizeGarbageCollectedObject() | 93 void NodeRareData::finalizeGarbageCollectedObject() |
| 82 { | 94 { |
| 83 RELEASE_ASSERT(!layoutObject()); | 95 RELEASE_ASSERT(!layoutObject()); |
| 96 CHECK(!computedStyle()); |
| 84 if (m_isElementRareData) | 97 if (m_isElementRareData) |
| 85 static_cast<ElementRareData*>(this)->~ElementRareData(); | 98 static_cast<ElementRareData*>(this)->~ElementRareData(); |
| 86 else | 99 else |
| 87 this->~NodeRareData(); | 100 this->~NodeRareData(); |
| 88 } | 101 } |
| 89 | 102 |
| 90 void NodeRareData::incrementConnectedSubframeCount() | 103 void NodeRareData::incrementConnectedSubframeCount() |
| 91 { | 104 { |
| 92 SECURITY_CHECK((m_connectedFrameCount + 1) <= FrameHost::maxNumberOfFrames); | 105 SECURITY_CHECK((m_connectedFrameCount + 1) <= FrameHost::maxNumberOfFrames); |
| 93 ++m_connectedFrameCount; | 106 ++m_connectedFrameCount; |
| 94 } | 107 } |
| 95 | 108 |
| 96 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow | 109 // 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"); | 110 static_assert(FrameHost::maxNumberOfFrames < (1 << NodeRareData::ConnectedFrameC
ountBits), "Frame limit should fit in rare data count"); |
| 98 | 111 |
| 99 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |