⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249079 in webkit


Ignore:
Timestamp:
Aug 23, 2019, 7:22:28 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

Implement StaticRange constructor
https://bugs.webkit.org/show_bug.cgi?id=201055

Reviewed by Wenson Hsieh.

LayoutTests/imported/w3c:

Added a test from https://github.com/web-platform-tests/wpt/pull/18619
with my review comment addressed.

  • web-platform-tests/dom/interfaces-expected.txt: Rebaselined.
  • web-platform-tests/dom/ranges/StaticRange-constructor-expected.txt: Added.
  • web-platform-tests/dom/ranges/StaticRange-constructor.html: Added.

Source/WebCore:

Added the constructor to StaticRange per https://github.com/whatwg/dom/pull/778.

Test: imported/w3c/web-platform-tests/dom/ranges/StaticRange-constructor.html

  • dom/StaticRange.cpp:

(WebCore::isDocumentTypeOrAttr):
(WebCore::StaticRange::create):

  • dom/StaticRange.h:
  • dom/StaticRange.idl:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r248960 r249079  
     12019-08-22  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Implement StaticRange constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=201055
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Added a test from https://github.com/web-platform-tests/wpt/pull/18619
     9        with my review comment addressed.
     10
     11        * web-platform-tests/dom/interfaces-expected.txt: Rebaselined.
     12        * web-platform-tests/dom/ranges/StaticRange-constructor-expected.txt: Added.
     13        * web-platform-tests/dom/ranges/StaticRange-constructor.html: Added.
     14
    1152019-08-21  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt

    r235889 r249079  
    14381438FAIL AbstractRange interface: attribute collapsed assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
    14391439FAIL StaticRange interface: existence and properties of interface object assert_own_property: should inherit from AbstractRange, but self has no such property expected property "AbstractRange" missing
    1440 PASS StaticRange interface object length
     1440FAIL StaticRange interface object length assert_equals: wrong value for StaticRange.length expected 0 but got 1
    14411441PASS StaticRange interface object name
    14421442FAIL StaticRange interface: existence and properties of interface prototype object assert_own_property: should inherit from AbstractRange, but self has no such property expected property "AbstractRange" missing
  • trunk/Source/WebCore/ChangeLog

    r249078 r249079  
     12019-08-22  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Implement StaticRange constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=201055
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Added the constructor to StaticRange per https://github.com/whatwg/dom/pull/778.
     9
     10        Test: imported/w3c/web-platform-tests/dom/ranges/StaticRange-constructor.html
     11
     12        * dom/StaticRange.cpp:
     13        (WebCore::isDocumentTypeOrAttr):
     14        (WebCore::StaticRange::create):
     15        * dom/StaticRange.h:
     16        * dom/StaticRange.idl:
     17
    1182019-08-23  Devin Rousso  <drousso@apple.com>
    219
  • trunk/Source/WebCore/dom/StaticRange.cpp

    r223728 r249079  
    2727#include "StaticRange.h"
    2828
     29#include "DOMException.h"
    2930#include "Node.h"
    3031#include "Range.h"
     
    5253}
    5354
     55static inline bool isDocumentTypeOrAttr(Node& node)
     56{
     57    return node.isDocumentTypeNode() || node.isAttributeNode();
     58}
     59
     60ExceptionOr<Ref<StaticRange>> StaticRange::create(Init&& init)
     61{
     62    ASSERT(init.startContainer);
     63    ASSERT(init.endContainer);
     64    if (isDocumentTypeOrAttr(*init.startContainer) || isDocumentTypeOrAttr(*init.endContainer))
     65        return Exception { InvalidNodeTypeError };
     66    return StaticRange::create(init.startContainer.releaseNonNull(), init.startOffset, init.endContainer.releaseNonNull(), init.endOffset);
     67}
     68
    5469Node* StaticRange::startContainer() const
    5570{
  • trunk/Source/WebCore/dom/StaticRange.h

    r218593 r249079  
    4141    static Ref<StaticRange> create(Ref<Node>&& startContainer, unsigned startOffset, Ref<Node>&& endContainer, unsigned endOffset);
    4242
     43    struct Init {
     44        RefPtr<Node> startContainer;
     45        unsigned long startOffset { 0 };
     46        RefPtr<Node> endContainer;
     47        unsigned long endOffset { 0 };
     48    };
     49
     50    static ExceptionOr<Ref<StaticRange>> create(Init&&);
     51
    4352    unsigned startOffset() const { return m_startOffset; }
    4453    unsigned endOffset() const { return m_endOffset; }
  • trunk/Source/WebCore/dom/StaticRange.idl

    r207670 r249079  
    2727    EnabledAtRuntime=InputEvents,
    2828    ImplementationLacksVTable,
     29    Exposed=Window,
     30    ConstructorMayThrowException,
     31    Constructor(StaticRangeInit staticRangeInitDict),
    2932] interface StaticRange {
    3033    readonly attribute unsigned long startOffset;
     
    3437    readonly attribute boolean collapsed;
    3538};
     39
     40dictionary StaticRangeInit {
     41  required Node startContainer;
     42  required unsigned long startOffset;
     43  required Node endContainer;
     44  required unsigned long endOffset;
     45};
Note: See TracChangeset for help on using the changeset viewer.