Implement ResizeObserver.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 08:37:46 +0000 (08:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 08:37:46 +0000 (08:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157743

Patch by Cathie Chen <cathiechen@igalia.com> on 2019-03-29
Reviewed by Simon Fraser.

.:

Add ENABLE_RESIZE_OBSERVER.

* Source/cmake/WebKitFeatures.cmake:

LayoutTests/imported/w3c:

Set ResizeObserverEnabled for test runner and update expectations.

* web-platform-tests/interfaces/ResizeObserver.idl: Added.
* web-platform-tests/resize-observer/eventloop-expected.txt:
* web-platform-tests/resize-observer/eventloop.html:
* web-platform-tests/resize-observer/idlharness.window-expected.txt:
* web-platform-tests/resize-observer/idlharness.window.html:
* web-platform-tests/resize-observer/notify-expected.txt:
* web-platform-tests/resize-observer/notify.html:
* web-platform-tests/resize-observer/observe-expected.txt:
* web-platform-tests/resize-observer/observe.html:
* web-platform-tests/resize-observer/svg-expected.txt:
* web-platform-tests/resize-observer/svg.html:

Source/JavaScriptCore:

Add ENABLE_RESIZE_OBSERVER.

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

Tests: resize-observer/modify-frametree-in-callback.html
       resize-observer/multi-frames.html
       resize-observer/observe-element-from-other-frame.html
       Imported from WPT by https://bugs.webkit.org/show_bug.cgi?id=193821

The data structure: Document has a ResizeObserver slot. ResizeObserver has a ResizeObservation slot.
ResizeObservation is related to one Element and the last reported size.
On the other hand, Element has a ResizeObservation slot.

At the beginning of willDisplayPage, it will check resize observations for current page if:
1. There is FrameView be layout and there are ResizeObservers in this page.
2. m_resizeObserverTimer has been started by observe() or hasSkippedResizeObservers().
During checkResizeObservations(), we'll gatherDocumentsNeedingResizeObservationCheck() first,
then notifyResizeObservers() for each document. During notifyResizeObservers(), it will gather
the m_activeObservations whose size changed and target element deeper than require depth.
The size changed shallower observations are skipped observations which will be delivered
in the next time. And an ErrorEvent will be reported.
After gathering, deliverResizeObservations create entries and invoke the callbacks with them.

The Element from other document could be observed.

* CMakeLists.txt:
* Configurations/FeatureDefines.xcconfig:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* dom/Document.cpp:
(WebCore::Document::getParserLocation const):
(WebCore::Document::addResizeObserver):
(WebCore::Document::removeResizeObserver):
(WebCore::Document::hasResizeObservers):
(WebCore::Document::gatherResizeObservations): Gather m_activeObservations at depth and return the shallowest depth.
(WebCore::Document::deliverResizeObservations): Deliver m_activeObservations, generate ResizeObserverEntries, and invoke the m_callbacks.
(WebCore::Document::hasSkippedResizeObservations const): To determine if Document has the size changed but not delivered observations.
(WebCore::Document::setHasSkippedResizeObservations):
(WebCore::Document::scheduleResizeObservations):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::~Element):
(WebCore::Element::disconnectFromResizeObservers):
(WebCore::Element::ensureResizeObserverData):
(WebCore::Element::resizeObserverData):
* dom/Element.h:
* dom/ElementRareData.cpp:
* dom/ElementRareData.h:
(WebCore::ElementRareData::resizeObserverData):
(WebCore::ElementRareData::setResizeObserverData):
(WebCore::ElementRareData::useTypes const):
* page/FrameView.cpp:
(WebCore::FrameView::didLayout):
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::layoutTimerFired): We need to start a ResizeObserver timer here, because for WK1 this might not trigger flushCompositingChanges.
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::willDisplayPage):
(WebCore::Page::hasResizeObservers const):
(WebCore::Page::gatherDocumentsNeedingResizeObservationCheck): Gather the documents with resize observers.
(WebCore::Page::checkResizeObservations): Gather documents then notifyResizeObservers for each document.
(WebCore::Page::scheduleResizeObservations):
(WebCore::Page::notifyResizeObservers): Gather m_activeObservations and deliver them. Report ErrorEvent if it has skipped observations.
* page/Page.h:
(WebCore::Page::setNeedsCheckResizeObservations): Page needs to check ResizeObservations if FrameView layout or m_resizeObserverTimer has been started.
(WebCore::Page::needsCheckResizeObservations const):
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::getParserLocationForConsoleMessage): Deleted.
* page/ResizeObservation.cpp: Added.
(WebCore::ResizeObservation::create):
(WebCore::ResizeObservation::ResizeObservation):
(WebCore::ResizeObservation::~ResizeObservation):
(WebCore::ResizeObservation::updateObservationSize):
(WebCore::ResizeObservation::computeObservedSize const):
(WebCore::ResizeObservation::computeTargetLocation const):
(WebCore::ResizeObservation::computeContentRect const):
(WebCore::ResizeObservation::elementSizeChanged const):
(WebCore::ResizeObservation::targetElementDepth const):
* page/ResizeObservation.h: Copied from Tools/DumpRenderTree/TestOptions.h.
(WebCore::ResizeObservation::target const):
* page/ResizeObserver.cpp: Added.
(WebCore::ResizeObserver::create):
(WebCore::ResizeObserver::ResizeObserver):
(WebCore::ResizeObserver::~ResizeObserver):
(WebCore::ResizeObserver::scheduleObservations):
(WebCore::ResizeObserver::observe):
(WebCore::ResizeObserver::unobserve):
(WebCore::ResizeObserver::disconnect):
(WebCore::ResizeObserver::targetDestroyed):
(WebCore::ResizeObserver::gatherObservations):
(WebCore::ResizeObserver::deliverObservations):
(WebCore::ResizeObserver::removeTarget):
(WebCore::ResizeObserver::removeAllTargets):
(WebCore::ResizeObserver::removeObservation):
(WebCore::ResizeObserver::hasPendingActivity const):
(WebCore::ResizeObserver::activeDOMObjectName const):
(WebCore::ResizeObserver::canSuspendForDocumentSuspension const):
(WebCore::ResizeObserver::stop):
* page/ResizeObserver.h: Added.
(WebCore::ResizeObserver::hasObservations const):
(WebCore::ResizeObserver::hasActiveObservations const):
(WebCore::ResizeObserver::maxElementDepth):
(WebCore::ResizeObserver::hasSkippedObservations const):
(WebCore::ResizeObserver::setHasSkippedObservations):
* page/ResizeObserver.idl: Copied from Tools/DumpRenderTree/TestOptions.h.
* page/ResizeObserverCallback.h: Copied from Tools/DumpRenderTree/TestOptions.h.
* page/ResizeObserverCallback.idl: Copied from Tools/DumpRenderTree/TestOptions.h.
* page/ResizeObserverEntry.h: Copied from Tools/DumpRenderTree/TestOptions.h.
(WebCore::ResizeObserverEntry::create):
(WebCore::ResizeObserverEntry::target const):
(WebCore::ResizeObserverEntry::contentRect const):
(WebCore::ResizeObserverEntry::ResizeObserverEntry):
* page/ResizeObserverEntry.idl: Copied from Tools/DumpRenderTree/TestOptions.h.
* page/Settings.yaml:

Source/WebCore/PAL:

Add ENABLE_RESIZE_OBSERVER.

* Configurations/FeatureDefines.xcconfig:

Source/WebKit:

Add WebPreferences and FeatureDefines for ResizeObserver.

* Configurations/FeatureDefines.xcconfig:
* Shared/WebPreferences.yaml:

Source/WebKitLegacy/mac:

* Configurations/FeatureDefines.xcconfig:
* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences resizeObserverEnabled]):
(-[WebPreferences setResizeObserverEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):
(-[WebView _flushCompositingChanges]): checkResizeObservations() in the begining.

Source/WebKitLegacy/win:

* Interfaces/IWebPreferencesPrivate.idl:
* WebPreferenceKeysPrivate.h:
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings):
(WebPreferences::resizeObserverEnabled):
(WebPreferences::setResizeObserverEnabled):
* WebPreferences.h:
* WebView.cpp:
(WebView::notifyPreferencesChanged):

Tools:

Support resizeObserverEnabled webPreferences.

* DumpRenderTree/TestOptions.cpp:
(TestOptions::TestOptions):
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/mac/DumpRenderTree.mm:
(setWebPreferencesForTestOptions):
* DumpRenderTree/win/DumpRenderTree.cpp:
(enableExperimentalFeatures):
* Scripts/webkitperl/FeatureList.pm:
* TestWebKitAPI/Configurations/FeatureDefines.xcconfig:

LayoutTests:

Add tests for resize-observer of multiframe.

* resize-observer/modify-frametree-in-callback-expected.txt: Added.
* resize-observer/modify-frametree-in-callback.html: Added.
* resize-observer/multi-frames-expected.txt: Added.
* resize-observer/multi-frames.html: Added.
* resize-observer/observe-element-from-other-frame-expected.txt: Added.
* resize-observer/observe-element-from-other-frame.html: Added.
* resize-observer/resources/frame1.html: Added.
* resize-observer/resources/frame2.html: Added.
* resize-observer/resources/frame3.html: Added.
* resize-observer/resources/frame4.html: Added.
* resize-observer/resources/frameset1.html: Added.
* resize-observer/resources/frameset2.html: Added.
* resize-observer/resources/iframe1.html: Added.
* resize-observer/resources/resizeTestHelper.js: Added.
(ResizeTestHelper):
(ResizeTestHelper.prototype.get _currentStep):
(ResizeTestHelper.prototype._nextStep):
(ResizeTestHelper.prototype._handleNotification):
(ResizeTestHelper.prototype._handleTimeout):
(ResizeTestHelper.prototype._done):
(ResizeTestHelper.prototype.start):
(ResizeTestHelper.prototype.get rafCount):
(ResizeTestHelper.prototype._incrementRaf):
(ResizeTestHelper.prototype.startCountingRaf):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243643 268f45cc-cd09-0410-ab3c-d52691b4dbfc

83 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/interfaces/ResizeObserver.idl [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/resize-observer/eventloop-expected.txt
LayoutTests/imported/w3c/web-platform-tests/resize-observer/eventloop.html
LayoutTests/imported/w3c/web-platform-tests/resize-observer/idlharness.window-expected.txt
LayoutTests/imported/w3c/web-platform-tests/resize-observer/idlharness.window.html
LayoutTests/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt
LayoutTests/imported/w3c/web-platform-tests/resize-observer/notify.html
LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-expected.txt
LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe.html
LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt
LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg.html
LayoutTests/resize-observer/modify-frametree-in-callback-expected.txt [new file with mode: 0644]
LayoutTests/resize-observer/modify-frametree-in-callback.html [new file with mode: 0644]
LayoutTests/resize-observer/multi-frames-expected.txt [new file with mode: 0644]
LayoutTests/resize-observer/multi-frames.html [new file with mode: 0644]
LayoutTests/resize-observer/observe-element-from-other-frame-expected.txt [new file with mode: 0644]
LayoutTests/resize-observer/observe-element-from-other-frame.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/frame1.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/frame2.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/frame3.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/frame4.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/frameset1.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/frameset2.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/iframe1.html [new file with mode: 0644]
LayoutTests/resize-observer/resources/resizeTestHelper.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/DerivedSources.make
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementRareData.cpp
Source/WebCore/dom/ElementRareData.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameViewLayoutContext.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageConsoleClient.cpp
Source/WebCore/page/ResizeObservation.cpp [new file with mode: 0644]
Source/WebCore/page/ResizeObservation.h [new file with mode: 0644]
Source/WebCore/page/ResizeObserver.cpp [new file with mode: 0644]
Source/WebCore/page/ResizeObserver.h [new file with mode: 0644]
Source/WebCore/page/ResizeObserver.idl [new file with mode: 0644]
Source/WebCore/page/ResizeObserverCallback.h [new file with mode: 0644]
Source/WebCore/page/ResizeObserverCallback.idl [new file with mode: 0644]
Source/WebCore/page/ResizeObserverEntry.h [new file with mode: 0644]
Source/WebCore/page/ResizeObserverEntry.idl [new file with mode: 0644]
Source/WebCore/page/Settings.yaml
Source/WebKit/ChangeLog
Source/WebKit/Configurations/FeatureDefines.xcconfig
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig
Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/mac/WebView/WebPreferences.mm
Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl
Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/win/WebPreferences.cpp
Source/WebKitLegacy/win/WebPreferences.h
Source/WebKitLegacy/win/WebView.cpp
Source/cmake/WebKitFeatures.cmake
Tools/ChangeLog
Tools/DumpRenderTree/TestOptions.cpp
Tools/DumpRenderTree/TestOptions.h
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/Scripts/webkitperl/FeatureList.pm
Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig

index 4a1dde6..91a88f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Add ENABLE_RESIZE_OBSERVER.
+
+        * Source/cmake/WebKitFeatures.cmake:
+
 2019-03-25  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE][GTK] Make building WebVR (w/OpenVR) not depend on ENABLE_EXPERIMENTAL_FEATURES
