Commit 63997d3d authored by Olivier Yiptong's avatar Olivier Yiptong Committed by Commit Bot

FontAccess: Initial font chooser interface

This creates the initial API to initiate a font chooser, behind a flag.
It is different from enumeration at this point for now because the
use-cases they are trying to solve are different.

Both could be unified in the future.

Change-Id: I55d2ac5079f325d86e62e2a348380507b53ea681
Bug: 1138621
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2488602Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Auto-Submit: Olivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820658}
parent 3c1dcd02
...@@ -251,6 +251,7 @@ static_idl_files_in_modules = get_path_info( ...@@ -251,6 +251,7 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/font_access/font_metadata.idl", "//third_party/blink/renderer/modules/font_access/font_metadata.idl",
"//third_party/blink/renderer/modules/font_access/font_table_map.idl", "//third_party/blink/renderer/modules/font_access/font_table_map.idl",
"//third_party/blink/renderer/modules/font_access/navigator_fonts.idl", "//third_party/blink/renderer/modules/font_access/navigator_fonts.idl",
"//third_party/blink/renderer/modules/font_access/query_options.idl",
"//third_party/blink/renderer/modules/gamepad/gamepad.idl", "//third_party/blink/renderer/modules/gamepad/gamepad.idl",
"//third_party/blink/renderer/modules/gamepad/gamepad_axis_event.idl", "//third_party/blink/renderer/modules/gamepad/gamepad_axis_event.idl",
"//third_party/blink/renderer/modules/gamepad/gamepad_axis_event_init.idl", "//third_party/blink/renderer/modules/gamepad/gamepad_axis_event_init.idl",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h" #include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/dom/dom_exception.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/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/font_access/font_iterator.h" #include "third_party/blink/renderer/modules/font_access/font_iterator.h"
...@@ -46,6 +47,14 @@ ScriptValue FontManager::query(ScriptState* script_state, ...@@ -46,6 +47,14 @@ ScriptValue FontManager::query(ScriptState* script_state,
return ScriptValue(script_state->GetIsolate(), result); return ScriptValue(script_state->GetIsolate(), result);
} }
ScriptPromise FontManager::showFontChooser(ScriptState* script_state,
const QueryOptions* options) {
return ScriptPromise::RejectWithDOMException(
script_state,
MakeGarbageCollected<DOMException>(DOMExceptionCode::kNotSupportedError,
"Not implemented yet"));
}
void FontManager::Trace(blink::Visitor* visitor) const { void FontManager::Trace(blink::Visitor* visitor) const {
ScriptWrappable::Trace(visitor); ScriptWrappable::Trace(visitor);
} }
......
...@@ -14,6 +14,8 @@ namespace blink { ...@@ -14,6 +14,8 @@ namespace blink {
class ScriptState; class ScriptState;
class ScriptValue; class ScriptValue;
class ScriptPromise;
class QueryOptions;
class FontManager final : public ScriptWrappable { class FontManager final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
...@@ -25,7 +27,9 @@ class FontManager final : public ScriptWrappable { ...@@ -25,7 +27,9 @@ class FontManager final : public ScriptWrappable {
FontManager(const FontManager&) = delete; FontManager(const FontManager&) = delete;
FontManager operator=(const FontManager&) = delete; FontManager operator=(const FontManager&) = delete;
// FontManager IDL interface implementation.
ScriptValue query(ScriptState*, ExceptionState&); ScriptValue query(ScriptState*, ExceptionState&);
ScriptPromise showFontChooser(ScriptState*, const QueryOptions* options);
void Trace(blink::Visitor*) const override; void Trace(blink::Visitor*) const override;
}; };
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// 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.
// TODO(https://crbug.com/1062766): Update spec documents with objects as implemented.
// https://wicg.github.io/local-font-access/ // https://wicg.github.io/local-font-access/
[ [
Exposed=(Window,Worker), Exposed=(Window,Worker),
...@@ -10,4 +9,5 @@ ...@@ -10,4 +9,5 @@
RuntimeEnabled=FontAccess RuntimeEnabled=FontAccess
] interface FontManager { ] interface FontManager {
[CallWith=ScriptState, RaisesException, Measure] object query(); [CallWith=ScriptState, RaisesException, Measure] object query();
[CallWith=ScriptState, RuntimeEnabled=FontAccessChooser] Promise<FontIterator> showFontChooser(optional QueryOptions options = {});
}; };
...@@ -9,6 +9,9 @@ modules_idl_files = [ ...@@ -9,6 +9,9 @@ modules_idl_files = [
"font_manager.idl", "font_manager.idl",
] ]
modules_dictionary_idl_files = [ "font_iterator_entry.idl" ] modules_dictionary_idl_files = [
"font_iterator_entry.idl",
"query_options.idl",
]
modules_dependency_idl_files = [ "navigator_fonts.idl" ] modules_dependency_idl_files = [ "navigator_fonts.idl" ]
// Copyright 2020 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://wicg.github.io/local-font-access/
dictionary QueryOptions {
boolean all = false;
sequence<ByteString> fonts;
};
...@@ -867,6 +867,12 @@ ...@@ -867,6 +867,12 @@
// It's controlled by the corresponding Chromium feature which needs to // It's controlled by the corresponding Chromium feature which needs to
// be enabled to make the whole feature work. // be enabled to make the whole feature work.
}, },
{
name: "FontAccessChooser",
// TODO(crbug.com/1000486): Add when the Origin Trial dependency bug is fixed.
// depends_on: ["FontAccess"],
status: "experimental",
},
{ {
name: "FontSrcLocalMatching", name: "FontSrcLocalMatching",
// No status, as the web platform runtime enabled feature is controlled by // No status, as the web platform runtime enabled feature is controlled by
......
...@@ -2205,8 +2205,13 @@ crbug.com/626703 [ Win ] external/wpt/html/editing/dnd/events/historical-manual. ...@@ -2205,8 +2205,13 @@ crbug.com/626703 [ Win ] external/wpt/html/editing/dnd/events/historical-manual.
# Remove from virtual tests when FontAccess is turned on by default. # Remove from virtual tests when FontAccess is turned on by default.
external/wpt/font-access/font_access-blob.tentative.https.window.html [ Skip ] external/wpt/font-access/font_access-blob.tentative.https.window.html [ Skip ]
external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Skip ] external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Skip ]
external/wpt/font-access/font_access-chooser.tentative.https.window.html [ Skip ]
virtual/font-access/external/wpt/font-access/font_access-blob.tentative.https.window.html [ Pass ] virtual/font-access/external/wpt/font-access/font_access-blob.tentative.https.window.html [ Pass ]
virtual/font-access/external/wpt/font-access/font_access-chooser.tentative.https.window.html [ Skip ]
virtual/font-access/external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Pass ] virtual/font-access/external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Pass ]
virtual/font-access-chooser/external/wpt/font-access/font_access-blob.tentative.https.window.html [ Skip ]
virtual/font-access-chooser/external/wpt/font-access/font_access-chooser.tentative.https.window.html [ Pass ]
virtual/font-access-chooser/external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Skip ]
# text-orientation:upright # text-orientation:upright
crbug.com/1005518 external/wpt/css/css-writing-modes/table-progression-vlr-003.html [ Skip ] crbug.com/1005518 external/wpt/css/css-writing-modes/table-progression-vlr-003.html [ Skip ]
......
...@@ -1269,6 +1269,7 @@ crbug.com/626703 external/wpt/css/css-text/text-transform/math/text-transform-ma ...@@ -1269,6 +1269,7 @@ crbug.com/626703 external/wpt/css/css-text/text-transform/math/text-transform-ma
crbug.com/626703 external/wpt/css/css-text/text-transform/math/text-transform-math-sans-serif-001.tentative.html [ Failure ] crbug.com/626703 external/wpt/css/css-text/text-transform/math/text-transform-math-sans-serif-001.tentative.html [ Failure ]
crbug.com/1043295 [ Fuchsia ] virtual/font-access/external/wpt/font-access/font_access-blob.tentative.https.window.html [ Skip ] crbug.com/1043295 [ Fuchsia ] virtual/font-access/external/wpt/font-access/font_access-blob.tentative.https.window.html [ Skip ]
crbug.com/1043295 [ Fuchsia ] virtual/font-access/external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Skip ] crbug.com/1043295 [ Fuchsia ] virtual/font-access/external/wpt/font-access/font_access-enumeration.tentative.https.window.html [ Skip ]
crbug.com/1043295 [ Fuchsia ] virtual/font-access-chooser/external/wpt/font-access/font_access-chooser.tentative.https.window.html [ Skip ]
# ====== Style team owned tests from here ====== # ====== Style team owned tests from here ======
......
...@@ -190,6 +190,11 @@ ...@@ -190,6 +190,11 @@
"bases": ["external/wpt/font-access"], "bases": ["external/wpt/font-access"],
"args": ["--enable-features=FontAccess"] "args": ["--enable-features=FontAccess"]
}, },
{
"prefix": "font-access-chooser",
"bases": ["external/wpt/font-access"],
"args": ["--enable-features=FontAccess,FontAccessChooser"]
},
{ {
"prefix": "highdpi-threaded", "prefix": "highdpi-threaded",
"bases": ["external/wpt/css/css-paint-api/hidpi"], "bases": ["external/wpt/css/css-paint-api/hidpi"],
......
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/test-expectations.js
// META: script=resources/window-tests-chooser.js
'use strict';
font_access_test(async t => {
await promise_rejects_dom(
t, 'NotSupportedError', navigator.fonts.showFontChooser());
await promise_rejects_dom(
t, 'NotSupportedError', navigator.fonts.showFontChooser({all: false}));
});
file://third_party/blink/renderer/modules/font_access/OWNERS
# This suite runs tests with --enable-features=FontAccess,FontAccessChooser
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