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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp

Issue 1133713008: [WIP] Migrate hasPendingActivity from ActiveDOMObject to ScriptWrappable. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 2 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
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return; 126 return;
127 127
128 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 128 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
129 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 129 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
130 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); 130 ASSERT(V8Node::hasInstance(wrapper, m_isolate));
131 Node* node = V8Node::toImpl(wrapper); 131 Node* node = V8Node::toImpl(wrapper);
132 // A minor DOM GC can handle only node wrappers in the main world. 132 // A minor DOM GC can handle only node wrappers in the main world.
133 // Note that node->wrapper().IsEmpty() returns true for nodes that 133 // Note that node->wrapper().IsEmpty() returns true for nodes that
134 // do not have wrappers in the main world. 134 // do not have wrappers in the main world.
135 if (node->containsWrapper()) { 135 if (node->containsWrapper()) {
136 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); 136 ScriptWrappable* scriptwrappable = getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper);
137 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(wrapper); 137 if (scriptwrappable && scriptwrappable->hasPendingActivity())
138 if (activeDOMObject && activeDOMObject->hasPendingActivity())
139 return; 138 return;
140 // FIXME: Remove the special handling for image elements. 139 // FIXME: Remove the special handling for image elements.
141 // The same special handling is in V8GCController::opaqueRootForGC() . 140 // The same special handling is in V8GCController::opaqueRootForGC() .
142 // Maybe should image elements be active DOM nodes? 141 // Maybe should image elements be active DOM nodes?
143 // See https://code.google.com/p/chromium/issues/detail?id=164882 142 // See https://code.google.com/p/chromium/issues/detail?id=164882
144 if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendin gActivity()) 143 if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendin gActivity())
145 return; 144 return;
146 // FIXME: Remove the special handling for SVG elements. 145 // FIXME: Remove the special handling for SVG elements.
147 // We currently can't collect SVG Elements from minor gc, as we have 146 // We currently can't collect SVG Elements from minor gc, as we have
148 // strong references from SVG property tear-offs keeping context SVG element alive. 147 // strong references from SVG property tear-offs keeping context SVG element alive.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return; 255 return;
257 256
258 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value)); 257 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New(m_isolate, v8 ::Persistent<v8::Object>::Cast(*value));
259 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); 258 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
260 259
261 if (value->IsIndependent()) 260 if (value->IsIndependent())
262 return; 261 return;
263 262
264 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); 263 const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
265 264
266 ActiveDOMObject* activeDOMObject = type->toActiveDOMObject(wrapper); 265 ScriptWrappable* scriptwrappable = getInternalField<ScriptWrappable, v8D OMWrapperObjectIndex>(wrapper);
haraken 2015/10/09 09:48:09 Is it guaranteed that NPObject has the internal fi
267 if (activeDOMObject && activeDOMObject->hasPendingActivity()) { 266 if (scriptwrappable && scriptwrappable->hasPendingActivity()) {
268 m_isolate->SetObjectGroupId(*value, liveRootId()); 267 m_isolate->SetObjectGroupId(*value, liveRootId());
269 ++m_domObjectsWithPendingActivity; 268 ++m_domObjectsWithPendingActivity;
270 } 269 }
271 270
272 if (classId == WrapperTypeInfo::NodeClassId) { 271 if (classId == WrapperTypeInfo::NodeClassId) {
273 ASSERT(V8Node::hasInstance(wrapper, m_isolate)); 272 ASSERT(V8Node::hasInstance(wrapper, m_isolate));
274 Node* node = V8Node::toImpl(wrapper); 273 Node* node = V8Node::toImpl(wrapper);
275 if (node->hasEventListeners()) 274 if (node->hasEventListeners())
276 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value)); 275 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Pers istent<v8::Object>::Cast(*value));
277 Node* root = V8GCController::opaqueRootForGC(m_isolate, node); 276 Node* root = V8GCController::opaqueRootForGC(m_isolate, node);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 Visitor* m_visitor; 527 Visitor* m_visitor;
529 }; 528 };
530 529
531 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor) 530 void V8GCController::traceDOMWrappers(v8::Isolate* isolate, Visitor* visitor)
532 { 531 {
533 DOMWrapperTracer tracer(visitor); 532 DOMWrapperTracer tracer(visitor);
534 v8::V8::VisitHandlesWithClassIds(isolate, &tracer); 533 v8::V8::VisitHandlesWithClassIds(isolate, &tracer);
535 } 534 }
536 535
537 } // namespace blink 536 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptWrappable.cpp ('k') | third_party/WebKit/Source/core/dom/ActiveDOMObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698