index 08bd472..a390402 100644 (file)
@@ -1,3 +1,37 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Add tests for resize-observer of multiframe.
+
+        * resize-observer/modify-frametree-in-callback-expected.txt: Added.
+        * resize-observer/modify-frametree-in-callback.html: Added.
+        * resize-observer/multi-frames-expected.txt: Added.
+        * resize-observer/multi-frames.html: Added.
+        * resize-observer/observe-element-from-other-frame-expected.txt: Added.
+        * resize-observer/observe-element-from-other-frame.html: Added.
+        * resize-observer/resources/frame1.html: Added.
+        * resize-observer/resources/frame2.html: Added.
+        * resize-observer/resources/frame3.html: Added.
+        * resize-observer/resources/frame4.html: Added.
+        * resize-observer/resources/frameset1.html: Added.
+        * resize-observer/resources/frameset2.html: Added.
+        * resize-observer/resources/iframe1.html: Added.
+        * resize-observer/resources/resizeTestHelper.js: Added.
+        (ResizeTestHelper):
+        (ResizeTestHelper.prototype.get _currentStep):
+        (ResizeTestHelper.prototype._nextStep):
+        (ResizeTestHelper.prototype._handleNotification):
+        (ResizeTestHelper.prototype._handleTimeout):
+        (ResizeTestHelper.prototype._done):
+        (ResizeTestHelper.prototype.start):
+        (ResizeTestHelper.prototype.get rafCount):
+        (ResizeTestHelper.prototype._incrementRaf):
+        (ResizeTestHelper.prototype.startCountingRaf):
+
 2019-03-28  Chris Dumez  <cdumez@apple.com>
 
         Support <object>.contentWindow
index 9d756f9..a7691bf 100644 (file)
@@ -1,3 +1,24 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Set ResizeObserverEnabled for test runner and update expectations.
+
+        * web-platform-tests/interfaces/ResizeObserver.idl: Added.
+        * web-platform-tests/resize-observer/eventloop-expected.txt:
+        * web-platform-tests/resize-observer/eventloop.html:
+        * web-platform-tests/resize-observer/idlharness.window-expected.txt:
+        * web-platform-tests/resize-observer/idlharness.window.html:
+        * web-platform-tests/resize-observer/notify-expected.txt:
+        * web-platform-tests/resize-observer/notify.html:
+        * web-platform-tests/resize-observer/observe-expected.txt:
+        * web-platform-tests/resize-observer/observe.html:
+        * web-platform-tests/resize-observer/svg-expected.txt:
+        * web-platform-tests/resize-observer/svg.html:
+
 2019-03-28  Chris Dumez  <cdumez@apple.com>
 
         Support <object>.contentWindow
diff --git a/LayoutTests/imported/w3c/web-platform-tests/interfaces/ResizeObserver.idl b/LayoutTests/imported/w3c/web-platform-tests/interfaces/ResizeObserver.idl
new file mode 100644 (file)
index 0000000..fc56faf
--- /dev/null
@@ -0,0 +1,30 @@
+// GENERATED CONTENT - DO NOT EDIT
+// Content was automatically extracted by Reffy into reffy-reports
+// (https://github.com/tidoust/reffy-reports)
+// Source: Resize Observer 1 (https://wicg.github.io/ResizeObserver/)
+
+[Constructor(ResizeObserverCallback callback),
+    Exposed=Window]
+interface ResizeObserver {
+    void observe(Element target);
+    void unobserve(Element target);
+    void disconnect();
+};
+
+callback ResizeObserverCallback = void (sequence<ResizeObserverEntry> entries, ResizeObserver observer);
+
+[Constructor(Element target)
+]
+interface ResizeObserverEntry {
+    readonly attribute Element target;
+    readonly attribute DOMRectReadOnly contentRect;
+};
+
+[Constructor(Element target)
+]
+interface ResizeObservation {
+    readonly attribute Element target;
+    readonly attribute float broadcastWidth;
+    readonly attribute float broadcastHeight;
+    boolean isActive();
+};
index 7b23106..6158cd4 100644 (file)
@@ -1,7 +1,11 @@
-CONSOLE MESSAGE: line 50: ReferenceError: Can't find variable: ResizeObserver
+CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
 ResizeObserver notification event loop tests
 
 t1
 
-FAIL ResizeObserver implemented assert_own_property: expected property "ResizeObserver" missing
+Harness Error (TIMEOUT), message = null
+
+PASS ResizeObserver implemented 
+NOTRUN guard 
+FAIL test0: multiple notifications inside same event loop assert_equals: new loop expected 1 but got 0
 
index 559f52a..622d724 100644 (file)
@@ -1,4 +1,4 @@
-<!doctype html>
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="./resources/resizeTestHelper.js"></script>
index a7ea327..8c84928 100644 (file)
@@ -1,30 +1,43 @@
+CONSOLE MESSAGE: line 482: callback not yet supported
 
-FAIL idl_test setup promise_test: Unhandled rejection with value: object "Got an error before parsing any named definition: Unrecognised tokens, line 1 (tokens: "{\"error\": {\"message\"")
-[
-    {
-        "type": "{",
-        "value": "{",
-        "trivia": ""
-    },
-    {
-        "type": "string",
-        "value": "\"error\"",
-        "trivia": ""
-    },
-    {
-        "type": ":",
-        "value": ":",
-        "trivia": ""
-    },
-    {
-        "type": "{",
-        "value": "{",
-        "trivia": " "
-    },
-    {
-        "type": "string",
-        "value": "\"message\"",
-        "trivia": ""
-    }
-]"
+PASS idl_test setup 
+PASS ResizeObserverEntry creator 
+PASS ResizeObserver interface: existence and properties of interface object 
+PASS ResizeObserver interface object length 
+PASS ResizeObserver interface object name 
+PASS ResizeObserver interface: existence and properties of interface prototype object 
+PASS ResizeObserver interface: existence and properties of interface prototype object's "constructor" property 
+PASS ResizeObserver interface: existence and properties of interface prototype object's @@unscopables property 
+PASS ResizeObserver interface: operation observe(Element) 
+PASS ResizeObserver interface: operation unobserve(Element) 
+PASS ResizeObserver interface: operation disconnect() 
+PASS ResizeObserver must be primary interface of observer 
+PASS Stringification of observer 
+PASS ResizeObserver interface: observer must inherit property "observe(Element)" with the proper type 
+PASS ResizeObserver interface: calling observe(Element) on observer with too few arguments must throw TypeError 
+PASS ResizeObserver interface: observer must inherit property "unobserve(Element)" with the proper type 
+PASS ResizeObserver interface: calling unobserve(Element) on observer with too few arguments must throw TypeError 
+PASS ResizeObserver interface: observer must inherit property "disconnect()" with the proper type 
+PASS ResizeObserverEntry interface: existence and properties of interface object 
+FAIL ResizeObserverEntry interface object length assert_equals: wrong value for ResizeObserverEntry.length expected 1 but got 0
+PASS ResizeObserverEntry interface object name 
+PASS ResizeObserverEntry interface: existence and properties of interface prototype object 
+PASS ResizeObserverEntry interface: existence and properties of interface prototype object's "constructor" property 
+PASS ResizeObserverEntry interface: existence and properties of interface prototype object's @@unscopables property 
+PASS ResizeObserverEntry interface: attribute target 
+PASS ResizeObserverEntry interface: attribute contentRect 
+PASS ResizeObserverEntry must be primary interface of entry 
+PASS Stringification of entry 
+PASS ResizeObserverEntry interface: entry must inherit property "target" with the proper type 
+PASS ResizeObserverEntry interface: entry must inherit property "contentRect" with the proper type 
+FAIL ResizeObservation interface: existence and properties of interface object assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface object length assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface object name assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: existence and properties of interface prototype object assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: attribute target assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: attribute broadcastWidth assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: attribute broadcastHeight assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
+FAIL ResizeObservation interface: operation isActive() assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing
 
index 2382913..6621b07 100644 (file)
@@ -1 +1 @@
-<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
+<!-- This file is required for WebKit test infrastructure to run the templated test --><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
index 9532784..436a343 100644 (file)
@@ -1,11 +1,21 @@
-CONSOLE MESSAGE: line 50: ReferenceError: Can't find variable: ResizeObserver
 ResizeObserver tests
 
 t1
 t2
-t3 inline
+t3
+inline
 
-Harness Error (FAIL), message = ReferenceError: Can't find variable: ResizeObserver
-
-FAIL ResizeObserver implemented assert_own_property: expected property "ResizeObserver" missing
+PASS ResizeObserver implemented 
+PASS guard 
+PASS test0: notification ordering 
+PASS test1: display:none triggers notification 
+PASS test2: remove/appendChild trigger notification 
+PASS test3: dimensions match 
+PASS test4: transform do not cause notifications 
+PASS test5: moving an element does not trigger notifications 
+PASS test6: inline element does not notify 
+PASS test7: unobserve inside notify callback 
+PASS test8: observe inside notify callback 
+PASS test9: disconnect inside notify callback 
+PASS test10: element notifies when parent removed 
 
index d588851..b1038a3 100644 (file)
@@ -1,4 +1,4 @@
-<!doctype html>
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="./resources/resizeTestHelper.js"></script>
index 75003e0..2211b21 100644 (file)
@@ -1,9 +1,18 @@
-CONSOLE MESSAGE: line 50: ReferenceError: Can't find variable: ResizeObserver
+CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
 ResizeObserver tests
 
 t1
 t2
  
 
-FAIL ResizeObserver implemented assert_own_property: expected property "ResizeObserver" missing
+PASS ResizeObserver implemented 
+PASS guard 
+PASS test0: simple observation 
+PASS test1: multiple observation on same element trigger only one 
+PASS test2: throw exception when observing non-element 
+PASS test3: disconnect stops all notifications 
+PASS test4: unobserve target stops notifications, unobserve non-observed does nothing 
+PASS test5: observe img 
+PASS test6: iframe notifications 
+FAIL test7: callback.this assert_equals: callback.this is ResizeObserver expected (object) object "[object ResizeObserver]" but got (undefined) undefined
 
index dc1f195..fc4592d 100644 (file)
@@ -1,4 +1,4 @@
-<!doctype html>
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="./resources/resizeTestHelper.js"></script>
index dcf836e..f285f88 100644 (file)
@@ -1,9 +1,20 @@
-CONSOLE MESSAGE: line 50: ReferenceError: Can't find variable: ResizeObserver
 ResizeObserver svg tests
 
 Here is a paragraph that requires word wrap
 
 svg text tag
 
-FAIL ResizeObserver implemented assert_own_property: expected property "ResizeObserver" missing
+PASS ResizeObserver implemented 
+PASS guard 
+PASS test0: observe svg:circle 
+PASS test1: observe svg:ellipse 
+PASS test2: observe svg:foreignObject 
+PASS test3: observe svg:image 
+PASS test4: observe svg:line 
+PASS test5: observe svg:path 
+PASS test6: observe svg:path 
+PASS test7: observe svg:polyline 
+PASS test8: observe svg:rect 
+PASS test9: observe svg:text 
+PASS test10: observe svg:svg, top/left is 0 even with padding 
 
