Commit b95a3cd5 authored by Jaeyong Bae's avatar Jaeyong Bae Committed by Chromium LUCI CQ

[DOM] Implement AbstractRange superclass

This patch means implementing AbstractRange according to
specification[1]. The bits shared between StaticRange and Range objects
are put on a shared superclass named AbstractRange. And, make the failed
the web test[2] successful.

[1] https://dom.spec.whatwg.org/#interface-abstractrange
[2] https://github.com/w3c/web-platform-tests/pull/9967

Bug: 820947
Change-Id: If9ea0b4d9b3f3fa0c30920e0c1972b76da995453
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212290
Commit-Queue: Jaeyong Bae <jdragon.bae@gmail.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845074}
parent 04070d7e
......@@ -491,6 +491,8 @@ generated_interface_sources_in_core = [
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_abort_controller.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_abort_signal.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_abort_signal.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_abstract_range.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_abstract_range.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_accessible_node.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_accessible_node.h",
"$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_accessible_node_list.cc",
......
......@@ -111,6 +111,7 @@ static_idl_files_in_core = get_path_info(
"//third_party/blink/renderer/core/document_transition/document_transition_supplement.idl",
"//third_party/blink/renderer/core/dom/abort_controller.idl",
"//third_party/blink/renderer/core/dom/abort_signal.idl",
"//third_party/blink/renderer/core/dom/abstract_range.idl",
"//third_party/blink/renderer/core/dom/accessibility_role.idl",
"//third_party/blink/renderer/core/dom/aria_attributes.idl",
"//third_party/blink/renderer/core/dom/aria_relationship_attributes.idl",
......
......@@ -114,6 +114,7 @@ core_interface_idl_files_core_only =
"document_transition/document_transition.idl",
"dom/abort_controller.idl",
"dom/abort_signal.idl",
"dom/abstract_range.idl",
"dom/attr.idl",
"dom/cdata_section.idl",
"dom/character_data.idl",
......
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/dom/abstract_range.h"
namespace blink {
AbstractRange::AbstractRange() = default;
AbstractRange::~AbstractRange() = default;
} // namespace blink
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DOM_ABSTRACT_RANGE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_ABSTRACT_RANGE_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
namespace blink {
class CORE_EXPORT AbstractRange : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
virtual Node* startContainer() const = 0;
virtual unsigned startOffset() const = 0;
virtual Node* endContainer() const = 0;
virtual unsigned endOffset() const = 0;
virtual bool collapsed() const = 0;
protected:
AbstractRange();
~AbstractRange() override;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_DOM_ABSTRACT_RANGE_H_
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://dom.spec.whatwg.org/#interface-abstractrange
[
Exposed=Window
] interface AbstractRange {
readonly attribute Node startContainer;
readonly attribute unsigned long startOffset;
readonly attribute Node endContainer;
readonly attribute unsigned long endOffset;
readonly attribute boolean collapsed;
};
......@@ -35,6 +35,8 @@ blink_core_sources_dom = [
"abort_controller.h",
"abort_signal.cc",
"abort_signal.h",
"abstract_range.cc",
"abstract_range.h",
"attr.cc",
"attr.h",
"attribute.h",
......
......@@ -27,6 +27,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_RANGE_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/abstract_range.h"
#include "third_party/blink/renderer/core/dom/range_boundary_point.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
......@@ -48,7 +49,7 @@ class Node;
class NodeWithIndex;
class Text;
class CORE_EXPORT Range final : public ScriptWrappable {
class CORE_EXPORT Range final : public AbstractRange {
DEFINE_WRAPPERTYPEINFO();
public:
......@@ -68,12 +69,12 @@ class CORE_EXPORT Range final : public ScriptWrappable {
DCHECK(owner_document_);
return *owner_document_.Get();
}
Node* startContainer() const { return &start_.Container(); }
unsigned startOffset() const { return start_.Offset(); }
Node* endContainer() const { return &end_.Container(); }
unsigned endOffset() const { return end_.Offset(); }
Node* startContainer() const override { return &start_.Container(); }
unsigned startOffset() const override { return start_.Offset(); }
Node* endContainer() const override { return &end_.Container(); }
unsigned endOffset() const override { return end_.Offset(); }
bool collapsed() const { return start_ == end_; }
bool collapsed() const override { return start_ == end_; }
bool IsConnected() const;
Node* commonAncestorContainer() const;
......
......@@ -21,13 +21,8 @@
// https://dom.spec.whatwg.org/#interface-range
[
Exposed=Window
] interface Range {
] interface Range : AbstractRange {
[CallWith=Document] constructor();
readonly attribute Node startContainer;
readonly attribute unsigned long startOffset;
readonly attribute Node endContainer;
readonly attribute unsigned long endOffset;
readonly attribute boolean collapsed;
readonly attribute Node commonAncestorContainer;
[RaisesException] void setStart(Node node, unsigned long offset);
......
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_STATIC_RANGE_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/abstract_range.h"
#include "third_party/blink/renderer/core/dom/range.h"
#include "third_party/blink/renderer/core/editing/forward.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
......@@ -16,7 +17,7 @@ namespace blink {
class Document;
class ExceptionState;
class CORE_EXPORT StaticRange final : public ScriptWrappable {
class CORE_EXPORT StaticRange final : public AbstractRange {
DEFINE_WRAPPERTYPEINFO();
public:
......@@ -34,21 +35,21 @@ class CORE_EXPORT StaticRange final : public ScriptWrappable {
Node* end_container,
unsigned end_offset);
Node* startContainer() const { return start_container_.Get(); }
Node* startContainer() const override { return start_container_.Get(); }
void setStartContainer(Node* start_container) {
start_container_ = start_container;
}
unsigned startOffset() const { return start_offset_; }
unsigned startOffset() const override { return start_offset_; }
void setStartOffset(unsigned start_offset) { start_offset_ = start_offset; }
Node* endContainer() const { return end_container_.Get(); }
Node* endContainer() const override { return end_container_.Get(); }
void setEndContainer(Node* end_container) { end_container_ = end_container; }
unsigned endOffset() const { return end_offset_; }
unsigned endOffset() const override { return end_offset_; }
void setEndOffset(unsigned end_offset) { end_offset_ = end_offset; }
bool collapsed() const {
bool collapsed() const override {
return start_container_ == end_container_ && start_offset_ == end_offset_;
}
......
......@@ -6,10 +6,5 @@
[
Exposed=Window
] interface StaticRange {
readonly attribute Node startContainer;
readonly attribute unsigned long startOffset;
readonly attribute Node endContainer;
readonly attribute unsigned long endOffset;
readonly attribute boolean collapsed;
] interface StaticRange : AbstractRange {
};
This is a testharness.js-based test.
Found 1252 tests; 1232 PASS, 20 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 1252 tests; 1247 PASS, 5 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface Window: original interface defined
......@@ -884,27 +884,27 @@ PASS EventTarget interface: document.createComment("abc") must inherit property
PASS EventTarget interface: calling removeEventListener(DOMString, EventListener?, optional (EventListenerOptions or boolean)) on document.createComment("abc") with too few arguments must throw TypeError
PASS EventTarget interface: document.createComment("abc") must inherit property "dispatchEvent(Event)" with the proper type
PASS EventTarget interface: calling dispatchEvent(Event) on document.createComment("abc") with too few arguments must throw TypeError
FAIL AbstractRange interface: existence and properties of interface object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface object length assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface object name assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: existence and properties of interface prototype object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: attribute startContainer assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: attribute startOffset assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: attribute endContainer assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: attribute endOffset assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL AbstractRange interface: attribute collapsed assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
FAIL StaticRange interface: existence and properties of interface object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
PASS AbstractRange interface: existence and properties of interface object
PASS AbstractRange interface object length
PASS AbstractRange interface object name
PASS AbstractRange interface: existence and properties of interface prototype object
PASS AbstractRange interface: existence and properties of interface prototype object's "constructor" property
PASS AbstractRange interface: existence and properties of interface prototype object's @@unscopables property
PASS AbstractRange interface: attribute startContainer
PASS AbstractRange interface: attribute startOffset
PASS AbstractRange interface: attribute endContainer
PASS AbstractRange interface: attribute endOffset
PASS AbstractRange interface: attribute collapsed
PASS StaticRange interface: existence and properties of interface object
FAIL StaticRange interface object length assert_equals: wrong value for StaticRange.length expected 1 but got 0
PASS StaticRange interface object name
FAIL StaticRange interface: existence and properties of interface prototype object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
PASS StaticRange interface: existence and properties of interface prototype object
PASS StaticRange interface: existence and properties of interface prototype object's "constructor" property
PASS StaticRange interface: existence and properties of interface prototype object's @@unscopables property
FAIL Range interface: existence and properties of interface object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
PASS Range interface: existence and properties of interface object
PASS Range interface object length
PASS Range interface object name
FAIL Range interface: existence and properties of interface prototype object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
PASS Range interface: existence and properties of interface prototype object
PASS Range interface: existence and properties of interface prototype object's "constructor" property
PASS Range interface: existence and properties of interface prototype object's @@unscopables property
PASS Range interface: attribute commonAncestorContainer
......
......@@ -17,6 +17,14 @@ interface AbortSignal : EventTarget
interface AbsoluteOrientationSensor : OrientationSensor
attribute @@toStringTag
method constructor
interface AbstractRange
attribute @@toStringTag
getter collapsed
getter endContainer
getter endOffset
getter startContainer
getter startOffset
method constructor
interface Accelerometer : Sensor
attribute @@toStringTag
getter x
......@@ -5613,18 +5621,13 @@ interface RadioNodeList : NodeList
method @@iterator
method constructor
setter value
interface Range
interface Range : AbstractRange
attribute @@toStringTag
attribute END_TO_END
attribute END_TO_START
attribute START_TO_END
attribute START_TO_START
getter collapsed
getter commonAncestorContainer
getter endContainer
getter endOffset
getter startContainer
getter startOffset
method cloneContents
method cloneRange
method collapse
......@@ -7175,13 +7178,8 @@ interface SpeechSynthesisUtterance : EventTarget
setter text
setter voice
setter volume
interface StaticRange
interface StaticRange : AbstractRange
attribute @@toStringTag
getter collapsed
getter endContainer
getter endOffset
getter startContainer
getter startOffset
method constructor
interface StereoPannerNode : AudioNode
attribute @@toStringTag
......
......@@ -17,6 +17,14 @@ interface AbortSignal : EventTarget
interface AbsoluteOrientationSensor : OrientationSensor
attribute @@toStringTag
method constructor
interface AbstractRange
attribute @@toStringTag
getter collapsed
getter endContainer
getter endOffset
getter startContainer
getter startOffset
method constructor
interface Accelerometer : Sensor
attribute @@toStringTag
getter x
......@@ -6591,18 +6599,13 @@ interface RadioNodeList : NodeList
method @@iterator
method constructor
setter value
interface Range
interface Range : AbstractRange
attribute @@toStringTag
attribute END_TO_END
attribute END_TO_START
attribute START_TO_END
attribute START_TO_START
getter collapsed
getter commonAncestorContainer
getter endContainer
getter endOffset
getter startContainer
getter startOffset
method cloneContents
method cloneRange
method collapse
......@@ -8204,13 +8207,8 @@ interface SpeechSynthesisUtterance : EventTarget
setter text
setter voice
setter volume
interface StaticRange
interface StaticRange : AbstractRange
attribute @@toStringTag
getter collapsed
getter endContainer
getter endOffset
getter startContainer
getter startOffset
method constructor
interface StereoPannerNode : AudioNode
attribute @@toStringTag
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment