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 29 matching lines...) Expand all Loading... |
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/TemplateContentDocumentFragment.h" |
46 #include "core/dom/shadow/ElementShadow.h" | 46 #include "core/dom/shadow/ElementShadow.h" |
47 #include "core/dom/shadow/ShadowRoot.h" | 47 #include "core/dom/shadow/ShadowRoot.h" |
48 #include "core/html/HTMLImageElement.h" | 48 #include "core/html/HTMLImageElement.h" |
49 #include "core/html/HTMLTemplateElement.h" | 49 #include "core/html/HTMLTemplateElement.h" |
| 50 #include "core/svg/SVGElement.h" |
50 #include "platform/TraceEvent.h" | 51 #include "platform/TraceEvent.h" |
51 | 52 |
52 namespace WebCore { | 53 namespace WebCore { |
53 | 54 |
54 // FIXME: This should use opaque GC roots. | 55 // FIXME: This should use opaque GC roots. |
55 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
ode, const v8::Persistent<v8::Object>& wrapper) | 56 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
ode, const v8::Persistent<v8::Object>& wrapper) |
56 { | 57 { |
57 ASSERT(node->hasEventListeners()); | 58 ASSERT(node->hasEventListeners()); |
58 | 59 |
59 EventListenerIterator iterator(node); | 60 EventListenerIterator iterator(node); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 154 |
154 private: | 155 private: |
155 bool traverseTree(Node* rootNode, Vector<Node*, initialNodeVectorSize>* newS
paceNodes) | 156 bool traverseTree(Node* rootNode, Vector<Node*, initialNodeVectorSize>* newS
paceNodes) |
156 { | 157 { |
157 // To make each minor GC time bounded, we might need to give up | 158 // To make each minor GC time bounded, we might need to give up |
158 // traversing at some point for a large DOM tree. That being said, | 159 // traversing at some point for a large DOM tree. That being said, |
159 // I could not observe the need even in pathological test cases. | 160 // I could not observe the need even in pathological test cases. |
160 for (Node* node = rootNode; node; node = NodeTraversal::next(*node)) { | 161 for (Node* node = rootNode; node; node = NodeTraversal::next(*node)) { |
161 if (node->containsWrapper()) { | 162 if (node->containsWrapper()) { |
162 // FIXME: Remove the special handling for image elements. | 163 // FIXME: Remove the special handling for image elements. |
| 164 // FIXME: Remove the special handling for SVG context elements. |
163 // The same special handling is in V8GCController::opaqueRootFor
GC(). | 165 // The same special handling is in V8GCController::opaqueRootFor
GC(). |
164 // Maybe should image elements be active DOM nodes? | 166 // Maybe should image elements be active DOM nodes? |
165 // See https://code.google.com/p/chromium/issues/detail?id=16488
2 | 167 // See https://code.google.com/p/chromium/issues/detail?id=16488
2 |
166 if (!node->isV8CollectableDuringMinorGC() || (node->hasTagName(H
TMLNames::imgTag) && toHTMLImageElement(node)->hasPendingActivity())) { | 168 if (!node->isV8CollectableDuringMinorGC() || (node->hasTagName(H
TMLNames::imgTag) && toHTMLImageElement(node)->hasPendingActivity()) || (node->i
sSVGElement() && toSVGElement(node)->isContextElement())) { |
167 // This node is not in the new space of V8. This indicates t
hat | 169 // This node is not in the new space of V8. This indicates t
hat |
168 // the minor GC cannot anyway judge reachability of this DOM
tree. | 170 // the minor GC cannot anyway judge reachability of this DOM
tree. |
169 // Thus we give up traversing the DOM tree. | 171 // Thus we give up traversing the DOM tree. |
170 return false; | 172 return false; |
171 } | 173 } |
172 node->setV8CollectableDuringMinorGC(false); | 174 node->setV8CollectableDuringMinorGC(false); |
173 newSpaceNodes->append(node); | 175 newSpaceNodes->append(node); |
174 } | 176 } |
175 if (ShadowRoot* shadowRoot = node->youngestShadowRoot()) { | 177 if (ShadowRoot* shadowRoot = node->youngestShadowRoot()) { |
176 if (!traverseTree(shadowRoot, newSpaceNodes)) | 178 if (!traverseTree(shadowRoot, newSpaceNodes)) |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 { | 424 { |
423 v8::HandleScope handleScope(isolate); | 425 v8::HandleScope handleScope(isolate); |
424 v8::Local<v8::Context> context = v8::Context::New(isolate); | 426 v8::Local<v8::Context> context = v8::Context::New(isolate); |
425 if (context.IsEmpty()) | 427 if (context.IsEmpty()) |
426 return; | 428 return; |
427 v8::Context::Scope contextScope(context); | 429 v8::Context::Scope contextScope(context); |
428 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat
e), isolate); | 430 V8ScriptRunner::compileAndRunInternalScript(v8String("if (gc) gc();", isolat
e), isolate); |
429 } | 431 } |
430 | 432 |
431 } // namespace WebCore | 433 } // namespace WebCore |
OLD | NEW |