index e3a1ab6..49e5c19 100644 (file)
@@ -1,4 +1,4 @@
-<!doctype html>
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="./resources/resizeTestHelper.js"></script>
diff --git a/LayoutTests/resize-observer/modify-frametree-in-callback-expected.txt b/LayoutTests/resize-observer/modify-frametree-in-callback-expected.txt
new file mode 100644 (file)
index 0000000..70c8f01
--- /dev/null
@@ -0,0 +1,6 @@
+Test pass if no crash.
+
+
+PASS ResizeObserver implemented 
+PASS test0: Frametree changed in callback 
+
diff --git a/LayoutTests/resize-observer/modify-frametree-in-callback.html b/LayoutTests/resize-observer/modify-frametree-in-callback.html
new file mode 100644 (file)
index 0000000..f4e4519
--- /dev/null
@@ -0,0 +1,26 @@
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<div>Test pass if no crash.</div>
+
+<iframe src="./resources/frameset1.html"></iframe>
+
+<script>
+
+function test0() {
+    let test = async_test('test0: Frametree changed in callback');
+    setInterval(function() {
+        let frameset = document.querySelector('iframe').contentDocument.querySelector('frameset');
+        if (frameset && frameset.childElementCount == 0) {
+            test.done();
+        }
+    }, 10);
+}
+
+test(_ => {
+    assert_own_property(window, "ResizeObserver");
+}, "ResizeObserver implemented");
+
+test0();
+</script>
\ No newline at end of file
diff --git a/LayoutTests/resize-observer/multi-frames-expected.txt b/LayoutTests/resize-observer/multi-frames-expected.txt
new file mode 100644 (file)
index 0000000..8cad402
--- /dev/null
@@ -0,0 +1,10 @@
+ResizeObserver tests
+
+t1
+t2 
+
+PASS ResizeObserver implemented 
+PASS guard 
+PASS test0: depth of target from child frame 
+PASS test1: observed element move to new document 
+
diff --git a/LayoutTests/resize-observer/multi-frames.html b/LayoutTests/resize-observer/multi-frames.html
new file mode 100644 (file)
index 0000000..12e808e
--- /dev/null
@@ -0,0 +1,117 @@
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="./resources/resizeTestHelper.js"></script>
+<p>ResizeObserver tests</p>
+<div id="target1" style="width:100px;height:100px;">t1
+    <div id="target2" style="width:100px;height:100px;">t2
+        <iframe id="iframe1" src="./resources/iframe1.html"></iframe>
+    </div>
+</div>
+<div id="target3" style="width:100px;height:100px;">t3</div>
+
+<div id="log"></div>
+<script type="text/javascript">
+'use strict';
+
+function test0() {
+    let t1 = document.querySelector('#target1');
+    let t2 = document.querySelector('#target2');
+    let it1 = document.querySelector("#iframe1").contentDocument.querySelector("#iframe1-target1");
+
+    let helper = new ResizeTestHelper(
+        "test0: depth of target from child frame",
+    [
+        {
+            setup: observer => {
+                observer.observe(t1);
+                observer.observe(t2);
+                observer.observe(it1);
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 3, "3 entries");
+                assert_equals(entries[0].target, t1, "observe target from child frame");
+                assert_equals(entries[1].target, t2, "observe target from child frame");
+                assert_equals(entries[2].target, it1, "observe target from child frame");
+            }
+        },
+        {
+            setup: observer => {
+                t2.style.width = "50px";
+                it1.style.width = "50px";
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 2, "2 entries");
+                assert_equals(entries[0].target, t2, "t2 deeper than t1");
+                assert_equals(entries[1].target, it1, "it1 deeper than t1");
+            }
+        },
+        {
+            setup: observer => {
+                it1.style.width = "25px";
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 1, "1 entry");
+                assert_equals(entries[0].target, it1, "it1 deeper than t2");
+            }
+        }
+    ]);
+    return helper.start();
+}
+
+function test1() {
+    let t1 = document.querySelector('#target1');
+    let t3 = document.querySelector('#target3');
+    let it1 = document.querySelector("#iframe1").contentDocument.querySelector("#iframe1-target1");
+
+    let helper = new ResizeTestHelper(
+        "test1: observed element move to new document",
+    [
+        {
+            setup: observer => {
+                observer.observe(t1);
+                observer.observe(t3);
+                observer.observe(it1);
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 3, "3 entries");
+                assert_equals(entries[0].target, t1, "move to new document");
+                assert_equals(entries[1].target, t3, "move to new document");
+                assert_equals(entries[2].target, it1, "move to new document");
+            }
+        },
+        {
+            setup: observer => {
+                t3.parentElement.removeChild(t3);
+                it1.parentElement.appendChild(t3);
+                t3.style.width = "25px";
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 1, "1 entry");
+                assert_equals(entries[0].target, t3, "still observed after moving to new document");
+            }
+        }
+    ]);
+    return helper.start();
+}
+
+function startTest() {
+    let guard;
+    test(_ => {
+        assert_own_property(window, "ResizeObserver");
+        guard = async_test('guard');
+    }, "ResizeObserver implemented");
+
+    test0()
+        .then(() => { return test1(); })
+        .then(() => { guard.done(); });
+}
+
+window.addEventListener('message', function(event) {
+    switch(event.data) {
+        case 'readyToTest':
+            startTest();
+        break;
+    }
+});
+</script>
diff --git a/LayoutTests/resize-observer/observe-element-from-other-frame-expected.txt b/LayoutTests/resize-observer/observe-element-from-other-frame-expected.txt
new file mode 100644 (file)
index 0000000..c0d234b
--- /dev/null
@@ -0,0 +1,5 @@
+
+
+PASS ResizeObserver implemented 
+PASS test0: Observe element from other frame 
+
diff --git a/LayoutTests/resize-observer/observe-element-from-other-frame.html b/LayoutTests/resize-observer/observe-element-from-other-frame.html
new file mode 100644 (file)
index 0000000..0d357e9
--- /dev/null
@@ -0,0 +1,30 @@
+<!doctype html><!-- webkit-test-runner [ experimental:ResizeObserverEnabled=true ] -->
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+
+<iframe src="./resources/frameset2.html"></iframe>
+
+<script>
+
+function test0() {
+    let test = async_test('test0: Observe element from other frame');
+    window.addEventListener('message', event => {
+        switch(event.data) {
+        case 'success':
+        case 'fail':
+            test.step( () => {
+                assert_equals(event.data, 'success');
+                test.done();
+            });
+        break;
+        }
+    }, false);
+}
+
+test(_ => {
+    assert_own_property(window, "ResizeObserver");
+}, "ResizeObserver implemented");
+
+test0();
+</script>
\ No newline at end of file
diff --git a/LayoutTests/resize-observer/resources/frame1.html b/LayoutTests/resize-observer/resources/frame1.html
new file mode 100644 (file)
index 0000000..46c1df1
--- /dev/null
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+    <body>
+        <h1>frame1</h1>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/resize-observer/resources/frame2.html b/LayoutTests/resize-observer/resources/frame2.html
new file mode 100644 (file)
index 0000000..8a47bad
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<body>
+    <h1>frame2</h1>
+</body>
+
+<script type="text/javascript">
+function test0() {
+    let ro = new ResizeObserver(entries => {
+        for (let entry of entries) {
+            if (entry.target.parentNode) {
+                entry.target.parentNode.removeChild(entry.target);
+            }
+        }
+    });
+    let frame1 = parent.document.querySelector('#frame1');
+    let frame2 = parent.document.querySelector('#frame2');
+    ro.observe(frame1);
+    ro.observe(frame2);
+}
+
+window.addEventListener('message', function(event) {
+    switch(event.data) {
+        case 'readyToTest':
+            test0();
+        break;
+    }
+});
+</script>
+</html>
diff --git a/LayoutTests/resize-observer/resources/frame3.html b/LayoutTests/resize-observer/resources/frame3.html
new file mode 100644 (file)
index 0000000..1e6ead8
--- /dev/null
@@ -0,0 +1,4 @@
+<h1>frame3</h1>
+<div id="target1" style="width: 100px; height: 100px;">
+    <div id="target2" style="width: 100px; height: 100px;"></div>
+</div>
diff --git a/LayoutTests/resize-observer/resources/frame4.html b/LayoutTests/resize-observer/resources/frame4.html
new file mode 100644 (file)
index 0000000..c25920a
--- /dev/null
@@ -0,0 +1,58 @@
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="./resizeTestHelper.js"></script>
+
+<h1>frame4</h1>
+
+<script>
+'use strict';
+
+function test() {
+    let target1 = parent.frames[0].document.querySelector('#target1');
+    let target2 = parent.frames[0].document.querySelector('#target2');
+
+    if (!target1 || !target2) {
+        setTimeout("test()", 10);
+        return;
+    }
+
+    let timeoutId = window.setTimeout( () => {
+        parent.parent.postMessage('fail', '*');
+    }, ResizeTestHelper.TIMEOUT);
+    let helper = new ResizeTestHelper(
+        "test: observe elements from sibling frames",
+    [
+        {
+            setup: observer => {
+                observer.observe(target1);
+                observer.observe(target2);
+                target1.style.width = "50px";
+                target2.style.width = "50px";
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 2, "1 resizes");
+                assert_equals(entries[0].target, target1, "element from sibling frame");
+                assert_equals(entries[1].target, target2, "element from sibling frame");
+            }
+        },
+        {
+            setup: observer => {
+                target2.style.width = "25px";
+            },
+            notify: (entries, observer) => {
+                assert_equals(entries.length, 1, "1 resizes");
+                assert_equals(entries[0].target, target2, "element from sibling frame");
+                window.clearTimeout(timeoutId);
+                parent.parent.postMessage('success', '*');
+            }
+        }
+    ]);
+    add_result_callback(function(testobj) {
+        if (testobj.FAIL == testobj.status)
+            parent.parent.postMessage('fail', '*');
+    });
+    return helper.start();
+}
+
+test();
+</script>
diff --git a/LayoutTests/resize-observer/resources/frameset1.html b/LayoutTests/resize-observer/resources/frameset1.html
new file mode 100644 (file)
index 0000000..0d1f86e
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+
+<frameset rows="50%, 50%" onload="frames[1].postMessage('readyToTest', '*')">
+    <frame id="frame1" src="./frame1.html"></frame>
+    <frame id="frame2" src="./frame2.html"></frame>
+</frameset>
\ No newline at end of file
diff --git a/LayoutTests/resize-observer/resources/frameset2.html b/LayoutTests/resize-observer/resources/frameset2.html
new file mode 100644 (file)
index 0000000..2b2ed80
--- /dev/null
@@ -0,0 +1,4 @@
+<frameset rows="50%, 50%">
+  <frame id="frame3" src="./frame3.html"></frame>
+  <frame id="frame4" src="./frame4.html"></frame>
+</frameset>
diff --git a/LayoutTests/resize-observer/resources/iframe1.html b/LayoutTests/resize-observer/resources/iframe1.html
new file mode 100644 (file)
index 0000000..b2a8b8c
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<div id="iframe1-target1" style="width:100px;height:100px;">iframe1-t1</div>
+
+<script type="text/javascript">
+'use strict';
+window.parent.postMessage('readyToTest', '*');
+</script>
\ No newline at end of file
diff --git a/LayoutTests/resize-observer/resources/resizeTestHelper.js b/LayoutTests/resize-observer/resources/resizeTestHelper.js
new file mode 100644 (file)
index 0000000..60c681b
--- /dev/null
@@ -0,0 +1,148 @@
+'use strict';
+
+/**
+  ResizeTestHelper is a framework to test ResizeObserver
+  notifications. Use it to make assertions about ResizeObserverEntries.
+  This framework is needed because ResizeObservations are
+  delivered asynchronously inside the event loop.
+
+  Features:
+  - can queue multiple notification steps in a test
+  - handles timeouts
+  - returns Promise that is fullfilled when test completes.
+    Use to chain tests (since parallel async ResizeObserver tests
+    would conflict if reusing same DOM elements).
+
+  Usage:
+
+  create ResizeTestHelper for every test.
+  Make assertions inside notify, timeout callbacks.
+  Start tests with helper.start()
+  Chain tests with Promises.
+  Counts animation frames, see startCountingRaf
+*/
+
+/*
+  @param name: test name
+  @param steps:
+  {
+    setup: function(ResizeObserver) {
+      // called at the beginning of the test step
+      // your observe/resize code goes here
+    },
+    notify: function(entries, observer) {
+      // ResizeObserver callback.
+      // Make assertions here.
+      // Return true if next step should start on the next event loop.
+    },
+    timeout: function() {
+      // Define this if your test expects to time out.
+      // If undefined, timeout is assert_unreached.
+    }
+  }
+*/
+function ResizeTestHelper(name, steps)
+{
+    this._name = name;
+    this._steps = steps || [];
+    this._stepIdx = -1;
+    this._harnessTest = null;
+    this._observer = new ResizeObserver(this._handleNotification.bind(this));
+    this._timeoutBind = this._handleTimeout.bind(this);
+    this._nextStepBind = this._nextStep.bind(this);
+}
+
+ResizeTestHelper.TIMEOUT = 100;
+
+ResizeTestHelper.prototype = {
+  get _currentStep() {
+    return this._steps[this._stepIdx];
+  },
+
+  _nextStep: function() {
+    if (++this._stepIdx == this._steps.length)
+      return this._done();
+    this._timeoutId = this._harnessTest.step_timeout(
+      this._timeoutBind, ResizeTestHelper.TIMEOUT);
+    try {
+      this._steps[this._stepIdx].setup(this._observer);
+    }
+    catch(err) {
+      this._harnessTest.step(() => {
+        assert_unreached("Caught a throw, possible syntax error");
+      });
+    }
+  },
+
+  _handleNotification: function(entries) {
+    if (this._timeoutId) {
+      window.clearTimeout(this._timeoutId);
+      delete this._timeoutId;
+    }
+    this._harnessTest.step(() => {
+      let rafDelay = this._currentStep.notify(entries, this._observer);
+      if (rafDelay)
+        window.requestAnimationFrame(this._nextStepBind);
+      else
+        this._nextStep();
+    });
+  },
+
+  _handleTimeout: function() {
+    delete this._timeoutId;
+    this._harnessTest.step(() => {
+      if (this._currentStep.timeout) {
+        this._currentStep.timeout();
+      }
+      else {
+        assert_unreached("Timed out waiting for notification. (" + ResizeTestHelper.TIMEOUT + "ms)");
+      }
+      this._nextStep();
+    });
+  },
+
+  _done: function() {
+    this._observer.disconnect();
+    delete this._observer;
+    this._harnessTest.done();
+    if (this._rafCountRequest) {
+      window.cancelAnimationFrame(this._rafCountRequest);
+      delete this._rafCountRequest;
+    }
+    window.requestAnimationFrame(() => { this._resolvePromise(); });
+  },
+
+  start: function() {
+    this._harnessTest = async_test(this._name);
+    this._harnessTest.step(() => {
+      assert_equals(this._stepIdx, -1, "start can only be called once");
+      this._nextStep();
+    });
+    return new Promise( (resolve, reject) => {
+      this._resolvePromise = resolve;
+      this._rejectPromise = reject;
+    });
+  },
+
+  get rafCount() {
+    if (!this._rafCountRequest)
+      throw "rAF count is not active";
+    return this._rafCount;
+  },
+
+  _incrementRaf: function() {
+    if (this._rafCountRequest) {
+      this._rafCount++;
+      this._rafCountRequest = window.requestAnimationFrame(this._incrementRafBind);
+    }
+  },
+
+  startCountingRaf: function() {
+    if (this._rafCountRequest)
+      window.cancelAnimationFrame(this._rafCountRequest);
+    if (!this._incrementRafBind)
+      this._incrementRafBind = this._incrementRaf.bind(this);
+    this._rafCount = 0;
+    this._rafCountRequest = window.requestAnimationFrame(this._incrementRafBind);
+  }
+}
index bba9881..a41b596 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Add ENABLE_RESIZE_OBSERVER.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2019-03-28  Michael Saboff  <msaboff@apple.com>
 
         [YARR] Precompute BMP / non-BMP status when constructing character classes
index 9173ab3..ac52484 100644 (file)
@@ -314,6 +314,8 @@ ENABLE_QUOTA = ;
 
 ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR;
 
+ENABLE_RESIZE_OBSERVER = ENABLE_RESIZE_OBSERVER;
+
 ENABLE_RESOLUTION_MEDIA_QUERY = ;
 
 ENABLE_RESOURCE_LOAD_STATISTICS = ENABLE_RESOURCE_LOAD_STATISTICS;
