Index: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp b/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp |
index 87d93525711c43f86222e5707988b4ec1ec0a64f..9b4ebfde87ab90475bf8359d4f54a2b1a24be015 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp |
@@ -41,6 +41,7 @@ |
#include "core/dom/Attr.h" |
#include "core/dom/Element.h" |
#include "core/dom/Node.h" |
+#include "core/dom/shadow/ShadowRoot.h" |
#include "core/html/imports/HTMLImportsController.h" |
#include "core/inspector/InspectorTraceEvents.h" |
#include "platform/Histogram.h" |
@@ -92,6 +93,13 @@ Node* V8GCController::opaqueRootForGC(v8::Isolate*, Node* node) { |
node = ownerElement; |
} |
+ // Node -> Host (if any) is O(1) |
+ while (node->isInShadowTree()) |
+ node = &node->containingShadowRoot()->host(); |
+ |
+ // The "ShadowHost" part is redundant because of the isInShadowTree |
+ // loop, but this is still preferable because parent/shadow host |
+ // pointer occupies the same space. |
while (Node* parent = node->parentOrShadowHostOrTemplateHostNode()) |
node = parent; |