haikuwebkit/Source/WebCore/page/IntersectionObserverEntry.h

84 lines
2.9 KiB
C
Raw Permalink Normal View History

Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
/*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* 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
#if ENABLE(INTERSECTION_OBSERVER)
#include "DOMRectReadOnly.h"
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
#include "Element.h"
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class Element;
class IntersectionObserverEntry : public RefCounted<IntersectionObserverEntry> {
WTF_MAKE_FAST_ALLOCATED;
public:
struct Init {
double time;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<DOMRectInit> rootBounds;
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
DOMRectInit boundingClientRect;
DOMRectInit intersectionRect;
double intersectionRatio;
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
RefPtr<Element> target;
bool isIntersecting;
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
};
static Ref<IntersectionObserverEntry> create(const Init& init)
{
return WTF::adoptRef(*new IntersectionObserverEntry(init));
}
double time() const { return m_time; }
DOMRectReadOnly* rootBounds() const { return m_rootBounds.get(); }
DOMRectReadOnly* boundingClientRect() const { return m_boundingClientRect.get(); }
DOMRectReadOnly* intersectionRect() const { return m_intersectionRect.get(); }
IntersectionObserver doesn't keep target's JS wrapper alive https://bugs.webkit.org/show_bug.cgi?id=190235 Reviewed by Ryosuke Niwa. Source/WebCore: Retain JS wrappers of targets in queued entries using a vector of GCReachableRef owned by IntersectionObserver, which gets cleared after the entries have been delivered. Make IntersectionObserver::takeRecords return a struct which has both the vector of GCReachableRefs for targets and the vector of intersection observer entries, so that the GCReachableRefs survive until the creation of JS wrappers for the entries. Modify IntersectionObserver::hasPendingActivity to keep the observer alive while it has entries to deliver. Tests: intersection-observer/intersection-observer-entry-keeps-js-wrapper-of-target-alive.html intersection-observer/intersection-observer-keeps-js-wrapper-of-target-alive.html intersection-observer/target-deleted.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSIntersectionObserverEntryCustom.cpp: (WebCore::JSIntersectionObserverEntry::visitAdditionalChildren): Keep the target element's wrapper alive while the IntersectionObserverEntry's wrapper is alive. * page/IntersectionObserver.cpp: (WebCore::IntersectionObserver::takeRecords): Change return type to include GCReachableRefs for each record's target, so that each target can be kept until a JS wrapper is constructed for its IntersectionObserverEntry. (WebCore::IntersectionObserver::appendQueuedEntry): (WebCore::IntersectionObserver::notify): Erase GCReachableRefs for targets after delivering the corresponding records. (WebCore::IntersectionObserver::hasPendingActivity const): Keep the IntersectionObserver alive until queued entries are delivered. (WebCore::IntersectionObserver::stop): * page/IntersectionObserver.h: * page/IntersectionObserver.idl: * page/IntersectionObserverEntry.h: (WebCore::IntersectionObserverEntry::target const): Make this return a raw pointer instead of a RefPtr so that it can be called in JSIntersectionObserverEntry::visitAdditionalChildren, which runs on the GC thread (it's illegal to ref a Node on a non-main thread). * page/IntersectionObserverEntry.idl: LayoutTests: Add test coverage. Update test that depends on a target getting GC'd to call takeRecords() since targets with pending entries are no logner GC'd. * intersection-observer/intersection-observer-entry-keeps-js-wrapper-of-target-alive-expected.txt: Added. * intersection-observer/intersection-observer-entry-keeps-js-wrapper-of-target-alive.html: Added. * intersection-observer/intersection-observer-keeps-js-wrapper-of-target-alive-expected.txt: Added. * intersection-observer/intersection-observer-keeps-js-wrapper-of-target-alive.html: Added. * intersection-observer/root-element-deleted.html: * intersection-observer/target-deleted-expected.txt: Added. * intersection-observer/target-deleted.html: Added. Canonical link: https://commits.webkit.org/206123@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 20:52:51 +00:00
Element* target() const { return m_target.get(); }
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
bool isIntersecting() const { return m_isIntersecting; }
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
double intersectionRatio() const { return m_intersectionRatio; }
private:
IntersectionObserverEntry(const Init&);
double m_time { 0 };
RefPtr<DOMRectReadOnly> m_rootBounds;
RefPtr<DOMRectReadOnly> m_boundingClientRect;
RefPtr<DOMRectReadOnly> m_intersectionRect;
double m_intersectionRatio { 0 };
RefPtr<Element> m_target;
bool m_isIntersecting { false };
Implement IntersectionObserver https://bugs.webkit.org/show_bug.cgi?id=159475 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Add bindings support for Intersection Observer <https://wicg.github.io/IntersectionObserver/> Code is wrapped in ENABLE(INTERSECTION_OBSERVER), and controlled by a runtime Setting (off by default for now). A minor bindings change was required to fix the callback code. IntersectionObserver is just a shell for now. Tests: intersection-observer/intersection-observer-entry-interface.html intersection-observer/intersection-observer-interface.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (ShouldPassWrapperByReference): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::construct): * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefsConstructor::construct): * page/IntersectionObserver.cpp: Added. (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::disconnect): (WebCore::IntersectionObserver::takeRecords): * page/IntersectionObserver.h: Added. (WebCore::IntersectionObserver::create): (WebCore::IntersectionObserver::root): (WebCore::IntersectionObserver::rootMargin): (WebCore::IntersectionObserver::thresholds): * page/IntersectionObserver.idl: Added. * page/IntersectionObserverCallback.h: Added. (WebCore::IntersectionObserverCallback::~IntersectionObserverCallback): * page/IntersectionObserverCallback.idl: Added. * page/IntersectionObserverEntry.cpp: Added. (WebCore::IntersectionObserverEntry::IntersectionObserverEntry): * page/IntersectionObserverEntry.h: Added. (WebCore::IntersectionObserverEntry::create): (WebCore::IntersectionObserverEntry::time): (WebCore::IntersectionObserverEntry::rootBounds): (WebCore::IntersectionObserverEntry::boundingClientRect): (WebCore::IntersectionObserverEntry::intersectionRect): (WebCore::IntersectionObserverEntry::target): (WebCore::IntersectionObserverEntry::intersectionRatio): * page/IntersectionObserverEntry.idl: Added. * page/Settings.in: Source/WebKit2: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * Configurations/FeatureDefines.xcconfig: Tools: Add ENABLE_INTERSECTION_OBSERVER, enabled by default. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic interface tests. * intersection-observer/intersection-observer-entry-interface-expected.txt: Added. * intersection-observer/intersection-observer-entry-interface.html: Added. * intersection-observer/intersection-observer-interface-expected.txt: Added. * intersection-observer/intersection-observer-interface.html: Added. Canonical link: https://commits.webkit.org/181957@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 22:12:05 +00:00
};
} // namespace WebCore
#endif // ENABLE(INTERSECTION_OBSERVER)