@@ -411,4 +413,4 @@ ENABLE_WIRELESS_PLAYBACK_TARGET = ENABLE_WIRELESS_PLAYBACK_TARGET;
 
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESIZE_OBSERVER) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
index 20d9ee1..a222687 100644 (file)
@@ -940,6 +940,9 @@ set(WebCore_NON_SVG_IDL_FILES
     page/PerformanceServerTiming.idl
     page/PerformanceTiming.idl
     page/RemoteDOMWindow.idl
+    page/ResizeObserver.idl
+    page/ResizeObserverCallback.idl
+    page/ResizeObserverEntry.idl
     page/Screen.idl
     page/ScrollIntoViewOptions.idl
     page/ScrollLogicalPosition.idl
index 2a78e42..0bb2998 100644 (file)
@@ -1,3 +1,124 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Tests: resize-observer/modify-frametree-in-callback.html
+               resize-observer/multi-frames.html
+               resize-observer/observe-element-from-other-frame.html
+               Imported from WPT by https://bugs.webkit.org/show_bug.cgi?id=193821
+
+        The data structure: Document has a ResizeObserver slot. ResizeObserver has a ResizeObservation slot.
+        ResizeObservation is related to one Element and the last reported size.
+        On the other hand, Element has a ResizeObservation slot.
+
+        At the beginning of willDisplayPage, it will check resize observations for current page if:
+        1. There is FrameView be layout and there are ResizeObservers in this page.
+        2. m_resizeObserverTimer has been started by observe() or hasSkippedResizeObservers().
+        During checkResizeObservations(), we'll gatherDocumentsNeedingResizeObservationCheck() first,
+        then notifyResizeObservers() for each document. During notifyResizeObservers(), it will gather
+        the m_activeObservations whose size changed and target element deeper than require depth.
+        The size changed shallower observations are skipped observations which will be delivered
+        in the next time. And an ErrorEvent will be reported.
+        After gathering, deliverResizeObservations create entries and invoke the callbacks with them.
+
+        The Element from other document could be observed.
+
+        * CMakeLists.txt:
+        * Configurations/FeatureDefines.xcconfig:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+        * dom/Document.cpp:
+        (WebCore::Document::getParserLocation const):
+        (WebCore::Document::addResizeObserver):
+        (WebCore::Document::removeResizeObserver):
+        (WebCore::Document::hasResizeObservers):
+        (WebCore::Document::gatherResizeObservations): Gather m_activeObservations at depth and return the shallowest depth.
+        (WebCore::Document::deliverResizeObservations): Deliver m_activeObservations, generate ResizeObserverEntries, and invoke the m_callbacks.
+        (WebCore::Document::hasSkippedResizeObservations const): To determine if Document has the size changed but not delivered observations.
+        (WebCore::Document::setHasSkippedResizeObservations):
+        (WebCore::Document::scheduleResizeObservations):
+        * dom/Document.h:
+        * dom/Element.cpp:
+        (WebCore::Element::~Element):
+        (WebCore::Element::disconnectFromResizeObservers):
+        (WebCore::Element::ensureResizeObserverData):
+        (WebCore::Element::resizeObserverData):
+        * dom/Element.h:
+        * dom/ElementRareData.cpp:
+        * dom/ElementRareData.h:
+        (WebCore::ElementRareData::resizeObserverData):
+        (WebCore::ElementRareData::setResizeObserverData):
+        (WebCore::ElementRareData::useTypes const):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::didLayout):
+        * page/FrameViewLayoutContext.cpp:
+        (WebCore::FrameViewLayoutContext::layoutTimerFired): We need to start a ResizeObserver timer here, because for WK1 this might not trigger flushCompositingChanges.
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        (WebCore::Page::willDisplayPage):
+        (WebCore::Page::hasResizeObservers const):
+        (WebCore::Page::gatherDocumentsNeedingResizeObservationCheck): Gather the documents with resize observers.
+        (WebCore::Page::checkResizeObservations): Gather documents then notifyResizeObservers for each document.
+        (WebCore::Page::scheduleResizeObservations):
+        (WebCore::Page::notifyResizeObservers): Gather m_activeObservations and deliver them. Report ErrorEvent if it has skipped observations.
+        * page/Page.h:
+        (WebCore::Page::setNeedsCheckResizeObservations): Page needs to check ResizeObservations if FrameView layout or m_resizeObserverTimer has been started.
+        (WebCore::Page::needsCheckResizeObservations const):
+        * page/PageConsoleClient.cpp:
+        (WebCore::PageConsoleClient::addMessage):
+        (WebCore::getParserLocationForConsoleMessage): Deleted.
+        * page/ResizeObservation.cpp: Added.
+        (WebCore::ResizeObservation::create):
+        (WebCore::ResizeObservation::ResizeObservation):
+        (WebCore::ResizeObservation::~ResizeObservation):
+        (WebCore::ResizeObservation::updateObservationSize):
+        (WebCore::ResizeObservation::computeObservedSize const):
+        (WebCore::ResizeObservation::computeTargetLocation const):
+        (WebCore::ResizeObservation::computeContentRect const):
+        (WebCore::ResizeObservation::elementSizeChanged const):
+        (WebCore::ResizeObservation::targetElementDepth const):
+        * page/ResizeObservation.h: Copied from Tools/DumpRenderTree/TestOptions.h.
+        (WebCore::ResizeObservation::target const):
+        * page/ResizeObserver.cpp: Added.
+        (WebCore::ResizeObserver::create):
+        (WebCore::ResizeObserver::ResizeObserver):
+        (WebCore::ResizeObserver::~ResizeObserver):
+        (WebCore::ResizeObserver::scheduleObservations):
+        (WebCore::ResizeObserver::observe):
+        (WebCore::ResizeObserver::unobserve):
+        (WebCore::ResizeObserver::disconnect):
+        (WebCore::ResizeObserver::targetDestroyed):
+        (WebCore::ResizeObserver::gatherObservations):
+        (WebCore::ResizeObserver::deliverObservations):
+        (WebCore::ResizeObserver::removeTarget):
+        (WebCore::ResizeObserver::removeAllTargets):
+        (WebCore::ResizeObserver::removeObservation):
+        (WebCore::ResizeObserver::hasPendingActivity const):
+        (WebCore::ResizeObserver::activeDOMObjectName const):
+        (WebCore::ResizeObserver::canSuspendForDocumentSuspension const):
+        (WebCore::ResizeObserver::stop):
+        * page/ResizeObserver.h: Added.
+        (WebCore::ResizeObserver::hasObservations const):
+        (WebCore::ResizeObserver::hasActiveObservations const):
+        (WebCore::ResizeObserver::maxElementDepth):
+        (WebCore::ResizeObserver::hasSkippedObservations const):
+        (WebCore::ResizeObserver::setHasSkippedObservations):
+        * page/ResizeObserver.idl: Copied from Tools/DumpRenderTree/TestOptions.h.
+        * page/ResizeObserverCallback.h: Copied from Tools/DumpRenderTree/TestOptions.h.
+        * page/ResizeObserverCallback.idl: Copied from Tools/DumpRenderTree/TestOptions.h.
+        * page/ResizeObserverEntry.h: Copied from Tools/DumpRenderTree/TestOptions.h.
+        (WebCore::ResizeObserverEntry::create):
+        (WebCore::ResizeObserverEntry::target const):
+        (WebCore::ResizeObserverEntry::contentRect const):
+        (WebCore::ResizeObserverEntry::ResizeObserverEntry):
+        * page/ResizeObserverEntry.idl: Copied from Tools/DumpRenderTree/TestOptions.h.
+        * page/Settings.yaml:
+
 2019-03-28  Chris Dumez  <cdumez@apple.com>
 
         Support <object>.contentWindow
index 9173ab3..ac52484 100644 (file)
@@ -314,6 +314,8 @@ ENABLE_QUOTA = ;
 
 ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR;
 
+ENABLE_RESIZE_OBSERVER = ENABLE_RESIZE_OBSERVER;
+
 ENABLE_RESOLUTION_MEDIA_QUERY = ;
 
 ENABLE_RESOURCE_LOAD_STATISTICS = ENABLE_RESOURCE_LOAD_STATISTICS;
@@ -411,4 +413,4 @@ ENABLE_WIRELESS_PLAYBACK_TARGET = ENABLE_WIRELESS_PLAYBACK_TARGET;
 
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESIZE_OBSERVER) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
index e4b53f9..951b96a 100644 (file)
@@ -890,6 +890,9 @@ JS_BINDING_IDLS = \
     $(WebCore)/page/PerformanceServerTiming.idl \
     $(WebCore)/page/PerformanceTiming.idl \
     $(WebCore)/page/RemoteDOMWindow.idl \
+    $(WebCore)/page/ResizeObserver.idl \
+    $(WebCore)/page/ResizeObserverCallback.idl \
+    $(WebCore)/page/ResizeObserverEntry.idl \
     $(WebCore)/page/Screen.idl \
     $(WebCore)/page/ScrollIntoViewOptions.idl \
     $(WebCore)/page/ScrollLogicalPosition.idl \
index 80600a0..024fa87 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Add ENABLE_RESIZE_OBSERVER.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2019-03-25  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
 
         Remove NavigatorContentUtils in WebCore/Modules
index 9173ab3..ac52484 100644 (file)
@@ -314,6 +314,8 @@ ENABLE_QUOTA = ;
 
 ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR;
 
+ENABLE_RESIZE_OBSERVER = ENABLE_RESIZE_OBSERVER;
+
 ENABLE_RESOLUTION_MEDIA_QUERY = ;
 
 ENABLE_RESOURCE_LOAD_STATISTICS = ENABLE_RESOURCE_LOAD_STATISTICS;
@@ -411,4 +413,4 @@ ENABLE_WIRELESS_PLAYBACK_TARGET = ENABLE_WIRELESS_PLAYBACK_TARGET;
 
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESIZE_OBSERVER) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
index 58069eb..9d30181 100644 (file)
@@ -1547,6 +1547,8 @@ page/ProcessWarming.cpp
 page/Quirks.cpp
 page/RemoteDOMWindow.cpp
 page/RemoteFrame.cpp
+page/ResizeObservation.cpp
+page/ResizeObserver.cpp
 page/ResourceUsageOverlay.cpp
 page/ResourceUsageThread.cpp
 page/RuntimeEnabledFeatures.cpp
@@ -3090,6 +3092,9 @@ JSReadableStreamSink.cpp
 JSReadableStreamSource.cpp
 JSRemoteDOMWindow.cpp
 JSRequestAnimationFrameCallback.cpp
+JSResizeObserver.cpp
+JSResizeObserverCallback.cpp
+JSResizeObserverEntry.cpp
 JSRsaHashedImportParams.cpp
 JSRsaHashedKeyGenParams.cpp
 JSRsaKeyGenParams.cpp
index 79db34a..4e937eb 100644 (file)
                582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */; };
                585D6E041A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h in Headers */ = {isa = PBXBuildFile; fileRef = 585D6E021A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h */; };
                589556ED18D4A44000764B03 /* BorderEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 589556EC18D4A44000764B03 /* BorderEdge.h */; };
+               58B2F9F42232D45300938D63 /* ResizeObservation.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2F9F32232D43F00938D63 /* ResizeObservation.h */; };
+               58B2F9F52232D45800938D63 /* ResizeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2F9EC2232D43B00938D63 /* ResizeObserver.h */; };
+               58B2F9F62232D45C00938D63 /* ResizeObserverCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2F9F02232D43E00938D63 /* ResizeObserverCallback.h */; };
+               58B2F9F72232D46100938D63 /* ResizeObserverEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2F9EE2232D43D00938D63 /* ResizeObserverEntry.h */; };
+               58B2FA042232D9BE00938D63 /* JSResizeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2FA012232D60A00938D63 /* JSResizeObserver.h */; };
+               58B2FA052232DC4F00938D63 /* JSResizeObserverEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2FA022232D60A00938D63 /* JSResizeObserverEntry.h */; };
+               58B2FA062232DC5500938D63 /* JSResizeObserverCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 58B2F9FF2232D60800938D63 /* JSResizeObserverCallback.h */; };
                58CD35CB18EB4C3900B9F3AC /* FloatSizeHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 58CD35CA18EB4C3900B9F3AC /* FloatSizeHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5905ADC01302F3CE00F116DF /* XMLTreeViewer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5905ADBE1302F3CE00F116DF /* XMLTreeViewer.h */; };
                590E1B4911E4EF4B0069F784 /* DeviceOrientationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 590E1B4811E4EF4B0069F784 /* DeviceOrientationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                585D6E021A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFlowContents.h; sourceTree = "<group>"; };
                589556EC18D4A44000764B03 /* BorderEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BorderEdge.h; sourceTree = "<group>"; };
                58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BorderEdge.cpp; sourceTree = "<group>"; };
+               58B2F9EA2232D43B00938D63 /* ResizeObserverEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ResizeObserverEntry.idl; sourceTree = "<group>"; };
+               58B2F9EC2232D43B00938D63 /* ResizeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObserver.h; sourceTree = "<group>"; };
+               58B2F9ED2232D43C00938D63 /* ResizeObserverCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ResizeObserverCallback.idl; sourceTree = "<group>"; };
+               58B2F9EE2232D43D00938D63 /* ResizeObserverEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObserverEntry.h; sourceTree = "<group>"; };
+               58B2F9EF2232D43D00938D63 /* ResizeObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeObserver.cpp; sourceTree = "<group>"; };
+               58B2F9F02232D43E00938D63 /* ResizeObserverCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObserverCallback.h; sourceTree = "<group>"; };
+               58B2F9F12232D43E00938D63 /* ResizeObserver.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ResizeObserver.idl; sourceTree = "<group>"; };
+               58B2F9F22232D43F00938D63 /* ResizeObservation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeObservation.cpp; sourceTree = "<group>"; };
+               58B2F9F32232D43F00938D63 /* ResizeObservation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObservation.h; sourceTree = "<group>"; };
+               58B2F9FE2232D60700938D63 /* JSResizeObserverCallback.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSResizeObserverCallback.cpp; sourceTree = "<group>"; };
+               58B2F9FF2232D60800938D63 /* JSResizeObserverCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSResizeObserverCallback.h; sourceTree = "<group>"; };
+               58B2FA002232D60900938D63 /* JSResizeObserverEntry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSResizeObserverEntry.cpp; sourceTree = "<group>"; };
+               58B2FA012232D60A00938D63 /* JSResizeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSResizeObserver.h; sourceTree = "<group>"; };
+               58B2FA022232D60A00938D63 /* JSResizeObserverEntry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSResizeObserverEntry.h; sourceTree = "<group>"; };
+               58B2FA032232D60B00938D63 /* JSResizeObserver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSResizeObserver.cpp; sourceTree = "<group>"; };
                58CD35CA18EB4C3900B9F3AC /* FloatSizeHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatSizeHash.h; sourceTree = "<group>"; };
                58DEED8519873FF000888FF3 /* RenderSelectionInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSelectionInfo.cpp; sourceTree = "<group>"; };
                5905ADBD1302F3CE00F116DF /* XMLTreeViewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTreeViewer.cpp; sourceTree = "<group>"; };
                                46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */,
                                46B9518C207D632900A7D2DD /* RemoteFrame.cpp */,
                                46B95192207D632E00A7D2DD /* RemoteFrame.h */,
