Chromium Code Reviews| 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" | |
|
Timothy Loh
2016/06/23 23:58:02
not needed?
| |
| 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; |
| 43 Member<void*> m_willbeMember[2]; | 44 Member<void*> m_willbeMember[2]; |
| 44 unsigned m_bitfields; | 45 unsigned m_bitfields; |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 static_assert(sizeof(NodeRareData) == sizeof(SameSizeAsNodeRareData), "NodeRareD ata should stay small"); | 48 static_assert(sizeof(NodeRareData) == sizeof(SameSizeAsNodeRareData), "NodeRareD ata should stay small"); |
| 48 | 49 |
| 49 DEFINE_TRACE_AFTER_DISPATCH(NodeRareData) | 50 DEFINE_TRACE_AFTER_DISPATCH(NodeRareData) |
| 50 { | 51 { |
| 51 visitor->trace(m_mutationObserverData); | 52 visitor->trace(m_mutationObserverData); |
| 52 // Do not keep empty NodeListsNodeData objects around. | 53 // Do not keep empty NodeListsNodeData objects around. |
| 53 if (m_nodeLists && m_nodeLists->isEmpty()) | 54 if (m_nodeLists && m_nodeLists->isEmpty()) |
| 54 m_nodeLists.clear(); | 55 m_nodeLists.clear(); |
| 55 else | 56 else |
| 56 visitor->trace(m_nodeLists); | 57 visitor->trace(m_nodeLists); |
| 57 } | 58 } |
| 58 | 59 |
| 59 DEFINE_TRACE(NodeRareData) | 60 DEFINE_TRACE(NodeRareData) |
| 60 { | 61 { |
| 61 if (m_isElementRareData) | 62 if (isElementRareData()) |
| 62 static_cast<ElementRareData*>(this)->traceAfterDispatch(visitor); | 63 static_cast<ElementRareData*>(this)->traceAfterDispatch(visitor); |
| 63 else | 64 else |
| 64 traceAfterDispatch(visitor); | 65 traceAfterDispatch(visitor); |
| 65 } | 66 } |
| 66 | 67 |
| 67 DEFINE_TRACE_WRAPPERS(NodeRareData) | 68 DEFINE_TRACE_WRAPPERS(NodeRareData) |
| 68 { | 69 { |
| 69 if (m_isElementRareData) | 70 if (isElementRareData()) |
| 70 static_cast<const ElementRareData*>(this)->traceWrappersAfterDispatch(vi sitor); | 71 static_cast<const ElementRareData*>(this)->traceWrappersAfterDispatch(vi sitor); |
| 71 else | 72 else |
| 72 traceWrappersAfterDispatch(visitor); | 73 traceWrappersAfterDispatch(visitor); |
| 73 } | 74 } |
| 74 | 75 |
| 75 DEFINE_TRACE_WRAPPERS_AFTER_DISPATCH(NodeRareData) | 76 DEFINE_TRACE_WRAPPERS_AFTER_DISPATCH(NodeRareData) |
| 76 { | 77 { |
| 77 visitor->traceWrappers(m_nodeLists); | 78 visitor->traceWrappers(m_nodeLists); |
| 78 visitor->traceWrappers(m_mutationObserverData); | 79 visitor->traceWrappers(m_mutationObserverData); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void NodeRareData::finalizeGarbageCollectedObject() | 82 void NodeRareData::finalizeGarbageCollectedObject() |
| 82 { | 83 { |
| 83 RELEASE_ASSERT(!layoutObject()); | 84 RELEASE_ASSERT(!layoutObject()); |
| 84 if (m_isElementRareData) | 85 if (isElementRareData()) |
| 85 static_cast<ElementRareData*>(this)->~ElementRareData(); | 86 static_cast<ElementRareData*>(this)->~ElementRareData(); |
| 86 else | 87 else |
| 87 this->~NodeRareData(); | 88 this->~NodeRareData(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void NodeRareData::incrementConnectedSubframeCount() | 91 void NodeRareData::incrementConnectedSubframeCount() |
| 91 { | 92 { |
| 92 SECURITY_CHECK((m_connectedFrameCount + 1) <= FrameHost::maxNumberOfFrames); | 93 SECURITY_CHECK((m_connectedFrameCount + 1) <= FrameHost::maxNumberOfFrames); |
| 93 ++m_connectedFrameCount; | 94 ++m_connectedFrameCount; |
| 94 } | 95 } |
| 95 | 96 |
| 96 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow | 97 // 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"); | 98 static_assert(FrameHost::maxNumberOfFrames < (1 << NodeRareData::ConnectedFrameC ountBits), "Frame limit should fit in rare data count"); |
| 98 | 99 |
| 99 } // namespace blink | 100 } // namespace blink |
| OLD | NEW |