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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #include "core/dom/DocumentFragment.h" | 69 #include "core/dom/DocumentFragment.h" |
70 #include "core/dom/DocumentLifecycleObserver.h" | 70 #include "core/dom/DocumentLifecycleObserver.h" |
71 #include "core/dom/DocumentType.h" | 71 #include "core/dom/DocumentType.h" |
72 #include "core/dom/Element.h" | 72 #include "core/dom/Element.h" |
73 #include "core/dom/ElementDataCache.h" | 73 #include "core/dom/ElementDataCache.h" |
74 #include "core/dom/ElementRegistrationOptions.h" | 74 #include "core/dom/ElementRegistrationOptions.h" |
75 #include "core/dom/ElementTraversal.h" | 75 #include "core/dom/ElementTraversal.h" |
76 #include "core/dom/ExceptionCode.h" | 76 #include "core/dom/ExceptionCode.h" |
77 #include "core/dom/ExecutionContextTask.h" | 77 #include "core/dom/ExecutionContextTask.h" |
78 #include "core/dom/FrameRequestCallback.h" | 78 #include "core/dom/FrameRequestCallback.h" |
| 79 #include "core/dom/IntersectionObserver.h" |
79 #include "core/dom/LayoutTreeBuilderTraversal.h" | 80 #include "core/dom/LayoutTreeBuilderTraversal.h" |
80 #include "core/dom/MainThreadTaskRunner.h" | 81 #include "core/dom/MainThreadTaskRunner.h" |
81 #include "core/dom/Microtask.h" | 82 #include "core/dom/Microtask.h" |
82 #include "core/dom/MutationObserver.h" | 83 #include "core/dom/MutationObserver.h" |
83 #include "core/dom/NodeChildRemovalTracker.h" | 84 #include "core/dom/NodeChildRemovalTracker.h" |
84 #include "core/dom/NodeComputedStyle.h" | 85 #include "core/dom/NodeComputedStyle.h" |
85 #include "core/dom/NodeFilter.h" | 86 #include "core/dom/NodeFilter.h" |
86 #include "core/dom/NodeIterator.h" | 87 #include "core/dom/NodeIterator.h" |
87 #include "core/dom/NodeRareData.h" | 88 #include "core/dom/NodeRareData.h" |
88 #include "core/dom/NodeTraversal.h" | 89 #include "core/dom/NodeTraversal.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 #include "wtf/text/StringBuffer.h" | 226 #include "wtf/text/StringBuffer.h" |
226 #include "wtf/text/TextEncodingRegistry.h" | 227 #include "wtf/text/TextEncodingRegistry.h" |
227 | 228 |
228 using namespace WTF; | 229 using namespace WTF; |
229 using namespace Unicode; | 230 using namespace Unicode; |
230 | 231 |
231 namespace blink { | 232 namespace blink { |
232 | 233 |
233 using namespace HTMLNames; | 234 using namespace HTMLNames; |
234 | 235 |
| 236 using IntersectionObserverVector = WillBeHeapVector<RefPtrWillBeMember<Intersect
ionObserver>>; |
| 237 |
235 static const unsigned cMaxWriteRecursionDepth = 21; | 238 static const unsigned cMaxWriteRecursionDepth = 21; |
236 | 239 |
237 // This amount of time must have elapsed before we will even consider scheduling
a layout without a delay. | 240 // This amount of time must have elapsed before we will even consider scheduling
a layout without a delay. |
238 // FIXME: For faster machines this value can really be lowered to 200. 250 is a
dequate, but a little high | 241 // FIXME: For faster machines this value can really be lowered to 200. 250 is a
dequate, but a little high |
239 // for dual G5s. :) | 242 // for dual G5s. :) |
240 static const int cLayoutScheduleThreshold = 250; | 243 static const int cLayoutScheduleThreshold = 250; |
241 | 244 |
242 // DOM Level 2 says (letters added): | 245 // DOM Level 2 says (letters added): |
243 // | 246 // |
244 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl. | 247 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 , m_isMobileDocument(false) | 426 , m_isMobileDocument(false) |
424 , m_layoutView(0) | 427 , m_layoutView(0) |
425 #if !ENABLE(OILPAN) | 428 #if !ENABLE(OILPAN) |
426 , m_weakFactory(this) | 429 , m_weakFactory(this) |
427 #endif | 430 #endif |
428 , m_contextDocument(initializer.contextDocument()) | 431 , m_contextDocument(initializer.contextDocument()) |
429 , m_hasFullscreenSupplement(false) | 432 , m_hasFullscreenSupplement(false) |
430 , m_loadEventDelayCount(0) | 433 , m_loadEventDelayCount(0) |
431 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) | 434 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) |
432 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) | 435 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) |
| 436 , m_deliverIntersectionObservationsTimer(this, &Document::deliverIntersectio
nObservationsTimerFired) |
433 , m_documentTiming(*this) | 437 , m_documentTiming(*this) |
434 , m_writeRecursionIsTooDeep(false) | 438 , m_writeRecursionIsTooDeep(false) |
435 , m_writeRecursionDepth(0) | 439 , m_writeRecursionDepth(0) |
436 , m_taskRunner(MainThreadTaskRunner::create(this)) | 440 , m_taskRunner(MainThreadTaskRunner::create(this)) |
437 , m_registrationContext(initializer.registrationContext(this)) | 441 , m_registrationContext(initializer.registrationContext(this)) |
438 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) | 442 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) |
439 , m_timeline(AnimationTimeline::create(this)) | 443 , m_timeline(AnimationTimeline::create(this)) |
440 , m_templateDocumentHost(nullptr) | 444 , m_templateDocumentHost(nullptr) |
441 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) | 445 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) |
442 , m_hasViewportUnits(false) | 446 , m_hasViewportUnits(false) |
(...skipping 5222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5665 if (!context->securityOrigin()->isPotentiallyTrustworthy(err
orMessage)) | 5669 if (!context->securityOrigin()->isPotentiallyTrustworthy(err
orMessage)) |
5666 return false; | 5670 return false; |
5667 } | 5671 } |
5668 } | 5672 } |
5669 context = context->parentDocument(); | 5673 context = context->parentDocument(); |
5670 } | 5674 } |
5671 } | 5675 } |
5672 return true; | 5676 return true; |
5673 } | 5677 } |
5674 | 5678 |
| 5679 void Document::activateIntersectionObserver(IntersectionObserver& observer) |
| 5680 { |
| 5681 if (m_activeIntersectionObservers.isEmpty()) |
| 5682 m_deliverIntersectionObservationsTimer.startOneShot(0, FROM_HERE); |
| 5683 |
| 5684 m_activeIntersectionObservers.add(&observer); |
| 5685 } |
| 5686 |
| 5687 void Document::resumeSuspendedIntersectionObservers() |
| 5688 { |
| 5689 ASSERT(isMainThread()); |
| 5690 if (m_suspendedIntersectionObservers.isEmpty()) |
| 5691 return; |
| 5692 |
| 5693 IntersectionObserverVector suspended; |
| 5694 copyToVector(m_suspendedIntersectionObservers, suspended); |
| 5695 for (size_t i = 0; i < suspended.size(); ++i) { |
| 5696 if (!suspended[i]->shouldBeSuspended()) { |
| 5697 m_suspendedIntersectionObservers.remove(suspended[i]); |
| 5698 activateIntersectionObserver(*suspended[i]); |
| 5699 } |
| 5700 } |
| 5701 } |
| 5702 |
| 5703 void Document::deliverIntersectionObservationsTimerFired(Timer<Document>*) |
| 5704 { |
| 5705 ASSERT(isMainThread()); |
| 5706 IntersectionObserverVector observers; |
| 5707 copyToVector(m_activeIntersectionObservers, observers); |
| 5708 m_activeIntersectionObservers.clear(); |
| 5709 for (size_t i = 0; i < observers.size(); ++i) { |
| 5710 if (observers[i]->shouldBeSuspended()) |
| 5711 m_suspendedIntersectionObservers.add(observers[i]); |
| 5712 else |
| 5713 observers[i]->deliver(); |
| 5714 } |
| 5715 } |
| 5716 |
5675 DEFINE_TRACE(Document) | 5717 DEFINE_TRACE(Document) |
5676 { | 5718 { |
5677 #if ENABLE(OILPAN) | 5719 #if ENABLE(OILPAN) |
5678 visitor->trace(m_importsController); | 5720 visitor->trace(m_importsController); |
5679 visitor->trace(m_docType); | 5721 visitor->trace(m_docType); |
5680 visitor->trace(m_implementation); | 5722 visitor->trace(m_implementation); |
5681 visitor->trace(m_autofocusElement); | 5723 visitor->trace(m_autofocusElement); |
5682 visitor->trace(m_focusedElement); | 5724 visitor->trace(m_focusedElement); |
5683 visitor->trace(m_hoverNode); | 5725 visitor->trace(m_hoverNode); |
5684 visitor->trace(m_activeHoverElement); | 5726 visitor->trace(m_activeHoverElement); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5721 visitor->trace(m_timers); | 5763 visitor->trace(m_timers); |
5722 visitor->trace(m_templateDocument); | 5764 visitor->trace(m_templateDocument); |
5723 visitor->trace(m_templateDocumentHost); | 5765 visitor->trace(m_templateDocumentHost); |
5724 visitor->trace(m_visibilityObservers); | 5766 visitor->trace(m_visibilityObservers); |
5725 visitor->trace(m_userActionElements); | 5767 visitor->trace(m_userActionElements); |
5726 visitor->trace(m_svgExtensions); | 5768 visitor->trace(m_svgExtensions); |
5727 visitor->trace(m_timeline); | 5769 visitor->trace(m_timeline); |
5728 visitor->trace(m_compositorPendingAnimations); | 5770 visitor->trace(m_compositorPendingAnimations); |
5729 visitor->trace(m_contextDocument); | 5771 visitor->trace(m_contextDocument); |
5730 visitor->trace(m_canvasFontCache); | 5772 visitor->trace(m_canvasFontCache); |
| 5773 visitor->trace(m_activeIntersectionObservers); |
| 5774 visitor->trace(m_suspendedIntersectionObservers); |
5731 WillBeHeapSupplementable<Document>::trace(visitor); | 5775 WillBeHeapSupplementable<Document>::trace(visitor); |
5732 #endif | 5776 #endif |
5733 TreeScope::trace(visitor); | 5777 TreeScope::trace(visitor); |
5734 ContainerNode::trace(visitor); | 5778 ContainerNode::trace(visitor); |
5735 ExecutionContext::trace(visitor); | 5779 ExecutionContext::trace(visitor); |
5736 DocumentLifecycleNotifier::trace(visitor); | 5780 DocumentLifecycleNotifier::trace(visitor); |
5737 SecurityContext::trace(visitor); | 5781 SecurityContext::trace(visitor); |
5738 } | 5782 } |
5739 | 5783 |
5740 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; | 5784 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; |
5741 | 5785 |
5742 } // namespace blink | 5786 } // namespace blink |
5743 | 5787 |
5744 #ifndef NDEBUG | 5788 #ifndef NDEBUG |
5745 using namespace blink; | 5789 using namespace blink; |
5746 void showLiveDocumentInstances() | 5790 void showLiveDocumentInstances() |
5747 { | 5791 { |
5748 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5792 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5749 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5793 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5750 for (Document* document : set) | 5794 for (Document* document : set) |
5751 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5795 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5752 } | 5796 } |
5753 #endif | 5797 #endif |
OLD | NEW |