+                               58B2F9F22232D43F00938D63 /* ResizeObservation.cpp */,
+                               58B2F9F32232D43F00938D63 /* ResizeObservation.h */,
+                               58B2F9EF2232D43D00938D63 /* ResizeObserver.cpp */,
+                               58B2F9EC2232D43B00938D63 /* ResizeObserver.h */,
+                               58B2F9F12232D43E00938D63 /* ResizeObserver.idl */,
+                               58B2F9F02232D43E00938D63 /* ResizeObserverCallback.h */,
+                               58B2F9ED2232D43C00938D63 /* ResizeObserverCallback.idl */,
+                               58B2F9EE2232D43D00938D63 /* ResizeObserverEntry.h */,
+                               58B2F9EA2232D43B00938D63 /* ResizeObserverEntry.idl */,
                                A5071E821C56D079009951BE /* ResourceUsageData.h */,
                                ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
                                ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */,
                                8A9A587711E84C98008ACFD1 /* JSPerformanceTiming.h */,
                                46C3765F2085176C00C73829 /* JSRemoteDOMWindow.cpp */,
                                46C376612085176D00C73829 /* JSRemoteDOMWindow.h */,
+                               58B2FA032232D60B00938D63 /* JSResizeObserver.cpp */,
+                               58B2FA012232D60A00938D63 /* JSResizeObserver.h */,
+                               58B2F9FE2232D60700938D63 /* JSResizeObserverCallback.cpp */,
+                               58B2F9FF2232D60800938D63 /* JSResizeObserverCallback.h */,
+                               58B2FA002232D60900938D63 /* JSResizeObserverEntry.cpp */,
+                               58B2FA022232D60A00938D63 /* JSResizeObserverEntry.h */,
                                BCEC01C00C274DDD009F4EC9 /* JSScreen.cpp */,
                                BCEC01C10C274DDD009F4EC9 /* JSScreen.h */,
                                83E9B3001DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.cpp */,
                                46C376622085177D00C73829 /* JSRemoteDOMWindow.h in Headers */,
                                46BCBBC22085008F00710638 /* JSRemoteDOMWindowBase.h in Headers */,
                                4998AECE13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.h in Headers */,
+                               58B2FA042232D9BE00938D63 /* JSResizeObserver.h in Headers */,
+                               58B2FA062232DC5500938D63 /* JSResizeObserverCallback.h in Headers */,
+                               58B2FA052232DC4F00938D63 /* JSResizeObserverEntry.h in Headers */,
                                57E233711DCD468F00F28D01 /* JSRsaHashedImportParams.h in Headers */,
                                5768E4341DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h in Headers */,
                                57FEDD411DB6D73A00EB96F5 /* JSRsaKeyGenParams.h in Headers */,
                                93309E0A099E64920056E581 /* ReplaceSelectionCommand.h in Headers */,
                                4998AEC613F9D0EA0090B1AA /* RequestAnimationFrameCallback.h in Headers */,
                                F55B3DD01251F12D003EF269 /* ResetInputType.h in Headers */,
+                               58B2F9F42232D45300938D63 /* ResizeObservation.h in Headers */,
+                               58B2F9F52232D45800938D63 /* ResizeObserver.h in Headers */,
+                               58B2F9F62232D45C00938D63 /* ResizeObserverCallback.h in Headers */,
+                               58B2F9F72232D46100938D63 /* ResizeObserverEntry.h in Headers */,
                                7C2FA6121EA95A3C00A03108 /* ResourceCryptographicDigest.h in Headers */,
                                7EE6846A12D26E3800E79415 /* ResourceError.h in Headers */,
                                934F713C0D5A6F1900018D69 /* ResourceErrorBase.h in Headers */,
index 35d5784..80d8e69 100644 (file)
@@ -155,6 +155,8 @@ namespace WebCore {
     macro(PerformanceServerTiming) \
     macro(PointerEvent) \
     macro(PublicKeyCredential) \
+    macro(ResizeObserver) \
+    macro(ResizeObserverEntry) \
     macro(RTCCertificate) \
     macro(RTCDTMFSender) \
     macro(RTCDTMFToneChangeEvent) \
index a7bd98d..adf4dd8 100644 (file)
 #include "RenderView.h"
 #include "RenderWidget.h"
 #include "RequestAnimationFrameCallback.h"
+#include "ResizeObserver.h"
 #include "ResourceLoadObserver.h"
 #include "RuntimeApplicationChecks.h"
 #include "RuntimeEnabledFeatures.h"
@@ -6126,6 +6127,26 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl)
     m_haveExplicitlyDisabledDNSPrefetch = true;
 }
 
+void Document::getParserLocation(String& completedURL, unsigned& line, unsigned& column) const
+{
+    // We definitely cannot associate the message with a location being parsed if we are not even parsing.
+    if (!parsing())
+        return;
+
+    ScriptableDocumentParser* parser = scriptableDocumentParser();
+    if (!parser)
+        return;
+
+    // When the parser waits for scripts, any messages must be coming from some other source, and are not related to the location of the script element that made the parser wait.
+    if (!parser->shouldAssociateConsoleMessagesWithTextPosition())
+        return;
+
+    completedURL = url().string();
+    TextPosition position = parser->textPosition();
+    line = position.m_line.oneBasedInt();
+    column = position.m_column.oneBasedInt();
+}
+
 void Document::addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&& consoleMessage)
 {
     if (!isContextThread()) {
@@ -8026,6 +8047,67 @@ void Document::notifyIntersectionObserversTimerFired()
 }
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+void Document::addResizeObserver(ResizeObserver& observer)
+{
+    ASSERT(m_resizeObservers.find(&observer) == notFound);
+    m_resizeObservers.append(makeWeakPtr(&observer));
+}
+
+void Document::removeResizeObserver(ResizeObserver& observer)
+{
+    m_resizeObservers.removeFirst(&observer);
+}
+
+bool Document::hasResizeObservers()
+{
+    return !m_resizeObservers.isEmpty();
+}
+
+size_t Document::gatherResizeObservations(size_t deeperThan)
+{
+    size_t minDepth = ResizeObserver::maxElementDepth();
+    for (const auto& observer : m_resizeObservers) {
+        if (!observer->hasObservations())
+            continue;
+        auto depth = observer->gatherObservations(deeperThan);
+        minDepth = std::min(minDepth, depth);
+    }
+    return minDepth;
+}
+
+void Document::deliverResizeObservations()
+{
+    for (const auto& observer : m_resizeObservers) {
+        if (!observer->hasActiveObservations())
+            continue;
+        observer->deliverObservations();
+    }
+}
+
+bool Document::hasSkippedResizeObservations() const
+{
+    for (const auto& observer : m_resizeObservers) {
+        if (observer->hasSkippedObservations())
+            return true;
+    }
+    return false;
+}
+
+void Document::setHasSkippedResizeObservations(bool skipped)
+{
+    for (const auto& observer : m_resizeObservers)
+        observer->setHasSkippedObservations(skipped);
+}
+
+void Document::scheduleResizeObservations()
+{
+    if (!page())
+        return;
+    page()->scheduleResizeObservations();
+}
+#endif
+
 const AtomicString& Document::dir() const
 {
     auto* documentElement = this->documentElement();
index 670fa05..837b05f 100644 (file)
@@ -253,6 +253,10 @@ class HTMLAttachmentElement;
 class IntersectionObserver;
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+class ResizeObserver;
+#endif
+
 namespace Style {
 class Scope;
 };
@@ -1352,6 +1356,8 @@ public:
     void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
     void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
 
+    void getParserLocation(String& url, unsigned& line, unsigned& column) const;
+
     WEBCORE_EXPORT void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) final;
 
     // The following addConsoleMessage function is deprecated.
@@ -1417,6 +1423,18 @@ public:
     void updateIntersectionObservations();
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    void addResizeObserver(ResizeObserver&);
+    void removeResizeObserver(ResizeObserver&);
+    bool hasResizeObservers();
+    // Return the minDepth of the active observations.
+    size_t gatherResizeObservations(size_t deeperThan);
+    void deliverResizeObservations();
+    bool hasSkippedResizeObservations() const;
+    void setHasSkippedResizeObservations(bool);
+    void scheduleResizeObservations();
+#endif
+
 #if ENABLE(MEDIA_STREAM)
     void setHasCaptureMediaStreamTrack() { m_hasHadCaptureMediaStreamTrack = true; }
     bool hasHadCaptureMediaStreamTrack() const { return m_hasHadCaptureMediaStreamTrack; }
@@ -1861,6 +1879,10 @@ private:
     Timer m_intersectionObserversNotifyTimer;
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    Vector<WeakPtr<ResizeObserver>> m_resizeObservers;
+#endif
+
     Timer m_loadEventDelayTimer;
 
     ViewportArguments m_viewportArguments;
index 912f184..858c542 100644 (file)
@@ -198,6 +198,10 @@ Element::~Element()
     disconnectFromIntersectionObservers();
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    disconnectFromResizeObservers();
+#endif
+
     removeShadowRoot();
 
     if (hasSyntheticAttrChildNodes())
@@ -3531,6 +3535,32 @@ IntersectionObserverData* Element::intersectionObserverData()
 }
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+void Element::disconnectFromResizeObservers()
+{
+    auto* observerData = resizeObserverData();
+    if (!observerData)
+        return;
+
+    for (const auto& observer : observerData->observers)
+        observer->targetDestroyed(*this);
+    observerData->observers.clear();
+}
+
+ResizeObserverData& Element::ensureResizeObserverData()
+{
+    auto& rareData = ensureElementRareData();
+    if (!rareData.resizeObserverData())
+        rareData.setResizeObserverData(std::make_unique<ResizeObserverData>());
+    return *rareData.resizeObserverData();
+}
+
+ResizeObserverData* Element::resizeObserverData()
+{
+    return hasRareData() ? elementRareData()->resizeObserverData() : nullptr;
+}
+#endif
+
 SpellcheckAttributeState Element::spellcheckAttributeState() const
 {
     const AtomicString& value = attributeWithoutSynchronization(HTMLNames::spellcheckAttr);
index f459ed2..cfc5a4c 100644 (file)
@@ -63,6 +63,10 @@ struct ScrollIntoViewOptions;
 struct IntersectionObserverData;
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+struct ResizeObserverData;
+#endif
+
 enum SpellcheckAttributeState {
     SpellcheckAttributeTrue,
     SpellcheckAttributeFalse,
@@ -587,6 +591,11 @@ public:
     IntersectionObserverData* intersectionObserverData();
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    ResizeObserverData& ensureResizeObserverData();
+    ResizeObserverData* resizeObserverData();
+#endif
+
     Element* findAnchorElementForLink(String& outAnchorName);
 
     ExceptionOr<Ref<WebAnimation>> animate(JSC::ExecState&, JSC::Strong<JSC::JSObject>&&, Optional<Variant<double, KeyframeAnimationOptions>>&&);
@@ -682,6 +691,10 @@ private:
     void disconnectFromIntersectionObservers();
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    void disconnectFromResizeObservers();
+#endif
+
     // The cloneNode function is private so that non-virtual cloneElementWith/WithoutChildren are used instead.
     Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
     virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&);
index 92657ff..1cb5058 100644 (file)
@@ -50,6 +50,9 @@ struct SameSizeAsElementRareData : NodeRareData {
 #if ENABLE(CSS_TYPED_OM)
     void* typedOMData;
 #endif
+#if ENABLE(RESIZE_OBSERVER)
+    void* resizeObserverData;
+#endif
 
 };
 
index b6fd640..1bb66d0 100644 (file)
@@ -29,6 +29,7 @@
 #include "NodeRareData.h"
 #include "PseudoElement.h"
 #include "RenderElement.h"
+#include "ResizeObserver.h"
 #include "ShadowRoot.h"
 #include "StylePropertyMap.h"
 
@@ -131,6 +132,11 @@ public:
     void setIntersectionObserverData(std::unique_ptr<IntersectionObserverData>&& data) { m_intersectionObserverData = WTFMove(data); }
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    ResizeObserverData* resizeObserverData() { return m_resizeObserverData.get(); }
+    void setResizeObserverData(std::unique_ptr<ResizeObserverData>&& data) { m_resizeObserverData = WTFMove(data); }
+#endif
+
 #if ENABLE(CSS_TYPED_OM)
     StylePropertyMap* attributeStyleMap() { return m_attributeStyleMap.get(); }
     void setAttributeStyleMap(Ref<StylePropertyMap>&& map) { m_attributeStyleMap = WTFMove(map); }
@@ -165,6 +171,10 @@ public:
             result.add(UseType::AttributeMap);
         if (m_intersectionObserverData)
             result.add(UseType::InteractionObserver);
+#if ENABLE(RESIZE_OBSERVER)
+        if (m_resizeObserverData)
+            result.add(UseType::ResizeObserver);
+#endif
         if (m_beforePseudoElement || m_afterPseudoElement)
             result.add(UseType::PseudoElements);
         return result;
@@ -209,6 +219,10 @@ private:
     std::unique_ptr<IntersectionObserverData> m_intersectionObserverData;
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    std::unique_ptr<ResizeObserverData> m_resizeObserverData;
+#endif
+
     RefPtr<PseudoElement> m_beforePseudoElement;
     RefPtr<PseudoElement> m_afterPseudoElement;
 
index 73f800f..11159ee 100644 (file)
@@ -85,6 +85,7 @@
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "ResizeObserver.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGDocument.h"
 #include "SVGSVGElement.h"
@@ -1258,6 +1259,11 @@ void FrameView::willDoLayout(WeakPtr<RenderElement> layoutRoot)
 
 void FrameView::didLayout(WeakPtr<RenderElement> layoutRoot)
 {
+#if ENABLE(RESIZE_OBSERVER)
+    auto page = frame().page();
+    if (page && page->hasResizeObservers())
+        page->setNeedsCheckResizeObservations(true);
+#endif
     renderView()->releaseProtectedRenderWidgets();
     auto* layoutRootEnclosingLayer = layoutRoot->enclosingLayer();
     layoutRootEnclosingLayer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layoutRootEnclosingLayer, !is<RenderView>(*layoutRoot), layoutContext().needsFullRepaint()));
