Changeset 282441 in webkit


Ignore:
Timestamp:
Sep 14, 2021 11:16:57 PM (10 months ago)
Author:
Simon Fraser
Message:

Implement the borderBoxSize/contentBoxSize parts of ResizeObserver
https://bugs.webkit.org/show_bug.cgi?id=230242

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

New results. WebKit seems to fire the "resize loop error" more than
other browsers, which seems to be an issue with the spec[1].

[1] https://github.com/w3c/csswg-drafts/issues/6610

  • web-platform-tests/resize-observer/idlharness.window-expected.txt:
  • web-platform-tests/resize-observer/observe-expected.txt:
  • web-platform-tests/resize-observer/svg-expected.txt:

Source/WebCore:

The Resize Observer spec has been updated to allow authors to observe
"content-box", "border-box" and "device-pixel-content-box". Add support
for the first two, adding ResizeObserverSize, ResizeObserverBoxOptions and
ResizeObserverOptions per spec.

ResizeObserverEntry also contains borderBoxSize and contentBoxSize now,
so support that.

Add some helpers to make it easier to get box logical sizes.

"device-pixel-content-box" is not yet supported because it's expensive to compute[2].

[1] https://drafts.csswg.org/resize-observer
[2] https://github.com/w3c/csswg-drafts/issues/6608

Tested by WPT.

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • page/ResizeObservation.cpp:

(WebCore::ResizeObservation::create):
(WebCore::ResizeObservation::ResizeObservation):
(WebCore::ResizeObservation::updateObservationSize):
(WebCore::ResizeObservation::computeObservedSizes const):
(WebCore::ResizeObservation::computeContentRect const):
(WebCore::ResizeObservation::borderBoxSize const):
(WebCore::ResizeObservation::contentBoxSize const):
(WebCore::ResizeObservation::snappedContentBoxSize const):
(WebCore::ResizeObservation::elementSizeChanged const):
(WebCore::ResizeObservation::~ResizeObservation): Deleted.
(WebCore::ResizeObservation::computeObservedSize const): Deleted.

  • page/ResizeObservation.h:

(WebCore::ResizeObservation::observedBox const):

  • page/ResizeObserver.cpp:

(WebCore::ResizeObserver::observe):
(WebCore::ResizeObserver::gatherObservations):
(WebCore::ResizeObserver::deliverObservations):

  • page/ResizeObserver.h:
  • page/ResizeObserver.idl:
  • page/ResizeObserverBoxOptions.h: Added.
  • page/ResizeObserverBoxOptions.idl: Copied from Source/WebCore/page/ResizeObserverEntry.idl.
  • page/ResizeObserverEntry.h:

(WebCore::ResizeObserverEntry::create):
(WebCore::ResizeObserverEntry::contentRect const):
(WebCore::ResizeObserverEntry::borderBoxSize const):
(WebCore::ResizeObserverEntry::contentBoxSize const):
(WebCore::ResizeObserverEntry::ResizeObserverEntry):
(WebCore::ResizeObserverEntry::m_contentBoxSizes):

  • page/ResizeObserverEntry.idl:
  • page/ResizeObserverOptions.h: Added.
  • page/ResizeObserverOptions.idl: Copied from Source/WebCore/page/ResizeObserverEntry.idl.
  • page/ResizeObserverSize.h: Added.

(WebCore::ResizeObserverSize::create):
(WebCore::ResizeObserverSize::inlineSize const):
(WebCore::ResizeObserverSize::blockSize const):
(WebCore::ResizeObserverSize::ResizeObserverSize):

  • page/ResizeObserverSize.idl: Copied from Source/WebCore/page/ResizeObserverEntry.idl.
  • rendering/RenderBox.h:

(WebCore::RenderBox::logicalSize const):
(WebCore::RenderBox::borderBoxLogicalSize const):
(WebCore::RenderBox::contentLogicalSize const):

  • rendering/RenderElement.h:

(WebCore::adjustLayoutSizeForAbsoluteZoom):

  • rendering/style/RenderStyle.h:

(WebCore::adjustLayoutSizeForAbsoluteZoom):

LayoutTests:

Give macOS a platform expectation for this test since its results seem to be the odd one out.

  • platform/ios/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: Removed.
  • platform/mac/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt.
