Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84a5d125b4edd705b3fdd46967290ab3dda2de82 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.cpp |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "bindings/core/v8/ScriptWrappableVisitor.h" |
| + |
| +#include "bindings/core/v8/ScriptWrappable.h" |
| +#include "bindings/core/v8/ScriptWrappableHeapTracer.h" |
| +#include "core/dom/NodeRareData.h" |
| +#include "core/events/EventListenerMap.h" |
| +#include "core/events/EventTarget.h" |
| +#include "platform/heap/HeapPage.h" |
| + |
| +namespace blink { |
| + |
| +bool ScriptWrappableVisitor::isMarked(const void* garbageCollected) const |
| +{ |
| + return HeapObjectHeader::fromPayload(garbageCollected)->isDOMMarked(); |
| +} |
| + |
| +void ScriptWrappableVisitor::mark(const ScriptWrappable* scriptWrappable) const |
| +{ |
| + mark(static_cast<const void*>(scriptWrappable)); |
| + |
| + if (scriptWrappable->containsWrapper()) |
|
haraken
2016/04/13 12:26:22
It would be better to move this check into ScriptW
Marcel Hlopko
2016/04/14 16:39:08
Done.
|
| + scriptWrappable->markWrapperAlive(m_isolate); |
| +} |
| + |
| +void ScriptWrappableVisitor::mark(const void* garbageCollected) const |
| +{ |
| + HeapObjectHeader* header = HeapObjectHeader::fromPayload(garbageCollected); |
| + header->markDOM(); |
| + m_tracer->AddHeaderToUnmark(header); |
| +} |
| + |
| +void ScriptWrappableVisitor::markHandle(v8::Persistent<v8::Object>& handle) const |
| +{ |
| + ScriptWrappable::markWrapperAlive(handle, m_isolate); |
| +} |
| + |
| +void ScriptWrappableVisitor::trace(const ScriptWrappable* wrappable) const |
| +{ |
| + if (wrappable && !isMarked(wrappable)) { |
| + mark(wrappable); |
| + wrappable->traceWrappers(this); |
| + } |
| +} |
| + |
| +void ScriptWrappableVisitor::trace(const ScriptWrappable& wrappable) const |
| +{ |
| + trace(&wrappable); |
| +} |
| + |
| +void ScriptWrappableVisitor::trace(const NodeRareData* data) const |
|
haraken
2016/04/13 11:09:05
Do we need to add a trace(const T*) method every t
Marcel Hlopko
2016/04/13 11:11:57
Yes. Do you have a better approach in mind?
|
| +{ |
| + if (data && !isMarked(data)) { |
| + mark(data); |
| + data->traceWrappers(this); |
| + } |
| +} |
| + |
| +} // namespace blink |