OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 24 matching lines...) Expand all Loading... | |
35 #include "V8MessagePort.h" | 35 #include "V8MessagePort.h" |
36 #include "V8MutationObserver.h" | 36 #include "V8MutationObserver.h" |
37 #include "V8Node.h" | 37 #include "V8Node.h" |
38 #include "V8ScriptRunner.h" | 38 #include "V8ScriptRunner.h" |
39 #include "bindings/v8/RetainedDOMInfo.h" | 39 #include "bindings/v8/RetainedDOMInfo.h" |
40 #include "bindings/v8/V8AbstractEventListener.h" | 40 #include "bindings/v8/V8AbstractEventListener.h" |
41 #include "bindings/v8/V8Binding.h" | 41 #include "bindings/v8/V8Binding.h" |
42 #include "bindings/v8/WrapperTypeInfo.h" | 42 #include "bindings/v8/WrapperTypeInfo.h" |
43 #include "core/dom/Attr.h" | 43 #include "core/dom/Attr.h" |
44 #include "core/dom/NodeTraversal.h" | 44 #include "core/dom/NodeTraversal.h" |
45 #include "core/dom/TemplateContentDocumentFragment.h" | |
45 #include "core/dom/shadow/ElementShadow.h" | 46 #include "core/dom/shadow/ElementShadow.h" |
46 #include "core/dom/shadow/ShadowRoot.h" | 47 #include "core/dom/shadow/ShadowRoot.h" |
47 #include "core/html/HTMLImageElement.h" | 48 #include "core/html/HTMLImageElement.h" |
49 #include "core/html/HTMLTemplateElement.h" | |
48 #include "platform/TraceEvent.h" | 50 #include "platform/TraceEvent.h" |
49 | 51 |
50 namespace WebCore { | 52 namespace WebCore { |
51 | 53 |
52 // FIXME: This should use opaque GC roots. | 54 // FIXME: This should use opaque GC roots. |
53 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n ode, const v8::Persistent<v8::Object>& wrapper) | 55 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n ode, const v8::Persistent<v8::Object>& wrapper) |
54 { | 56 { |
55 ASSERT(node->hasEventListeners()); | 57 ASSERT(node->hasEventListeners()); |
56 | 58 |
57 EventListenerIterator iterator(node); | 59 EventListenerIterator iterator(node); |
(...skipping 19 matching lines...) Expand all Loading... | |
77 if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImag eElement(node)->hasPendingActivity())) | 79 if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImag eElement(node)->hasPendingActivity())) |
78 return &node->document(); | 80 return &node->document(); |
79 | 81 |
80 if (node->isAttributeNode()) { | 82 if (node->isAttributeNode()) { |
81 Node* ownerElement = toAttr(node)->ownerElement(); | 83 Node* ownerElement = toAttr(node)->ownerElement(); |
82 if (!ownerElement) | 84 if (!ownerElement) |
83 return node; | 85 return node; |
84 node = ownerElement; | 86 node = ownerElement; |
85 } | 87 } |
86 | 88 |
87 while (Node* parent = node->parentOrShadowHostNode()) | 89 while (Node* parent = node->parentOrShadowHostOrTemplateHostNode()) |
88 node = parent; | 90 node = parent; |
89 | 91 |
90 return node; | 92 return node; |
91 } | 93 } |
92 | 94 |
93 // Regarding a minor GC algorithm for DOM nodes, see this document: | 95 // Regarding a minor GC algorithm for DOM nodes, see this document: |
94 // https://docs.google.com/a/google.com/presentation/d/1uifwVYGNYTZDoGLyCb7sXa7g 49mWNMW2gaWvMN5NLk8/edit#slide=id.p | 96 // https://docs.google.com/a/google.com/presentation/d/1uifwVYGNYTZDoGLyCb7sXa7g 49mWNMW2gaWvMN5NLk8/edit#slide=id.p |
95 class MinorGCWrapperVisitor : public v8::PersistentHandleVisitor { | 97 class MinorGCWrapperVisitor : public v8::PersistentHandleVisitor { |
96 public: | 98 public: |
97 explicit MinorGCWrapperVisitor(v8::Isolate* isolate) | 99 explicit MinorGCWrapperVisitor(v8::Isolate* isolate) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 } | 174 } |
173 if (ShadowRoot* shadowRoot = node->youngestShadowRoot()) { | 175 if (ShadowRoot* shadowRoot = node->youngestShadowRoot()) { |
174 if (!traverseTree(shadowRoot, newSpaceNodes)) | 176 if (!traverseTree(shadowRoot, newSpaceNodes)) |
175 return false; | 177 return false; |
176 } else if (node->isShadowRoot()) { | 178 } else if (node->isShadowRoot()) { |
177 if (ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot ()) { | 179 if (ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot ()) { |
178 if (!traverseTree(shadowRoot, newSpaceNodes)) | 180 if (!traverseTree(shadowRoot, newSpaceNodes)) |
179 return false; | 181 return false; |
180 } | 182 } |
181 } | 183 } |
184 if (node->hasTagName(HTMLNames::templateTag)) { | |
haraken
2013/10/31 22:32:53
Let's add a comment about this.
adamk
2013/11/04 19:15:41
Done.
| |
185 if (!traverseTree(toHTMLTemplateElement(node)->content(), newSpa ceNodes)) | |
186 return false; | |
187 } | |
182 } | 188 } |
183 return true; | 189 return true; |
184 } | 190 } |
185 | 191 |
186 void gcTree(v8::Isolate* isolate, Node* startNode) | 192 void gcTree(v8::Isolate* isolate, Node* startNode) |
187 { | 193 { |
188 Vector<Node*, initialNodeVectorSize> newSpaceNodes; | 194 Vector<Node*, initialNodeVectorSize> newSpaceNodes; |
189 | 195 |
190 Node* node = startNode; | 196 Node* node = startNode; |
191 while (node->parentOrShadowHostNode()) | 197 while (Node* parent = node->parentOrShadowHostOrTemplateHostNode()) |
192 node = node->parentOrShadowHostNode(); | 198 node = parent; |
193 | 199 |
194 if (!traverseTree(node, &newSpaceNodes)) | 200 if (!traverseTree(node, &newSpaceNodes)) |
195 return; | 201 return; |
196 | 202 |
197 // We completed the DOM tree traversal. All wrappers in the DOM tree are | 203 // We completed the DOM tree traversal. All wrappers in the DOM tree are |
198 // stored in newSpaceNodes and are expected to exist in the new space of V8. | 204 // stored in newSpaceNodes and are expected to exist in the new space of V8. |
199 // We report those wrappers to V8 as an object group. | 205 // We report those wrappers to V8 as an object group. |
200 Node** nodeIterator = newSpaceNodes.begin(); | 206 Node** nodeIterator = newSpaceNodes.begin(); |
201 Node** const nodeIteratorEnd = newSpaceNodes.end(); | 207 Node** const nodeIteratorEnd = newSpaceNodes.end(); |
202 if (nodeIterator == nodeIteratorEnd) | 208 if (nodeIterator == nodeIteratorEnd) |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 { | 420 { |
415 v8::HandleScope handleScope(isolate); | 421 v8::HandleScope handleScope(isolate); |
416 v8::Local<v8::Context> context = v8::Context::New(isolate); | 422 v8::Local<v8::Context> context = v8::Context::New(isolate); |
417 if (context.IsEmpty()) | 423 if (context.IsEmpty()) |
418 return; | 424 return; |
419 v8::Context::Scope contextScope(context); | 425 v8::Context::Scope contextScope(context); |
420 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate); | 426 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat e), isolate); |
421 } | 427 } |
422 | 428 |
423 } // namespace WebCore | 429 } // namespace WebCore |
OLD | NEW |