@@ -5353,5 +5359,5 @@ bool FrameView::shouldPlaceBlockDirectionScrollbarOnLeft() const
 {
     return renderView() && renderView()->shouldPlaceBlockDirectionScrollbarOnLeft();
 }
-    
+
 } // namespace WebCore
index fb46bb5..49c3fe8 100644 (file)
@@ -456,6 +456,14 @@ void FrameViewLayoutContext::layoutTimerFired()
         LOG(Layout, "FrameView %p layout timer fired at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
 #endif
     layout();
+
+#if ENABLE(RESIZE_OBSERVER)
+    // After this layout, it might not trigger display timer. E.g.: Running layout test for WK1.
+    // So scheduleResizeObservations() here to make sure ResizeObserver could be fired properly.
+    auto page = frame().page();
+    if (page && page->needsCheckResizeObservations())
+        page->scheduleResizeObservations();
+#endif
 }
 
 void FrameViewLayoutContext::convertSubtreeLayoutToFullLayout()
@@ -624,7 +632,7 @@ void FrameViewLayoutContext::popLayoutState()
 {
     m_layoutStateStack.removeLast();
 }
-    
+
 #ifndef NDEBUG
 void FrameViewLayoutContext::checkLayoutState()
 {
index 60559d4..1b14ae6 100644 (file)
@@ -93,6 +93,7 @@
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "ResizeObserver.h"
 #include "ResourceUsageOverlay.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGDocumentExtensions.h"
 #include "WebGLStateTracker.h"
 #include "WheelEventDeltaFilter.h"
 #include "Widget.h"
+#if ENABLE(RESIZE_OBSERVER)
+#include <JavaScriptCore/ScriptCallStack.h>
+#endif
 #include <wtf/FileSystem.h>
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/StdLibExtras.h>
@@ -260,6 +264,9 @@ Page::Page(PageConfiguration&& pageConfiguration)
 #if ENABLE(VIDEO)
     , m_playbackControlsManagerUpdateTimer(*this, &Page::playbackControlsManagerUpdateTimerFired)
 #endif
+#if ENABLE(RESIZE_OBSERVER)
+    , m_resizeObserverTimer(*this, &Page::checkResizeObservations)
+#endif
     , m_isUtilityPage(isUtilityPageChromeClient(chrome().client()))
     , m_performanceMonitor(isUtilityPage() ? nullptr : std::make_unique<PerformanceMonitor>(*this))
     , m_lowPowerModeNotifier(std::make_unique<LowPowerModeNotifier>([this](bool isLowPowerModeEnabled) { handleLowModePowerChange(isLowPowerModeEnabled); }))
@@ -1116,6 +1123,10 @@ void Page::didFinishLoad()
 
 void Page::willDisplayPage()
 {
+#if ENABLE(RESIZE_OBSERVER)
+    checkResizeObservations();
+#endif
+
 #if ENABLE(INTERSECTION_OBSERVER)
     updateIntersectionObservations();
 #endif
@@ -1288,6 +1299,80 @@ void Page::scheduleForcedIntersectionObservationUpdate(Document& document)
 }
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+bool Page::hasResizeObservers() const
+{
+    for (const Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+        auto doc = frame->document();
+        if (doc && doc->hasResizeObservers())
+            return true;
+    }
+    return false;
+}
+
+void Page::gatherDocumentsNeedingResizeObservationCheck(Vector<WeakPtr<Document>>& documentsNeedingResizeObservationCheck)
+{
+    forEachDocument([&] (Document& document) {
+        if (document.hasResizeObservers())
+            documentsNeedingResizeObservationCheck.append(makeWeakPtr(document));
+    });
+}
+
+void Page::checkResizeObservations()
+{
+    if (!needsCheckResizeObservations())
+        return;
+    setNeedsCheckResizeObservations(false);
+    m_resizeObserverTimer.stop();
+
+    Vector<WeakPtr<Document>> documentsNeedingResizeObservationCheck;
+    gatherDocumentsNeedingResizeObservationCheck(documentsNeedingResizeObservationCheck);
+    for (const auto& document : documentsNeedingResizeObservationCheck)
+        notifyResizeObservers(document);
+    documentsNeedingResizeObservationCheck.clear();
+}
+
+void Page::scheduleResizeObservations()
+{
+    setNeedsCheckResizeObservations(true);
+    if (m_resizeObserverTimer.isActive())
+        return;
+    m_resizeObserverTimer.startOneShot(0_s);
+}
+
+void Page::notifyResizeObservers(WeakPtr<Document> document)
+{
+    if (!document)
+        return;
+
+    // We need layout the whole frame tree here. Because ResizeObserver could observe element in other frame,
+    // and it could change other frame in deliverResizeObservations().
+    if (mainFrame().view())
+        mainFrame().view()->updateLayoutAndStyleIfNeededRecursive();
+
+    // Start check resize obervers;
+    for (size_t depth = document->gatherResizeObservations(0); depth != ResizeObserver::maxElementDepth(); depth = document->gatherResizeObservations(depth)) {
+        document->deliverResizeObservations();
+        if (!document)
+            return;
+        if (mainFrame().view())
+            mainFrame().view()->updateLayoutAndStyleIfNeededRecursive();
+    }
+
+    if (document->hasSkippedResizeObservations()) {
+        document->setHasSkippedResizeObservations(false);
+        String url;
+        unsigned line = 0;
+        unsigned column = 0;
+        document->getParserLocation(url, line, column);
+        document->reportException("ResizeObserver loop completed with undelivered notifications.", line, column, url, nullptr, nullptr);
+        // TODO: We are starting a timer to schedule the next round of notify.
+        // However, this should be in synchrony with the next requestAnimationFrame.
+        scheduleResizeObservations();
+    }
+}
+#endif
+
 void Page::suspendScriptedAnimations()
 {
     m_scriptedAnimationsSuspended = true;
index 648683b..dfeda26 100644 (file)
@@ -471,6 +471,17 @@ public:
     void updateIntersectionObservations();
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    WEBCORE_EXPORT void checkResizeObservations();
+    bool hasResizeObservers() const;
+    void gatherDocumentsNeedingResizeObservationCheck(Vector<WeakPtr<Document>>&);
+    void scheduleResizeObservations();
+    void notifyResizeObservers(WeakPtr<Document>);
+    void setNeedsCheckResizeObservations(bool check) { m_needsCheckResizeObservations = check; }
+    bool needsCheckResizeObservations() const { return m_needsCheckResizeObservations; }
+
+#endif
+
     WEBCORE_EXPORT void suspendScriptedAnimations();
     WEBCORE_EXPORT void resumeScriptedAnimations();
     bool scriptedAnimationsSuspended() const { return m_scriptedAnimationsSuspended; }
@@ -937,6 +948,11 @@ private:
     Timer m_playbackControlsManagerUpdateTimer;
 #endif
 
+#if ENABLE(RESIZE_OBSERVER)
+    Timer m_resizeObserverTimer;
+    bool m_needsCheckResizeObservations { false };
+#endif
+
     bool m_allowsMediaDocumentInlinePlayback { false };
     bool m_allowsPlaybackControlsForAutoplayingAudio { false };
     bool m_showAllPlugins { false };
index c12368f..75fd8ee 100644 (file)
@@ -99,29 +99,6 @@ void PageConsoleClient::unmute()
     muteCount--;
 }
 
-static void getParserLocationForConsoleMessage(Document* document, String& url, unsigned& line, unsigned& column)
-{
-    if (!document)
-        return;
-
-    // We definitely cannot associate the message with a location being parsed if we are not even parsing.
-    if (!document->parsing())
-        return;
-
-    ScriptableDocumentParser* parser = document->scriptableDocumentParser();
-    if (!parser)
-        return;
-
-    // When the parser waits for scripts, any messages must be coming from some other source, and are not related to the location of the script element that made the parser wait.
-    if (!parser->shouldAssociateConsoleMessagesWithTextPosition())
-        return;
-
-    url = document->url().string();
-    TextPosition position = parser->textPosition();
-    line = position.m_line.oneBasedInt();
-    column = position.m_column.oneBasedInt();
-}
-
 void PageConsoleClient::addMessage(std::unique_ptr<Inspector::ConsoleMessage>&& consoleMessage)
 {
     if (consoleMessage->source() != MessageSource::CSS && consoleMessage->type() != MessageType::Image && !m_page.usesEphemeralSession()) {
@@ -139,7 +116,8 @@ void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, con
     String url;
     unsigned line = 0;
     unsigned column = 0;
-    getParserLocationForConsoleMessage(document, url, line, column);
+    if (document)
+        document->getParserLocation(url, line, column);
 
     addMessage(source, level, message, url, line, column, 0, JSExecState::currentState(), requestIdentifier);
 }
diff --git a/Source/WebCore/page/ResizeObservation.cpp b/Source/WebCore/page/ResizeObservation.cpp
new file mode 100644 (file)
index 0000000..58547df
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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"
+
+#if ENABLE(RESIZE_OBSERVER)
+#include "ResizeObservation.h"
+
+#include "SVGElement.h"
+
+namespace WebCore {
+
+Ref<ResizeObservation> ResizeObservation::create(Element* target)
+{
+    return adoptRef(*new ResizeObservation(target));
+}
+
+ResizeObservation::ResizeObservation(Element* element)
+    : m_target(element)
+{
+}
+
+ResizeObservation::~ResizeObservation()
+{
+}
+
+void ResizeObservation::updateObservationSize(const LayoutSize& size)
+{
+    m_lastObservationSize = size;
+}
+
+LayoutSize ResizeObservation::computeObservedSize() const
+{
+    if (m_target->isSVGElement()) {
+        FloatRect svgRect;
+        if (downcast<SVGElement>(*m_target).getBoundingBox(svgRect))
+            return LayoutSize(svgRect.width(), svgRect.height());
+    }
+    if (m_target->renderBox())
+        return m_target->renderBox()->contentSize();
+    return LayoutSize();
+}
+
+LayoutPoint ResizeObservation::computeTargetLocation() const
+{
+    if (!m_target->isSVGElement()) {
+        if (auto box = m_target->renderBox())
+            return LayoutPoint(box->paddingLeft(), box->paddingTop());
+    }
+
+    return { };
+}
+
+FloatRect ResizeObservation::computeContentRect() const
+{
+    return FloatRect(FloatPoint(computeTargetLocation()), FloatSize(m_lastObservationSize));
+}
+
+bool ResizeObservation::elementSizeChanged(LayoutSize& currentSize) const
+{
+    currentSize = computeObservedSize();
+    return m_lastObservationSize != currentSize;
+}
+
+size_t ResizeObservation::targetElementDepth() const
+{
+    unsigned depth = 0;
+    for (Element* ownerElement  = m_target; ownerElement; ownerElement = ownerElement->document().ownerElement()) {
+        for (Element* parent = ownerElement; parent; parent = parent->parentElement())
+            ++depth;
+    }
+
+    return depth;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RESIZE_OBSERVER)
diff --git a/Source/WebCore/page/ResizeObservation.h b/Source/WebCore/page/ResizeObservation.h
new file mode 100644 (file)
index 0000000..c7db1fd
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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
+
+#if ENABLE(RESIZE_OBSERVER)
+#include "FloatRect.h"
+#include "LayoutSize.h"
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Element;
+
+class ResizeObservation : public RefCounted<ResizeObservation> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static Ref<ResizeObservation> create(Element* target);
+
+    ~ResizeObservation();
+
+    void updateObservationSize(const LayoutSize&);
+    LayoutSize computeObservedSize() const;
+    LayoutPoint computeTargetLocation() const;
+    FloatRect computeContentRect() const;
+
+    bool elementSizeChanged(LayoutSize&) const;
+    Element* target() const { return m_target; }
+    size_t targetElementDepth() const;
+
+private:
+    ResizeObservation(Element* target);
+
+    Element* m_target;
+    LayoutSize m_lastObservationSize;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(RESIZE_OBSERVER)
diff --git a/Source/WebCore/page/ResizeObserver.cpp b/Source/WebCore/page/ResizeObserver.cpp
new file mode 100644 (file)
index 0000000..c3513b7
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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"
+
+#if ENABLE(RESIZE_OBSERVER)
+#include "ResizeObserver.h"
+
+#include "Element.h"
+#include "ResizeObserverEntry.h"
+
+namespace WebCore {
+
+Ref<ResizeObserver> ResizeObserver::create(Document& document, Ref<ResizeObserverCallback>&& callback)
+{
+    return adoptRef(*new ResizeObserver(document, WTFMove(callback)));
+}
+
+ResizeObserver::ResizeObserver(Document& document, Ref<ResizeObserverCallback>&& callback)
+    : ActiveDOMObject(callback->scriptExecutionContext())
+    , m_document(makeWeakPtr(document))
+    , m_callback(WTFMove(callback))
+{
+    suspendIfNeeded();
+}
+
+ResizeObserver::~ResizeObserver()
+{
+    disconnect();
+    if (m_document)
+        m_document->removeResizeObserver(*this);
+}
+
+void ResizeObserver::scheduleObservations()
+{
+    if (m_document)
+        m_document->scheduleResizeObservations();
+}
+
+void ResizeObserver::observe(Element& target)
+{
+    if (!m_callback)
+        return;
+
+    for (auto& observation : m_observations) {
+        if (observation->target() == &target)
+            return;
+    }
+
+    auto& observerData = target.ensureResizeObserverData();
+    observerData.observers.append(makeWeakPtr(this));
+    if (m_document && !hasObservations())
+        m_document->addResizeObserver(*this);
+    m_observations.append(ResizeObservation::create(&target));
+
+    scheduleObservations();
+}
+
+void ResizeObserver::unobserve(Element& target)
+{
+    if (!removeTarget(target))
+        return;
+
+    removeObservation(target);
+}
+
+void ResizeObserver::disconnect()
+{
+    removeAllTargets();
+}
+
+void ResizeObserver::targetDestroyed(Element& target)
+{
+    removeObservation(target);
+}
+
+size_t ResizeObserver::gatherObservations(size_t deeperThan)
+{
+    m_hasSkippedObservations = false;
+    size_t minObservedDepth = maxElementDepth();
+    for (const auto& observation : m_observations) {
+        LayoutSize currentSize;
+        if (observation->elementSizeChanged(currentSize)) {
+            size_t depth = observation->targetElementDepth();
+            if (depth > deeperThan) {
+                observation->updateObservationSize(currentSize);
+                m_activeObservations.append(observation.get());
+                minObservedDepth = std::min(depth, minObservedDepth);
+            } else
+                m_hasSkippedObservations = true;
+        }
+    }
+    return minObservedDepth;
+}
+
+void ResizeObserver::deliverObservations()
+{
+    Vector<Ref<ResizeObserverEntry>> entries;
+    for (const auto& observation : m_activeObservations) {
+        ASSERT(observation->target());
+        entries.append(ResizeObserverEntry::create(observation->target(), observation->computeContentRect()));
+    }
+    m_activeObservations.clear();
+    m_callback->handleEvent(entries, *this);
+}
+
+bool ResizeObserver::removeTarget(Element& target)
+{
+    auto* observerData = target.resizeObserverData();
+    if (!observerData)
+        return false;
+
+    auto& observers = observerData->observers;
+    return observers.removeFirst(this);
+}
+
+void ResizeObserver::removeAllTargets()
+{
+    for (auto& observation : m_observations) {
+        bool removed = removeTarget(*observation->target());
+        ASSERT_UNUSED(removed, removed);
+    }
+    m_observations.clear();
+}
+
+bool ResizeObserver::removeObservation(const Element& target)
+{
+    m_activeObservations.removeFirstMatching([&target](auto& observation) {
+        return observation->target() == &target;
+    });
+
+    return m_observations.removeFirstMatching([&target](auto& observation) {
+        return observation->target() == &target;
+    });
+}
+
+bool ResizeObserver::hasPendingActivity() const
+{
+    return (hasObservations() && m_document) || !m_activeObservations.isEmpty();
+}
+
+const char* ResizeObserver::activeDOMObjectName() const
+{
+    return "ResizeObserver";
+}
+
+bool ResizeObserver::canSuspendForDocumentSuspension() const
+{
+    return true;
+}
+
+void ResizeObserver::stop()
+{
+    disconnect();
+    m_callback = nullptr;
+    m_observations.clear();
+    m_activeObservations.clear();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RESIZE_OBSERVER)
diff --git a/Source/WebCore/page/ResizeObserver.h b/Source/WebCore/page/ResizeObserver.h
new file mode 100644 (file)
index 0000000..dad1401
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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
+
+#if ENABLE(RESIZE_OBSERVER)
+
+#include "ActiveDOMObject.h"
+#include "ResizeObservation.h"
+#include "ResizeObserverCallback.h"
+#include <wtf/RefCounted.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class Document;
+class Element;
+
+struct ResizeObserverData {
+    Vector<WeakPtr<ResizeObserver>> observers;
+};
+
+class ResizeObserver : public RefCounted<ResizeObserver>, public ActiveDOMObject, public CanMakeWeakPtr<ResizeObserver> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static Ref<ResizeObserver> create(Document&, Ref<ResizeObserverCallback>&&);
+    ~ResizeObserver();
+
+    bool hasObservations() const { return m_observations.size(); }
+    bool hasActiveObservations() const { return m_activeObservations.size(); }
+    void scheduleObservations();
+
+    void observe(Element&);
+    void unobserve(Element&);
+    void disconnect();
+    void targetDestroyed(Element&);
+
+    static size_t maxElementDepth() { return SIZE_MAX; }
+    size_t gatherObservations(size_t depth);
+    void deliverObservations();
+    bool hasSkippedObservations() const { return m_hasSkippedObservations; }
+    void setHasSkippedObservations(bool skipped) { m_hasSkippedObservations = skipped; }
+
+    // ActiveDOMObject.
+    bool hasPendingActivity() const override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspendForDocumentSuspension() const override;
+    void stop() override;
+
+private:
+    ResizeObserver(Document&, Ref<ResizeObserverCallback>&&);
+
+    bool removeTarget(Element&);
+    void removeAllTargets();
+    bool removeObservation(const Element&);
+
+    WeakPtr<Document> m_document;
+    RefPtr<ResizeObserverCallback> m_callback;
+    Vector<Ref<ResizeObservation>> m_observations;
+
+    Vector<Ref<ResizeObservation>> m_activeObservations;
+    bool m_hasSkippedObservations { false };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(RESIZE_OBSERVER)
diff --git a/Source/WebCore/page/ResizeObserver.idl b/Source/WebCore/page/ResizeObserver.idl
new file mode 100644 (file)
index 0000000..87f8010
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+// https://wicg.github.io/ResizeObserver/
+
+[
+    ActiveDOMObject,
+    Conditional=RESIZE_OBSERVER,
+    Constructor(ResizeObserverCallback callback),
+    ConstructorCallWith=Document,
+    EnabledBySetting=ResizeObserver
+] interface ResizeObserver {
+    void observe(Element target);
+    void unobserve(Element target);
+    void disconnect();
+};
diff --git a/Source/WebCore/page/ResizeObserverCallback.h b/Source/WebCore/page/ResizeObserverCallback.h
new file mode 100644 (file)
index 0000000..b39d762
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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
+
+#if ENABLE(RESIZE_OBSERVER)
+
+#include "ActiveDOMCallback.h"
+#include "CallbackResult.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class ResizeObserver;
+class ResizeObserverEntry;
+
+class ResizeObserverCallback : public RefCounted<ResizeObserverCallback>, public ActiveDOMCallback {
+public:
+    using ActiveDOMCallback::ActiveDOMCallback;
+    virtual CallbackResult<void> handleEvent(const Vector<Ref<ResizeObserverEntry>>&, ResizeObserver&) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(RESIZE_OBSERVER)
diff --git a/Source/WebCore/page/ResizeObserverCallback.idl b/Source/WebCore/page/ResizeObserverCallback.idl
new file mode 100644 (file)
index 0000000..6fc9039
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+// https://wicg.github.io/ResizeObserver/
+
+[
+    Conditional=RESIZE_OBSERVER
+] callback ResizeObserverCallback = void (sequence<ResizeObserverEntry> entries, ResizeObserver observer);
diff --git a/Source/WebCore/page/ResizeObserverEntry.h b/Source/WebCore/page/ResizeObserverEntry.h
new file mode 100644 (file)
index 0000000..9c39fb8
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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
+
+#if ENABLE(RESIZE_OBSERVER)
+
+#include "DOMRectReadOnly.h"
+#include "Element.h"
+#include "FloatRect.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Element;
+
+class ResizeObserverEntry : public RefCounted<ResizeObserverEntry> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static Ref<ResizeObserverEntry> create(Element* target, const FloatRect& contentRect)
+    {
+        return adoptRef(*new ResizeObserverEntry(target, contentRect));
+    }
+
+    Element* target() const { return m_target.get(); }
+    DOMRectReadOnly* contentRect() const { return m_contentRect.get(); }
+
+private:
+    ResizeObserverEntry(Element* target, const FloatRect& contentRect)
+        : m_target(target)
+        , m_contentRect(DOMRectReadOnly::create(contentRect.x(), contentRect.y(), contentRect.width(), contentRect.height()))
+    {
+    }
+
+    RefPtr<Element> m_target;
+    RefPtr<DOMRectReadOnly> m_contentRect;
+};
+
+} // namespace WebCore
+#endif // ENABLE(RESIZE_OBSERVER)
diff --git a/Source/WebCore/page/ResizeObserverEntry.idl b/Source/WebCore/page/ResizeObserverEntry.idl
new file mode 100644 (file)
index 0000000..b051bb5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+// https://wicg.github.io/ResizeObserver/
+
+[
+    Conditional=RESIZE_OBSERVER,
+    ImplementationLacksVTable,
+    EnabledBySetting=ResizeObserver
+] interface ResizeObserverEntry {
+    readonly attribute Element target;
+    readonly attribute DOMRectReadOnly contentRect;
+};
\ No newline at end of file
index d7d5283..bd6828d 100644 (file)
@@ -731,6 +731,10 @@ shouldAllowUserInstalledFonts:
   initial: true
   onChange: setNeedsRecalcStyleInAllFrames
 
+resizeObserverEnabled:
+  initial: false
+  conditional: RESIZE_OBSERVER
+
 # Only set by Layout Tests.
 mediaTypeOverride:
   type: String
index f34fcd5..e6e1d57 100644 (file)
@@ -1,3 +1,15 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Add WebPreferences and FeatureDefines for ResizeObserver.
+
+        * Configurations/FeatureDefines.xcconfig:
+        * Shared/WebPreferences.yaml:
+
 2019-03-28  Timothy Hatcher  <timothy@apple.com>
 
         CFDictionary encoder crashes on non-string keys.
index 9173ab3..ac52484 100644 (file)
@@ -314,6 +314,8 @@ ENABLE_QUOTA = ;
 
 ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR;
 
+ENABLE_RESIZE_OBSERVER = ENABLE_RESIZE_OBSERVER;
+
 ENABLE_RESOLUTION_MEDIA_QUERY = ;
 
 ENABLE_RESOURCE_LOAD_STATISTICS = ENABLE_RESOURCE_LOAD_STATISTICS;
@@ -411,4 +413,4 @@ ENABLE_WIRELESS_PLAYBACK_TARGET = ENABLE_WIRELESS_PLAYBACK_TARGET;
 
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESIZE_OBSERVER) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
index 609d31f..d2a3bfd 100644 (file)
@@ -1389,6 +1389,14 @@ IsITPFirstPartyWebsiteDataRemovalEnabled:
     webcoreBinding: RuntimeEnabledFeatures
     category: experimental
 
+ResizeObserverEnabled:
+  type: bool
+  defaultValue: false
+  humanReadableName: "Resize Observer"
+  humanReadableDescription: "Enable Resize Observer support"
+  category: experimental
+  condition: ENABLE(RESIZE_OBSERVER)
+
 # For internal features:
 # The type should be boolean.
 # You must provide a humanReadableName and humanReadableDescription for all debug features. They
index ded8cc5..ff0e08c 100644 (file)
@@ -1,3 +1,21 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        * Configurations/FeatureDefines.xcconfig:
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences resizeObserverEnabled]):
+        (-[WebPreferences setResizeObserverEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+        (-[WebView _flushCompositingChanges]): checkResizeObservations() in the begining.
+
 2019-03-27  Ryosuke Niwa  <rniwa@webkit.org>
 
         [macOS] Select element doesn't show popup if select element had lost focus while popup was previosuly shown
index 9173ab3..ac52484 100644 (file)
@@ -314,6 +314,8 @@ ENABLE_QUOTA = ;
 
 ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR;
 
+ENABLE_RESIZE_OBSERVER = ENABLE_RESIZE_OBSERVER;
+
 ENABLE_RESOLUTION_MEDIA_QUERY = ;
 
 ENABLE_RESOURCE_LOAD_STATISTICS = ENABLE_RESOURCE_LOAD_STATISTICS;
@@ -411,4 +413,4 @@ ENABLE_WIRELESS_PLAYBACK_TARGET = ENABLE_WIRELESS_PLAYBACK_TARGET;
 
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESIZE_OBSERVER) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
index 1eff3b8..7e2d989 100644 (file)
 #define WebKitCSSLogicalEnabledPreferenceKey @"WebKitCSSLogicalEnabled"
 #define WebKitAdClickAttributionEnabledPreferenceKey @"WebKitAdClickAttributionEnabled"
 #define WebKitReferrerPolicyAttributeEnabledPreferenceKey @"WebKitReferrerPolicyAttributeEnabled"
+#define WebKitResizeObserverEnabledPreferenceKey @"WebKitResizeObserverEnabled"
index 06163c8..9da600a 100644 (file)
@@ -695,6 +695,9 @@ public:
         @NO, WebKitFetchAPIKeepAliveEnabledPreferenceKey,
         @NO, WebKitServerTimingEnabledPreferenceKey,
         @NO, WebKitReferrerPolicyAttributeEnabledPreferenceKey,
+#if ENABLE(RESIZE_OBSERVER)
+        @NO, WebKitResizeObserverEnabledPreferenceKey,
+#endif
         nil];
 
 #if !PLATFORM(IOS_FAMILY)
