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. | |
Erik Corry
2014/04/24 13:53:16
Is it worth checking that they are all dead at thi
Mads Ager (chromium)
2014/04/24 14:12:14
I don't think so, no.
| |
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(). |
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 WillBeHeapHashSet<RawPtrWillBeWeakMember<DocumentVisibilityObserver> >::cons t_iterator observerEnd = m_visibilityObservers.end(); |
Erik Corry
2014/04/24 13:53:16
I think a typedef would be good here.
Mads Ager (chromium)
2014/04/24 14:12:14
Done.
| |
1439 for (HashSet<DocumentVisibilityObserver*>::const_iterator it = m_visibilityO bservers.begin(); it != observerEnd; ++it) | 1449 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<DocumentVisibilityObserver> >: :const_iterator it = m_visibilityObservers.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) |
Erik Corry
2014/04/24 13:53:16
Style guide was just revised so you can write == 0
Mads Ager (chromium)
2014/04/24 14:12:14
OK, not going to bother with that right now. The r
| |
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 // With Oilpan, always delay load events until after garbage collection. | |
Erik Corry
2014/04/24 13:53:16
The "With Oilpan" part of the comment is obsolete
Mads Ager (chromium)
2014/04/24 14:12:14
Yes, true. Done.
| |
5069 // This way we don't have to explicitly delay load events via | |
5070 // incrementLoadEventDelayCount and decrementLoadEventDelayCount in | |
5071 // Node destructors. | |
5072 if (!m_loadEventDelayCount && ThreadState::current()->isSweepInProgress()) { | |
5073 checkLoadEventSoon(); | |
Erik Corry
2014/04/24 13:53:16
Just because we asked whether load events are bein
Mads Ager (chromium)
2014/04/24 14:12:14
Good point. Done. If we are sweeping, we check for
| |
5074 return true; | |
5075 } | |
5076 #endif | |
5077 return m_loadEventDelayCount; | |
Erik Corry
2014/04/24 13:53:16
!= 0
Mads Ager (chromium)
2014/04/24 14:12:14
Nah, not in this change. The rest of this code use
| |
5078 } | |
5079 | |
5080 | |
5049 void Document::loadEventDelayTimerFired(Timer<Document>*) | 5081 void Document::loadEventDelayTimerFired(Timer<Document>*) |
5050 { | 5082 { |
5051 if (frame()) | 5083 if (frame()) |
5052 frame()->loader().checkCompleted(); | 5084 frame()->loader().checkCompleted(); |
5053 } | 5085 } |
5054 | 5086 |
5055 void Document::loadPluginsSoon() | 5087 void Document::loadPluginsSoon() |
5056 { | 5088 { |
5057 // FIXME: Remove this timer once we don't need to compute layout to load plu gins. | 5089 // FIXME: Remove this timer once we don't need to compute layout to load plu gins. |
5058 if (!m_pluginLoadingTimer.isActive()) | 5090 if (!m_pluginLoadingTimer.isActive()) |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5592 return false; | 5624 return false; |
5593 } | 5625 } |
5594 | 5626 |
5595 void Document::invalidateNodeListCaches(const QualifiedName* attrName) | 5627 void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
5596 { | 5628 { |
5597 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); | 5629 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); |
5598 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) | 5630 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) |
5599 (*it)->invalidateCacheForAttribute(attrName); | 5631 (*it)->invalidateCacheForAttribute(attrName); |
5600 } | 5632 } |
5601 | 5633 |
5634 void Document::clearWeakMembers(Visitor* visitor) | |
5635 { | |
5636 if (m_axObjectCache) | |
5637 m_axObjectCache->clearWeakMembers(visitor); | |
5638 | |
5639 if (m_markers) | |
5640 m_markers->clearWeakMembers(visitor); | |
5641 | |
5642 // FIXME: Oilpan: Use a weak counted set instead. | |
5643 if (m_touchEventTargets) { | |
5644 Vector<Node*> deadNodes; | |
5645 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it != m_touchEventTargets->end(); ++it) { | |
5646 if (!visitor->isAlive(it->key)) | |
5647 deadNodes.append(it->key); | |
5648 } | |
5649 for (unsigned i = 0; i < deadNodes.size(); ++i) | |
5650 didClearTouchEventHandlers(deadNodes[i]); | |
5651 } | |
5652 } | |
5653 | |
5602 void Document::trace(Visitor* visitor) | 5654 void Document::trace(Visitor* visitor) |
5603 { | 5655 { |
5656 visitor->trace(m_styleSheetList); | |
5657 visitor->trace(m_visibilityObservers); | |
5658 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); | |
5604 Supplementable<Document>::trace(visitor); | 5659 Supplementable<Document>::trace(visitor); |
5660 TreeScope::trace(visitor); | |
5605 ContainerNode::trace(visitor); | 5661 ContainerNode::trace(visitor); |
5606 } | 5662 } |
5607 | 5663 |
5608 } // namespace WebCore | 5664 } // namespace WebCore |
OLD | NEW |