LEFT | RIGHT |
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-2018 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004-2018 Apple Inc. All rights 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #include "PlatformStrategies.h" | 147 #include "PlatformStrategies.h" |
148 #include "PlugInsResources.h" | 148 #include "PlugInsResources.h" |
149 #include "PluginDocument.h" | 149 #include "PluginDocument.h" |
150 #include "PointerLockController.h" | 150 #include "PointerLockController.h" |
151 #include "PolicyChecker.h" | 151 #include "PolicyChecker.h" |
152 #include "PopStateEvent.h" | 152 #include "PopStateEvent.h" |
153 #include "ProcessingInstruction.h" | 153 #include "ProcessingInstruction.h" |
154 #include "PublicSuffix.h" | 154 #include "PublicSuffix.h" |
155 #include "RealtimeMediaSourceCenter.h" | 155 #include "RealtimeMediaSourceCenter.h" |
156 #include "RenderChildIterator.h" | 156 #include "RenderChildIterator.h" |
| 157 #include "RenderInline.h" |
157 #include "RenderLayerCompositor.h" | 158 #include "RenderLayerCompositor.h" |
| 159 #include "RenderLineBreak.h" |
158 #include "RenderTreeUpdater.h" | 160 #include "RenderTreeUpdater.h" |
159 #include "RenderView.h" | 161 #include "RenderView.h" |
160 #include "RenderWidget.h" | 162 #include "RenderWidget.h" |
161 #include "RequestAnimationFrameCallback.h" | 163 #include "RequestAnimationFrameCallback.h" |
162 #include "ResourceLoadObserver.h" | 164 #include "ResourceLoadObserver.h" |
163 #include "RuntimeApplicationChecks.h" | 165 #include "RuntimeApplicationChecks.h" |
164 #include "RuntimeEnabledFeatures.h" | 166 #include "RuntimeEnabledFeatures.h" |
165 #include "SVGDocumentExtensions.h" | 167 #include "SVGDocumentExtensions.h" |
166 #include "SVGElement.h" | 168 #include "SVGElement.h" |
167 #include "SVGElementFactory.h" | 169 #include "SVGElementFactory.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 #if ENABLE(VIDEO) | 646 #if ENABLE(VIDEO) |
645 if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedM
anagerIfExists()) | 647 if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedM
anagerIfExists()) |
646 platformMediaSessionManager->stopAllMediaPlaybackForDocument(this); | 648 platformMediaSessionManager->stopAllMediaPlaybackForDocument(this); |
647 #endif | 649 #endif |
648 ···· | 650 ···· |
649 // We must call clearRareData() here since a Document class inherits TreeSco
pe | 651 // We must call clearRareData() here since a Document class inherits TreeSco
pe |
650 // as well as Node. See a comment on TreeScope.h for the reason. | 652 // as well as Node. See a comment on TreeScope.h for the reason. |
651 if (hasRareData()) | 653 if (hasRareData()) |
652 clearRareData(); | 654 clearRareData(); |
653 | 655 |
| 656 for (auto* observer : m_viewportIntersectionObservers) |
| 657 observer->implicitRootDocumentDestroyed(); |
| 658 m_viewportIntersectionObservers.clear(); |
| 659 |
654 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_listsInvalidatedAtDocument.isEmpt
y()); | 660 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_listsInvalidatedAtDocument.isEmpt
y()); |
655 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_collectionsInvalidatedAtDocument.
isEmpty()); | 661 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_collectionsInvalidatedAtDocument.
isEmpty()); |
656 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_svgUseElements.isEmpty()); | 662 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_svgUseElements.isEmpty()); |
657 | 663 |
658 for (unsigned count : m_nodeListAndCollectionCounts) | 664 for (unsigned count : m_nodeListAndCollectionCounts) |
659 ASSERT_UNUSED(count, !count); | 665 ASSERT_UNUSED(count, !count); |
660 } | 666 } |
661 | 667 |
662 void Document::removedLastRef() | 668 void Document::removedLastRef() |
663 { | 669 { |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 { | 1355 { |
1350 if (!XMLDocumentParser::supportsXMLVersion(version)) | 1356 if (!XMLDocumentParser::supportsXMLVersion(version)) |
1351 return Exception { NotSupportedError }; | 1357 return Exception { NotSupportedError }; |
1352 | 1358 |
1353 m_xmlVersion = version; | 1359 m_xmlVersion = version; |
1354 return { }; | 1360 return { }; |
1355 } | 1361 } |
1356 | 1362 |
1357 void Document::setXMLStandalone(bool standalone) | 1363 void Document::setXMLStandalone(bool standalone) |
1358 { | 1364 { |
1359 m_xmlStandalone = standalone ? Standalone : NotStandalone; | 1365 m_xmlStandalone = standalone ? StandaloneStatus::Standalone : StandaloneStat
us::NotStandalone; |
1360 } | 1366 } |
1361 | 1367 |
1362 void Document::setDocumentURI(const String& uri) | 1368 void Document::setDocumentURI(const String& uri) |
1363 { | 1369 { |
1364 // This property is read-only from JavaScript, but writable from Objective-C
. | 1370 // This property is read-only from JavaScript, but writable from Objective-C
. |
1365 m_documentURI = uri; | 1371 m_documentURI = uri; |
1366 updateBaseURL(); | 1372 updateBaseURL(); |
1367 } | 1373 } |
1368 | 1374 |
1369 void Document::setContent(const String& content) | 1375 void Document::setContent(const String& content) |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 styleScope().flushPendingUpdate(); | 1971 styleScope().flushPendingUpdate(); |
1966 | 1972 |
1967 if (!needsStyleRecalc()) | 1973 if (!needsStyleRecalc()) |
1968 return false; | 1974 return false; |
1969 } | 1975 } |
1970 | 1976 |
1971 // The early exit above for !needsStyleRecalc() is needed when updateWidgetP
ositions() is called in runOrScheduleAsynchronousTasks(). | 1977 // The early exit above for !needsStyleRecalc() is needed when updateWidgetP
ositions() is called in runOrScheduleAsynchronousTasks(). |
1972 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout(*this))
; | 1978 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout(*this))
; |
1973 | 1979 |
1974 resolveStyle(); | 1980 resolveStyle(); |
1975 updateIntersectionObservations(); | |
1976 return true; | 1981 return true; |
1977 } | 1982 } |
1978 | 1983 |
1979 void Document::updateLayout() | 1984 void Document::updateLayout() |
1980 { | 1985 { |
1981 ASSERT(isMainThread()); | 1986 ASSERT(isMainThread()); |
1982 | 1987 |
1983 RefPtr<FrameView> frameView = view(); | 1988 RefPtr<FrameView> frameView = view(); |
1984 if (frameView && frameView->layoutContext().isInRenderTreeLayout()) { | 1989 if (frameView && frameView->layoutContext().isInRenderTreeLayout()) { |
1985 // View layout should not be re-entrant. | 1990 // View layout should not be re-entrant. |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2261 wheelEventHandlersChanged(); | 2266 wheelEventHandlersChanged(); |
2262 | 2267 |
2263 // Ensure that the scheduled task state of the document matches the DOM susp
ension state of the frame. It can | 2268 // Ensure that the scheduled task state of the document matches the DOM susp
ension state of the frame. It can |
2264 // be out of sync if the DOM suspension state changed while the document was
not in the frame (possibly in the | 2269 // be out of sync if the DOM suspension state changed while the document was
not in the frame (possibly in the |
2265 // page cache, or simply newly created). | 2270 // page cache, or simply newly created). |
2266 if (m_frame->activeDOMObjectsAndAnimationsSuspended()) { | 2271 if (m_frame->activeDOMObjectsAndAnimationsSuspended()) { |
2267 if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegration
Enabled()) | 2272 if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegration
Enabled()) |
2268 timeline().suspendAnimations(); | 2273 timeline().suspendAnimations(); |
2269 else | 2274 else |
2270 m_frame->animation().suspendAnimationsForDocument(this); | 2275 m_frame->animation().suspendAnimationsForDocument(this); |
2271 suspendScheduledTasks(ActiveDOMObject::PageWillBeSuspended); | 2276 suspendScheduledTasks(ReasonForSuspension::PageWillBeSuspended); |
2272 } else { | 2277 } else { |
2273 resumeScheduledTasks(ActiveDOMObject::PageWillBeSuspended); | 2278 resumeScheduledTasks(ReasonForSuspension::PageWillBeSuspended); |
2274 if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegration
Enabled()) | 2279 if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegration
Enabled()) |
2275 timeline().resumeAnimations(); | 2280 timeline().resumeAnimations(); |
2276 else | 2281 else |
2277 m_frame->animation().resumeAnimationsForDocument(this); | 2282 m_frame->animation().resumeAnimationsForDocument(this); |
2278 } | 2283 } |
2279 } | 2284 } |
2280 | 2285 |
2281 void Document::frameDestroyed() | 2286 void Document::frameDestroyed() |
2282 { | 2287 { |
2283 // detachFromFrame() must be called before destroying the Frame. | 2288 // detachFromFrame() must be called before destroying the Frame. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 #if PLATFORM(IOS) | 2528 #if PLATFORM(IOS) |
2524 if (WebThreadCountOfObservedContentModifiers() > 0) { | 2529 if (WebThreadCountOfObservedContentModifiers() > 0) { |
2525 if (auto* frame = this->frame()) { | 2530 if (auto* frame = this->frame()) { |
2526 if (auto* page = frame->page()) | 2531 if (auto* page = frame->page()) |
2527 page->chrome().client().clearContentChangeObservers(*frame); | 2532 page->chrome().client().clearContentChangeObservers(*frame); |
2528 } | 2533 } |
2529 } | 2534 } |
2530 #endif | 2535 #endif |
2531 } | 2536 } |
2532 | 2537 |
2533 void Document::suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension why) | 2538 void Document::suspendActiveDOMObjects(ReasonForSuspension why) |
2534 { | 2539 { |
2535 ScriptExecutionContext::suspendActiveDOMObjects(why); | 2540 ScriptExecutionContext::suspendActiveDOMObjects(why); |
2536 suspendDeviceMotionAndOrientationUpdates(); | 2541 suspendDeviceMotionAndOrientationUpdates(); |
2537 platformSuspendOrStopActiveDOMObjects(); | 2542 platformSuspendOrStopActiveDOMObjects(); |
2538 } | 2543 } |
2539 | 2544 |
2540 void Document::resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension why) | 2545 void Document::resumeActiveDOMObjects(ReasonForSuspension why) |
2541 { | 2546 { |
2542 ScriptExecutionContext::resumeActiveDOMObjects(why); | 2547 ScriptExecutionContext::resumeActiveDOMObjects(why); |
2543 resumeDeviceMotionAndOrientationUpdates(); | 2548 resumeDeviceMotionAndOrientationUpdates(); |
2544 // FIXME: For iOS, do we need to add content change observers that were remo
ved in Document::suspendActiveDOMObjects()? | 2549 // FIXME: For iOS, do we need to add content change observers that were remo
ved in Document::suspendActiveDOMObjects()? |
2545 } | 2550 } |
2546 | 2551 |
2547 void Document::stopActiveDOMObjects() | 2552 void Document::stopActiveDOMObjects() |
2548 { | 2553 { |
2549 ScriptExecutionContext::stopActiveDOMObjects(); | 2554 ScriptExecutionContext::stopActiveDOMObjects(); |
2550 platformSuspendOrStopActiveDOMObjects(); | 2555 platformSuspendOrStopActiveDOMObjects(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 { | 2614 { |
2610 if (!m_domWindow) | 2615 if (!m_domWindow) |
2611 return Exception { InvalidAccessError }; | 2616 return Exception { InvalidAccessError }; |
2612 | 2617 |
2613 return m_domWindow->open(activeWindow, firstWindow, url, name, features); | 2618 return m_domWindow->open(activeWindow, firstWindow, url, name, features); |
2614 } | 2619 } |
2615 | 2620 |
2616 // FIXME: Add support for the 'type' and 'replace' parameters. | 2621 // FIXME: Add support for the 'type' and 'replace' parameters. |
2617 ExceptionOr<Document&> Document::openForBindings(Document* responsibleDocument,
const String&, const String&) | 2622 ExceptionOr<Document&> Document::openForBindings(Document* responsibleDocument,
const String&, const String&) |
2618 { | 2623 { |
2619 if (!isHTMLDocument()) | 2624 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) |
2620 return Exception { InvalidStateError }; | 2625 return Exception { InvalidStateError }; |
2621 | |
2622 // FIXME: This should also throw if "document's throw-on-dynamic-markup-inse
rtion counter is greater than 0". | |
2623 // https://bugs.webkit.org/show_bug.cgi?id=187319 | |
2624 | 2626 |
2625 open(responsibleDocument); | 2627 open(responsibleDocument); |
2626 return *this; | 2628 return *this; |
2627 } | 2629 } |
2628 | 2630 |
2629 void Document::open(Document* responsibleDocument) | 2631 void Document::open(Document* responsibleDocument) |
2630 { | 2632 { |
2631 if (m_ignoreOpensDuringUnloadCount) | 2633 if (m_ignoreOpensDuringUnloadCount) |
2632 return; | 2634 return; |
2633 | 2635 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 } | 2688 } |
2687 | 2689 |
2688 void Document::implicitOpen() | 2690 void Document::implicitOpen() |
2689 { | 2691 { |
2690 removeChildren(); | 2692 removeChildren(); |
2691 | 2693 |
2692 setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode); | 2694 setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode); |
2693 | 2695 |
2694 cancelParsing(); | 2696 cancelParsing(); |
2695 m_parser = createParser(); | 2697 m_parser = createParser(); |
| 2698 |
| 2699 if (hasActiveParserYieldToken()) |
| 2700 m_parser->didBeginYieldingParser(); |
| 2701 |
2696 setParsing(true); | 2702 setParsing(true); |
2697 setReadyState(Loading); | 2703 setReadyState(Loading); |
2698 } | 2704 } |
2699 | 2705 |
2700 HTMLBodyElement* Document::body() const | 2706 HTMLBodyElement* Document::body() const |
2701 { | 2707 { |
2702 auto* element = documentElement(); | 2708 auto* element = documentElement(); |
2703 if (!element) | 2709 if (!element) |
2704 return nullptr; | 2710 return nullptr; |
2705 return childrenOfType<HTMLBodyElement>(*element).first(); | 2711 return childrenOfType<HTMLBodyElement>(*element).first(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 if (auto element = documentElement()) | 2755 if (auto element = documentElement()) |
2750 return childrenOfType<HTMLHeadElement>(*element).first(); | 2756 return childrenOfType<HTMLHeadElement>(*element).first(); |
2751 return nullptr; | 2757 return nullptr; |
2752 } | 2758 } |
2753 | 2759 |
2754 ExceptionOr<void> Document::closeForBindings() | 2760 ExceptionOr<void> Document::closeForBindings() |
2755 { | 2761 { |
2756 // FIXME: We should follow the specification more closely: | 2762 // FIXME: We should follow the specification more closely: |
2757 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cl
ose | 2763 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cl
ose |
2758 | 2764 |
2759 if (!isHTMLDocument()) | 2765 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) |
2760 return Exception { InvalidStateError }; | 2766 return Exception { InvalidStateError }; |
2761 | |
2762 // FIXME: This should also throw if "document's throw-on-dynamic-markup-inse
rtion counter is greater than 0". | |
2763 // https://bugs.webkit.org/show_bug.cgi?id=187319 | |
2764 | 2767 |
2765 close(); | 2768 close(); |
2766 return { }; | 2769 return { }; |
2767 } | 2770 } |
2768 | 2771 |
2769 void Document::close() | 2772 void Document::close() |
2770 { | 2773 { |
2771 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy
Script() || !scriptableDocumentParser()->isParsing()) | 2774 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy
Script() || !scriptableDocumentParser()->isParsing()) |
2772 return; | 2775 return; |
2773 | 2776 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 | 2983 |
2981 if (!hasInsertionPoint) | 2984 if (!hasInsertionPoint) |
2982 open(responsibleDocument); | 2985 open(responsibleDocument); |
2983 | 2986 |
2984 ASSERT(m_parser); | 2987 ASSERT(m_parser); |
2985 m_parser->insert(WTFMove(text)); | 2988 m_parser->insert(WTFMove(text)); |
2986 } | 2989 } |
2987 | 2990 |
2988 ExceptionOr<void> Document::write(Document* responsibleDocument, Vector<String>&
& strings) | 2991 ExceptionOr<void> Document::write(Document* responsibleDocument, Vector<String>&
& strings) |
2989 { | 2992 { |
2990 if (!isHTMLDocument()) | 2993 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) |
2991 return Exception { InvalidStateError }; | 2994 return Exception { InvalidStateError }; |
2992 | |
2993 // FIXME: This should also throw if "document's throw-on-dynamic-markup-inse
rtion counter is greater than 0". | |
2994 // https://bugs.webkit.org/show_bug.cgi?id=187319 | |
2995 | 2995 |
2996 SegmentedString text; | 2996 SegmentedString text; |
2997 for (auto& string : strings) | 2997 for (auto& string : strings) |
2998 text.append(WTFMove(string)); | 2998 text.append(WTFMove(string)); |
2999 | 2999 |
3000 write(responsibleDocument, WTFMove(text)); | 3000 write(responsibleDocument, WTFMove(text)); |
3001 | 3001 |
3002 return { }; | 3002 return { }; |
3003 } | 3003 } |
3004 | 3004 |
3005 ExceptionOr<void> Document::writeln(Document* responsibleDocument, Vector<String
>&& strings) | 3005 ExceptionOr<void> Document::writeln(Document* responsibleDocument, Vector<String
>&& strings) |
3006 { | 3006 { |
3007 if (!isHTMLDocument()) | 3007 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) |
3008 return Exception { InvalidStateError }; | 3008 return Exception { InvalidStateError }; |
3009 | |
3010 // FIXME: This should also throw if "document's throw-on-dynamic-markup-inse
rtion counter is greater than 0". | |
3011 // https://bugs.webkit.org/show_bug.cgi?id=187319 | |
3012 | 3009 |
3013 SegmentedString text; | 3010 SegmentedString text; |
3014 for (auto& string : strings) | 3011 for (auto& string : strings) |
3015 text.append(WTFMove(string)); | 3012 text.append(WTFMove(string)); |
3016 | 3013 |
3017 text.append("\n"_s); | 3014 text.append("\n"_s); |
3018 write(responsibleDocument, WTFMove(text)); | 3015 write(responsibleDocument, WTFMove(text)); |
3019 | 3016 |
3020 return { }; | 3017 return { }; |
3021 } | 3018 } |
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4897 break; | 4894 break; |
4898 } | 4895 } |
4899 } | 4896 } |
4900 | 4897 |
4901 void Document::documentWillBecomeInactive() | 4898 void Document::documentWillBecomeInactive() |
4902 { | 4899 { |
4903 if (renderView()) | 4900 if (renderView()) |
4904 renderView()->setIsInWindow(false); | 4901 renderView()->setIsInWindow(false); |
4905 } | 4902 } |
4906 | 4903 |
4907 void Document::suspend(ActiveDOMObject::ReasonForSuspension reason) | 4904 void Document::suspend(ReasonForSuspension reason) |
4908 { | 4905 { |
4909 if (m_isSuspended) | 4906 if (m_isSuspended) |
4910 return; | 4907 return; |
4911 | 4908 |
4912 documentWillBecomeInactive(); | 4909 documentWillBecomeInactive(); |
4913 | 4910 |
4914 for (auto* element : m_documentSuspensionCallbackElements) | 4911 for (auto* element : m_documentSuspensionCallbackElements) |
4915 element->prepareForDocumentSuspension(); | 4912 element->prepareForDocumentSuspension(); |
4916 | 4913 |
4917 #ifndef NDEBUG | 4914 #ifndef NDEBUG |
(...skipping 12 matching lines...) Expand all Loading... |
4930 | 4927 |
4931 #if USE(LIBWEBRTC) | 4928 #if USE(LIBWEBRTC) |
4932 // FIXME: This should be moved to Modules/mediastream. | 4929 // FIXME: This should be moved to Modules/mediastream. |
4933 if (LibWebRTCProvider::webRTCAvailable()) { | 4930 if (LibWebRTCProvider::webRTCAvailable()) { |
4934 if (auto* page = this->page()) | 4931 if (auto* page = this->page()) |
4935 page->libWebRTCProvider().unregisterMDNSNames(identifier().toUInt64(
)); | 4932 page->libWebRTCProvider().unregisterMDNSNames(identifier().toUInt64(
)); |
4936 } | 4933 } |
4937 #endif | 4934 #endif |
4938 | 4935 |
4939 #if ENABLE(SERVICE_WORKER) | 4936 #if ENABLE(SERVICE_WORKER) |
4940 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reaso
n == ActiveDOMObject::ReasonForSuspension::PageCache) { | 4937 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reaso
n == ReasonForSuspension::PageCache) { |
4941 ASSERT_WITH_MESSAGE(!activeServiceWorker(), "Documents with an active se
rvice worker should not go into PageCache in the first place"); | 4938 ASSERT_WITH_MESSAGE(!activeServiceWorker(), "Documents with an active se
rvice worker should not go into PageCache in the first place"); |
4942 setServiceWorkerConnection(nullptr); | 4939 setServiceWorkerConnection(nullptr); |
4943 } | 4940 } |
4944 #endif | 4941 #endif |
4945 | 4942 |
4946 suspendScheduledTasks(reason); | 4943 suspendScheduledTasks(reason); |
4947 | 4944 |
4948 ASSERT(m_frame); | 4945 ASSERT(m_frame); |
4949 m_frame->clearTimers(); | 4946 m_frame->clearTimers(); |
4950 | 4947 |
4951 m_visualUpdatesAllowed = false; | 4948 m_visualUpdatesAllowed = false; |
4952 m_visualUpdatesSuppressionTimer.stop(); | 4949 m_visualUpdatesSuppressionTimer.stop(); |
4953 | 4950 |
4954 m_isSuspended = true; | 4951 m_isSuspended = true; |
4955 } | 4952 } |
4956 | 4953 |
4957 void Document::resume(ActiveDOMObject::ReasonForSuspension reason) | 4954 void Document::resume(ReasonForSuspension reason) |
4958 { | 4955 { |
4959 if (!m_isSuspended) | 4956 if (!m_isSuspended) |
4960 return; | 4957 return; |
4961 | 4958 |
4962 for (auto* element : copyToVector(m_documentSuspensionCallbackElements)) | 4959 for (auto* element : copyToVector(m_documentSuspensionCallbackElements)) |
4963 element->resumeFromDocumentSuspension(); | 4960 element->resumeFromDocumentSuspension(); |
4964 | 4961 |
4965 if (renderView()) | 4962 if (renderView()) |
4966 renderView()->setIsInWindow(true); | 4963 renderView()->setIsInWindow(true); |
4967 | 4964 |
4968 ASSERT(page()); | 4965 ASSERT(page()); |
4969 page()->lockAllOverlayScrollbarsToHidden(false); | 4966 page()->lockAllOverlayScrollbarsToHidden(false); |
4970 | 4967 |
4971 ASSERT(m_frame); | 4968 ASSERT(m_frame); |
4972 m_frame->loader().client().dispatchDidBecomeFrameset(isFrameSet()); | 4969 m_frame->loader().client().dispatchDidBecomeFrameset(isFrameSet()); |
4973 | 4970 |
4974 if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnab
led()) | 4971 if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnab
led()) |
4975 timeline().resumeAnimations(); | 4972 timeline().resumeAnimations(); |
4976 else | 4973 else |
4977 m_frame->animation().resumeAnimationsForDocument(this); | 4974 m_frame->animation().resumeAnimationsForDocument(this); |
4978 | 4975 |
4979 resumeScheduledTasks(reason); | 4976 resumeScheduledTasks(reason); |
4980 | 4977 |
4981 m_visualUpdatesAllowed = true; | 4978 m_visualUpdatesAllowed = true; |
4982 | 4979 |
4983 m_isSuspended = false; | 4980 m_isSuspended = false; |
4984 | 4981 |
4985 #if ENABLE(SERVICE_WORKER) | 4982 #if ENABLE(SERVICE_WORKER) |
4986 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reaso
n == ActiveDOMObject::ReasonForSuspension::PageCache) { | 4983 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reaso
n == ReasonForSuspension::PageCache) { |
4987 ASSERT_WITH_MESSAGE(!activeServiceWorker(), "Documents with an active se
rvice worker should not go into PageCache in the first place"); | 4984 ASSERT_WITH_MESSAGE(!activeServiceWorker(), "Documents with an active se
rvice worker should not go into PageCache in the first place"); |
4988 setServiceWorkerConnection(ServiceWorkerProvider::singleton().existingSe
rviceWorkerConnectionForSession(sessionID())); | 4985 setServiceWorkerConnection(ServiceWorkerProvider::singleton().existingSe
rviceWorkerConnectionForSession(sessionID())); |
4989 } | 4986 } |
4990 #endif | 4987 #endif |
4991 } | 4988 } |
4992 | 4989 |
4993 void Document::registerForDocumentSuspensionCallbacks(Element* e) | 4990 void Document::registerForDocumentSuspensionCallbacks(Element* e) |
4994 { | 4991 { |
4995 m_documentSuspensionCallbackElements.add(e); | 4992 m_documentSuspensionCallbackElements.add(e); |
4996 } | 4993 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5187 | 5184 |
5188 void Document::pushCurrentScript(HTMLScriptElement* newCurrentScript) | 5185 void Document::pushCurrentScript(HTMLScriptElement* newCurrentScript) |
5189 { | 5186 { |
5190 m_currentScriptStack.append(newCurrentScript); | 5187 m_currentScriptStack.append(newCurrentScript); |
5191 } | 5188 } |
5192 | 5189 |
5193 void Document::popCurrentScript() | 5190 void Document::popCurrentScript() |
5194 { | 5191 { |
5195 ASSERT(!m_currentScriptStack.isEmpty()); | 5192 ASSERT(!m_currentScriptStack.isEmpty()); |
5196 m_currentScriptStack.removeLast(); | 5193 m_currentScriptStack.removeLast(); |
| 5194 } |
| 5195 |
| 5196 bool Document::shouldDeferAsynchronousScriptsUntilParsingFinishes() const |
| 5197 { |
| 5198 return parsing() && settings().shouldDeferAsynchronousScriptsUntilAfterDocum
entLoad(); |
5197 } | 5199 } |
5198 | 5200 |
5199 #if ENABLE(XSLT) | 5201 #if ENABLE(XSLT) |
5200 | 5202 |
5201 void Document::scheduleToApplyXSLTransforms() | 5203 void Document::scheduleToApplyXSLTransforms() |
5202 { | 5204 { |
5203 m_hasPendingXSLTransforms = true; | 5205 m_hasPendingXSLTransforms = true; |
5204 if (!m_applyPendingXSLTransformsTimer.isActive()) | 5206 if (!m_applyPendingXSLTransformsTimer.isActive()) |
5205 m_applyPendingXSLTransformsTimer.startOneShot(0_s); | 5207 m_applyPendingXSLTransformsTimer.startOneShot(0_s); |
5206 } | 5208 } |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5424 return ensureRareData().ensureNodeLists().addCachedCollection<DocumentNameCo
llection>(*this, DocumentNamedItems, name); | 5426 return ensureRareData().ensureNodeLists().addCachedCollection<DocumentNameCo
llection>(*this, DocumentNamedItems, name); |
5425 } | 5427 } |
5426 | 5428 |
5427 void Document::finishedParsing() | 5429 void Document::finishedParsing() |
5428 { | 5430 { |
5429 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); | 5431 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); |
5430 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); | 5432 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); |
5431 setParsing(false); | 5433 setParsing(false); |
5432 | 5434 |
5433 Ref<Document> protectedThis(*this); | 5435 Ref<Document> protectedThis(*this); |
| 5436 |
| 5437 scriptRunner()->documentFinishedParsing(); |
5434 | 5438 |
5435 if (!m_documentTiming.domContentLoadedEventStart) | 5439 if (!m_documentTiming.domContentLoadedEventStart) |
5436 m_documentTiming.domContentLoadedEventStart = MonotonicTime::now(); | 5440 m_documentTiming.domContentLoadedEventStart = MonotonicTime::now(); |
5437 | 5441 |
5438 dispatchEvent(Event::create(eventNames().DOMContentLoadedEvent, true, false)
); | 5442 dispatchEvent(Event::create(eventNames().DOMContentLoadedEvent, true, false)
); |
5439 | 5443 |
5440 if (!m_documentTiming.domContentLoadedEventEnd) | 5444 if (!m_documentTiming.domContentLoadedEventEnd) |
5441 m_documentTiming.domContentLoadedEventEnd = MonotonicTime::now(); | 5445 m_documentTiming.domContentLoadedEventEnd = MonotonicTime::now(); |
5442 | 5446 |
5443 if (RefPtr<Frame> frame = this->frame()) { | 5447 if (RefPtr<Frame> frame = this->frame()) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5658 return openerFrame->document()->securityOrigin().canAccess(securityOrigin())
; | 5662 return openerFrame->document()->securityOrigin().canAccess(securityOrigin())
; |
5659 } | 5663 } |
5660 | 5664 |
5661 void Document::initContentSecurityPolicy() | 5665 void Document::initContentSecurityPolicy() |
5662 { | 5666 { |
5663 // 1. Inherit Upgrade Insecure Requests | 5667 // 1. Inherit Upgrade Insecure Requests |
5664 Frame* parentFrame = m_frame->tree().parent(); | 5668 Frame* parentFrame = m_frame->tree().parent(); |
5665 if (parentFrame) | 5669 if (parentFrame) |
5666 contentSecurityPolicy()->copyUpgradeInsecureRequestStateFrom(*parentFram
e->document()->contentSecurityPolicy()); | 5670 contentSecurityPolicy()->copyUpgradeInsecureRequestStateFrom(*parentFram
e->document()->contentSecurityPolicy()); |
5667 | 5671 |
5668 // 2. Inherit Content Security Policy | 5672 // 2. Inherit Content Security Policy (without copying Upgrade Insecure Requ
ests state). |
5669 if (!shouldInheritContentSecurityPolicyFromOwner()) | 5673 if (!shouldInheritContentSecurityPolicyFromOwner()) |
5670 return; | 5674 return; |
5671 Frame* ownerFrame = parentFrame; | 5675 Frame* ownerFrame = parentFrame; |
5672 if (!ownerFrame) | 5676 if (!ownerFrame) |
5673 ownerFrame = m_frame->loader().opener(); | 5677 ownerFrame = m_frame->loader().opener(); |
5674 if (!ownerFrame) | 5678 if (!ownerFrame) |
5675 return; | 5679 return; |
5676 contentSecurityPolicy()->copyStateFrom(ownerFrame->document()->contentSecuri
tyPolicy()); // Does not copy Upgrade Insecure Requests state. | 5680 // FIXME: The CSP 3 spec. implies that only plugin documents delivered with
a local scheme (e.g. blob, file, data) |
| 5681 // should inherit a policy. |
| 5682 if (isPluginDocument() && m_frame->loader().opener()) |
| 5683 contentSecurityPolicy()->createPolicyForPluginDocumentFrom(*ownerFrame->
document()->contentSecurityPolicy()); |
| 5684 else |
| 5685 contentSecurityPolicy()->copyStateFrom(ownerFrame->document()->contentSe
curityPolicy()); |
5677 } | 5686 } |
5678 | 5687 |
5679 bool Document::isContextThread() const | 5688 bool Document::isContextThread() const |
5680 { | 5689 { |
5681 return isMainThread(); | 5690 return isMainThread(); |
5682 } | 5691 } |
5683 | 5692 |
5684 bool Document::isSecureContext() const | 5693 bool Document::isSecureContext() const |
5685 { | 5694 { |
5686 if (!m_frame) | 5695 if (!m_frame) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5864 }); | 5873 }); |
5865 } | 5874 } |
5866 | 5875 |
5867 void Document::pendingTasksTimerFired() | 5876 void Document::pendingTasksTimerFired() |
5868 { | 5877 { |
5869 Vector<Task> pendingTasks = WTFMove(m_pendingTasks); | 5878 Vector<Task> pendingTasks = WTFMove(m_pendingTasks); |
5870 for (auto& task : pendingTasks) | 5879 for (auto& task : pendingTasks) |
5871 task.performTask(*this); | 5880 task.performTask(*this); |
5872 } | 5881 } |
5873 | 5882 |
5874 void Document::suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension reason
) | 5883 void Document::suspendScheduledTasks(ReasonForSuspension reason) |
5875 { | 5884 { |
5876 if (m_scheduledTasksAreSuspended) { | 5885 if (m_scheduledTasksAreSuspended) { |
5877 // A page may subsequently suspend DOM objects, say as part of handling
a scroll or zoom gesture, after the | 5886 // A page may subsequently suspend DOM objects, say as part of handling
a scroll or zoom gesture, after the |
5878 // embedding client requested the page be suspended. We ignore such requ
ests so long as the embedding client | 5887 // embedding client requested the page be suspended. We ignore such requ
ests so long as the embedding client |
5879 // requested the suspension first. See <rdar://problem/13754896> for mor
e details. | 5888 // requested the suspension first. See <rdar://problem/13754896> for mor
e details. |
5880 ASSERT(reasonForSuspendingActiveDOMObjects() == ActiveDOMObject::PageWil
lBeSuspended); | 5889 ASSERT(reasonForSuspendingActiveDOMObjects() == ReasonForSuspension::Pag
eWillBeSuspended); |
5881 return; | 5890 return; |
5882 } | 5891 } |
5883 | 5892 |
5884 suspendScriptedAnimationControllerCallbacks(); | 5893 suspendScriptedAnimationControllerCallbacks(); |
5885 suspendActiveDOMObjects(reason); | 5894 suspendActiveDOMObjects(reason); |
5886 scriptRunner()->suspend(); | 5895 scriptRunner()->suspend(); |
5887 m_pendingTasksTimer.stop(); | 5896 m_pendingTasksTimer.stop(); |
5888 | 5897 |
5889 #if ENABLE(XSLT) | 5898 #if ENABLE(XSLT) |
5890 m_applyPendingXSLTransformsTimer.stop(); | 5899 m_applyPendingXSLTransformsTimer.stop(); |
5891 #endif | 5900 #endif |
5892 | 5901 |
5893 // Deferring loading and suspending parser is necessary when we need to prev
ent re-entrant JavaScript execution | 5902 // Deferring loading and suspending parser is necessary when we need to prev
ent re-entrant JavaScript execution |
5894 // (e.g. while displaying an alert). | 5903 // (e.g. while displaying an alert). |
5895 // It is not currently possible to suspend parser unless loading is deferred
, because new data arriving from network | 5904 // It is not currently possible to suspend parser unless loading is deferred
, because new data arriving from network |
5896 // will trigger parsing, and leave the scheduler in an inconsistent state wh
ere it doesn't know whether it's suspended or not. | 5905 // will trigger parsing, and leave the scheduler in an inconsistent state wh
ere it doesn't know whether it's suspended or not. |
5897 if (reason == ActiveDOMObject::WillDeferLoading && m_parser) | 5906 if (reason == ReasonForSuspension::WillDeferLoading && m_parser) |
5898 m_parser->suspendScheduledTasks(); | 5907 m_parser->suspendScheduledTasks(); |
5899 | 5908 |
5900 m_scheduledTasksAreSuspended = true; | 5909 m_scheduledTasksAreSuspended = true; |
5901 } | 5910 } |
5902 | 5911 |
5903 void Document::resumeScheduledTasks(ActiveDOMObject::ReasonForSuspension reason) | 5912 void Document::resumeScheduledTasks(ReasonForSuspension reason) |
5904 { | 5913 { |
5905 if (reasonForSuspendingActiveDOMObjects() != reason) | 5914 if (reasonForSuspendingActiveDOMObjects() != reason) |
5906 return; | 5915 return; |
5907 | 5916 |
5908 ASSERT(m_scheduledTasksAreSuspended); | 5917 ASSERT(m_scheduledTasksAreSuspended); |
5909 | 5918 |
5910 if (reason == ActiveDOMObject::WillDeferLoading && m_parser) | 5919 if (reason == ReasonForSuspension::WillDeferLoading && m_parser) |
5911 m_parser->resumeScheduledTasks(); | 5920 m_parser->resumeScheduledTasks(); |
5912 | 5921 |
5913 #if ENABLE(XSLT) | 5922 #if ENABLE(XSLT) |
5914 if (m_hasPendingXSLTransforms) | 5923 if (m_hasPendingXSLTransforms) |
5915 m_applyPendingXSLTransformsTimer.startOneShot(0_s); | 5924 m_applyPendingXSLTransformsTimer.startOneShot(0_s); |
5916 #endif | 5925 #endif |
5917 | 5926 |
5918 if (!m_pendingTasks.isEmpty()) | 5927 if (!m_pendingTasks.isEmpty()) |
5919 m_pendingTasksTimer.startOneShot(0_s); | 5928 m_pendingTasksTimer.startOneShot(0_s); |
5920 scriptRunner()->resume(); | 5929 scriptRunner()->resume(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6018 | 6027 |
6019 void Document::requestFullScreenForElement(Element* element, FullScreenCheckType
checkType) | 6028 void Document::requestFullScreenForElement(Element* element, FullScreenCheckType
checkType) |
6020 { | 6029 { |
6021 do { | 6030 do { |
6022 if (!element) | 6031 if (!element) |
6023 element = documentElement(); | 6032 element = documentElement(); |
6024 · | 6033 · |
6025 // 1. If any of the following conditions are true, terminate these steps
and queue a task to fire | 6034 // 1. If any of the following conditions are true, terminate these steps
and queue a task to fire |
6026 // an event named fullscreenerror with its bubbles attribute set to true
on the context object's· | 6035 // an event named fullscreenerror with its bubbles attribute set to true
on the context object's· |
6027 // node document: | 6036 // node document: |
| 6037 |
| 6038 // Don't allow fullscreen if document is hidden. |
| 6039 if (!page() || !page()->chrome().client().isViewVisible()) |
| 6040 break; |
6028 | 6041 |
6029 // The context object is not in a document. | 6042 // The context object is not in a document. |
6030 if (!element->isConnected()) | 6043 if (!element->isConnected()) |
6031 break; | 6044 break; |
6032 | 6045 |
6033 // The context object's node document, or an ancestor browsing context's
document does not have | 6046 // The context object's node document, or an ancestor browsing context's
document does not have |
6034 // the fullscreen enabled flag set. | 6047 // the fullscreen enabled flag set. |
6035 if (checkType == EnforceIFrameAllowFullScreenRequirement && !fullScreenI
sAllowedForElement(element)) | 6048 if (checkType == EnforceIFrameAllowFullScreenRequirement && !fullScreenI
sAllowedForElement(element)) |
6036 break; | 6049 break; |
6037 | 6050 |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6895 void Document::decrementActiveParserCount() | 6908 void Document::decrementActiveParserCount() |
6896 { | 6909 { |
6897 --m_activeParserCount; | 6910 --m_activeParserCount; |
6898 if (!frame()) | 6911 if (!frame()) |
6899 return; | 6912 return; |
6900 | 6913 |
6901 // FIXME: We should call DocumentLoader::checkLoadComplete as well here, | 6914 // FIXME: We should call DocumentLoader::checkLoadComplete as well here, |
6902 // but it seems to cause http/tests/security/feed-urls-from-remote.html | 6915 // but it seems to cause http/tests/security/feed-urls-from-remote.html |
6903 // to timeout on Mac WK1; see http://webkit.org/b/110554 and http://webkit.o
rg/b/110401. | 6916 // to timeout on Mac WK1; see http://webkit.org/b/110554 and http://webkit.o
rg/b/110401. |
6904 frame()->loader().checkLoadComplete(); | 6917 frame()->loader().checkLoadComplete(); |
| 6918 } |
| 6919 |
| 6920 DocumentParserYieldToken::DocumentParserYieldToken(Document& document) |
| 6921 : m_document(makeWeakPtr(document)) |
| 6922 { |
| 6923 if (++document.m_parserYieldTokenCount != 1) |
| 6924 return; |
| 6925 |
| 6926 document.scriptRunner()->didBeginYieldingParser(); |
| 6927 if (auto* parser = document.parser()) |
| 6928 parser->didBeginYieldingParser(); |
| 6929 } |
| 6930 |
| 6931 DocumentParserYieldToken::~DocumentParserYieldToken() |
| 6932 { |
| 6933 if (!m_document) |
| 6934 return; |
| 6935 |
| 6936 ASSERT(m_document->m_parserYieldTokenCount); |
| 6937 if (--m_document->m_parserYieldTokenCount) |
| 6938 return; |
| 6939 |
| 6940 m_document->scriptRunner()->didEndYieldingParser(); |
| 6941 if (auto* parser = m_document->parser()) |
| 6942 parser->didEndYieldingParser(); |
6905 } | 6943 } |
6906 | 6944 |
6907 static RenderElement* nearestCommonHoverAncestor(RenderElement* obj1, RenderElem
ent* obj2) | 6945 static RenderElement* nearestCommonHoverAncestor(RenderElement* obj1, RenderElem
ent* obj2) |
6908 { | 6946 { |
6909 if (!obj1 || !obj2) | 6947 if (!obj1 || !obj2) |
6910 return nullptr; | 6948 return nullptr; |
6911 | 6949 |
6912 for (RenderElement* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAnc
estor()) { | 6950 for (RenderElement* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAnc
estor()) { |
6913 for (RenderElement* currObj2 = obj2; currObj2; currObj2 = currObj2->hove
rAncestor()) { | 6951 for (RenderElement* currObj2 = obj2; currObj2; currObj2 = currObj2->hove
rAncestor()) { |
6914 if (currObj1 == currObj2) | 6952 if (currObj1 == currObj2) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7084 } | 7122 } |
7085 | 7123 |
7086 bool Document::useSystemAppearance() const | 7124 bool Document::useSystemAppearance() const |
7087 { | 7125 { |
7088 bool useSystemAppearance = false; | 7126 bool useSystemAppearance = false; |
7089 if (Page* documentPage = page()) | 7127 if (Page* documentPage = page()) |
7090 useSystemAppearance = documentPage->useSystemAppearance(); | 7128 useSystemAppearance = documentPage->useSystemAppearance(); |
7091 return useSystemAppearance; | 7129 return useSystemAppearance; |
7092 } | 7130 } |
7093 | 7131 |
7094 bool Document::useDefaultAppearance() const | 7132 bool Document::useDarkAppearance() const |
7095 { | 7133 { |
7096 bool useDefaultAppearance = true; | 7134 bool useDarkAppearance = false; |
7097 if (Page* documentPage = page()) | 7135 if (Page* documentPage = page()) |
7098 useDefaultAppearance = documentPage->defaultAppearance(); | 7136 useDarkAppearance = documentPage->useDarkAppearance(); |
7099 return useDefaultAppearance; | 7137 return useDarkAppearance; |
7100 } | 7138 } |
7101 | 7139 |
7102 OptionSet<StyleColor::Options> Document::styleColorOptions() const | 7140 OptionSet<StyleColor::Options> Document::styleColorOptions() const |
7103 { | 7141 { |
7104 OptionSet<StyleColor::Options> options; | 7142 OptionSet<StyleColor::Options> options; |
7105 if (useSystemAppearance()) | 7143 if (useSystemAppearance()) |
7106 options |= StyleColor::Options::UseSystemAppearance; | 7144 options |= StyleColor::Options::UseSystemAppearance; |
7107 if (useDefaultAppearance()) | 7145 if (useDarkAppearance()) |
7108 options |= StyleColor::Options::UseDefaultAppearance; | 7146 options |= StyleColor::Options::UseDarkAppearance; |
7109 return options; | 7147 return options; |
7110 } | 7148 } |
7111 | 7149 |
7112 void Document::didAssociateFormControl(Element* element) | 7150 void Document::didAssociateFormControl(Element* element) |
7113 { | 7151 { |
7114 if (!frame() || !frame()->page() || !frame()->page()->chrome().client().shou
ldNotifyOnFormChanges()) | 7152 if (!frame() || !frame()->page() || !frame()->page()->chrome().client().shou
ldNotifyOnFormChanges()) |
7115 return; | 7153 return; |
7116 m_associatedFormControls.add(element); | 7154 m_associatedFormControls.add(element); |
7117 if (!m_didAssociateFormControlsTimer.isActive()) | 7155 if (!m_didAssociateFormControlsTimer.isActive()) |
7118 m_didAssociateFormControlsTimer.startOneShot(0_s); | 7156 m_didAssociateFormControlsTimer.startOneShot(0_s); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7382 m_viewportDependentPictures.add(&picture); | 7420 m_viewportDependentPictures.add(&picture); |
7383 } | 7421 } |
7384 | 7422 |
7385 void Document::removeViewportDependentPicture(HTMLPictureElement& picture) | 7423 void Document::removeViewportDependentPicture(HTMLPictureElement& picture) |
7386 { | 7424 { |
7387 m_viewportDependentPictures.remove(&picture); | 7425 m_viewportDependentPictures.remove(&picture); |
7388 } | 7426 } |
7389 | 7427 |
7390 #if ENABLE(INTERSECTION_OBSERVER) | 7428 #if ENABLE(INTERSECTION_OBSERVER) |
7391 | 7429 |
7392 void Document::addToIntersectionObserverTargets(Element& element) | 7430 void Document::activateIntersectionObserver(IntersectionObserver& observer) |
7393 { | 7431 { |
7394 m_intersectionObserverTargets.add(&element); | 7432 m_activeIntersectionObservers.add(&observer); |
7395 } | 7433 } |
7396 | 7434 |
7397 void Document::removeFromIntersectionObserverTargets(Element& element) | 7435 bool Document::deactivateIntersectionObserver(IntersectionObserver& observer) |
7398 { | 7436 { |
7399 m_intersectionObserverTargets.remove(&element); | 7437 return m_activeIntersectionObservers.remove(&observer); |
7400 } | 7438 } |
7401 | 7439 |
7402 void Document::collectIntersectionObservers(HashSet<IntersectionObserver*>& obse
rvers) | 7440 void Document::addViewportIntersectionObserver(IntersectionObserver& observer) |
7403 { | 7441 { |
7404 for (auto element : m_intersectionObserverTargets) { | 7442 m_viewportIntersectionObservers.add(&observer); |
7405 auto registrations = element->intersectionObserverRegistrations(); | 7443 } |
7406 if (!registrations) | 7444 |
7407 continue; | 7445 void Document::removeViewportIntersectionObserver(IntersectionObserver& observer
) |
7408 | 7446 { |
7409 for (auto& registration : *registrations) { | 7447 m_viewportIntersectionObservers.remove(&observer); |
7410 auto root = registration.observer->root(); | |
7411 if (!root || (root->isConnected() && &root->document() == this)) | |
7412 observers.add(registration.observer.get()); | |
7413 } | |
7414 } | |
7415 } | 7448 } |
7416 | 7449 |
7417 void Document::updateIntersectionObservations() | 7450 void Document::updateIntersectionObservations() |
7418 { | 7451 { |
7419 if (m_intersectionObserverTargets.isEmpty()) | 7452 if (m_activeIntersectionObservers.isEmpty()) |
7420 return; | 7453 return; |
7421 | 7454 |
7422 // FIXME: For cross-document observation, do we need to check for pending la
yout in ancestor frames? In other frames? (which might move this one offscreen) | |
7423 auto frameView = view(); | 7455 auto frameView = view(); |
7424 bool needsLayout = frameView && renderView() && (frameView->layoutContext().
isLayoutPending() || renderView()->needsLayout()); | 7456 bool needsLayout = frameView && renderView() && (frameView->layoutContext().
isLayoutPending() || renderView()->needsLayout()); |
7425 if (needsLayout || hasPendingStyleRecalc()) | 7457 if (needsLayout || hasPendingStyleRecalc()) |
7426 return; | 7458 return; |
7427 | 7459 |
7428 // 1. Let observer list be a list of all IntersectionObservers whose root is
in the DOM tree of document. | 7460 LOG(IntersectionObserver, "Document %p updateIntersectionObservations(), %u
observers", this, m_activeIntersectionObservers.size()); |
7429 HashSet<IntersectionObserver*> observers; | |
7430 collectIntersectionObservers(observers); | |
7431 | |
7432 LOG(IntersectionObserver, "Document %p updateIntersectionObservations(), %u
target elements, %u observers", this, m_intersectionObserverTargets.size(), obse
rvers.size()); | |
7433 | 7461 |
7434 // 2. For each observer in observer list: | 7462 // 2. For each observer in observer list: |
7435 bool needNotify = false; | 7463 bool needNotify = false; |
7436 for (auto observer : observers) { | 7464 for (auto observer : m_activeIntersectionObservers) { |
| 7465 ASSERT(!observer->root() || &observer->root()->document() == this); |
7437 // FIXME: this timestamp should probably be shared with subsequent rAF. | 7466 // FIXME: this timestamp should probably be shared with subsequent rAF. |
7438 double timeStamp = observer->document().domWindow()->performance()->now(
); | 7467 DOMHighResTimeStamp timestamp; |
7439 if (updateIntersectionObservation(*observer, timeStamp)) | 7468 if (!observer->createTimestamp(timestamp)) |
| 7469 continue; |
| 7470 if (updateIntersectionObservation(*observer, timestamp)) |
7440 needNotify = true; | 7471 needNotify = true; |
7441 } | 7472 } |
7442 | 7473 |
7443 if (needNotify) | 7474 if (needNotify) |
7444 m_intersectionObserversNotifyTimer.startOneShot(0_s); | 7475 m_intersectionObserversNotifyTimer.startOneShot(0_s); |
7445 } | 7476 } |
7446 | 7477 |
7447 static float floatValueForLengthInLayoutUnits(const Length& length, float extent
, float cssToLayoutScale) | 7478 static float floatValueForLengthInLayoutUnits(const Length& length, float extent
, float cssToLayoutScale) |
7448 { | 7479 { |
7449 float unscaled = floatValueForLength(length, extent); | 7480 float unscaled = floatValueForLength(length, extent); |
(...skipping 29 matching lines...) Expand all Loading... |
7479 return false; | 7510 return false; |
7480 } | 7511 } |
7481 | 7512 |
7482 float cssToLayoutScale = 1.0f; | 7513 float cssToLayoutScale = 1.0f; |
7483 | 7514 |
7484 // We compute the intersections in the local space of the coordinate root. | 7515 // We compute the intersections in the local space of the coordinate root. |
7485 // See the return line at the end of this function where we transform from | 7516 // See the return line at the end of this function where we transform from |
7486 // local to absolute space. | 7517 // local to absolute space. |
7487 // | 7518 // |
7488 // The coordinate root is usually the root element, but in the implicit root | 7519 // The coordinate root is usually the root element, but in the implicit root |
7489 // case, it is the main frame's layout viewport rect. | 7520 // case, it is the target frame's RenderView. |
7490 | 7521 |
7491 // 1. Let rootBounds be observers root intersection rectangle. | 7522 // 1. Let rootBounds be observers root intersection rectangle. |
7492 FloatRect rootBounds; | 7523 FloatRect rootBounds; |
7493 RenderBlock* coordinateRoot = rendererForRoot; | 7524 RenderBlock* coordinateRoot = rendererForRoot; |
7494 if (rendererForRoot) { | 7525 if (rendererForRoot) { |
7495 // If the intersection root is a scrollable element, it's the elements c
ontent area. | 7526 // If the intersection root is a scrollable element, it's the element's
content area. |
7496 if (rendererForRoot->hasOverflowClip()) { | 7527 if (rendererForRoot->hasOverflowClip()) { |
7497 // This is local/content space. See RenderBox::absoluteContentQuad. | 7528 // This is local/content space. See RenderBox::absoluteContentQuad. |
7498 rootBounds = rendererForRoot->contentBoxRect(); | 7529 rootBounds = rendererForRoot->contentBoxRect(); |
7499 } else { | 7530 } else { |
7500 // Otherwise, it's the result of running the getBoundingClientRect()
algorithm on the intersection root. | 7531 // Otherwise, it's the result of running the getBoundingClientRect()
algorithm on the intersection root. |
7501 // We just take the RenderBox's bounds in local coordinates (see Ren
derBox::absoluteQuads() which is what getBoundingClientRect() uses); | 7532 // We just take the RenderBox's bounds in local coordinates (see Ren
derBox::absoluteQuads() which is what getBoundingClientRect() uses); |
7502 rootBounds = { { 0, 0 }, rendererForRoot->size() }; | 7533 rootBounds = { { 0, 0 }, rendererForRoot->size() }; |
7503 } | 7534 } |
7504 cssToLayoutScale = frameView.frame().pageZoomFactor() * frameView.frame(
).frameScaleFactor(); | 7535 cssToLayoutScale = frameView.frame().pageZoomFactor() * frameView.frame(
).frameScaleFactor(); |
7505 } else { | 7536 } else { |
(...skipping 22 matching lines...) Expand all Loading... |
7528 | 7559 |
7529 // FIXME: The spec says to only do this expansion if root and target are sim
ilar-origin. Check what other browsers | 7560 // FIXME: The spec says to only do this expansion if root and target are sim
ilar-origin. Check what other browsers |
7530 // do. Also, for the cross-document case, this needs to be applied before ap
plying any clips. See above. | 7561 // do. Also, for the cross-document case, this needs to be applied before ap
plying any clips. See above. |
7531 rootBounds.expand(rootMarginBoxExtent.left() + rootMarginBoxExtent.right(),
rootMarginBoxExtent.top() + rootMarginBoxExtent.bottom()); | 7562 rootBounds.expand(rootMarginBoxExtent.left() + rootMarginBoxExtent.right(),
rootMarginBoxExtent.top() + rootMarginBoxExtent.bottom()); |
7532 | 7563 |
7533 // Map rootBounds into absolute coords for the caller. | 7564 // Map rootBounds into absolute coords for the caller. |
7534 if (rendererForRoot) | 7565 if (rendererForRoot) |
7535 absRootBounds = coordinateRoot->localToAbsoluteQuad(rootBounds).bounding
Box(); | 7566 absRootBounds = coordinateRoot->localToAbsoluteQuad(rootBounds).bounding
Box(); |
7536 else { | 7567 else { |
7537 // The caller needs unclipped root bounds. | 7568 // The caller needs unclipped root bounds. |
7538 FloatRect unclippedRootBounds = frameView.frame().mainFrame().view()->la
youtViewportRect(); | 7569 ASSERT(frameView.frame().isMainFrame()); |
| 7570 FloatRect unclippedRootBounds = frameView.layoutViewportRect(); |
7539 unclippedRootBounds.move(-rootMarginBoxExtent.left(), -rootMarginBoxExte
nt.top()); | 7571 unclippedRootBounds.move(-rootMarginBoxExtent.left(), -rootMarginBoxExte
nt.top()); |
7540 unclippedRootBounds.expand(rootMarginBoxExtent.left() + rootMarginBoxExt
ent.right(), rootMarginBoxExtent.top() + rootMarginBoxExtent.bottom()); | 7572 unclippedRootBounds.expand(rootMarginBoxExtent.left() + rootMarginBoxExt
ent.right(), rootMarginBoxExtent.top() + rootMarginBoxExtent.bottom()); |
7541 absRootBounds = frameView.frame().mainFrame().contentRenderer()->localTo
AbsoluteQuad(unclippedRootBounds).boundingBox(); | 7573 absRootBounds = frameView.renderView()->localToAbsoluteQuad(unclippedRoo
tBounds).boundingBox(); |
7542 } | 7574 } |
7543 | 7575 |
7544 // 1. Let intersectionRect be the result of running the getBoundingClientRec
t() algorithm on the target. | 7576 // 1. Let intersectionRect be the result of running the getBoundingClientRec
t() algorithm on the target. |
7545 // This gets targetBounds in target-local coordinates. | 7577 // This gets targetBounds in target-local coordinates. |
7546 LayoutRect targetBounds; | 7578 LayoutRect targetBounds; |
7547 if (is<RenderBoxModelObject>(rendererForTarget)) | 7579 if (is<RenderBox>(rendererForTarget)) |
7548 targetBounds = downcast<RenderBoxModelObject>(rendererForTarget).borderB
oundingBox(); | 7580 targetBounds = downcast<RenderBox>(rendererForTarget).borderBoundingBox(
); |
| 7581 else if (is<RenderInline>(rendererForTarget)) |
| 7582 targetBounds = downcast<RenderInline>(rendererForTarget).linesBoundingBo
x(); |
| 7583 else if (is<RenderLineBreak>(rendererForTarget)) |
| 7584 targetBounds = downcast<RenderLineBreak>(rendererForTarget).linesBoundin
gBox(); |
7549 else if (rendererForTarget.element() && rendererForTarget.element()->isSVGEl
ement()) { | 7585 else if (rendererForTarget.element() && rendererForTarget.element()->isSVGEl
ement()) { |
7550 // Get the bounding rectangle from the SVG model. | 7586 // Get the bounding rectangle from the SVG model. |
7551 SVGElement& svgElement = downcast<SVGElement>(*rendererForTarget.element
()); | 7587 SVGElement& svgElement = downcast<SVGElement>(*rendererForTarget.element
()); |
7552 FloatRect localRect; | 7588 FloatRect localRect; |
7553 if (svgElement.getBoundingBox(localRect)) | 7589 if (svgElement.getBoundingBox(localRect)) |
7554 targetBounds = LayoutRect(localRect); | 7590 targetBounds = LayoutRect(localRect); |
7555 } | 7591 } |
7556 | 7592 |
7557 absTargetRect = rendererForTarget.localToAbsoluteQuad(FloatRect(targetBounds
)).boundingBox(); | 7593 absTargetRect = rendererForTarget.localToAbsoluteQuad(FloatRect(targetBounds
)).boundingBox(); |
7558 | 7594 |
7559 // 2-3. Map to coordinateRoot, clipping along the way. | 7595 // 2-3. Map to coordinateRoot, clipping along the way. |
7560 // FIXME: clippedOverflowRectForRepaint() may do some things we don't want. | 7596 // FIXME: clippedOverflowRectForRepaint() may do some things we don't want. |
7561 // 4. Map intersectionRect to the coordinate space of the intersection root. | 7597 // 4. Map intersectionRect to the coordinate space of the intersection root. |
7562 isIntersecting = true; | 7598 isIntersecting = true; |
7563 FloatRect intersectionRect = rendererForTarget.computeRectForRepaint(targetB
ounds, coordinateRoot, {false /* hasPositionFixedDescendant */, false /* dirtyRe
ctIsFlipped */, true /* useInclusiveIntersection */, &isIntersecting}); | 7599 FloatRect intersectionRect = rendererForTarget.computeRectForRepaint(targetB
ounds, coordinateRoot, {false /* hasPositionFixedDescendant */, false /* dirtyRe
ctIsFlipped */, true /* useInclusiveIntersection */, &isIntersecting}); |
7564 | 7600 |
7565 LOG_WITH_STREAM(IntersectionObserver, stream << " target in root space " <<
intersectionRect << " root bounds " << rootBounds); | 7601 LOG_WITH_STREAM(IntersectionObserver, stream << " target in root space " <<
intersectionRect << " root bounds " << rootBounds); |
7566 | 7602 |
7567 if (isIntersecting) { | 7603 if (isIntersecting) { |
7568 // 5. Update intersectionRect by intersecting it with the root intersect
ion rectangle. | 7604 // 5. Update intersectionRect by intersecting it with the root intersect
ion rectangle. |
7569 isIntersecting = intersectionRect.inclusiveIntersect(rootBounds); | 7605 isIntersecting = intersectionRect.inclusiveIntersect(rootBounds); |
7570 } | 7606 |
7571 | |
7572 if (isIntersecting) { | |
7573 // 6. Map intersectionRect to the coordinate space of the viewport of th
e Document containing the target. | 7607 // 6. Map intersectionRect to the coordinate space of the viewport of th
e Document containing the target. |
7574 // We'll use absolute coordinates instead. | 7608 // We'll use absolute coordinates instead. |
7575 absIntersectionRect = coordinateRoot->localToAbsoluteQuad(intersectionRe
ct).boundingBox(); | 7609 absIntersectionRect = coordinateRoot->localToAbsoluteQuad(intersectionRe
ct).boundingBox(); |
7576 } | 7610 } |
7577 return true; | 7611 return true; |
7578 } | 7612 } |
7579 | 7613 |
7580 bool Document::updateIntersectionObservation(IntersectionObserver& observer, dou
ble timeStamp) | 7614 bool Document::updateIntersectionObservation(IntersectionObserver& observer, dou
ble timeStamp) |
7581 { | 7615 { |
7582 FrameView* frameView = view(); | 7616 FrameView* frameView = view(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7625 setIndex = true; | 7659 setIndex = true; |
7626 break; | 7660 break; |
7627 } | 7661 } |
7628 } | 7662 } |
7629 if (!setIndex) | 7663 if (!setIndex) |
7630 thresholdIndex = observer.thresholds().size(); | 7664 thresholdIndex = observer.thresholds().size(); |
7631 } | 7665 } |
7632 | 7666 |
7633 // 9. Let intersectionObserverRegistration be the IntersectionObserverRe
gistration record in | 7667 // 9. Let intersectionObserverRegistration be the IntersectionObserverRe
gistration record in |
7634 // target's internal [[RegisteredIntersectionObservers]] slot whose obse
rver property is equal to observer. | 7668 // target's internal [[RegisteredIntersectionObservers]] slot whose obse
rver property is equal to observer. |
7635 // FIXME: sucks to have to re-find this when we had it in updateIntersec
tionObservations(). | |
7636 IntersectionObserverRegistration* registration = nullptr; | 7669 IntersectionObserverRegistration* registration = nullptr; |
7637 auto registrations = target->intersectionObserverRegistrations(); | 7670 auto* observerData = target->intersectionObserverData(); |
7638 if (registrations) { | 7671 if (observerData) { |
7639 for (auto& currRegistration : *registrations) { | 7672 auto& registrations = observerData->registrations; |
| 7673 for (auto& currRegistration : registrations) { |
7640 if (currRegistration.observer == &observer) { | 7674 if (currRegistration.observer == &observer) { |
7641 registration = &currRegistration; | 7675 registration = &currRegistration; |
7642 break; | 7676 break; |
7643 } | 7677 } |
7644 } | 7678 } |
7645 } | 7679 } |
7646 | 7680 |
7647 if (!registration) { | 7681 if (!registration) { |
7648 ASSERT_NOT_REACHED(); | 7682 ASSERT_NOT_REACHED(); |
7649 continue; | 7683 continue; |
7650 } | 7684 } |
7651 | 7685 |
7652 // 10. Let previousThreshold be set to intersectionObserverRegistration'
s previousThreshold property. | 7686 // 10. Let previousThreshold be set to intersectionObserverRegistration'
s previousThreshold property. |
7653 // 11. If threshold does not equal previousThreshold, queue an Intersect
ionObserverEntry, | 7687 // 11. If threshold does not equal previousThreshold, queue an Intersect
ionObserverEntry, |
7654 // passing in observer, time, rootBounds, boundingClientRect, intersecti
onRect and target. | 7688 // passing in observer, time, rootBounds, boundingClientRect, intersecti
onRect and target. |
7655 LOG_WITH_STREAM(IntersectionObserver, stream << " registration->previous
ThresholdIndex " << registration->previousThresholdIndex << " thresholdIndex " <
< thresholdIndex); | 7689 LOG_WITH_STREAM(IntersectionObserver, stream << " registration->previous
ThresholdIndex " << registration->previousThresholdIndex << " thresholdIndex " <
< thresholdIndex); |
7656 | 7690 |
7657 if (thresholdIndex != registration->previousThresholdIndex || isIntersec
ting != registration->previousIsIntersecting) { | 7691 if (thresholdIndex != registration->previousThresholdIndex || isIntersec
ting != registration->previousIsIntersecting) { |
7658 // These two rects are in client coordinates in target's frame. | 7692 // These two rects are in client coordinates in target's frame. |
7659 FloatRect rootBounds; | 7693 FloatRect rootBounds; |
7660 FloatRect targetClientRect; | 7694 FloatRect targetClientRect; |
7661 FloatRect clientIntersectionRect; | 7695 FloatRect clientIntersectionRect; |
7662 | 7696 |
7663 bool shouldReportRootBounds; | 7697 bool shouldReportRootBounds; |
7664 if (observer.root()) | 7698 if (observer.root()) |
7665 shouldReportRootBounds = true; | 7699 shouldReportRootBounds = true; |
7666 else { | 7700 else { |
7667 auto& targetDocument = target->document(); | 7701 auto& targetDocument = target->document(); |
7668 auto* mainFrameView = targetDocument.frame()->mainFrame().view()
; | 7702 shouldReportRootBounds = targetDocument.securityOrigin().canAcc
ess(frameView->frame().document()->securityOrigin()); |
7669 shouldReportRootBounds = targetDocument.securityOrigin().canAcc
ess(mainFrameView->frame().document()->securityOrigin()); | |
7670 } | 7703 } |
7671 if (computedIntersection) { | 7704 if (computedIntersection) { |
7672 // FIXME: unclear if this needs to be reported in client coordin
ates: https://github.com/WICG/IntersectionObserver/issues/170 | 7705 // FIXME: unclear if this needs to be reported in client coordin
ates: https://github.com/WICG/IntersectionObserver/issues/170 |
7673 if (observer.root()) { | 7706 if (observer.root()) { |
7674 // If there's an explicit root, we've already checked that t
he target's document is this, and the root and target are in | 7707 // If there's an explicit root, we've already checked that t
he target's document is this, and the root and target are in |
7675 // the same document. | 7708 // the same document. |
7676 rootBounds = frameView->documentToClientRect(frameView->abso
luteToDocumentRect(absRootBounds)); | 7709 rootBounds = frameView->documentToClientRect(frameView->abso
luteToDocumentRect(absRootBounds)); |
7677 | 7710 |
7678 } else { | 7711 } else { |
7679 auto* mainFrameView = target->document().frame()->mainFrame(
).view(); | 7712 ASSERT(frameView->frame().isMainFrame()); |
7680 if (shouldReportRootBounds) | 7713 if (shouldReportRootBounds) |
7681 rootBounds = mainFrameView->documentToClientRect(mainFra
meView->absoluteToDocumentRect(absRootBounds)); | 7714 rootBounds = frameView->documentToClientRect(frameView->
absoluteToDocumentRect(absRootBounds)); |
7682 } | 7715 } |
7683 | 7716 |
7684 targetClientRect = target->boundingRectInClientCoordinates(); | 7717 targetClientRect = target->boundingRectInClientCoordinates(); |
7685 if (isIntersecting) | 7718 if (isIntersecting) { |
7686 clientIntersectionRect = frameView->contentsToView(enclosing
IntRect(absIntersectionRect)); | 7719 auto* targetFrameView = target->document().view(); |
| 7720 clientIntersectionRect = targetFrameView->contentsToView(enc
losingIntRect(absIntersectionRect)); |
| 7721 } |
7687 } | 7722 } |
7688 | 7723 |
7689 std::optional<DOMRectInit> entryRootBounds; | 7724 std::optional<DOMRectInit> entryRootBounds; |
7690 if (shouldReportRootBounds) | 7725 if (shouldReportRootBounds) |
7691 entryRootBounds = DOMRectInit({ rootBounds.x(), rootBounds.y(),
rootBounds.width(), rootBounds.height() }); | 7726 entryRootBounds = DOMRectInit({ rootBounds.x(), rootBounds.y(),
rootBounds.width(), rootBounds.height() }); |
7692 observer.appendQueuedEntry(IntersectionObserverEntry::create({ | 7727 observer.appendQueuedEntry(IntersectionObserverEntry::create({ |
7693 timeStamp, | 7728 timeStamp, |
7694 entryRootBounds, | 7729 entryRootBounds, |
7695 { targetClientRect.x(), targetClientRect.y(), targetClientRect.w
idth(), targetClientRect.height() }, | 7730 { targetClientRect.x(), targetClientRect.y(), targetClientRect.w
idth(), targetClientRect.height() }, |
7696 { clientIntersectionRect.x(), clientIntersectionRect.y(), client
IntersectionRect.width(), clientIntersectionRect.height() }, | 7731 { clientIntersectionRect.x(), clientIntersectionRect.y(), client
IntersectionRect.width(), clientIntersectionRect.height() }, |
7697 isIntersecting, | |
7698 intersectionRatio, | 7732 intersectionRatio, |
7699 target | 7733 target, |
| 7734 isIntersecting |
7700 })); | 7735 })); |
7701 | 7736 |
7702 // 12. Assign threshold to intersectionObserverRegistration's previo
usThreshold property. | 7737 // 12. Assign threshold to intersectionObserverRegistration's previo
usThreshold property. |
7703 registration->previousThresholdIndex = thresholdIndex; | 7738 registration->previousThresholdIndex = thresholdIndex; |
7704 registration->previousIsIntersecting = isIntersecting; | 7739 registration->previousIsIntersecting = isIntersecting; |
7705 anyNeedNotify = true; | 7740 anyNeedNotify = true; |
7706 } | 7741 } |
7707 } | 7742 } |
7708 | 7743 |
7709 return anyNeedNotify; | 7744 return anyNeedNotify; |
7710 } | 7745 } |
7711 | 7746 |
7712 void Document::notifyIntersectionObserversTimerFired() | 7747 void Document::notifyIntersectionObserversTimerFired() |
7713 { | 7748 { |
7714 LOG_WITH_STREAM(IntersectionObserver, stream << "notifyIntersectionObservers
TimerFired"); | 7749 LOG_WITH_STREAM(IntersectionObserver, stream << "notifyIntersectionObservers
TimerFired"); |
7715 // 1. Let observer list be a list of all IntersectionObservers whose root is
in the DOM tree of document. | 7750 for (auto* observer : m_activeIntersectionObservers) |
7716 HashSet<IntersectionObserver*> observers; | |
7717 collectIntersectionObservers(observers); | |
7718 | |
7719 // 2. For each observer in observer list: | |
7720 for (auto observer : observers) | |
7721 observer->notify(); | 7751 observer->notify(); |
7722 } | 7752 } |
7723 | 7753 |
7724 #endif | 7754 #endif |
7725 | 7755 |
7726 const AtomicString& Document::dir() const | 7756 const AtomicString& Document::dir() const |
7727 { | 7757 { |
7728 auto* documentElement = this->documentElement(); | 7758 auto* documentElement = this->documentElement(); |
7729 if (!is<HTMLHtmlElement>(documentElement)) | 7759 if (!is<HTMLHtmlElement>(documentElement)) |
7730 return nullAtom(); | 7760 return nullAtom(); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8033 void Document::enableTemporaryTimeUserGesture() | 8063 void Document::enableTemporaryTimeUserGesture() |
8034 { | 8064 { |
8035 m_temporaryUserGesture = std::make_unique<UserGestureIndicator>(ProcessingUs
erGesture, this); | 8065 m_temporaryUserGesture = std::make_unique<UserGestureIndicator>(ProcessingUs
erGesture, this); |
8036 } | 8066 } |
8037 | 8067 |
8038 void Document::consumeTemporaryTimeUserGesture() | 8068 void Document::consumeTemporaryTimeUserGesture() |
8039 { | 8069 { |
8040 m_temporaryUserGesture = nullptr; | 8070 m_temporaryUserGesture = nullptr; |
8041 } | 8071 } |
8042 | 8072 |
| 8073 void Document::registerArticleElement(Element& article) |
| 8074 { |
| 8075 m_articleElements.add(&article); |
| 8076 } |
| 8077 |
| 8078 void Document::unregisterArticleElement(Element& article) |
| 8079 { |
| 8080 m_articleElements.remove(&article); |
| 8081 if (m_mainArticleElement == &article) |
| 8082 m_mainArticleElement = nullptr; |
| 8083 } |
| 8084 |
| 8085 void Document::updateMainArticleElementAfterLayout() |
| 8086 { |
| 8087 // If there are too many article elements on the page, don't consider any on
e of them to be "main content". |
| 8088 const unsigned maxNumberOfArticlesBeforeIgnoringMainContentArticle = 10; |
| 8089 |
| 8090 // We consider an article to be main content if it is either: |
| 8091 // 1. The only article element in the document. |
| 8092 // 2. Much taller than the next tallest article, and also much larger than t
he viewport. |
| 8093 const float minimumSecondTallestArticleHeightFactor = 4; |
| 8094 const float minimumViewportAreaFactor = 5; |
| 8095 |
| 8096 m_mainArticleElement = nullptr; |
| 8097 |
| 8098 auto numberOfArticles = m_articleElements.size(); |
| 8099 if (!numberOfArticles || numberOfArticles > maxNumberOfArticlesBeforeIgnorin
gMainContentArticle) |
| 8100 return; |
| 8101 |
| 8102 Element* tallestArticle = nullptr; |
| 8103 float tallestArticleHeight = 0; |
| 8104 float tallestArticleWidth = 0; |
| 8105 float secondTallestArticleHeight = 0; |
| 8106 |
| 8107 for (auto* article : m_articleElements) { |
| 8108 auto* box = article->renderBox(); |
| 8109 float height = box ? box->height().toFloat() : 0; |
| 8110 if (height >= tallestArticleHeight) { |
| 8111 secondTallestArticleHeight = tallestArticleHeight; |
| 8112 tallestArticleHeight = height; |
| 8113 tallestArticleWidth = box ? box->width().toFloat() : 0; |
| 8114 tallestArticle = article; |
| 8115 } else if (height >= secondTallestArticleHeight) |
| 8116 secondTallestArticleHeight = height; |
| 8117 } |
| 8118 |
| 8119 if (numberOfArticles == 1) { |
| 8120 m_mainArticleElement = tallestArticle; |
| 8121 return; |
| 8122 } |
| 8123 |
| 8124 if (tallestArticleHeight < minimumSecondTallestArticleHeightFactor * secondT
allestArticleHeight) |
| 8125 return; |
| 8126 |
| 8127 if (!view()) |
| 8128 return; |
| 8129 |
| 8130 auto viewportSize = view()->layoutViewportRect().size(); |
| 8131 if (tallestArticleWidth * tallestArticleHeight < minimumViewportAreaFactor *
(viewportSize.width() * viewportSize.height()).toFloat()) |
| 8132 return; |
| 8133 |
| 8134 m_mainArticleElement = tallestArticle; |
| 8135 } |
| 8136 |
8043 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) | 8137 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) |
8044 bool Document::hasFrameSpecificStorageAccess() const | 8138 bool Document::hasFrameSpecificStorageAccess() const |
8045 { | 8139 { |
8046 return m_frame->loader().client().hasFrameSpecificStorageAccess(); | 8140 return m_frame->loader().client().hasFrameSpecificStorageAccess(); |
8047 } | 8141 } |
8048 ···· | 8142 ···· |
8049 void Document::setHasFrameSpecificStorageAccess(bool value) | 8143 void Document::setHasFrameSpecificStorageAccess(bool value) |
8050 { | 8144 { |
8051 m_frame->loader().client().setHasFrameSpecificStorageAccess(value); | 8145 m_frame->loader().client().setHasFrameSpecificStorageAccess(value); |
8052 } | 8146 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8221 | 8315 |
8222 String Document::signedPublicKeyAndChallengeString(unsigned keySizeIndex, const
String& challengeString, const URL& url) | 8316 String Document::signedPublicKeyAndChallengeString(unsigned keySizeIndex, const
String& challengeString, const URL& url) |
8223 { | 8317 { |
8224 Page* page = this->page(); | 8318 Page* page = this->page(); |
8225 if (!page) | 8319 if (!page) |
8226 return emptyString(); | 8320 return emptyString(); |
8227 return page->chrome().client().signedPublicKeyAndChallengeString(keySizeInde
x, challengeString, url); | 8321 return page->chrome().client().signedPublicKeyAndChallengeString(keySizeInde
x, challengeString, url); |
8228 } | 8322 } |
8229 | 8323 |
8230 } // namespace WebCore | 8324 } // namespace WebCore |
LEFT | RIGHT |