Commit 1644eff7 authored by Nick Burris's avatar Nick Burris Committed by Commit Bot

Update scroll to text feature detectability API

Update the feature detectability API to
window.location.fragmentDirective per
https://github.com/WICG/ScrollToTextFragment/issues/19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705010}
parent e980e86d
...@@ -187,6 +187,7 @@ core_idl_files = ...@@ -187,6 +187,7 @@ core_idl_files =
"frame/deprecation_report_body.idl", "frame/deprecation_report_body.idl",
"frame/external.idl", "frame/external.idl",
"frame/feature_policy_violation_report_body.idl", "frame/feature_policy_violation_report_body.idl",
"frame/fragment_directive.idl",
"frame/history.idl", "frame/history.idl",
"frame/intervention_report_body.idl", "frame/intervention_report_body.idl",
"frame/location.idl", "frame/location.idl",
...@@ -194,7 +195,6 @@ core_idl_files = ...@@ -194,7 +195,6 @@ core_idl_files =
"frame/report_body.idl", "frame/report_body.idl",
"frame/reporting_observer.idl", "frame/reporting_observer.idl",
"frame/scheduling.idl", "frame/scheduling.idl",
"frame/selector.idl",
"frame/test_report_body.idl", "frame/test_report_body.idl",
"frame/user_activation.idl", "frame/user_activation.idl",
"frame/visual_viewport.idl", "frame/visual_viewport.idl",
......
...@@ -57,6 +57,7 @@ blink_core_sources("frame") { ...@@ -57,6 +57,7 @@ blink_core_sources("frame") {
"feature_policy_violation_report_body.h", "feature_policy_violation_report_body.h",
"find_in_page.cc", "find_in_page.cc",
"find_in_page.h", "find_in_page.h",
"fragment_directive.h",
"frame.cc", "frame.cc",
"frame.h", "frame.h",
"frame_client.h", "frame_client.h",
...@@ -168,7 +169,6 @@ blink_core_sources("frame") { ...@@ -168,7 +169,6 @@ blink_core_sources("frame") {
"screen.h", "screen.h",
"screen_orientation_controller.cc", "screen_orientation_controller.cc",
"screen_orientation_controller.h", "screen_orientation_controller.h",
"selector.h",
"settings.cc", "settings.cc",
"settings.h", "settings.h",
"settings_delegate.cc", "settings_delegate.cc",
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_SELECTOR_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_FRAGMENT_DIRECTIVE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_SELECTOR_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_FRAGMENT_DIRECTIVE_H_
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
namespace blink { namespace blink {
// TODO(crbug/1000308): Implement the Selector type. This member currently // TODO(crbug/1000308): Implement the FragmentDirective type. This member
// serves as a feature detectable API for the Text Fragment Identifiers // currently serves as a feature detectable API for the Text Fragment
// feature. // Identifiers feature.
class Selector : public ScriptWrappable { class FragmentDirective : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_SELECTOR_H_ #endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_FRAGMENT_DIRECTIVE_H_
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
// https://github.com/WICG/ScrollToTextFragment // https://github.com/WICG/ScrollToTextFragment
[RuntimeEnabled=TextFragmentIdentifiers] [RuntimeEnabled=TextFragmentIdentifiers]
interface Selector { interface FragmentDirective {
}; };
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h" #include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/dom_window.h" #include "third_party/blink/renderer/core/frame/dom_window.h"
#include "third_party/blink/renderer/core/frame/fragment_directive.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/selector.h"
#include "third_party/blink/renderer/core/loader/frame_load_request.h" #include "third_party/blink/renderer/core/loader/frame_load_request.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h" #include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_types_util.h" #include "third_party/blink/renderer/core/trustedtypes/trusted_types_util.h"
...@@ -47,11 +47,12 @@ ...@@ -47,11 +47,12 @@
namespace blink { namespace blink {
Location::Location(DOMWindow* dom_window) Location::Location(DOMWindow* dom_window)
: dom_window_(dom_window), selector_(MakeGarbageCollected<Selector>()) {} : dom_window_(dom_window),
fragment_directive_(MakeGarbageCollected<FragmentDirective>()) {}
void Location::Trace(blink::Visitor* visitor) { void Location::Trace(blink::Visitor* visitor) {
visitor->Trace(dom_window_); visitor->Trace(dom_window_);
visitor->Trace(selector_); visitor->Trace(fragment_directive_);
ScriptWrappable::Trace(visitor); ScriptWrappable::Trace(visitor);
} }
...@@ -98,8 +99,8 @@ String Location::origin() const { ...@@ -98,8 +99,8 @@ String Location::origin() const {
return DOMURLUtilsReadOnly::origin(Url()); return DOMURLUtilsReadOnly::origin(Url());
} }
Selector* Location::selector() const { FragmentDirective* Location::fragmentDirective() const {
return selector_; return fragment_directive_;
} }
DOMStringList* Location::ancestorOrigins() const { DOMStringList* Location::ancestorOrigins() const {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/dom_string_list.h" #include "third_party/blink/renderer/core/dom/dom_string_list.h"
#include "third_party/blink/renderer/core/frame/dom_window.h" #include "third_party/blink/renderer/core/frame/dom_window.h"
#include "third_party/blink/renderer/core/frame/selector.h" #include "third_party/blink/renderer/core/frame/fragment_directive.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -83,7 +83,7 @@ class CORE_EXPORT Location final : public ScriptWrappable { ...@@ -83,7 +83,7 @@ class CORE_EXPORT Location final : public ScriptWrappable {
DOMStringList* ancestorOrigins() const; DOMStringList* ancestorOrigins() const;
Selector* selector() const; FragmentDirective* fragmentDirective() const;
// Just return the |this| object the way the normal valueOf function on the // Just return the |this| object the way the normal valueOf function on the
// Object prototype would. The valueOf function is only added to make sure // Object prototype would. The valueOf function is only added to make sure
...@@ -116,7 +116,7 @@ class CORE_EXPORT Location final : public ScriptWrappable { ...@@ -116,7 +116,7 @@ class CORE_EXPORT Location final : public ScriptWrappable {
const Member<DOMWindow> dom_window_; const Member<DOMWindow> dom_window_;
Member<Selector> selector_; Member<FragmentDirective> fragment_directive_;
}; };
} // namespace blink } // namespace blink
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
[SetterCallWith=Isolate, RaisesException=Setter, Unforgeable] attribute USVString search; [SetterCallWith=Isolate, RaisesException=Setter, Unforgeable] attribute USVString search;
[SetterCallWith=Isolate, RaisesException=Setter, Unforgeable] attribute USVString hash; [SetterCallWith=Isolate, RaisesException=Setter, Unforgeable] attribute USVString hash;
[RuntimeEnabled=TextFragmentIdentifiers] readonly attribute Selector selector; [RuntimeEnabled=TextFragmentIdentifiers] readonly attribute FragmentDirective fragmentDirective;
// TODO(foolip): Location does not have a valueOf() override in the spec. // TODO(foolip): Location does not have a valueOf() override in the spec.
// See the comment in Location.h for the purpose of this. // See the comment in Location.h for the purpose of this.
......
...@@ -24,8 +24,8 @@ let test_cases = [ ...@@ -24,8 +24,8 @@ let test_cases = [
]; ];
test(t => { test(t => {
assert_equals(typeof(window.location.selector), 'object', 'window.location.selector is defined'); assert_equals(typeof(window.location.fragmentDirective), 'object', 'window.location.fragmentDirective is defined');
}, 'Scroll to text is feature detectable via window.location.selector'); }, 'Scroll to text is feature detectable via window.location.fragmentDirective');
for (const test_case of test_cases) { for (const test_case of test_cases) {
promise_test(t => new Promise(resolve => { promise_test(t => new Promise(resolve => {
......
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