Diff
Modified: trunk/LayoutTests/ChangeLog (251707 => 251708)
--- trunk/LayoutTests/ChangeLog 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/ChangeLog 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,3 +1,33 @@
+2019-10-29 Chris Dumez <[email protected]>
+
+ Unreviewed, revert r251637 as it caused http/tests/lazyload/scroll-element-removed-from-document.html to crash
+ https://bugs.webkit.org/show_bug.cgi?id=203566
+
+ * TestExpectations:
+ * http/tests/lazyload/attribute-expected.txt: Removed.
+ * http/tests/lazyload/attribute.html: Removed.
+ * http/tests/lazyload/invisible-image-expected.txt: Removed.
+ * http/tests/lazyload/invisible-image.html: Removed.
+ * http/tests/lazyload/js-image-expected.txt: Removed.
+ * http/tests/lazyload/js-image.html: Removed.
+ * http/tests/lazyload/lazy-expected.txt: Removed.
+ * http/tests/lazyload/lazy-image-load-in-iframes-scripting-disabled-expected.txt: Removed.
+ * http/tests/lazyload/lazy-image-load-in-iframes-scripting-disabled.html: Removed.
+ * http/tests/lazyload/lazy-image-load-in-iframes-scripting-enabled-expected.txt: Removed.
+ * http/tests/lazyload/lazy-image-load-in-iframes-scripting-enabled.html: Removed.
+ * http/tests/lazyload/lazy.html: Removed.
+ * http/tests/lazyload/lazy2-expected.txt: Removed.
+ * http/tests/lazyload/placeholder.js: Removed.
+ * http/tests/lazyload/resources/lazy-load-in-iframe.html: Removed.
+ * http/tests/lazyload/scroll-element-moved-from-document-expected.txt: Removed.
+ * http/tests/lazyload/scroll-element-moved-from-document.html: Removed.
+ * http/tests/lazyload/scroll-element-removed-from-document-expected.txt: Removed.
+ * http/tests/lazyload/scroll-element-removed-from-document.html: Removed.
+ * http/tests/lazyload/scroll-expected.txt: Removed.
+ * http/tests/lazyload/scroll.html: Removed.
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+
2019-10-29 Wenson Hsieh <[email protected]>
Unreviewed, add missing platform-specific test expectations after r251686
Modified: trunk/LayoutTests/TestExpectations (251707 => 251708)
--- trunk/LayoutTests/TestExpectations 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/TestExpectations 2019-10-29 16:56:03 UTC (rev 251708)
@@ -3878,6 +3878,7 @@
fast/text/design-system-ui-15.html [ ImageOnlyFailure ]
fast/text/design-system-ui-16.html [ ImageOnlyFailure ]
+webkit.org/b/196698 imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative.html
webkit.org/b/196698 imported/w3c/web-platform-tests/loading/lazyload/iframe-loading-lazy.tentative.html
webkit.org/b/202517 imported/w3c/web-platform-tests/2dcontext/text-styles/2d.text.draw.baseline.ideographic.html [ Skip ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (251707 => 251708)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,3 +1,11 @@
+2019-10-29 Chris Dumez <[email protected]>
+
+ Unreviewed, revert r251637 as it caused http/tests/lazyload/scroll-element-removed-from-document.html to crash
+ https://bugs.webkit.org/show_bug.cgi?id=203566
+
+ * web-platform-tests/loading/lazyload/image-loading-lazy.tentative-expected.txt: Removed.
+ * web-platform-tests/loading/lazyload/image-loading-lazy.tentative.html:
+
2019-10-29 Wenson Hsieh <[email protected]>
Unreviewed, add missing platform-specific test expectations after r251686
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative-expected.txt (251707 => 251708)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative-expected.txt 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative-expected.txt 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,5 +0,0 @@
-
-
-
-PASS Test that images with loading='lazy' load once they enter the viewport.
-
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative.html (251707 => 251708)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative.html 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/loading/lazyload/image-loading-lazy.tentative.html 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ experimental:enableLazyImageLoading=true ] -->
+<!DOCTYPE html>
<head>
<title>Images with loading='lazy' load when in the viewport</title>
<link rel="author" title="Scott Little" href=""
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (251707 => 251708)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2019-10-29 16:56:03 UTC (rev 251708)
@@ -152,9 +152,6 @@
imported/w3c/web-platform-tests/intersection-observer [ Skip ]
intersection-observer [ Skip ]
-http/tests/lazyload [ Skip ]
-imported/w3c/web-platform-tests/loading/lazyload [ Skip ]
-
# testRunner.queueLoad() does not support loading data URLs in Mac WK1
http/tests/security/contentSecurityPolicy/navigate-self-to-data-url.html [ Skip ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (251707 => 251708)
--- trunk/LayoutTests/platform/win/TestExpectations 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/LayoutTests/platform/win/TestExpectations 2019-10-29 16:56:03 UTC (rev 251708)
@@ -4468,7 +4468,3 @@
webkit.org/b/202952 http/tests/security/navigate-when-restoring-cached-page.html [ Timeout ]
webkit.org/b/202953 http/tests/websocket/tests/hybi/non-document-mixed-content-blocked-https-with-embedded-http-with-embedded-https.https.html [ Timeout ]
-
-# IntersectionObserver is off by default
-http/tests/lazyload [ Skip ]
-imported/w3c/web-platform-tests/loading/lazyload [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (251707 => 251708)
--- trunk/Source/WebCore/ChangeLog 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/ChangeLog 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,3 +1,38 @@
+2019-10-29 Chris Dumez <[email protected]>
+
+ Unreviewed, revert r251637 as it caused http/tests/lazyload/scroll-element-removed-from-document.html to crash
+ https://bugs.webkit.org/show_bug.cgi?id=203566
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Document.cpp:
+ * dom/Document.h:
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseAttribute):
+ (WebCore::HTMLImageElement::didMoveToNewDocument):
+ * html/HTMLImageElement.h:
+ * html/HTMLImageElement.idl:
+ * html/LazyLoadImageObserver.cpp: Removed.
+ * html/LazyLoadImageObserver.h: Removed.
+ * html/parser/HTMLPreloadScanner.cpp:
+ (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest):
+ (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
+ * loader/ImageLoader.cpp:
+ (WebCore::ImageLoader::updateFromElement):
+ (WebCore::ImageLoader::notifyFinished):
+ * loader/ImageLoader.h:
+ * loader/cache/CachedImage.h:
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestImage):
+ (WebCore::CachedResourceLoader::requestResource):
+ (WebCore::CachedResourceLoader::determineRevalidationPolicy const):
+ (WebCore::CachedResourceLoader::clientDefersImage const):
+ (WebCore::CachedResourceLoader::shouldDeferImageLoad const):
+ (WebCore::CachedResourceLoader::reloadImagesIfNotDeferred):
+ * loader/cache/CachedResourceLoader.h:
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::paintReplaced):
+
2019-10-29 Antoine Quint <[email protected]>
[Web Animations] Optimize blending for CSS Transitions
Modified: trunk/Source/WebCore/Sources.txt (251707 => 251708)
--- trunk/Source/WebCore/Sources.txt 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/Sources.txt 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1222,7 +1222,6 @@
html/InputTypeNames.cpp
html/LabelableElement.cpp
html/LabelsNodeList.cpp
-html/LazyLoadImageObserver.cpp
html/LinkIconCollector.cpp
html/LinkRelAttribute.cpp
html/MediaController.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (251707 => 251708)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-10-29 16:56:03 UTC (rev 251708)
@@ -3375,7 +3375,6 @@
AA7FEEAD16A4E74B004C0C33 /* JSSpeechSynthesis.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7FEEAC16A4E74B004C0C33 /* JSSpeechSynthesis.h */; };
AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA728F116D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h */; };
AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC08CF115F941FC00F1E188 /* AccessibilitySVGRoot.h */; };
- AAD9D0B521DFA810001B11C7 /* LazyLoadImageObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = AAD9D0B321DFA80E001B11C7 /* LazyLoadImageObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
AB23A32809BBA7D00067CC53 /* BeforeTextInsertedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */; };
AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = AB247A6B0AFD6383003FA5FD /* RenderSlider.h */; };
AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AB31C91D10AE1B8E000C7B92 /* LineClampValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -21914,8 +21913,6 @@
450CEBEF15073BBE002BB149 /* LabelableElement.h */,
A456FA2411AD4A830020B420 /* LabelsNodeList.cpp */,
A456FA2511AD4A830020B420 /* LabelsNodeList.h */,
- AAD9D0B121DFA80C001B11C7 /* LazyLoadImageObserver.cpp */,
- AAD9D0B321DFA80E001B11C7 /* LazyLoadImageObserver.h */,
1A4DA41F1CDD3A8300F4473C /* LinkIconCollector.cpp */,
1A4DA4201CDD3A8300F4473C /* LinkIconCollector.h */,
1A250E0C1CDD632000D0BE63 /* LinkIconType.h */,
@@ -31012,7 +31009,6 @@
6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */,
11310CF220BA4A320065A8D0 /* LayoutTreeBuilder.h in Headers */,
141DC0481648348F00371E5A /* LayoutUnit.h in Headers */,
- AAD9D0B521DFA810001B11C7 /* LazyLoadImageObserver.h in Headers */,
CDE8B5ED1A69777300B4B66A /* LegacyCDMPrivateClearKey.h in Headers */,
CDF4B7121E0087AE00E235A2 /* LegacyCDMSession.h in Headers */,
CDE8B5F11A69778B00B4B66A /* LegacyCDMSessionClearKey.h in Headers */,
Modified: trunk/Source/WebCore/dom/Document.cpp (251707 => 251708)
--- trunk/Source/WebCore/dom/Document.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/dom/Document.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -119,7 +119,6 @@
#include "KeyboardEvent.h"
#include "KeyframeEffect.h"
#include "LayoutDisallowedScope.h"
-#include "LazyLoadImageObserver.h"
#include "LegacySchemeRegistry.h"
#include "LibWebRTCProvider.h"
#include "LoaderStrategy.h"
@@ -8326,11 +8325,4 @@
return *m_textManipulationController;
}
-LazyLoadImageObserver& Document::lazyLoadImageObserver()
-{
- if (!m_lazyLoadImageObserver)
- m_lazyLoadImageObserver = makeUnique<LazyLoadImageObserver>();
- return *m_lazyLoadImageObserver;
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Document.h (251707 => 251708)
--- trunk/Source/WebCore/dom/Document.h 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/dom/Document.h 2019-10-29 16:56:03 UTC (rev 251708)
@@ -153,7 +153,6 @@
class JSNode;
class LayoutPoint;
class LayoutRect;
-class LazyLoadImageObserver;
class LiveNodeList;
class Locale;
class Location;
@@ -1557,8 +1556,6 @@
WEBCORE_EXPORT TextManipulationController& textManipulationController();
TextManipulationController* textManipulationControllerIfExists() { return m_textManipulationController.get(); }
- LazyLoadImageObserver& lazyLoadImageObserver();
-
protected:
enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
@@ -1744,8 +1741,6 @@
Element* m_cssTarget { nullptr };
- std::unique_ptr<LazyLoadImageObserver> m_lazyLoadImageObserver;
-
RefPtr<SerializedScriptValue> m_pendingStateObject;
MonotonicTime m_documentCreationTime;
bool m_overMinimumLayoutThreshold { false };
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (251707 => 251708)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -43,7 +43,6 @@
#include "HTMLMapElement.h"
#include "HTMLSourceElement.h"
#include "HTMLSrcsetParser.h"
-#include "LazyLoadImageObserver.h"
#include "Logging.h"
#include "MIMETypeRegistry.h"
#include "MediaList.h"
@@ -54,7 +53,6 @@
#include "RenderImage.h"
#include "RenderView.h"
#include "RuntimeEnabledFeatures.h"
-#include "ScriptController.h"
#include "Settings.h"
#include "ShadowRoot.h"
#include "SizesAttributeParser.h"
@@ -246,10 +244,7 @@
#endif
} else if (name == x_apple_editable_imageAttr)
updateEditableImage();
- else if (name == loadingAttr) {
- if (!equalLettersIgnoringASCIICase(value, "lazy"))
- loadDeferredImage();
- } else {
+ else {
if (name == nameAttr) {
bool willHaveName = !value.isNull();
if (m_hadNameBeforeAttributeChanged != willHaveName && isConnected() && !isInShadowTree() && is<HTMLDocument>(document())) {
@@ -268,11 +263,6 @@
}
}
-void HTMLImageElement::loadDeferredImage()
-{
- m_imageLoader->loadDeferredImage();
-}
-
const AtomString& HTMLImageElement::altText() const
{
// lets figure out the alt text.. magic stuff
@@ -675,7 +665,6 @@
void HTMLImageElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)
{
- m_createdByParser = false;
m_imageLoader->elementDidMoveToNewDocument();
HTMLElement::didMoveToNewDocument(oldDocument, newDocument);
}
@@ -872,35 +861,4 @@
return m_imageLoader->pendingDecodePromisesCountForTesting();
}
-const AtomString& HTMLImageElement::loadingForBindings() const
-{
- static NeverDestroyed<AtomString> autoValue("auto", AtomString::ConstructFromLiteral);
- static NeverDestroyed<AtomString> eager("eager", AtomString::ConstructFromLiteral);
- static NeverDestroyed<AtomString> lazy("lazy", AtomString::ConstructFromLiteral);
- auto attributeValue = attributeWithoutSynchronization(HTMLNames::loadingAttr);
- if (equalLettersIgnoringASCIICase(attributeValue, "eager"))
- return eager;
- if (equalLettersIgnoringASCIICase(attributeValue, "lazy"))
- return lazy;
- return autoValue;
}
-
-void HTMLImageElement::setLoadingForBindings(const AtomString& value)
-{
- setAttributeWithoutSynchronization(loadingAttr, value);
-}
-
-bool HTMLImageElement::isDeferred() const
-{
- return m_imageLoader->isDeferred();
-}
-
-bool HTMLImageElement::isLazyLoadable() const
-{
- if (document().frame() && !document().frame()->script().canExecuteScripts(NotAboutToExecuteScript))
- return false;
- // Never do lazy loading for image elements created from _javascript_.
- return createdByParser() && equalLettersIgnoringASCIICase(attributeWithoutSynchronization(HTMLNames::loadingAttr), "lazy");
-}
-
-}
Modified: trunk/Source/WebCore/html/HTMLImageElement.h (251707 => 251708)
--- trunk/Source/WebCore/html/HTMLImageElement.h 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/html/HTMLImageElement.h 2019-10-29 16:56:03 UTC (rev 251708)
@@ -126,17 +126,8 @@
void defaultEventHandler(Event&) final;
- void loadDeferredImage();
-
bool createdByParser() const { return m_createdByParser; }
- const AtomString& loadingForBindings() const;
- void setLoadingForBindings(const AtomString&);
-
- bool isLazyLoadable() const;
-
- bool isDeferred() const;
-
bool isDroppedImagePlaceholder() const { return m_isDroppedImagePlaceholder; }
void setIsDroppedImagePlaceholder() { m_isDroppedImagePlaceholder = true; }
Modified: trunk/Source/WebCore/html/HTMLImageElement.idl (251707 => 251708)
--- trunk/Source/WebCore/html/HTMLImageElement.idl 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/html/HTMLImageElement.idl 2019-10-29 16:56:03 UTC (rev 251708)
@@ -44,7 +44,7 @@
[Conditional=ATTACHMENT_ELEMENT, EnabledAtRuntime=AttachmentElement] readonly attribute DOMString attachmentIdentifier;
- [CEReactions, EnabledAtRuntime=LazyImageLoading, ImplementedAs=loadingForBindings] attribute DOMString loading;
+ [EnabledAtRuntime=LazyImageLoading, CEReactions, Reflect] attribute DOMString loading;
// Extensions
readonly attribute boolean complete;
Deleted: trunk/Source/WebCore/html/LazyLoadImageObserver.cpp (251707 => 251708)
--- trunk/Source/WebCore/html/LazyLoadImageObserver.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/html/LazyLoadImageObserver.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2019 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LazyLoadImageObserver.h"
-
-#include "Frame.h"
-#include "HTMLImageElement.h"
-#include "IntersectionObserverCallback.h"
-#include "RenderStyle.h"
-
-#include <limits>
-
-namespace WebCore {
-
-class LazyImageLoadIntersectionObserverCallback final : public IntersectionObserverCallback {
-public:
- static Ref<LazyImageLoadIntersectionObserverCallback> create(Document& document)
- {
- return adoptRef(*new LazyImageLoadIntersectionObserverCallback(document));
- }
-
-private:
- CallbackResult<void> handleEvent(const Vector<Ref<IntersectionObserverEntry>>& entries, IntersectionObserver&) final
- {
- ASSERT(!entries.isEmpty());
-
- for (auto& entry : entries) {
- if (!entry->isIntersecting())
- continue;
- Element* element = entry->target();
- if (is<HTMLImageElement>(element)) {
- downcast<HTMLImageElement>(*element).loadDeferredImage();
- element->document().lazyLoadImageObserver().unobserve(*element);
- }
- }
- return { };
- }
-
- LazyImageLoadIntersectionObserverCallback(Document& document)
- : IntersectionObserverCallback(&document)
- {
- }
-};
-
-void LazyLoadImageObserver::observe(Element& element)
-{
- auto& observer = element.document().lazyLoadImageObserver();
- auto* intersectionObserver = observer.intersectionObserver(element.document());
- if (!intersectionObserver)
- return;
- intersectionObserver->observe(element);
-}
-
-void LazyLoadImageObserver::unobserve(Element& element)
-{
- auto& observer = element.document().lazyLoadImageObserver();
- ASSERT(observer.isObserved(element));
- observer.m_lazyLoadIntersectionObserver->unobserve(element);
-}
-
-IntersectionObserver* LazyLoadImageObserver::intersectionObserver(Document& document)
-{
- if (!m_lazyLoadIntersectionObserver) {
- auto callback = LazyImageLoadIntersectionObserverCallback::create(document);
- auto options = IntersectionObserver::Init { nullptr, emptyString(), { } };
- auto observer = IntersectionObserver::create(document, WTFMove(callback), WTFMove(options));
- if (observer.hasException())
- return nullptr;
- m_lazyLoadIntersectionObserver = observer.returnValue().ptr();
- }
- return m_lazyLoadIntersectionObserver.get();
-}
-
-bool LazyLoadImageObserver::isObserved(Element& element) const
-{
- return m_lazyLoadIntersectionObserver && m_lazyLoadIntersectionObserver->observationTargets().contains(&element);
-}
-
-}
Deleted: trunk/Source/WebCore/html/LazyLoadImageObserver.h (251707 => 251708)
--- trunk/Source/WebCore/html/LazyLoadImageObserver.h 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/html/LazyLoadImageObserver.h 2019-10-29 16:56:03 UTC (rev 251708)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2019 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "IntersectionObserver.h"
-
-namespace WebCore {
-
-class Document;
-class Element;
-
-class LazyLoadImageObserver {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- LazyLoadImageObserver() = default;
-
- static void observe(Element&);
- static void unobserve(Element&);
-
-private:
- IntersectionObserver* intersectionObserver(Document&);
- bool isObserved(Element&) const;
-
- // The intersection observer responsible for loading the image once it's near
- // the viewport.
- RefPtr<IntersectionObserver> m_lazyLoadIntersectionObserver;
-};
-
-} // namespace
Modified: trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (251707 => 251708)
--- trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -161,10 +161,6 @@
if (!LinkLoader::isSupportedType(type.value(), m_typeAttribute))
return nullptr;
- // Do not preload if lazyload is possible but metadata fetch is disabled.
- if (equalLettersIgnoringASCIICase(m_lazyloadAttribute, "lazy"))
- return nullptr;
-
auto request = makeUnique<PreloadRequest>(initiatorFor(m_tagId), m_urlToLoad, predictedBaseURL, type.value(), m_mediaAttribute, m_moduleScript, m_referrerPolicy);
request->setCrossOriginMode(m_crossOriginMode);
request->setNonce(m_nonceAttribute);
@@ -210,12 +206,6 @@
m_sizesAttribute = attributeValue;
break;
}
- if (RuntimeEnabledFeatures::sharedFeatures().lazyImageLoadingEnabled()) {
- if (match(attributeName, loadingAttr) && m_lazyloadAttribute.isNull()) {
- m_lazyloadAttribute = attributeValue;
- break;
- }
- }
processImageAndScriptAttribute(attributeName, attributeValue);
break;
case TagId::Source:
@@ -380,7 +370,6 @@
String m_metaContent;
String m_asAttribute;
String m_typeAttribute;
- String m_lazyloadAttribute;
bool m_metaIsViewport;
bool m_metaIsDisabledAdaptations;
bool m_inputIsImage;
Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (251707 => 251708)
--- trunk/Source/WebCore/loader/ImageLoader.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -39,11 +39,9 @@
#include "HTMLParserIdioms.h"
#include "InspectorInstrumentation.h"
#include "JSDOMPromiseDeferred.h"
-#include "LazyLoadImageObserver.h"
#include "Page.h"
#include "RenderImage.h"
#include "RenderSVGImage.h"
-#include "RuntimeEnabledFeatures.h"
#include <wtf/NeverDestroyed.h>
#if ENABLE(VIDEO)
@@ -199,16 +197,8 @@
newImage->setLoading(true);
document.cachedResourceLoader().m_documentResources.set(newImage->url(), newImage.get());
document.cachedResourceLoader().setAutoLoadImages(autoLoadOtherImages);
- } else {
- if (m_lazyImageLoadState == LazyImageLoadState::None) {
- if (is<HTMLImageElement>(element())) {
- auto& imageElement = downcast<HTMLImageElement>(element());
- if (imageElement.isLazyLoadable() && RuntimeEnabledFeatures::sharedFeatures().lazyImageLoadingEnabled())
- m_lazyImageLoadState = LazyImageLoadState::Deferred;
- }
- }
- newImage = document.cachedResourceLoader().requestImage(WTFMove(request), (m_lazyImageLoadState == LazyImageLoadState::Deferred) ? ImageLoading::DeferredUntilVisible : ImageLoading::Immediate).value_or(nullptr);
- }
+ } else
+ newImage = document.cachedResourceLoader().requestImage(WTFMove(request)).value_or(nullptr);
// If we do not have an image here, it means that a cross-site
// violation occurred, or that the image was blocked via Content
@@ -261,9 +251,6 @@
} else
updateRenderer();
- if (m_lazyImageLoadState == LazyImageLoadState::Deferred)
- LazyLoadImageObserver::observe(element());
-
// If newImage is cached, addClient() will result in the load event
// being queued to fire. Ensure this happens after beforeload is
// dispatched.
@@ -320,11 +307,6 @@
ASSERT(m_failedLoadURL.isEmpty());
ASSERT_UNUSED(resource, &resource == m_image.get());
- if (m_lazyImageLoadState == LazyImageLoadState::Deferred) {
- LazyLoadImageObserver::unobserve(element());
- m_lazyImageLoadState = LazyImageLoadState::FullImage;
- }
-
m_imageComplete = true;
if (!hasPendingBeforeLoadEvent())
updateRenderer();
@@ -578,12 +560,4 @@
m_failedLoadURL = nullAtom();
}
-void ImageLoader::loadDeferredImage()
-{
- if (m_lazyImageLoadState != LazyImageLoadState::Deferred)
- return;
- m_lazyImageLoadState = LazyImageLoadState::FullImage;
- updateFromElement();
}
-
-}
Modified: trunk/Source/WebCore/loader/ImageLoader.h (251707 => 251708)
--- trunk/Source/WebCore/loader/ImageLoader.h 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/loader/ImageLoader.h 2019-10-29 16:56:03 UTC (rev 251708)
@@ -75,17 +75,11 @@
static void dispatchPendingLoadEvents();
static void dispatchPendingErrorEvents();
- void loadDeferredImage();
-
- bool isDeferred() const { return m_lazyImageLoadState == LazyImageLoadState::Deferred; }
-
protected:
explicit ImageLoader(Element&);
void notifyFinished(CachedResource&) override;
private:
- enum class LazyImageLoadState { None, Deferred, FullImage };
-
virtual void dispatchLoadEvent() = 0;
virtual String sourceURI(const AtomString&) const = 0;
@@ -120,7 +114,6 @@
bool m_imageComplete : 1;
bool m_loadManually : 1;
bool m_elementIsProtected : 1;
- LazyImageLoadState m_lazyImageLoadState { LazyImageLoadState::None };
};
}
Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (251707 => 251708)
--- trunk/Source/WebCore/loader/cache/CachedImage.h 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h 2019-10-29 16:56:03 UTC (rev 251708)
@@ -91,9 +91,7 @@
void removeAllClientsWaitingForAsyncDecoding();
void setForceUpdateImageDataEnabledForTesting(bool enabled) { m_forceUpdateImageDataEnabledForTesting = enabled; }
-
- bool stillNeedsLoad() const override { return !errorOccurred() && status() == Unknown && !isLoading(); }
-
+
private:
void clear();
@@ -130,6 +128,8 @@
// For compatibility, images keep loading even if there are HTTP errors.
bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; }
+ bool stillNeedsLoad() const override { return !errorOccurred() && status() == Unknown && !isLoading(); }
+
class CachedImageObserver final : public RefCounted<CachedImageObserver>, public ImageObserver {
public:
static Ref<CachedImageObserver> create(CachedImage& image) { return adoptRef(*new CachedImageObserver(image)); }
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (251707 => 251708)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -194,7 +194,7 @@
return m_documentLoader ? m_documentLoader->frame() : nullptr;
}
-ResourceErrorOr<CachedResourceHandle<CachedImage>> CachedResourceLoader::requestImage(CachedResourceRequest&& request, ImageLoading imageLoading)
+ResourceErrorOr<CachedResourceHandle<CachedImage>> CachedResourceLoader::requestImage(CachedResourceRequest&& request)
{
if (Frame* frame = this->frame()) {
if (frame->loader().pageDismissalEventBeingDispatched() != FrameLoader::PageDismissalType::None) {
@@ -207,9 +207,8 @@
}
}
- if (imageLoading == ImageLoading::Immediate)
- imageLoading = clientDefersImage(request.resourceRequest().url());
- return castCachedResourceTo<CachedImage>(requestResource(CachedResource::Type::ImageResource, WTFMove(request), ForPreload::No, imageLoading));
+ auto defer = clientDefersImage(request.resourceRequest().url()) ? DeferOption::DeferredByClient : DeferOption::NoDefer;
+ return castCachedResourceTo<CachedImage>(requestResource(CachedResource::Type::ImageResource, WTFMove(request), ForPreload::No, defer));
}
ResourceErrorOr<CachedResourceHandle<CachedFont>> CachedResourceLoader::requestFont(CachedResourceRequest&& request, bool isSVG)
@@ -782,7 +781,7 @@
return FetchOptions::Destination::EmptyString;
}
-ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, ImageLoading imageLoading)
+ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer)
{
if (!frame() || !frame()->page()) {
RELEASE_LOG_IF_ALLOWED("requestResource: failed because no frame or page");
@@ -900,7 +899,7 @@
auto& cookieJar = page.cookieJar();
- RevalidationPolicy policy = determineRevalidationPolicy(type, request, resource.get(), forPreload, imageLoading);
+ RevalidationPolicy policy = determineRevalidationPolicy(type, request, resource.get(), forPreload, defer);
switch (policy) {
case Reload:
memoryCache.remove(*resource);
@@ -962,7 +961,7 @@
incrementRequestCount(*resource);
}
- if ((policy != Use || resource->stillNeedsLoad()) && imageLoading == ImageLoading::Immediate) {
+ if ((policy != Use || resource->stillNeedsLoad()) && defer == DeferOption::NoDefer) {
resource->load(*this);
// We don't support immediate loads, but we do support immediate failure.
@@ -1071,7 +1070,7 @@
}
}
-CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalidationPolicy(CachedResource::Type type, CachedResourceRequest& cachedResourceRequest, CachedResource* existingResource, ForPreload forPreload, ImageLoading imageLoading) const
+CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalidationPolicy(CachedResource::Type type, CachedResourceRequest& cachedResourceRequest, CachedResource* existingResource, ForPreload forPreload, DeferOption defer) const
{
auto& request = cachedResourceRequest.resourceRequest();
@@ -1127,7 +1126,7 @@
ASSERT(!request.isConditional());
// Do not load from cache if images are not enabled. The load for this image will be blocked in CachedImage::load.
- if (imageLoading == ImageLoading::DeferredUntilVisible)
+ if (defer == DeferOption::DeferredByClient)
return Reload;
// Don't reload resources while pasting or if cache mode allows stale resources.
@@ -1272,9 +1271,9 @@
reloadImagesIfNotDeferred();
}
-ImageLoading CachedResourceLoader::clientDefersImage(const URL&) const
+bool CachedResourceLoader::clientDefersImage(const URL&) const
{
- return m_imagesEnabled ? ImageLoading::Immediate : ImageLoading::DeferredUntilVisible;
+ return !m_imagesEnabled;
}
bool CachedResourceLoader::shouldPerformImageLoad(const URL& url) const
@@ -1284,13 +1283,13 @@
bool CachedResourceLoader::shouldDeferImageLoad(const URL& url) const
{
- return clientDefersImage(url) == ImageLoading::DeferredUntilVisible || !shouldPerformImageLoad(url);
+ return clientDefersImage(url) || !shouldPerformImageLoad(url);
}
void CachedResourceLoader::reloadImagesIfNotDeferred()
{
for (auto& resource : m_documentResources.values()) {
- if (is<CachedImage>(*resource) && resource->stillNeedsLoad() && clientDefersImage(resource->url()) == ImageLoading::Immediate)
+ if (is<CachedImage>(*resource) && resource->stillNeedsLoad() && !clientDefersImage(resource->url()))
downcast<CachedImage>(*resource).load(*this);
}
}
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (251707 => 251708)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2019-10-29 16:56:03 UTC (rev 251708)
@@ -62,8 +62,6 @@
template <typename T>
using ResourceErrorOr = Expected<T, ResourceError>;
-enum class ImageLoading : uint8_t { Immediate, DeferredUntilVisible };
-
// The CachedResourceLoader provides a per-context interface to the MemoryCache
// and enforces a bunch of security checks and rules for resource revalidation.
// Its lifetime is roughly per-DocumentLoader, in that it is generally created
@@ -81,7 +79,7 @@
static Ref<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(*new CachedResourceLoader(documentLoader)); }
~CachedResourceLoader();
- ResourceErrorOr<CachedResourceHandle<CachedImage>> requestImage(CachedResourceRequest&&, ImageLoading = ImageLoading::Immediate);
+ ResourceErrorOr<CachedResourceHandle<CachedImage>> requestImage(CachedResourceRequest&&);
ResourceErrorOr<CachedResourceHandle<CachedCSSStyleSheet>> requestCSSStyleSheet(CachedResourceRequest&&);
CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(Page&, CachedResourceRequest&&);
ResourceErrorOr<CachedResourceHandle<CachedScript>> requestScript(CachedResourceRequest&&);
@@ -165,8 +163,9 @@
explicit CachedResourceLoader(DocumentLoader*);
enum class ForPreload { Yes, No };
+ enum class DeferOption { NoDefer, DeferredByClient };
- ResourceErrorOr<CachedResourceHandle<CachedResource>> requestResource(CachedResource::Type, CachedResourceRequest&&, ForPreload = ForPreload::No, ImageLoading = ImageLoading::Immediate);
+ ResourceErrorOr<CachedResourceHandle<CachedResource>> requestResource(CachedResource::Type, CachedResourceRequest&&, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer);
CachedResourceHandle<CachedResource> revalidateResource(CachedResourceRequest&&, CachedResource&);
CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, PAL::SessionID, CachedResourceRequest&&, const CookieJar&);
@@ -176,7 +175,7 @@
bool canRequest(CachedResource::Type, const URL&, const CachedResourceRequest&, ForPreload);
enum RevalidationPolicy { Use, Revalidate, Reload, Load };
- RevalidationPolicy determineRevalidationPolicy(CachedResource::Type, CachedResourceRequest&, CachedResource* existingResource, ForPreload, ImageLoading) const;
+ RevalidationPolicy determineRevalidationPolicy(CachedResource::Type, CachedResourceRequest&, CachedResource* existingResource, ForPreload, DeferOption) const;
bool shouldUpdateCachedResourceWithCurrentRequest(const CachedResource&, const CachedResourceRequest&);
CachedResourceHandle<CachedResource> updateCachedResourceWithCurrentRequest(const CachedResource&, CachedResourceRequest&&, const PAL::SessionID&, const CookieJar&);
@@ -186,7 +185,7 @@
void performPostLoadActions();
- ImageLoading clientDefersImage(const URL&) const;
+ bool clientDefersImage(const URL&) const;
void reloadImagesIfNotDeferred();
bool canRequestAfterRedirection(CachedResource::Type, const URL&, const ResourceLoaderOptions&) const;
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (251707 => 251708)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2019-10-29 16:19:47 UTC (rev 251707)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2019-10-29 16:56:03 UTC (rev 251708)
@@ -423,11 +423,6 @@
context.drawRect(snapRectToDevicePixels(LayoutRect({ paintOffset.x() + leftBorder + leftPadding, paintOffset.y() + topBorder + topPadding }, contentSize), document().deviceScaleFactor()), borderWidth);
}
-static bool isDeferredImage(Element* element)
-{
- return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element)->isDeferred();
-}
-
void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
GraphicsContext& context = paintInfo.context();
@@ -441,7 +436,7 @@
float deviceScaleFactor = document().deviceScaleFactor();
LayoutUnit missingImageBorderWidth(1 / deviceScaleFactor);
- if (!imageResource().cachedImage() || isDeferredImage(element()) || shouldDisplayBrokenImageIcon()) {
+ if (!imageResource().cachedImage() || shouldDisplayBrokenImageIcon()) {
if (paintInfo.phase == PaintPhase::Selection)
return;