@@ -3463,6 +3466,15 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitReferrerPolicyAttributeEnabledPreferenceKey];
 }
 
+- (BOOL)resizeObserverEnabled
+{
+    return [self _boolValueForKey:WebKitResizeObserverEnabledPreferenceKey];
+}
+
+- (void)setResizeObserverEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitResizeObserverEnabledPreferenceKey];
+}
 @end
 
 @implementation WebPreferences (WebInternal)
index 8b0915b..3356ed9 100644 (file)
@@ -628,6 +628,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification WEBKIT_DEPR
 @property (nonatomic) BOOL allowCrossOriginSubresourcesToAskForCredentials;
 @property (nonatomic) BOOL sourceBufferChangeTypeEnabled;
 @property (nonatomic) BOOL referrerPolicyAttributeEnabled;
+@property (nonatomic) BOOL resizeObserverEnabled;
 
 #if TARGET_OS_IPHONE
 @property (nonatomic) BOOL quickLookDocumentSavingEnabled;
index f06f518..c160605 100644 (file)
@@ -3221,6 +3221,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled([preferences serverTimingEnabled]);
 
     settings.setSelectionAcrossShadowBoundariesEnabled(preferences.selectionAcrossShadowBoundariesEnabled);
+
+#if ENABLE(RESIZE_OBSERVER)
+    settings.setResizeObserverEnabled([preferences resizeObserverEnabled]);
+#endif
 }
 
 static inline IMP getMethod(id o, SEL s)
