Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 }; | 371 }; |
| 372 | 372 |
| 373 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document) | 373 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document) |
| 374 : m_document(0) | 374 : m_document(0) |
| 375 { | 375 { |
| 376 registerObserver(document); | 376 registerObserver(document); |
| 377 } | 377 } |
| 378 | 378 |
| 379 DocumentVisibilityObserver::~DocumentVisibilityObserver() | 379 DocumentVisibilityObserver::~DocumentVisibilityObserver() |
| 380 { | 380 { |
| 381 #if !ENABLE(OILPAN) | |
| 381 unregisterObserver(); | 382 unregisterObserver(); |
| 383 #endif | |
| 382 } | 384 } |
| 383 | 385 |
| 384 void DocumentVisibilityObserver::unregisterObserver() | 386 void DocumentVisibilityObserver::unregisterObserver() |
| 385 { | 387 { |
| 386 if (m_document) { | 388 if (m_document) { |
| 387 m_document->unregisterVisibilityObserver(this); | 389 m_document->unregisterVisibilityObserver(this); |
| 388 m_document = 0; | 390 m_document = 0; |
| 389 } | 391 } |
| 390 } | 392 } |
| 391 | 393 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 // CSSFontSelector, need to initialize m_styleEngine after initializing | 517 // CSSFontSelector, need to initialize m_styleEngine after initializing |
| 516 // m_fetcher. | 518 // m_fetcher. |
| 517 m_styleEngine = StyleEngine::create(*this); | 519 m_styleEngine = StyleEngine::create(*this); |
| 518 } | 520 } |
| 519 | 521 |
| 520 Document::~Document() | 522 Document::~Document() |
| 521 { | 523 { |
| 522 ASSERT(!renderView()); | 524 ASSERT(!renderView()); |
| 523 ASSERT(m_ranges.isEmpty()); | 525 ASSERT(m_ranges.isEmpty()); |
| 524 ASSERT(!parentTreeScope()); | 526 ASSERT(!parentTreeScope()); |
| 527 #if !ENABLE(OILPAN) | |
| 525 ASSERT(!hasGuardRefCount()); | 528 ASSERT(!hasGuardRefCount()); |
| 529 // With Oilpan, either the document outlives the visibility observers | |
| 530 // or the visibility observers and the document die in the same GC round. | |
| 531 // When they die in the same GC round, the list of visibility observers | |
| 532 // will not be empty on Document destruction. | |
| 526 ASSERT(m_visibilityObservers.isEmpty()); | 533 ASSERT(m_visibilityObservers.isEmpty()); |
| 534 #endif | |
| 527 | 535 |
| 528 if (m_templateDocument) | 536 if (m_templateDocument) |
| 529 m_templateDocument->m_templateDocumentHost = 0; // balanced in ensureTem plateDocument(). | 537 m_templateDocument->m_templateDocumentHost = 0; // balanced in ensureTem plateDocument(). |
|
haraken
2014/04/25 05:21:42
At first I thought that it's not safe to touch m_t
Mads Ager (chromium)
2014/04/25 10:58:25
Exactly. :)
| |
| 530 | 538 |
| 531 m_scriptRunner.clear(); | 539 m_scriptRunner.clear(); |
| 532 | 540 |
| 533 removeAllEventListenersRecursively(); | 541 removeAllEventListenersRecursively(); |
| 534 | 542 |
| 535 // Currently we believe that Document can never outlive the parser. | 543 // Currently we believe that Document can never outlive the parser. |
| 536 // Although the Document may be replaced synchronously, DocumentParsers | 544 // Although the Document may be replaced synchronously, DocumentParsers |
| 537 // generally keep at least one reference to an Element which would in turn | 545 // generally keep at least one reference to an Element which would in turn |
| 538 // has a reference to the Document. If you hit this ASSERT, then that | 546 // has a reference to the Document. If you hit this ASSERT, then that |
| 539 // assumption is wrong. DocumentParser::detach() should ensure that even | 547 // assumption is wrong. DocumentParser::detach() should ensure that even |
| 540 // if the DocumentParser outlives the Document it won't cause badness. | 548 // if the DocumentParser outlives the Document it won't cause badness. |
| 541 ASSERT(!m_parser || m_parser->refCount() == 1); | 549 ASSERT(!m_parser || m_parser->refCount() == 1); |
| 542 detachParser(); | 550 detachParser(); |
| 543 | 551 |
| 544 if (this == topDocument()) | 552 if (this == topDocument()) |
| 545 clearAXObjectCache(); | 553 clearAXObjectCache(); |
| 546 | 554 |
| 555 #if !ENABLE(OILPAN) | |
| 547 if (m_styleSheetList) | 556 if (m_styleSheetList) |
| 548 m_styleSheetList->detachFromDocument(); | 557 m_styleSheetList->detachFromDocument(); |
| 558 #endif | |
| 549 | 559 |
| 550 if (m_importsController) { | 560 if (m_importsController) { |
| 551 m_importsController->wasDetachedFrom(*this); | 561 m_importsController->wasDetachedFrom(*this); |
| 552 m_importsController = 0; | 562 m_importsController = 0; |
| 553 } | 563 } |
| 554 | 564 |
| 555 m_timeline->detachFromDocument(); | 565 m_timeline->detachFromDocument(); |
| 556 m_transitionTimeline->detachFromDocument(); | 566 m_transitionTimeline->detachFromDocument(); |
| 557 | 567 |
| 558 // We need to destroy CSSFontSelector before destroying m_fetcher. | 568 // We need to destroy CSSFontSelector before destroying m_fetcher. |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1428 return pageVisibilityState() != PageVisibilityStateVisible; | 1438 return pageVisibilityState() != PageVisibilityStateVisible; |
| 1429 } | 1439 } |
| 1430 | 1440 |
| 1431 void Document::didChangeVisibilityState() | 1441 void Document::didChangeVisibilityState() |
| 1432 { | 1442 { |
| 1433 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); | 1443 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); |
| 1434 // Also send out the deprecated version until it can be removed. | 1444 // Also send out the deprecated version until it can be removed. |
| 1435 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); | 1445 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); |
| 1436 | 1446 |
| 1437 PageVisibilityState state = pageVisibilityState(); | 1447 PageVisibilityState state = pageVisibilityState(); |
| 1438 HashSet<DocumentVisibilityObserver*>::const_iterator observerEnd = m_visibil ityObservers.end(); | 1448 DocumentVisibilityObserverSet::const_iterator observerEnd = m_visibilityObse rvers.end(); |
| 1439 for (HashSet<DocumentVisibilityObserver*>::const_iterator it = m_visibilityO bservers.begin(); it != observerEnd; ++it) | 1449 for (DocumentVisibilityObserverSet::const_iterator it = m_visibilityObserver s.begin(); it != observerEnd; ++it) |
| 1440 (*it)->didChangeVisibilityState(state); | 1450 (*it)->didChangeVisibilityState(state); |
| 1441 } | 1451 } |
| 1442 | 1452 |
| 1443 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer) | 1453 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer) |
| 1444 { | 1454 { |
| 1445 ASSERT(!m_visibilityObservers.contains(observer)); | 1455 ASSERT(!m_visibilityObservers.contains(observer)); |
| 1446 m_visibilityObservers.add(observer); | 1456 m_visibilityObservers.add(observer); |
| 1447 } | 1457 } |
| 1448 | 1458 |
| 1449 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer ) | 1459 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer ) |
| (...skipping 3382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4832 m_ranges.add(range); | 4842 m_ranges.add(range); |
| 4833 } | 4843 } |
| 4834 | 4844 |
| 4835 void Document::detachRange(Range* range) | 4845 void Document::detachRange(Range* range) |
| 4836 { | 4846 { |
| 4837 // We don't ASSERT m_ranges.contains(range) to allow us to call this | 4847 // We don't ASSERT m_ranges.contains(range) to allow us to call this |
| 4838 // unconditionally to fix: https://bugs.webkit.org/show_bug.cgi?id=26044 | 4848 // unconditionally to fix: https://bugs.webkit.org/show_bug.cgi?id=26044 |
| 4839 m_ranges.remove(range); | 4849 m_ranges.remove(range); |
| 4840 } | 4850 } |
| 4841 | 4851 |
| 4842 void Document::getCSSCanvasContext(const String& type, const String& name, int w idth, int height, bool& is2d, RefPtr<CanvasRenderingContext2D>& context2d, bool& is3d, RefPtr<WebGLRenderingContext>& context3d) | 4852 void Document::getCSSCanvasContext(const String& type, const String& name, int w idth, int height, bool& is2d, RefPtrWillBeRawPtr<CanvasRenderingContext2D>& cont ext2d, bool& is3d, RefPtrWillBeRawPtr<WebGLRenderingContext>& context3d) |
| 4843 { | 4853 { |
| 4844 HTMLCanvasElement& element = getCSSCanvasElement(name); | 4854 HTMLCanvasElement& element = getCSSCanvasElement(name); |
| 4845 element.setSize(IntSize(width, height)); | 4855 element.setSize(IntSize(width, height)); |
| 4846 CanvasRenderingContext* context = element.getContext(type); | 4856 CanvasRenderingContext* context = element.getContext(type); |
| 4847 if (!context) | 4857 if (!context) |
| 4848 return; | 4858 return; |
| 4849 | 4859 |
| 4850 if (context->is2d()) { | 4860 if (context->is2d()) { |
| 4851 is2d = true; | 4861 is2d = true; |
| 4852 context2d = toCanvasRenderingContext2D(context); | 4862 context2d = toCanvasRenderingContext2D(context); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5035 return element; | 5045 return element; |
| 5036 } | 5046 } |
| 5037 return 0; | 5047 return 0; |
| 5038 } | 5048 } |
| 5039 | 5049 |
| 5040 void Document::decrementLoadEventDelayCount() | 5050 void Document::decrementLoadEventDelayCount() |
| 5041 { | 5051 { |
| 5042 ASSERT(m_loadEventDelayCount); | 5052 ASSERT(m_loadEventDelayCount); |
| 5043 --m_loadEventDelayCount; | 5053 --m_loadEventDelayCount; |
| 5044 | 5054 |
| 5045 if (frame() && !m_loadEventDelayCount && !m_loadEventDelayTimer.isActive()) | 5055 if (!m_loadEventDelayCount) |
| 5056 checkLoadEventSoon(); | |
| 5057 } | |
| 5058 | |
| 5059 void Document::checkLoadEventSoon() | |
| 5060 { | |
| 5061 if (frame() && !m_loadEventDelayTimer.isActive()) | |
| 5046 m_loadEventDelayTimer.startOneShot(0, FROM_HERE); | 5062 m_loadEventDelayTimer.startOneShot(0, FROM_HERE); |
| 5047 } | 5063 } |
| 5048 | 5064 |
| 5065 bool Document::isDelayingLoadEvent() | |
| 5066 { | |
| 5067 #if ENABLE(OILPAN) | |
| 5068 // Always delay load events until after garbage collection. | |
| 5069 // This way we don't have to explicitly delay load events via | |
| 5070 // incrementLoadEventDelayCount and decrementLoadEventDelayCount in | |
| 5071 // Node destructors. | |
| 5072 if (ThreadState::current()->isSweepInProgress()) { | |
| 5073 if (!m_loadEventDelayCount) | |
| 5074 checkLoadEventSoon(); | |
| 5075 return true; | |
| 5076 } | |
| 5077 #endif | |
| 5078 return m_loadEventDelayCount; | |
| 5079 } | |
| 5080 | |
| 5081 | |
| 5049 void Document::loadEventDelayTimerFired(Timer<Document>*) | 5082 void Document::loadEventDelayTimerFired(Timer<Document>*) |
| 5050 { | 5083 { |
| 5051 if (frame()) | 5084 if (frame()) |
| 5052 frame()->loader().checkCompleted(); | 5085 frame()->loader().checkCompleted(); |
| 5053 } | 5086 } |
| 5054 | 5087 |
| 5055 void Document::loadPluginsSoon() | 5088 void Document::loadPluginsSoon() |
| 5056 { | 5089 { |
| 5057 // FIXME: Remove this timer once we don't need to compute layout to load plu gins. | 5090 // FIXME: Remove this timer once we don't need to compute layout to load plu gins. |
| 5058 if (!m_pluginLoadingTimer.isActive()) | 5091 if (!m_pluginLoadingTimer.isActive()) |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5592 return false; | 5625 return false; |
| 5593 } | 5626 } |
| 5594 | 5627 |
| 5595 void Document::invalidateNodeListCaches(const QualifiedName* attrName) | 5628 void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
| 5596 { | 5629 { |
| 5597 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); | 5630 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); |
| 5598 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) | 5631 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) |
| 5599 (*it)->invalidateCacheForAttribute(attrName); | 5632 (*it)->invalidateCacheForAttribute(attrName); |
| 5600 } | 5633 } |
| 5601 | 5634 |
| 5635 void Document::clearWeakMembers(Visitor* visitor) | |
| 5636 { | |
| 5637 if (m_axObjectCache) | |
| 5638 m_axObjectCache->clearWeakMembers(visitor); | |
| 5639 | |
| 5640 if (m_markers) | |
| 5641 m_markers->clearWeakMembers(visitor); | |
| 5642 | |
| 5643 // FIXME: Oilpan: Use a weak counted set instead. | |
| 5644 if (m_touchEventTargets) { | |
| 5645 Vector<Node*> deadNodes; | |
| 5646 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it != m_touchEventTargets->end(); ++it) { | |
| 5647 if (!visitor->isAlive(it->key)) | |
| 5648 deadNodes.append(it->key); | |
| 5649 } | |
| 5650 for (unsigned i = 0; i < deadNodes.size(); ++i) | |
| 5651 didClearTouchEventHandlers(deadNodes[i]); | |
| 5652 } | |
| 5653 } | |
| 5654 | |
| 5602 void Document::trace(Visitor* visitor) | 5655 void Document::trace(Visitor* visitor) |
| 5603 { | 5656 { |
| 5657 visitor->trace(m_styleSheetList); | |
| 5658 visitor->trace(m_visibilityObservers); | |
| 5659 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); | |
| 5604 Supplementable<Document>::trace(visitor); | 5660 Supplementable<Document>::trace(visitor); |
| 5661 TreeScope::trace(visitor); | |
| 5605 ContainerNode::trace(visitor); | 5662 ContainerNode::trace(visitor); |
| 5606 } | 5663 } |
| 5607 | 5664 |
| 5608 } // namespace WebCore | 5665 } // namespace WebCore |
| OLD | NEW |