Location:
trunk
Files:
4 added
1 deleted
23 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r282438 r282441  
     12021-09-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Implement the borderBoxSize/contentBoxSize parts of ResizeObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=230242
     5
     6        Reviewed by Sam Weinig.
     7
     8        Give macOS a platform expectation for this test since its results seem to be the odd one out.
     9
     10        * platform/ios/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: Removed.
     11        * platform/mac/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt.
     12
    1132021-09-14  Rob Buis  <rbuis@igalia.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r282440 r282441  
     12021-09-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Implement the borderBoxSize/contentBoxSize parts of ResizeObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=230242
     5
     6        Reviewed by Sam Weinig.
     7
     8        New results. WebKit seems to fire the "resize loop error" more than
     9        other browsers, which seems to be an issue with the spec[1].
     10
     11        [1] https://github.com/w3c/csswg-drafts/issues/6610
     12
     13        * web-platform-tests/resize-observer/idlharness.window-expected.txt:
     14        * web-platform-tests/resize-observer/observe-expected.txt:
     15        * web-platform-tests/resize-observer/svg-expected.txt:
     16
    1172021-09-14  Rob Buis  <rbuis@igalia.com>
    218
  • trunk/LayoutTests/imported/w3c/web-platform-tests/resize-observer/idlharness.window-expected.txt

    r269214 r282441  
    3131PASS ResizeObserverEntry interface: attribute target
    3232PASS ResizeObserverEntry interface: attribute contentRect
    33 FAIL ResizeObserverEntry interface: attribute borderBoxSize assert_true: The prototype object must have a property "borderBoxSize" expected true got false
    34 FAIL ResizeObserverEntry interface: attribute contentBoxSize assert_true: The prototype object must have a property "contentBoxSize" expected true got false
     33PASS ResizeObserverEntry interface: attribute borderBoxSize
     34PASS ResizeObserverEntry interface: attribute contentBoxSize
    3535FAIL ResizeObserverEntry interface: attribute devicePixelContentBoxSize assert_true: The prototype object must have a property "devicePixelContentBoxSize" expected true got false
    3636PASS ResizeObserverEntry must be primary interface of entry
     
    3838PASS ResizeObserverEntry interface: entry must inherit property "target" with the proper type
    3939PASS ResizeObserverEntry interface: entry must inherit property "contentRect" with the proper type
    40 FAIL ResizeObserverEntry interface: entry must inherit property "borderBoxSize" with the proper type assert_inherits: property "borderBoxSize" not found in prototype chain
    41 FAIL ResizeObserverEntry interface: entry must inherit property "contentBoxSize" with the proper type assert_inherits: property "contentBoxSize" not found in prototype chain
     40PASS ResizeObserverEntry interface: entry must inherit property "borderBoxSize" with the proper type
     41PASS ResizeObserverEntry interface: entry must inherit property "contentBoxSize" with the proper type
    4242FAIL ResizeObserverEntry interface: entry must inherit property "devicePixelContentBoxSize" with the proper type assert_inherits: property "devicePixelContentBoxSize" not found in prototype chain
    43 FAIL ResizeObserverSize interface: existence and properties of interface object assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    44 FAIL ResizeObserverSize interface object length assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    45 FAIL ResizeObserverSize interface object name assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    46 FAIL ResizeObserverSize interface: existence and properties of interface prototype object assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    47 FAIL ResizeObserverSize interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    48 FAIL ResizeObserverSize interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    49 FAIL ResizeObserverSize interface: attribute inlineSize assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
    50 FAIL ResizeObserverSize interface: attribute blockSize assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
     43PASS ResizeObserverSize interface: existence and properties of interface object
     44PASS ResizeObserverSize interface object length
     45PASS ResizeObserverSize interface object name
     46PASS ResizeObserverSize interface: existence and properties of interface prototype object
     47PASS ResizeObserverSize interface: existence and properties of interface prototype object's "constructor" property
     48PASS ResizeObserverSize interface: existence and properties of interface prototype object's @@unscopables property
     49PASS ResizeObserverSize interface: attribute inlineSize
     50PASS ResizeObserverSize interface: attribute blockSize
    5151
  • trunk/LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-expected.txt

    r267647 r282441  
     1CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     2CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     3CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     4CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     5CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     6CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     7CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     8CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     9CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
     10CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
    111CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
    212CONSOLE MESSAGE: ResizeObserver loop completed with undelivered notifications.
    313
     14Harness Error (TIMEOUT), message = null
     15
    416PASS ResizeObserver implemented
    5 PASS guard
     17NOTRUN guard
    618PASS test0: simple observation
    719PASS test1: multiple observation on same element trigger only one
     
    1224PASS test6: iframe notifications
    1325PASS test7: callback.this
    14 FAIL test8: simple content-box observation undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    15 FAIL test9: simple content-box observation but keep border-box size unchanged undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    16 FAIL test10: simple border-box observation undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    17 FAIL test11: simple observation with vertical writing mode undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    18 FAIL test12: no observation is fired after the change of writing mode when box's specified size comes from logical size properties. undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    19 FAIL test13: an observation is fired after the change of writing mode when box's specified size comes from physical size properties. undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    20 FAIL test14: observe the same target but using a different box should override the previous one undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    21 FAIL test15: an observation is fired with box dimensions 0 when element's display property is set to inline undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
     26PASS test8: simple content-box observation
     27PASS test9: simple content-box observation but keep border-box size unchanged
     28PASS test10: simple border-box observation
     29PASS test11: simple observation with vertical writing mode
     30PASS test12: no observation is fired after the change of writing mode when box's specified size comes from logical size properties.
     31PASS test13: an observation is fired after the change of writing mode when box's specified size comes from physical size properties.
     32PASS test14: observe the same target but using a different box should override the previous one
     33PASS test15: an observation is fired with box dimensions 0 when element's display property is set to inline
    2234PASS test16: observations do not fire for non-replaced inline elements
    23 FAIL test17: Box sizing snd Resize Observer notifications undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    24 FAIL test18: an observation is fired when device-pixel-content-box is being observed undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
     35PASS test17: Box sizing snd Resize Observer notifications
     36FAIL test18: an observation is fired when device-pixel-content-box is being observed assert_unreached: Caught a throw, possible syntax error Reached unreachable code
    2537
  • trunk/LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt

    r267647 r282441  
    55svg text tag
    66
     7Harness Error (TIMEOUT), message = null
     8
    79PASS ResizeObserver implemented
    8 PASS guard
     10NOTRUN guard
    911PASS test0: observe svg:circle
    1012PASS test1: observe svg:ellipse
     
    1921PASS test10: observe svg:svg, top/left is 0 even with padding
    2022PASS test11: observe svg non-displayable element
    21 FAIL test12: observe svg:rect content box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    22 FAIL test13: observe svg:rect border box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    23 FAIL test14: observe g:rect content and border box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    24 FAIL test15: observe svg:text content and border box assert_equals: expected 30 but got 30.015625
    25 FAIL test16: observe g:rect content, border and device-pixel-content boxes undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
     23PASS test12: observe svg:rect content box
     24PASS test13: observe svg:rect border box
     25PASS test14: observe g:rect content and border box
     26PASS test15: observe svg:text content and border box
     27FAIL test16: observe g:rect content, border and device-pixel-content boxes assert_unreached: Caught a throw, possible syntax error Reached unreachable code
    2628
  • trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt

    r282440 r282441  
    55svg text tag
    66
     7Harness Error (TIMEOUT), message = null
     8
    79PASS ResizeObserver implemented
    8 PASS guard
     10NOTRUN guard
    911PASS test0: observe svg:circle
    1012PASS test1: observe svg:ellipse
     
    1921PASS test10: observe svg:svg, top/left is 0 even with padding
    2022PASS test11: observe svg non-displayable element
    21 FAIL test12: observe svg:rect content box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    22 FAIL test13: observe svg:rect border box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    23 FAIL test14: observe g:rect content and border box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    24 FAIL test15: observe svg:text content and border box undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
    25 FAIL test16: observe g:rect content, border and device-pixel-content boxes undefined is not an object (evaluating 'entries[0].contentBoxSize[0]')
     23PASS test12: observe svg:rect content box
     24PASS test13: observe svg:rect border box
     25PASS test14: observe g:rect content and border box
     26FAIL test15: observe svg:text content and border box assert_equals: expected 30 but got 30.015625
     27FAIL test16: observe g:rect content, border and device-pixel-content boxes assert_unreached: Caught a throw, possible syntax error Reached unreachable code
    2628
  • trunk/Source/WebCore/CMakeLists.txt

    r282401 r282441  
    11261126    page/RemoteDOMWindow.idl
    11271127    page/ResizeObserver.idl
     1128    page/ResizeObserverBoxOptions.idl
    11281129    page/ResizeObserverCallback.idl
    11291130    page/ResizeObserverEntry.idl
     1131    page/ResizeObserverOptions.idl
     1132    page/ResizeObserverSize.idl
    11301133    page/Screen.idl
    11311134    page/ScrollBehavior.idl
  • trunk/Source/WebCore/ChangeLog

    r282440 r282441  
     12021-09-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Implement the borderBoxSize/contentBoxSize parts of ResizeObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=230242
     5
     6        Reviewed by Sam Weinig.
     7
     8        The Resize Observer spec has been updated to allow authors to observe
     9        "content-box", "border-box" and "device-pixel-content-box". Add support
     10        for the first two, adding ResizeObserverSize, ResizeObserverBoxOptions and
     11        ResizeObserverOptions per spec.
     12
     13        ResizeObserverEntry also contains borderBoxSize and contentBoxSize now,
     14        so support that.
     15
     16        Add some helpers to make it easier to get box logical sizes.
     17
     18        "device-pixel-content-box" is not yet supported because it's expensive to compute[2].
     19
     20        [1] https://drafts.csswg.org/resize-observer
     21        [2] https://github.com/w3c/csswg-drafts/issues/6608
     22
     23        Tested by WPT.
     24
     25        * DerivedSources-input.xcfilelist:
     26        * DerivedSources-output.xcfilelist:
     27        * DerivedSources.make:
     28        * Sources.txt:
     29        * WebCore.xcodeproj/project.pbxproj:
     30        * page/ResizeObservation.cpp:
     31        (WebCore::ResizeObservation::create):
     32        (WebCore::ResizeObservation::ResizeObservation):
     33        (WebCore::ResizeObservation::updateObservationSize):
     34        (WebCore::ResizeObservation::computeObservedSizes const):
     35        (WebCore::ResizeObservation::computeContentRect const):
     36        (WebCore::ResizeObservation::borderBoxSize const):
     37        (WebCore::ResizeObservation::contentBoxSize const):
     38        (WebCore::ResizeObservation::snappedContentBoxSize const):
     39        (WebCore::ResizeObservation::elementSizeChanged const):
     40        (WebCore::ResizeObservation::~ResizeObservation): Deleted.
     41        (WebCore::ResizeObservation::computeObservedSize const): Deleted.
     42        * page/ResizeObservation.h:
     43        (WebCore::ResizeObservation::observedBox const):
     44        * page/ResizeObserver.cpp:
     45        (WebCore::ResizeObserver::observe):
     46        (WebCore::ResizeObserver::gatherObservations):
     47        (WebCore::ResizeObserver::deliverObservations):
     48        * page/ResizeObserver.h:
     49        * page/ResizeObserver.idl:
     50        * page/ResizeObserverBoxOptions.h: Added.
     51        * page/ResizeObserverBoxOptions.idl: Copied from Source/WebCore/page/ResizeObserverEntry.idl.
     52        * page/ResizeObserverEntry.h:
     53        (WebCore::ResizeObserverEntry::create):
     54        (WebCore::ResizeObserverEntry::contentRect const):
     55        (WebCore::ResizeObserverEntry::borderBoxSize const):
     56        (WebCore::ResizeObserverEntry::contentBoxSize const):
     57        (WebCore::ResizeObserverEntry::ResizeObserverEntry):
     58        (WebCore::ResizeObserverEntry::m_contentBoxSizes):
     59        * page/ResizeObserverEntry.idl:
     60        * page/ResizeObserverOptions.h: Added.
     61        * page/ResizeObserverOptions.idl: Copied from Source/WebCore/page/ResizeObserverEntry.idl.
     62        * page/ResizeObserverSize.h: Added.
     63        (WebCore::ResizeObserverSize::create):
     64        (WebCore::ResizeObserverSize::inlineSize const):
     65        (WebCore::ResizeObserverSize::blockSize const):
     66        (WebCore::ResizeObserverSize::ResizeObserverSize):
     67        * page/ResizeObserverSize.idl: Copied from Source/WebCore/page/ResizeObserverEntry.idl.
     68        * rendering/RenderBox.h:
     69        (WebCore::RenderBox::logicalSize const):
     70        (WebCore::RenderBox::borderBoxLogicalSize const):
     71        (WebCore::RenderBox::contentLogicalSize const):
     72        * rendering/RenderElement.h:
     73        (WebCore::adjustLayoutSizeForAbsoluteZoom):
     74        * rendering/style/RenderStyle.h:
     75        (WebCore::adjustLayoutSizeForAbsoluteZoom):
     76
    1772021-09-14  Rob Buis  <rbuis@igalia.com>
    278
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r282361 r282441  
    11921192$(PROJECT_DIR)/page/RemoteDOMWindow.idl
    11931193$(PROJECT_DIR)/page/ResizeObserver.idl
     1194$(PROJECT_DIR)/page/ResizeObserverBoxOptions.idl
    11941195$(PROJECT_DIR)/page/ResizeObserverCallback.idl
    11951196$(PROJECT_DIR)/page/ResizeObserverEntry.idl
     1197$(PROJECT_DIR)/page/ResizeObserverOptions.idl
     1198$(PROJECT_DIR)/page/ResizeObserverSize.idl
    11961199$(PROJECT_DIR)/page/Screen.idl
    11971200$(PROJECT_DIR)/page/ScrollBehavior.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r282361 r282441  
    18421842$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserver.cpp
    18431843$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserver.h
     1844$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverBoxOptions.cpp
     1845$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverBoxOptions.h
    18441846$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverCallback.cpp
    18451847$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverCallback.h
    18461848$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverEntry.cpp
    18471849$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverEntry.h
     1850$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverOptions.cpp
     1851$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverOptions.h
     1852$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverSize.cpp
     1853$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverSize.h
    18481854$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRsaHashedImportParams.cpp
    18491855$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRsaHashedImportParams.h
  • trunk/Source/WebCore/DerivedSources.make

    r282361 r282441  
    10391039    $(WebCore)/page/RemoteDOMWindow.idl \
    10401040    $(WebCore)/page/ResizeObserver.idl \
     1041    $(WebCore)/page/ResizeObserverBoxOptions.idl \
    10411042    $(WebCore)/page/ResizeObserverCallback.idl \
    10421043    $(WebCore)/page/ResizeObserverEntry.idl \
     1044    $(WebCore)/page/ResizeObserverOptions.idl \
     1045    $(WebCore)/page/ResizeObserverSize.idl \
    10431046    $(WebCore)/page/Screen.idl \
    10441047    $(WebCore)/page/ScrollBehavior.idl \
  • trunk/Source/WebCore/Sources.txt

    r282401 r282441  
    34043404JSRequestAnimationFrameCallback.cpp
    34053405JSResizeObserver.cpp
     3406JSResizeObserverBoxOptions.cpp
    34063407JSResizeObserverCallback.cpp
    34073408JSResizeObserverEntry.cpp
     3409JSResizeObserverOptions.cpp
     3410JSResizeObserverSize.cpp
    34083411JSRsaHashedImportParams.cpp
    34093412JSRsaHashedKeyGenParams.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r282401 r282441  
    363363                0FD41E6821F80C0E000C006D /* ScrollingTreeFrameHostingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD41E6621F80282000C006D /* ScrollingTreeFrameHostingNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    364364                0FD41E6921F80D14000C006D /* ScrollingStateFrameHostingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD41E6521F80261000C006D /* ScrollingStateFrameHostingNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
     365                0FD6A68526EEC221007B2231 /* JSResizeObserverOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6A68226EEC1D9007B2231 /* JSResizeObserverOptions.h */; };
     366                0FD6A68726EEC226007B2231 /* JSResizeObserverSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6A67D26EEC076007B2231 /* JSResizeObserverSize.h */; };
     367                0FD6A68826EEC22B007B2231 /* JSResizeObserverBoxOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6A67C26EEC076007B2231 /* JSResizeObserverBoxOptions.h */; };
     368                0FD6A68A26EEC32B007B2231 /* ResizeObserverOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6A68926EEC32A007B2231 /* ResizeObserverOptions.h */; };
     369                0FD6A68C26EEC37F007B2231 /* ResizeObserverBoxOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6A68B26EEC37F007B2231 /* ResizeObserverBoxOptions.h */; };
     370                0FD6A68E26EEC5E9007B2231 /* ResizeObserverSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6A68D26EEC5E8007B2231 /* ResizeObserverSize.h */; };
    365371                0FD723820EC8BD9300CA5DD7 /* FloatQuad.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */; settings = {ATTRIBUTES = (Private, ); }; };
    366372                0FD975D5245CCB4700C42299 /* ScrollingTreeGestureState.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD975D2245CBDAF00C42299 /* ScrollingTreeGestureState.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    63576363                0FD41E6621F80282000C006D /* ScrollingTreeFrameHostingNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeFrameHostingNode.h; sourceTree = "<group>"; };
    63586364                0FD41E6721F80282000C006D /* ScrollingTreeFrameHostingNode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeFrameHostingNode.cpp; sourceTree = "<group>"; };
     6365                0FD6A67226EEBA05007B2231 /* ResizeObserverOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ResizeObserverOptions.idl; sourceTree = "<group>"; };
     6366                0FD6A67426EEBAB9007B2231 /* ResizeObserverBoxOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ResizeObserverBoxOptions.idl; sourceTree = "<group>"; };
     6367                0FD6A67626EEBC7B007B2231 /* ResizeObserverSize.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ResizeObserverSize.idl; sourceTree = "<group>"; };
     6368                0FD6A67926EEC075007B2231 /* JSResizeObserverBoxOptions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSResizeObserverBoxOptions.cpp; sourceTree = "<group>"; };
     6369                0FD6A67B26EEC075007B2231 /* JSResizeObserverSize.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSResizeObserverSize.cpp; sourceTree = "<group>"; };
     6370                0FD6A67C26EEC076007B2231 /* JSResizeObserverBoxOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSResizeObserverBoxOptions.h; sourceTree = "<group>"; };
     6371                0FD6A67D26EEC076007B2231 /* JSResizeObserverSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSResizeObserverSize.h; sourceTree = "<group>"; };
     6372                0FD6A68026EEC1D9007B2231 /* JSResizeObserverOptions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSResizeObserverOptions.cpp; sourceTree = "<group>"; };
     6373                0FD6A68226EEC1D9007B2231 /* JSResizeObserverOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSResizeObserverOptions.h; sourceTree = "<group>"; };
     6374                0FD6A68926EEC32A007B2231 /* ResizeObserverOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObserverOptions.h; sourceTree = "<group>"; };
     6375                0FD6A68B26EEC37F007B2231 /* ResizeObserverBoxOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObserverBoxOptions.h; sourceTree = "<group>"; };
     6376                0FD6A68D26EEC5E8007B2231 /* ResizeObserverSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeObserverSize.h; sourceTree = "<group>"; };
    63596377                0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatQuad.h; sourceTree = "<group>"; };
    63606378                0FD723810EC8BD9300CA5DD7 /* FloatQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatQuad.cpp; sourceTree = "<group>"; };
     
    2235822376                                58B2F9EC2232D43B00938D63 /* ResizeObserver.h */,
    2235922377                                58B2F9F12232D43E00938D63 /* ResizeObserver.idl */,
     22378                                0FD6A68B26EEC37F007B2231 /* ResizeObserverBoxOptions.h */,
     22379                                0FD6A67426EEBAB9007B2231 /* ResizeObserverBoxOptions.idl */,
    2236022380                                58B2F9F02232D43E00938D63 /* ResizeObserverCallback.h */,
    2236122381                                58B2F9ED2232D43C00938D63 /* ResizeObserverCallback.idl */,
    2236222382                                58B2F9EE2232D43D00938D63 /* ResizeObserverEntry.h */,
    2236322383                                58B2F9EA2232D43B00938D63 /* ResizeObserverEntry.idl */,
     22384                                0FD6A68926EEC32A007B2231 /* ResizeObserverOptions.h */,
     22385                                0FD6A67226EEBA05007B2231 /* ResizeObserverOptions.idl */,
     22386                                0FD6A68D26EEC5E8007B2231 /* ResizeObserverSize.h */,
     22387                                0FD6A67626EEBC7B007B2231 /* ResizeObserverSize.idl */,
    2236422388                                A5071E821C56D079009951BE /* ResourceUsageData.h */,
    2236522389                                ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
     
    2752727551                                58B2FA032232D60B00938D63 /* JSResizeObserver.cpp */,
    2752827552                                58B2FA012232D60A00938D63 /* JSResizeObserver.h */,
     27553                                0FD6A67926EEC075007B2231 /* JSResizeObserverBoxOptions.cpp */,
     27554                                0FD6A67C26EEC076007B2231 /* JSResizeObserverBoxOptions.h */,
    2752927555                                58B2F9FE2232D60700938D63 /* JSResizeObserverCallback.cpp */,
    2753027556                                58B2F9FF2232D60800938D63 /* JSResizeObserverCallback.h */,
    2753127557                                58B2FA002232D60900938D63 /* JSResizeObserverEntry.cpp */,
    2753227558                                58B2FA022232D60A00938D63 /* JSResizeObserverEntry.h */,
     27559                                0FD6A68026EEC1D9007B2231 /* JSResizeObserverOptions.cpp */,
     27560                                0FD6A68226EEC1D9007B2231 /* JSResizeObserverOptions.h */,
     27561                                0FD6A67B26EEC075007B2231 /* JSResizeObserverSize.cpp */,
     27562                                0FD6A67D26EEC076007B2231 /* JSResizeObserverSize.h */,
    2753327563                                BCEC01C00C274DDD009F4EC9 /* JSScreen.cpp */,
    2753427564                                BCEC01C10C274DDD009F4EC9 /* JSScreen.h */,
     
    3339133421                                4998AECE13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.h in Headers */,
    3339233422                                58B2FA042232D9BE00938D63 /* JSResizeObserver.h in Headers */,
     33423                                0FD6A68826EEC22B007B2231 /* JSResizeObserverBoxOptions.h in Headers */,
    3339333424                                58B2FA062232DC5500938D63 /* JSResizeObserverCallback.h in Headers */,
    3339433425                                58B2FA052232DC4F00938D63 /* JSResizeObserverEntry.h in Headers */,
     33426                                0FD6A68526EEC221007B2231 /* JSResizeObserverOptions.h in Headers */,
     33427                                0FD6A68726EEC226007B2231 /* JSResizeObserverSize.h in Headers */,
    3339533428                                57E233711DCD468F00F28D01 /* JSRsaHashedImportParams.h in Headers */,
    3339633429                                5768E4341DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h in Headers */,
     
    3462334656                                58B2F9F42232D45300938D63 /* ResizeObservation.h in Headers */,
    3462434657                                58B2F9F52232D45800938D63 /* ResizeObserver.h in Headers */,
     34658                                0FD6A68C26EEC37F007B2231 /* ResizeObserverBoxOptions.h in Headers */,
    3462534659                                58B2F9F62232D45C00938D63 /* ResizeObserverCallback.h in Headers */,
    3462634660                                58B2F9F72232D46100938D63 /* ResizeObserverEntry.h in Headers */,
     34661                                0FD6A68A26EEC32B007B2231 /* ResizeObserverOptions.h in Headers */,
     34662                                0FD6A68E26EEC5E9007B2231 /* ResizeObserverSize.h in Headers */,
    3462734663                                7C2FA6121EA95A3C00A03108 /* ResourceCryptographicDigest.h in Headers */,
    3462834664                                7EE6846A12D26E3800E79415 /* ResourceError.h in Headers */,
  • trunk/Source/WebCore/page/ResizeObservation.cpp

    r279800 r282441  
    2727
    2828#if ENABLE(RESIZE_OBSERVER)
     29
    2930#include "ResizeObservation.h"
    3031
     
    3536namespace WebCore {
    3637
    37 Ref<ResizeObservation> ResizeObservation::create(Element& target)
     38Ref<ResizeObservation> ResizeObservation::create(Element& target, ResizeObserverBoxOptions observedBox)
    3839{
    39     return adoptRef(*new ResizeObservation(target));
     40    return adoptRef(*new ResizeObservation(target, observedBox));
    4041}
    4142
    42 ResizeObservation::ResizeObservation(Element& element)
     43ResizeObservation::ResizeObservation(Element& element, ResizeObserverBoxOptions observedBox)
    4344    : m_target { makeWeakPtr(element) }
     45    , m_observedBox { observedBox }
    4446{
    4547}
    4648
    47 ResizeObservation::~ResizeObservation()
     49ResizeObservation::~ResizeObservation() = default;
     50
     51void ResizeObservation::updateObservationSize(const BoxSizes& boxSizes)
    4852{
     53    m_lastObservationSizes = boxSizes;
    4954}
    5055
    51 void ResizeObservation::updateObservationSize(const LayoutSize& size)
    52 {
    53     m_lastObservationSize = size;
    54 }
    55 
    56 LayoutSize ResizeObservation::computeObservedSize() const
     56auto ResizeObservation::computeObservedSizes() const -> BoxSizes
    5757{
    5858    if (m_target->isSVGElement()) {
    59         if (auto svgRect = downcast<SVGElement>(*m_target).getBoundingBox())
    60             return LayoutSize(svgRect->width(), svgRect->height());
     59        if (auto svgRect = downcast<SVGElement>(*m_target).getBoundingBox()) {
     60            auto size = LayoutSize(svgRect->width(), svgRect->height());
     61            return { size, size, size };
     62        }
    6163    }
    6264    auto* box = m_target->renderBox();
    6365    if (box) {
    64         auto contentSize = box->contentSize();
    65         return LayoutSize(adjustLayoutUnitForAbsoluteZoom(contentSize.width(), *box), adjustLayoutUnitForAbsoluteZoom(contentSize.height(), *box));
     66        return {
     67            adjustLayoutSizeForAbsoluteZoom(box->contentSize(), *box),
     68            adjustLayoutSizeForAbsoluteZoom(box->contentLogicalSize(), *box),
     69            adjustLayoutSizeForAbsoluteZoom(box->borderBoxLogicalSize(), *box)
     70        };
    6671    }
    6772
    68     return LayoutSize();
     73    return { };
    6974}
    7075
     
    8186FloatRect ResizeObservation::computeContentRect() const
    8287{
    83     return FloatRect(FloatPoint(computeTargetLocation()), FloatSize(m_lastObservationSize));
     88    return FloatRect(FloatPoint(computeTargetLocation()), FloatSize(m_lastObservationSizes.contentBoxSize));
    8489}
    8590
    86 bool ResizeObservation::elementSizeChanged(LayoutSize& currentSize) const
     91FloatSize ResizeObservation::borderBoxSize() const
    8792{
    88     currentSize = computeObservedSize();
    89     return m_lastObservationSize != currentSize;
     93    return m_lastObservationSizes.borderBoxLogicalSize;
     94}
     95
     96FloatSize ResizeObservation::contentBoxSize() const
     97{
     98    return m_lastObservationSizes.contentBoxLogicalSize;
     99}
     100
     101FloatSize ResizeObservation::snappedContentBoxSize() const
     102{
     103    return m_lastObservationSizes.contentBoxLogicalSize; // FIXME: Need to pixel snap.
     104}
     105
     106std::optional<ResizeObservation::BoxSizes> ResizeObservation::elementSizeChanged() const
     107{
     108    auto currentSizes = computeObservedSizes();
     109
     110    switch (m_observedBox) {
     111    case ResizeObserverBoxOptions::BorderBox:
     112        if (m_lastObservationSizes.borderBoxLogicalSize != currentSizes.borderBoxLogicalSize)
     113            return currentSizes;
     114        break;
     115    case ResizeObserverBoxOptions::ContentBox:
     116        if (m_lastObservationSizes.contentBoxLogicalSize != currentSizes.contentBoxLogicalSize)
     117            return currentSizes;
     118        break;
     119    }
     120
     121    return { };
    90122}
    91123
  • trunk/Source/WebCore/page/ResizeObservation.h

    r279800 r282441  
    2727
    2828#if ENABLE(RESIZE_OBSERVER)
     29
    2930#include "FloatRect.h"
    3031#include "LayoutSize.h"
     32#include "ResizeObserverBoxOptions.h"
    3133
    3234#include <wtf/RefCounted.h>
     
    4042    WTF_MAKE_FAST_ALLOCATED;
    4143public:
    42     static Ref<ResizeObservation> create(Element& target);
     44    static Ref<ResizeObservation> create(Element& target, ResizeObserverBoxOptions);
    4345
    4446    ~ResizeObservation();
     47   
     48    struct BoxSizes {
     49        LayoutSize contentBoxSize;
     50        LayoutSize contentBoxLogicalSize;
     51        LayoutSize borderBoxLogicalSize;
     52    };
    4553
    46     void updateObservationSize(const LayoutSize&);
    47     LayoutSize computeObservedSize() const;
    48     LayoutPoint computeTargetLocation() const;
     54    std::optional<BoxSizes> elementSizeChanged() const;
     55    void updateObservationSize(const BoxSizes&);
     56
    4957    FloatRect computeContentRect() const;
     58    FloatSize borderBoxSize() const;
     59    FloatSize contentBoxSize() const;
     60    FloatSize snappedContentBoxSize() const;
    5061
    51     bool elementSizeChanged(LayoutSize&) const;
    5262    Element* target() const { return m_target.get(); }
     63    ResizeObserverBoxOptions observedBox() const { return m_observedBox; }
    5364    size_t targetElementDepth() const;
    5465
    5566private:
    56     ResizeObservation(Element& target);
     67    ResizeObservation(Element&, ResizeObserverBoxOptions);
     68
     69    BoxSizes computeObservedSizes() const;
     70    LayoutPoint computeTargetLocation() const;
    5771
    5872    WeakPtr<Element> m_target;
    59     LayoutSize m_lastObservationSize;
     73    BoxSizes m_lastObservationSizes;
     74    ResizeObserverBoxOptions m_observedBox;
    6075};
    6176
  • trunk/Source/WebCore/page/ResizeObserver.cpp

    r281188 r282441  
    3232#include "InspectorInstrumentation.h"
    3333#include "ResizeObserverEntry.h"
     34#include "ResizeObserverOptions.h"
    3435#include <JavaScriptCore/AbstractSlotVisitorInlines.h>
    3536
     
    5455}
    5556
    56 void ResizeObserver::observe(Element& target)
     57// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-observe
     58void ResizeObserver::observe(Element& target, const ResizeObserverOptions& options)
    5759{
    5860    if (!m_callback)
     
    6365    });
    6466
    65     if (position != notFound)
    66         return;
     67    if (position != notFound) {
     68        // The spec suggests unconditionally unobserving here, but that causes a test failure:
     69        // https://github.com/web-platform-tests/wpt/issues/30708
     70        if (m_observations[position]->observedBox() == options.box)
     71            return;
     72
     73        unobserve(target);
     74    }
    6775
    6876    auto& observerData = target.ensureResizeObserverData();
    6977    observerData.observers.append(makeWeakPtr(this));
    7078
    71     m_observations.append(ResizeObservation::create(target));
     79    m_observations.append(ResizeObservation::create(target, options.box));
    7280
    7381    if (m_document) {
     
    7785}
    7886
     87// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-unobserve
    7988void ResizeObserver::unobserve(Element& target)
    8089{
     
    8594}
    8695
     96// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-disconnect
    8797void ResizeObserver::disconnect()
    8898{
     
    100110    size_t minObservedDepth = maxElementDepth();
    101111    for (const auto& observation : m_observations) {
    102         LayoutSize currentSize;
    103         if (observation->elementSizeChanged(currentSize)) {
     112        if (auto currentSizes = observation->elementSizeChanged()) {
    104113            size_t depth = observation->targetElementDepth();
    105114            if (depth > deeperThan) {
    106                 observation->updateObservationSize(currentSize);
     115                observation->updateObservationSize(*currentSizes);
    107116                m_activeObservations.append(observation.get());
    108117                m_activeObservationTargets.append(*observation->target());
     
    120129    for (const auto& observation : m_activeObservations) {
    121130        ASSERT(observation->target());
    122         entries.append(ResizeObserverEntry::create(observation->target(), observation->computeContentRect()));
     131        entries.append(ResizeObserverEntry::create(observation->target(), observation->computeContentRect(), observation->borderBoxSize(), observation->contentBoxSize()));
    123132    }
    124133    m_activeObservations.clear();
  • trunk/Source/WebCore/page/ResizeObserver.h

    r279800 r282441  
    4545class Document;
    4646class Element;
     47struct ResizeObserverOptions;
    4748
    4849struct ResizeObserverData {
     
    5960    bool hasActiveObservations() const { return m_activeObservations.size(); }
    6061
    61     void observe(Element&);
     62    void observe(Element&, const ResizeObserverOptions&);
    6263    void unobserve(Element&);
    6364    void disconnect();
  • trunk/Source/WebCore/page/ResizeObserver.idl

    r279800 r282441  
    3636    [CallWith=Document] constructor(ResizeObserverCallback callback);
    3737
    38     undefined observe(Element target);
     38    undefined observe(Element target, optional ResizeObserverOptions options);
    3939    undefined unobserve(Element target);
    4040    undefined disconnect();
  • trunk/Source/WebCore/page/ResizeObserverBoxOptions.idl

    r282440 r282441  
    11/*
    2  * Copyright (C) 2019 Igalia S.L.
     2 * Copyright (C) 2021 Apple Inc.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 // https://wicg.github.io/ResizeObserver/
    27 
    28 [
    29     Conditional=RESIZE_OBSERVER,
    30     CallbackThisObject=ResizeObserver,
    31     IsWeakCallback,
    32 ] callback ResizeObserverCallback = undefined (sequence<ResizeObserverEntry> entries, ResizeObserver observer);
     26// https://drafts.csswg.org/resize-observer/#enumdef-resizeobserverboxoptions
     27enum ResizeObserverBoxOptions {
     28    "border-box",
     29    "content-box"
     30    // "device-pixel-content-box" webkit.org/b/219005
     31};
  • trunk/Source/WebCore/page/ResizeObserverCallback.idl

    r268860 r282441  
    2424 */
    2525
    26 // https://wicg.github.io/ResizeObserver/
    27 
     26// https://drafts.csswg.org/resize-observer/#resize-observer-callback
    2827[
    2928    Conditional=RESIZE_OBSERVER,
  • trunk/Source/WebCore/page/ResizeObserverEntry.h

    r243643 r282441  
    3131#include "Element.h"
    3232#include "FloatRect.h"
     33#include "ResizeObserverSize.h"
    3334#include <wtf/RefCounted.h>
    3435
     
    3637
    3738class Element;
     39class ResizeObserverSize;
    3840
    3941class ResizeObserverEntry : public RefCounted<ResizeObserverEntry> {
    4042    WTF_MAKE_FAST_ALLOCATED;
    4143public:
    42     static Ref<ResizeObserverEntry> create(Element* target, const FloatRect& contentRect)
     44    static Ref<ResizeObserverEntry> create(Element* target, const FloatRect& contentRect, FloatSize borderBoxSize, FloatSize contentBoxSize)
    4345    {
    44         return adoptRef(*new ResizeObserverEntry(target, contentRect));
     46        return adoptRef(*new ResizeObserverEntry(target, contentRect, borderBoxSize, contentBoxSize));
    4547    }
    4648
    4749    Element* target() const { return m_target.get(); }
    48     DOMRectReadOnly* contentRect() const { return m_contentRect.get(); }
     50    DOMRectReadOnly* contentRect() const { return m_contentRect.ptr(); }
     51   
     52    const Vector<Ref<ResizeObserverSize>>& borderBoxSize() const { return m_borderBoxSizes; }
     53    const Vector<Ref<ResizeObserverSize>>& contentBoxSize() const { return m_contentBoxSizes; }
    4954
    5055private:
    51     ResizeObserverEntry(Element* target, const FloatRect& contentRect)
     56    ResizeObserverEntry(Element* target, const FloatRect& contentRect, FloatSize borderBoxSize, FloatSize contentBoxSize)
    5257        : m_target(target)
    5358        , m_contentRect(DOMRectReadOnly::create(contentRect.x(), contentRect.y(), contentRect.width(), contentRect.height()))
     59        , m_borderBoxSizes({ ResizeObserverSize::create(borderBoxSize.width(), borderBoxSize.height()) })
     60        , m_contentBoxSizes({ ResizeObserverSize::create(contentBoxSize.width(), contentBoxSize.height()) })
    5461    {
    5562    }
    5663
    5764    RefPtr<Element> m_target;
    58     RefPtr<DOMRectReadOnly> m_contentRect;
     65    Ref<DOMRectReadOnly> m_contentRect;
     66    // The spec is designed to allow mulitple boxes for multicol scenarios, but for now these vectors only ever contain one entry.
     67    Vector<Ref<ResizeObserverSize>> m_borderBoxSizes;
     68    Vector<Ref<ResizeObserverSize>> m_contentBoxSizes;
    5969};
    6070
  • trunk/Source/WebCore/page/ResizeObserverEntry.idl

    r267813 r282441  
    2424 */
    2525
    26 // https://wicg.github.io/ResizeObserver/
    27 
     26// https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface
    2827[
    2928    Conditional=RESIZE_OBSERVER,
     
    3534    readonly attribute Element target;
    3635    readonly attribute DOMRectReadOnly contentRect;
     36    readonly attribute FrozenArray<ResizeObserverSize> borderBoxSize;
     37    readonly attribute FrozenArray<ResizeObserverSize> contentBoxSize;
    3738};
  • trunk/Source/WebCore/page/ResizeObserverOptions.idl

    r282440 r282441  
    11/*
    2  * Copyright (C) 2019 Igalia S.L.
     2 * Copyright (C) 2021 Apple Inc.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 // https://wicg.github.io/ResizeObserver/
    27 
     26// https://drafts.csswg.org/resize-observer/#dictdef-resizeobserveroptions
    2827[
    2928    Conditional=RESIZE_OBSERVER,
    30     CallbackThisObject=ResizeObserver,
    31     IsWeakCallback,
    32 ] callback ResizeObserverCallback = undefined (sequence<ResizeObserverEntry> entries, ResizeObserver observer);
     29] dictionary ResizeObserverOptions {
     30    ResizeObserverBoxOptions box = "content-box";
     31};
  • trunk/Source/WebCore/page/ResizeObserverSize.idl

    r282440 r282441  
    11/*
    2  * Copyright (C) 2019 Igalia S.L.
     2 * Copyright (C) 2021 Apple Inc.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 // https://wicg.github.io/ResizeObserver/
    27 
     26// https://drafts.csswg.org/resize-observer/#resizeobserversize
    2827[
    29     Conditional=RESIZE_OBSERVER,
    30     CallbackThisObject=ResizeObserver,
    31     IsWeakCallback,
    32 ] callback ResizeObserverCallback = undefined (sequence<ResizeObserverEntry> entries, ResizeObserver observer);
     28    Exposed=Window,
     29    Conditional=RESIZE_OBSERVER
     30] interface ResizeObserverSize {
     31    readonly attribute unrestricted double inlineSize;
     32    readonly attribute unrestricted double blockSize;
     33};
  • trunk/Source/WebCore/rendering/RenderBox.h

    r281239 r282441  
    139139    LayoutSize locationOffset() const { return LayoutSize(x(), y()); }
    140140    LayoutSize size() const { return m_frameRect.size(); }
     141    LayoutSize logicalSize() const { return style().isHorizontalWritingMode() ? m_frameRect.size() : m_frameRect.size().transposedSize(); }
    141142
    142143    void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(location); }
     
    158159    LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); }
    159160    LayoutRect borderBoundingBox() const final { return borderBoxRect(); }
     161    LayoutSize borderBoxLogicalSize() const { return logicalSize(); }
    160162
    161163    WEBCORE_EXPORT RoundedRect::Radii borderRadii() const;
     
    222224    LayoutUnit contentWidth() const { return std::max(0_lu, paddingBoxWidth() - paddingLeft() - paddingRight()); }
    223225    LayoutUnit contentHeight() const { return std::max(0_lu, paddingBoxHeight() - paddingTop() - paddingBottom()); }
     226    LayoutSize contentLogicalSize() const { return style().isHorizontalWritingMode() ? contentSize() : contentSize().transposedSize(); }
    224227    LayoutUnit contentLogicalWidth() const { return style().isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
    225228    LayoutUnit contentLogicalHeight() const { return style().isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
  • trunk/Source/WebCore/rendering/RenderElement.h

    r282223 r282441  
    532532}
    533533
     534inline LayoutSize adjustLayoutSizeForAbsoluteZoom(LayoutSize size, const RenderElement& renderer)
     535{
     536    return adjustLayoutSizeForAbsoluteZoom(size, renderer.style());
     537}
     538
    534539inline RenderObject* RenderElement::firstInFlowChild() const
    535540{
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r282397 r282441  
    20062006float adjustFloatForAbsoluteZoom(float, const RenderStyle&);
    20072007LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit, const RenderStyle&);
     2008LayoutSize adjustLayoutSizeForAbsoluteZoom(LayoutSize, const RenderStyle&);
    20082009
    20092010BorderStyle collapsedBorderStyle(BorderStyle);
     
    21282129}
    21292130
     2131inline LayoutSize adjustLayoutSizeForAbsoluteZoom(LayoutSize size, const RenderStyle& style)
     2132{
     2133    auto zoom = style.effectiveZoom();
     2134    return {
     2135        size.width() / zoom,
     2136        size.height() / zoom
     2137    };
     2138}
     2139
    21302140inline BorderStyle collapsedBorderStyle(BorderStyle style)
    21312141{
Note: See TracChangeset for help on using the changeset viewer.