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 317 matching lines...) Loading... |
328 | 328 |
329 static bool acceptsEditingFocus(const Element& element) | 329 static bool acceptsEditingFocus(const Element& element) |
330 { | 330 { |
331 ASSERT(element.hasEditableStyle()); | 331 ASSERT(element.hasEditableStyle()); |
332 | 332 |
333 return element.document().frame() && element.rootEditableElement(); | 333 return element.document().frame() && element.rootEditableElement(); |
334 } | 334 } |
335 | 335 |
336 uint64_t Document::s_globalTreeVersion = 0; | 336 uint64_t Document::s_globalTreeVersion = 0; |
337 | 337 |
338 #ifndef NDEBUG | 338 Document::WeakDocumentSet& Document::liveDocumentSet() |
339 using WeakDocumentSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<Document>>; | |
340 static WeakDocumentSet& liveDocumentSet() | |
341 { | 339 { |
342 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW
illBeNoop(new WeakDocumentSet()))); | 340 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW
illBeNoop(new WeakDocumentSet()))); |
343 return *set; | 341 return *set; |
344 } | 342 } |
345 #endif | |
346 | 343 |
347 // This class doesn't work with non-Document ExecutionContext. | 344 // This class doesn't work with non-Document ExecutionContext. |
348 class AutofocusTask final : public ExecutionContextTask { | 345 class AutofocusTask final : public ExecutionContextTask { |
349 public: | 346 public: |
350 static PassOwnPtr<AutofocusTask> create() | 347 static PassOwnPtr<AutofocusTask> create() |
351 { | 348 { |
352 return adoptPtr(new AutofocusTask()); | 349 return adoptPtr(new AutofocusTask()); |
353 } | 350 } |
354 ~AutofocusTask() override { } | 351 ~AutofocusTask() override { } |
355 | 352 |
(...skipping 72 matching lines...) Loading... |
428 , m_writeRecursionDepth(0) | 425 , m_writeRecursionDepth(0) |
429 , m_taskRunner(MainThreadTaskRunner::create(this)) | 426 , m_taskRunner(MainThreadTaskRunner::create(this)) |
430 , m_registrationContext(initializer.registrationContext(this)) | 427 , m_registrationContext(initializer.registrationContext(this)) |
431 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) | 428 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) |
432 , m_timeline(AnimationTimeline::create(this)) | 429 , m_timeline(AnimationTimeline::create(this)) |
433 , m_templateDocumentHost(nullptr) | 430 , m_templateDocumentHost(nullptr) |
434 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) | 431 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) |
435 , m_hasViewportUnits(false) | 432 , m_hasViewportUnits(false) |
436 , m_styleRecalcElementCounter(0) | 433 , m_styleRecalcElementCounter(0) |
437 , m_parserSyncPolicy(AllowAsynchronousParsing) | 434 , m_parserSyncPolicy(AllowAsynchronousParsing) |
| 435 , m_nodeCount(0) |
438 { | 436 { |
439 if (m_frame) { | 437 if (m_frame) { |
440 ASSERT(m_frame->page()); | 438 ASSERT(m_frame->page()); |
441 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 439 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
442 | 440 |
443 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 441 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
444 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 442 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
445 } else if (m_importsController) { | 443 } else if (m_importsController) { |
446 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); | 444 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); |
447 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 445 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
(...skipping 25 matching lines...) Loading... |
473 // CSSFontSelector, need to initialize m_styleEngine after initializing | 471 // CSSFontSelector, need to initialize m_styleEngine after initializing |
474 // m_fetcher. | 472 // m_fetcher. |
475 m_styleEngine = StyleEngine::create(*this); | 473 m_styleEngine = StyleEngine::create(*this); |
476 | 474 |
477 // The parent's parser should be suspended together with all the other objec
ts, | 475 // The parent's parser should be suspended together with all the other objec
ts, |
478 // else this new Document would have a new ExecutionContext which suspended
state | 476 // else this new Document would have a new ExecutionContext which suspended
state |
479 // would not match the one from the parent, and could start loading resource
s | 477 // would not match the one from the parent, and could start loading resource
s |
480 // ignoring the defersLoading flag. | 478 // ignoring the defersLoading flag. |
481 ASSERT(!parentDocument() || !parentDocument()->activeDOMObjectsAreSuspended(
)); | 479 ASSERT(!parentDocument() || !parentDocument()->activeDOMObjectsAreSuspended(
)); |
482 | 480 |
483 #ifndef NDEBUG | |
484 liveDocumentSet().add(this); | 481 liveDocumentSet().add(this); |
485 #endif | |
486 } | 482 } |
487 | 483 |
488 Document::~Document() | 484 Document::~Document() |
489 { | 485 { |
490 ASSERT(!layoutView()); | 486 ASSERT(!layoutView()); |
491 ASSERT(!parentTreeScope()); | 487 ASSERT(!parentTreeScope()); |
492 // If a top document with a cache, verify that it was comprehensively | 488 // If a top document with a cache, verify that it was comprehensively |
493 // cleared during detach. | 489 // cleared during detach. |
494 ASSERT(!m_axObjectCache); | 490 ASSERT(!m_axObjectCache); |
495 #if !ENABLE(OILPAN) | 491 #if !ENABLE(OILPAN) |
(...skipping 40 matching lines...) Loading... |
536 // We must call clearRareData() here since a Document class inherits TreeSco
pe | 532 // We must call clearRareData() here since a Document class inherits TreeSco
pe |
537 // as well as Node. See a comment on TreeScope.h for the reason. | 533 // as well as Node. See a comment on TreeScope.h for the reason. |
538 if (hasRareData()) | 534 if (hasRareData()) |
539 clearRareData(); | 535 clearRareData(); |
540 | 536 |
541 ASSERT(m_listsInvalidatedAtDocument.isEmpty()); | 537 ASSERT(m_listsInvalidatedAtDocument.isEmpty()); |
542 | 538 |
543 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); ++i) | 539 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); ++i) |
544 ASSERT(!m_nodeListCounts[i]); | 540 ASSERT(!m_nodeListCounts[i]); |
545 | 541 |
546 #ifndef NDEBUG | |
547 liveDocumentSet().remove(this); | 542 liveDocumentSet().remove(this); |
548 #endif | 543 #endif |
549 #endif | |
550 | 544 |
551 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); | 545 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); |
552 } | 546 } |
553 | 547 |
554 #if !ENABLE(OILPAN) | 548 #if !ENABLE(OILPAN) |
555 void Document::dispose() | 549 void Document::dispose() |
556 { | 550 { |
557 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); | 551 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); |
558 | 552 |
559 // We must make sure not to be retaining any of our children through | 553 // We must make sure not to be retaining any of our children through |
(...skipping 30 matching lines...) Loading... |
590 m_scriptedAnimationController->clearDocumentPointer(); | 584 m_scriptedAnimationController->clearDocumentPointer(); |
591 m_scriptedAnimationController.clear(); | 585 m_scriptedAnimationController.clear(); |
592 | 586 |
593 if (svgExtensions()) | 587 if (svgExtensions()) |
594 accessSVGExtensions().pauseAnimations(); | 588 accessSVGExtensions().pauseAnimations(); |
595 | 589 |
596 m_lifecycle.advanceTo(DocumentLifecycle::Disposed); | 590 m_lifecycle.advanceTo(DocumentLifecycle::Disposed); |
597 DocumentLifecycleNotifier::notifyDocumentWasDisposed(); | 591 DocumentLifecycleNotifier::notifyDocumentWasDisposed(); |
598 | 592 |
599 m_canvasFontCache.clear(); | 593 m_canvasFontCache.clear(); |
| 594 m_nodeCount = 0; |
600 } | 595 } |
601 #endif | 596 #endif |
602 | 597 |
603 SelectorQueryCache& Document::selectorQueryCache() | 598 SelectorQueryCache& Document::selectorQueryCache() |
604 { | 599 { |
605 if (!m_selectorQueryCache) | 600 if (!m_selectorQueryCache) |
606 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); | 601 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); |
607 return *m_selectorQueryCache; | 602 return *m_selectorQueryCache; |
608 } | 603 } |
609 | 604 |
(...skipping 5164 matching lines...) Loading... |
5774 } | 5769 } |
5775 | 5770 |
5776 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; | 5771 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; |
5777 | 5772 |
5778 } // namespace blink | 5773 } // namespace blink |
5779 | 5774 |
5780 #ifndef NDEBUG | 5775 #ifndef NDEBUG |
5781 using namespace blink; | 5776 using namespace blink; |
5782 void showLiveDocumentInstances() | 5777 void showLiveDocumentInstances() |
5783 { | 5778 { |
5784 WeakDocumentSet& set = liveDocumentSet(); | 5779 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5785 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5780 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5786 for (Document* document : set) | 5781 for (Document* document : set) |
5787 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5782 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5788 } | 5783 } |
5789 #endif | 5784 #endif |
OLD | NEW |