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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 }; | 369 }; |
370 | 370 |
371 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document) | 371 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document) |
372 : m_document(0) | 372 : m_document(0) |
373 { | 373 { |
374 registerObserver(document); | 374 registerObserver(document); |
375 } | 375 } |
376 | 376 |
377 DocumentVisibilityObserver::~DocumentVisibilityObserver() | 377 DocumentVisibilityObserver::~DocumentVisibilityObserver() |
378 { | 378 { |
| 379 #if !ENABLE(OILPAN) |
379 unregisterObserver(); | 380 unregisterObserver(); |
| 381 #endif |
380 } | 382 } |
381 | 383 |
382 void DocumentVisibilityObserver::unregisterObserver() | 384 void DocumentVisibilityObserver::unregisterObserver() |
383 { | 385 { |
384 if (m_document) { | 386 if (m_document) { |
385 m_document->unregisterVisibilityObserver(this); | 387 m_document->unregisterVisibilityObserver(this); |
386 m_document = 0; | 388 m_document = 0; |
387 } | 389 } |
388 } | 390 } |
389 | 391 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // m_fetcher. | 517 // m_fetcher. |
516 m_styleEngine = StyleEngine::create(*this); | 518 m_styleEngine = StyleEngine::create(*this); |
517 } | 519 } |
518 | 520 |
519 Document::~Document() | 521 Document::~Document() |
520 { | 522 { |
521 ASSERT(!renderView()); | 523 ASSERT(!renderView()); |
522 ASSERT(m_ranges.isEmpty()); | 524 ASSERT(m_ranges.isEmpty()); |
523 ASSERT(!parentTreeScope()); | 525 ASSERT(!parentTreeScope()); |
524 ASSERT(!hasGuardRefCount()); | 526 ASSERT(!hasGuardRefCount()); |
| 527 #if !ENABLE(OILPAN) |
| 528 // With oilpan the visibility obeservers and the document can die together |
| 529 // at which point the weak collection of observers will not be empty. |
525 ASSERT(m_visibilityObservers.isEmpty()); | 530 ASSERT(m_visibilityObservers.isEmpty()); |
| 531 #endif |
526 | 532 |
527 if (m_templateDocument) | 533 if (m_templateDocument) |
528 m_templateDocument->m_templateDocumentHost = 0; // balanced in ensureTem
plateDocument(). | 534 m_templateDocument->m_templateDocumentHost = 0; // balanced in ensureTem
plateDocument(). |
529 | 535 |
530 m_scriptRunner.clear(); | 536 m_scriptRunner.clear(); |
531 | 537 |
532 removeAllEventListenersRecursively(); | 538 removeAllEventListenersRecursively(); |
533 | 539 |
534 // Currently we believe that Document can never outlive the parser. | 540 // Currently we believe that Document can never outlive the parser. |
535 // Although the Document may be replaced synchronously, DocumentParsers | 541 // Although the Document may be replaced synchronously, DocumentParsers |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 return pageVisibilityState() != PageVisibilityStateVisible; | 1418 return pageVisibilityState() != PageVisibilityStateVisible; |
1413 } | 1419 } |
1414 | 1420 |
1415 void Document::didChangeVisibilityState() | 1421 void Document::didChangeVisibilityState() |
1416 { | 1422 { |
1417 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); | 1423 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); |
1418 // Also send out the deprecated version until it can be removed. | 1424 // Also send out the deprecated version until it can be removed. |
1419 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); | 1425 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); |
1420 | 1426 |
1421 PageVisibilityState state = pageVisibilityState(); | 1427 PageVisibilityState state = pageVisibilityState(); |
1422 HashSet<DocumentVisibilityObserver*>::const_iterator observerEnd = m_visibil
ityObservers.end(); | 1428 WillBeHeapHashSet<RawPtrWillBeWeakMember<DocumentVisibilityObserver> >::cons
t_iterator observerEnd = m_visibilityObservers.end(); |
1423 for (HashSet<DocumentVisibilityObserver*>::const_iterator it = m_visibilityO
bservers.begin(); it != observerEnd; ++it) | 1429 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<DocumentVisibilityObserver> >:
:const_iterator it = m_visibilityObservers.begin(); it != observerEnd; ++it) |
1424 (*it)->didChangeVisibilityState(state); | 1430 (*it)->didChangeVisibilityState(state); |
1425 } | 1431 } |
1426 | 1432 |
1427 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer) | 1433 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer) |
1428 { | 1434 { |
1429 ASSERT(!m_visibilityObservers.contains(observer)); | 1435 ASSERT(!m_visibilityObservers.contains(observer)); |
1430 m_visibilityObservers.add(observer); | 1436 m_visibilityObservers.add(observer); |
1431 } | 1437 } |
1432 | 1438 |
1433 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer
) | 1439 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer
) |
(...skipping 3322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4756 m_ranges.add(range); | 4762 m_ranges.add(range); |
4757 } | 4763 } |
4758 | 4764 |
4759 void Document::detachRange(Range* range) | 4765 void Document::detachRange(Range* range) |
4760 { | 4766 { |
4761 // We don't ASSERT m_ranges.contains(range) to allow us to call this | 4767 // We don't ASSERT m_ranges.contains(range) to allow us to call this |
4762 // unconditionally to fix: https://bugs.webkit.org/show_bug.cgi?id=26044 | 4768 // unconditionally to fix: https://bugs.webkit.org/show_bug.cgi?id=26044 |
4763 m_ranges.remove(range); | 4769 m_ranges.remove(range); |
4764 } | 4770 } |
4765 | 4771 |
4766 void Document::getCSSCanvasContext(const String& type, const String& name, int w
idth, int height, bool& is2d, RefPtr<CanvasRenderingContext2D>& context2d, bool&
is3d, RefPtr<WebGLRenderingContext>& context3d) | 4772 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) |
4767 { | 4773 { |
4768 HTMLCanvasElement& element = getCSSCanvasElement(name); | 4774 HTMLCanvasElement& element = getCSSCanvasElement(name); |
4769 element.setSize(IntSize(width, height)); | 4775 element.setSize(IntSize(width, height)); |
4770 CanvasRenderingContext* context = element.getContext(type); | 4776 CanvasRenderingContext* context = element.getContext(type); |
4771 if (!context) | 4777 if (!context) |
4772 return; | 4778 return; |
4773 | 4779 |
4774 if (context->is2d()) { | 4780 if (context->is2d()) { |
4775 is2d = true; | 4781 is2d = true; |
4776 context2d = toCanvasRenderingContext2D(context); | 4782 context2d = toCanvasRenderingContext2D(context); |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5516 return false; | 5522 return false; |
5517 } | 5523 } |
5518 | 5524 |
5519 void Document::invalidateNodeListCaches(const QualifiedName* attrName) | 5525 void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
5520 { | 5526 { |
5521 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end(
); | 5527 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end(
); |
5522 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument.
begin(); it != end; ++it) | 5528 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument.
begin(); it != end; ++it) |
5523 (*it)->invalidateCache(attrName); | 5529 (*it)->invalidateCache(attrName); |
5524 } | 5530 } |
5525 | 5531 |
| 5532 void Document::clearWeakMembers(Visitor* visitor) |
| 5533 { |
| 5534 if (m_axObjectCache) |
| 5535 m_axObjectCache->clearWeakMembers(visitor); |
| 5536 |
| 5537 if (m_markers) |
| 5538 m_markers->clearWeakMembers(visitor); |
| 5539 |
| 5540 // FIXME: Oilpan: Use a weak counted set instead. |
| 5541 if (m_touchEventTargets) { |
| 5542 Vector<Node*> deadNodes; |
| 5543 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it
!= m_touchEventTargets->end(); ++it) { |
| 5544 if (!visitor->isAlive(it->key)) |
| 5545 deadNodes.append(it->key); |
| 5546 } |
| 5547 for (unsigned i = 0; i < deadNodes.size(); ++i) |
| 5548 didClearTouchEventHandlers(deadNodes[i]); |
| 5549 } |
| 5550 } |
| 5551 |
5526 void Document::trace(Visitor* visitor) | 5552 void Document::trace(Visitor* visitor) |
5527 { | 5553 { |
| 5554 visitor->trace(m_visibilityObservers); |
| 5555 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); |
5528 Supplementable<Document>::trace(visitor); | 5556 Supplementable<Document>::trace(visitor); |
| 5557 TreeScope::trace(visitor); |
5529 ContainerNode::trace(visitor); | 5558 ContainerNode::trace(visitor); |
5530 } | 5559 } |
5531 | 5560 |
5532 } // namespace WebCore | 5561 } // namespace WebCore |
OLD | NEW |