Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: Source/bindings/v8/V8GCController.cpp

Issue 201383002: Use new is*Element() helper functions more in bindings/ code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Minor clean up Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/v8/V8WindowShell.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListene r*>(listener); 63 V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListene r*>(listener);
64 if (!v8listener->hasExistingListenerObject()) 64 if (!v8listener->hasExistingListenerObject())
65 continue; 65 continue;
66 66
67 isolate->SetReference(wrapper, v8::Persistent<v8::Value>::Cast(v8listene r->existingListenerObjectPersistentHandle())); 67 isolate->SetReference(wrapper, v8::Persistent<v8::Value>::Cast(v8listene r->existingListenerObjectPersistentHandle()));
68 } 68 }
69 } 69 }
70 70
71 Node* V8GCController::opaqueRootForGC(Node* node, v8::Isolate*) 71 Node* V8GCController::opaqueRootForGC(Node* node, v8::Isolate*)
72 { 72 {
73 ASSERT(node);
73 // FIXME: Remove the special handling for image elements. 74 // FIXME: Remove the special handling for image elements.
74 // The same special handling is in V8GCController::gcTree(). 75 // The same special handling is in V8GCController::gcTree().
75 // Maybe should image elements be active DOM nodes? 76 // Maybe should image elements be active DOM nodes?
76 // See https://code.google.com/p/chromium/issues/detail?id=164882 77 // See https://code.google.com/p/chromium/issues/detail?id=164882
77 if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImag eElement(node)->hasPendingActivity())) 78 if (node->inDocument() || (isHTMLImageElement(*node) && toHTMLImageElement(* node).hasPendingActivity()))
78 return &node->document(); 79 return &node->document();
79 80
80 if (node->isAttributeNode()) { 81 if (node->isAttributeNode()) {
81 Node* ownerElement = toAttr(node)->ownerElement(); 82 Node* ownerElement = toAttr(node)->ownerElement();
82 if (!ownerElement) 83 if (!ownerElement)
83 return node; 84 return node;
84 node = ownerElement; 85 node = ownerElement;
85 } 86 }
86 87
87 while (Node* parent = node->parentOrShadowHostOrTemplateHostNode()) 88 while (Node* parent = node->parentOrShadowHostOrTemplateHostNode())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // do not have wrappers in the main world. 128 // do not have wrappers in the main world.
128 if (node->containsWrapper()) { 129 if (node->containsWrapper()) {
129 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper); 130 const WrapperTypeInfo* type = toWrapperTypeInfo(*wrapper);
130 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper) ; 131 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(*wrapper) ;
131 if (activeDOMObject && activeDOMObject->hasPendingActivity()) 132 if (activeDOMObject && activeDOMObject->hasPendingActivity())
132 return; 133 return;
133 // FIXME: Remove the special handling for image elements. 134 // FIXME: Remove the special handling for image elements.
134 // The same special handling is in V8GCController::opaqueRootForGC() . 135 // The same special handling is in V8GCController::opaqueRootForGC() .
135 // Maybe should image elements be active DOM nodes? 136 // Maybe should image elements be active DOM nodes?
136 // See https://code.google.com/p/chromium/issues/detail?id=164882 137 // See https://code.google.com/p/chromium/issues/detail?id=164882
137 if (node->hasTagName(HTMLNames::imgTag) && toHTMLImageElement(node)- >hasPendingActivity()) 138 if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendin gActivity())
138 return; 139 return;
139 // FIXME: Remove the special handling for SVG context elements. 140 // FIXME: Remove the special handling for SVG context elements.
140 if (node->isSVGElement() && toSVGElement(node)->isContextElement()) 141 if (node->isSVGElement() && toSVGElement(node)->isContextElement())
141 return; 142 return;
142 143
143 m_nodesInNewSpace.append(node); 144 m_nodesInNewSpace.append(node);
144 node->markV8CollectableDuringMinorGC(); 145 node->markV8CollectableDuringMinorGC();
145 } 146 }
146 } 147 }
147 148
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (!traverseTree(shadowRoot, partiallyDependentNodes)) 181 if (!traverseTree(shadowRoot, partiallyDependentNodes))
181 return false; 182 return false;
182 } else if (node->isShadowRoot()) { 183 } else if (node->isShadowRoot()) {
183 if (ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot ()) { 184 if (ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot ()) {
184 if (!traverseTree(shadowRoot, partiallyDependentNodes)) 185 if (!traverseTree(shadowRoot, partiallyDependentNodes))
185 return false; 186 return false;
186 } 187 }
187 } 188 }
188 // <template> has a |content| property holding a DOM fragment which we must traverse, 189 // <template> has a |content| property holding a DOM fragment which we must traverse,
189 // just like we do for the shadow trees above. 190 // just like we do for the shadow trees above.
190 if (node->hasTagName(HTMLNames::templateTag)) { 191 if (isHTMLTemplateElement(*node)) {
191 if (!traverseTree(toHTMLTemplateElement(node)->content(), partia llyDependentNodes)) 192 if (!traverseTree(toHTMLTemplateElement(*node).content(), partia llyDependentNodes))
192 return false; 193 return false;
193 } 194 }
194 } 195 }
195 return true; 196 return true;
196 } 197 }
197 198
198 void gcTree(v8::Isolate* isolate, Node* startNode) 199 void gcTree(v8::Isolate* isolate, Node* startNode)
199 { 200 {
200 Vector<Node*, initialNodeVectorSize> partiallyDependentNodes; 201 Vector<Node*, initialNodeVectorSize> partiallyDependentNodes;
201 202
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)- >previousSamplingState()); 391 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)- >previousSamplingState());
391 } 392 }
392 393
393 void V8GCController::collectGarbage(v8::Isolate* isolate) 394 void V8GCController::collectGarbage(v8::Isolate* isolate)
394 { 395 {
395 V8ExecutionScope scope(isolate); 396 V8ExecutionScope scope(isolate);
396 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate); 397 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate);
397 } 398 }
398 399
399 } // namespace WebCore 400 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/V8WindowShell.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698