@@ -9388,6 +9392,11 @@ bool LayerFlushController::flushLayers()
 
 - (BOOL)_flushCompositingChanges
 {
+#if ENABLE(RESIZE_OBSERVER)
+    if (_private->page)
+        _private->page->checkResizeObservations();
+#endif
+
     Frame* frame = [self _mainCoreFrame];
     if (frame && frame->view())
         return frame->view()->flushCompositingStateIncludingSubframes();
index 68b9ffa..67150d8 100644 (file)
@@ -1,3 +1,20 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        * Interfaces/IWebPreferencesPrivate.idl:
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings):
+        (WebPreferences::resizeObserverEnabled):
+        (WebPreferences::setResizeObserverEnabled):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged):
+
 2019-03-17  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [Win][WK1] Null dereference in WebFrameNetworkingContext::storageSession
index 19882cd..ed8b1cc 100644 (file)
@@ -238,4 +238,6 @@ interface IWebPreferencesPrivate7 : IWebPreferencesPrivate6
 {
     HRESULT crossOriginWindowPolicySupportEnabled([out, retval] BOOL* enabled);
     HRESULT setCrossOriginWindowPolicySupportEnabled([in] BOOL enabled);
+    HRESULT resizeObserverEnabled([out, retval] BOOL*);
+    HRESULT setResizeObserverEnabled([in] BOOL enabled);
 }
index 940d5cf..413a6fd 100644 (file)
 
 #define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey "WebKitCSSOMViewScrollingAPIEnabled"
 
+#define WebKitResizeObserverEnabledPreferenceKey "WebKitResizeObserverEnabled"
index 025c20b..9023e3f 100644 (file)
@@ -329,6 +329,8 @@ void WebPreferences::initializeDefaultSettings()
 
     CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewScrollingAPIEnabledPreferenceKey), kCFBooleanFalse);
 
+    CFDictionaryAddValue(defaults, CFSTR(WebKitResizeObserverEnabledPreferenceKey), kCFBooleanFalse);
+
     defaultSettings = defaults;
 }
 
@@ -2260,3 +2262,17 @@ HRESULT WebPreferences::setServerTimingEnabled(BOOL enabled)
     setBoolValue(WebKitServerTimingEnabledPreferenceKey, enabled);
     return S_OK;
 }
+
+HRESULT WebPreferences::resizeObserverEnabled(_Out_ BOOL* enabled)
+{
+    if (!enabled)
+        return E_POINTER;
+    *enabled = boolValueForKey(WebKitResizeObserverEnabledPreferenceKey);
+    return S_OK;
+}
+
+HRESULT WebPreferences::setResizeObserverEnabled(BOOL enabled)
+{
+    setBoolValue(WebKitResizeObserverEnabledPreferenceKey, enabled);
+    return S_OK;
+}
index 2906b36..6eba17c 100644 (file)
@@ -283,6 +283,8 @@ public:
     // IWebPreferencesPrivate7
     virtual HRESULT STDMETHODCALLTYPE crossOriginWindowPolicySupportEnabled(_Out_ BOOL*);
     virtual HRESULT STDMETHODCALLTYPE setCrossOriginWindowPolicySupportEnabled(BOOL);
+    virtual HRESULT STDMETHODCALLTYPE resizeObserverEnabled(_Out_ BOOL*);
+    virtual HRESULT STDMETHODCALLTYPE setResizeObserverEnabled(BOOL);
 
     // WebPreferences
 
index 27236bb..631253a 100644 (file)
@@ -5597,6 +5597,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
         return hr;
     RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled(!!enabled);
 
+    hr = prefsPrivate->resizeObserverEnabled(&enabled);
+    if (FAILED(hr))
+        return hr;
+    settings.setResizeObserverEnabled(!!enabled);
+
     return S_OK;
 }
 
index 757ff6d..5520597 100644 (file)
@@ -183,6 +183,7 @@ macro(WEBKIT_OPTION_BEGIN)
     WEBKIT_OPTION_DEFINE(ENABLE_PUBLIC_SUFFIX_LIST "Toggle public suffix list support" PRIVATE ON)
     WEBKIT_OPTION_DEFINE(ENABLE_QUOTA "Toggle Quota support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_REMOTE_INSPECTOR "Toggle remote inspector support" PRIVATE ON)
+    WEBKIT_OPTION_DEFINE(ENABLE_RESIZE_OBSERVER "Enable Resize Observer support" PRIVATE ON)
     WEBKIT_OPTION_DEFINE(ENABLE_RESOLUTION_MEDIA_QUERY "Toggle resolution media query support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_RESOURCE_LOAD_STATISTICS "Toggle resource load statistics support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_RESOURCE_USAGE "Toggle resource usage support" PRIVATE OFF)
index 20b3bc8..1c40ce0 100644 (file)
@@ -1,3 +1,22 @@
+2019-03-29  Cathie Chen  <cathiechen@igalia.com>
+
+        Implement ResizeObserver.
+        https://bugs.webkit.org/show_bug.cgi?id=157743
+
+        Reviewed by Simon Fraser.
+
+        Support resizeObserverEnabled webPreferences.
+
+        * DumpRenderTree/TestOptions.cpp:
+        (TestOptions::TestOptions):
+        * DumpRenderTree/TestOptions.h:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (setWebPreferencesForTestOptions):
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (enableExperimentalFeatures):
+        * Scripts/webkitperl/FeatureList.pm:
+        * TestWebKitAPI/Configurations/FeatureDefines.xcconfig:
+
 2019-03-28  John Wilander  <wilander@apple.com>
 
         Resource Load Statistics: IPC to the WebsiteDataStore in the UI process from NetworkProcess::deleteWebsiteDataForRegistrableDomains()
index c926612..77a4aff 100644 (file)
@@ -111,6 +111,8 @@ TestOptions::TestOptions(const std::string& pathOrURL, const std::string& absolu
             enableCSSLogical = parseBooleanTestHeaderValue(value);
         else if (key == "internal:AdClickAttributionEnabled")
             adClickAttributionEnabled = parseBooleanTestHeaderValue(value);
+        else if (key == "experimental:ResizeObserverEnabled")
+            enableResizeObserver = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }
index c27e842..d885edb 100644 (file)
@@ -46,6 +46,7 @@ struct TestOptions {
     bool enableWebGPU { false };
     bool enableCSSLogical { false };
     bool adClickAttributionEnabled { false };
+    bool enableResizeObserver { false };
     std::string jscOptions;
 
     TestOptions(const std::string& pathOrURL, const std::string& absolutePath);
index c654729..6587253 100644 (file)
@@ -1019,6 +1019,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options)
     preferences.webGPUEnabled = options.enableWebGPU;
     preferences.CSSLogicalEnabled = options.enableCSSLogical;
     preferences.adClickAttributionEnabled = options.adClickAttributionEnabled;
+    preferences.resizeObserverEnabled = options.enableResizeObserver;
 }
 
 // Called once on DumpRenderTree startup.
index 86ecb8a..d17463e 100644 (file)
@@ -787,6 +787,7 @@ static void enableExperimentalFeatures(IWebPreferences* preferences)
     // FIXME: SubtleCrypto
     prefsPrivate->setVisualViewportAPIEnabled(TRUE);
     prefsPrivate->setCSSOMViewScrollingAPIEnabled(TRUE);
+    prefsPrivate->setResizeObserverEnabled(TRUE);
     prefsPrivate->setWebAnimationsEnabled(TRUE);
     prefsPrivate->setServerTimingEnabled(TRUE);
     // FIXME: WebGL2
index 809718f..d9539d8 100644 (file)
@@ -143,6 +143,7 @@ my (
     $quotaSupport,
     $registerProtocolHandlerSupport,
     $remoteInspectorSupport,
+    $resizeObserverSupport,
     $resolutionMediaQuerySupport,
     $resourceLoadStatisticsSupport,
     $resourceUsageSupport,
@@ -468,6 +469,9 @@ my @features = (
     { option => "remote-inspector", desc => "Toggle remote inspector support",
       define => "ENABLE_REMOTE_INSPECTOR", value => \$remoteInspectorSupport },
 
+    { option => "resize-observer", desc => "Enable Resize Observer support",
+      define => "ENABLE_RESIZE_OBSERVER", value => \$resizeObserverSupport },
+
     { option => "resolution-media-query", desc => "Toggle resolution media query support",
       define => "ENABLE_RESOLUTION_MEDIA_QUERY", value => \$resolutionMediaQuerySupport },
 
index 9173ab3..ac52484 100644 (file)
@@ -314,6 +314,8 @@ ENABLE_QUOTA = ;
 
 ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR;
 
+ENABLE_RESIZE_OBSERVER = ENABLE_RESIZE_OBSERVER;
+
 ENABLE_RESOLUTION_MEDIA_QUERY = ;
 
 ENABLE_RESOURCE_LOAD_STATISTICS = ENABLE_RESOURCE_LOAD_STATISTICS;
@@ -411,4 +413,4 @@ ENABLE_WIRELESS_PLAYBACK_TARGET = ENABLE_WIRELESS_PLAYBACK_TARGET;
 
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_TRANSFORMS) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_OVERFLOW_SCROLLING_TOUCH) $(ENABLE_ACCESSIBILITY_ISOLATED_TREE) $(ENABLE_APPLE_PAY) $(ENABLE_APPLE_PAY_SESSION_V3) $(ENABLE_APPLE_PAY_SESSION_V4) $(ENABLE_APPLICATION_MANIFEST) $(ENABLE_ATTACHMENT_ELEMENT) $(ENABLE_AVF_CAPTIONS) $(ENABLE_C_LOOP) $(ENABLE_CACHE_PARTITIONING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CONTENT_FILTERING) $(ENABLE_CSS3_TEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_PAINTING_API) $(ENABLE_CSS_SCROLL_SNAP) $(ENABLE_CSS_SELECTORS_LEVEL4) $(ENABLE_CSS_TRAILING_WORD) $(ENABLE_CSS_TYPED_OM) $(ENABLE_CURSOR_VISIBILITY) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_CSS_CONIC_GRADIENTS) $(ENABLE_DARK_MODE_CSS) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATA_INTERACTION) $(ENABLE_DATACUE_VALUE) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DRAG_SUPPORT) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_EXPERIMENTAL_FEATURES) $(ENABLE_FAST_JIT_PERMISSIONS) $(ENABLE_FILTERS_LEVEL_2) $(ENABLE_FTL_JIT) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INDEXED_DATABASE_IN_WORKERS) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_INTERSECTION_OBSERVER) $(ENABLE_INTL) $(ENABLE_IOS_GESTURE_EVENTS) $(ENABLE_IOS_TOUCH_EVENTS) $(ENABLE_JIT) $(ENABLE_KEYBOARD_CODE_ATTRIBUTE) $(ENABLE_KEYBOARD_KEY_ATTRIBUTE) $(ENABLE_LAYOUT_FORMATTING_CONTEXT) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_CUSTOM_PROTOCOL_MANAGER) $(ENABLE_LEGACY_ENCRYPTED_MEDIA) $(ENABLE_LETTERPRESS) $(ENABLE_MAC_GESTURE_EVENTS) $(ENABLE_MAC_VIDEO_TOOLBOX) $(ENABLE_MATHML) $(ENABLE_MEDIA_CAPTURE) $(ENABLE_MEDIA_CONTROLS_SCRIPT) $(ENABLE_MEDIA_SESSION) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_MEDIA_STREAM) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_STANDALONE) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAYMENT_REQUEST) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_POINTER_EVENTS) $(ENABLE_POINTER_LOCK) $(ENABLE_PUBLIC_SUFFIX_LIST) $(ENABLE_QUOTA) $(ENABLE_REMOTE_INSPECTOR) $(ENABLE_RESIZE_OBSERVER) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_RESOURCE_LOAD_STATISTICS) $(ENABLE_RESOURCE_USAGE) $(ENABLE_RUBBER_BANDING) $(ENABLE_SERVICE_CONTROLS) $(ENABLE_SERVICE_WORKER) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_STREAMS_API) $(ENABLE_WEB_CRYPTO) $(ENABLE_SVG_FONTS) $(ENABLE_TELEPHONE_NUMBER_DETECTION) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TOUCH_EVENTS) $(ENABLE_USER_MESSAGE_HANDLERS) $(ENABLE_USERSELECT_ALL) $(ENABLE_VARIATION_FONTS) $(ENABLE_VIDEO) $(ENABLE_VIDEO_PRESENTATION_MODE) $(ENABLE_VIDEO_TRACK) $(ENABLE_VIDEO_USES_ELEMENT_FULLSCREEN) $(ENABLE_WEB_API_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_AUTHN) $(ENABLE_WEB_RTC) $(ENABLE_WEBASSEMBLY) $(ENABLE_WEBASSEMBLY_STREAMING_API) $(ENABLE_WEBGL) $(ENABLE_WEBGL2) $(ENABLE_WEBGPU) $(ENABLE_WEBMETAL) $(ENABLE_WIRELESS_PLAYBACK_TARGET) $(ENABLE_XSLT);