Commit b111ee09 authored by Lam Lu's avatar Lam Lu Committed by Commit Bot

Add fontsUpdated event to devtools when init FontFace with byte data.

Notify devtools client on fontUdpated event when initialize CSS font
face with binary data. The current devtools fontUpdated event only
gets called when initialize font face from src url.

third_party/blink/tools/run_web_tests.py -t Release
third_party/blink/web_tests/inspector-protocol/css/
css-fonts-updated-event-with-data-buffer.js

Bug: 1095185
Test: autoninja -C out/Release blink_tests and run python
Change-Id: I8507953e3046c3c21e3bc9ec6e681961fb5a11de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247159
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784359}
parent d8951a5f
......@@ -582,6 +582,7 @@ Kyung Yeol Kim <chitacan@gmail.com>
Kyungtae Kim <ktf.kim@samsung.com>
Kyungyoung Heo <bbvch13531@gmail.com>
Lalit Chandivade <lalit.chandivade@einfochips.com>
Lam Lu <lamlu@amazon.com>
Laszlo Gombos <l.gombos@samsung.com>
Laszlo Radanyi <bekkra@gmail.com>
Lauren Yeun Kim <lauren.yeun.kim@gmail.com>
......
......@@ -4,6 +4,8 @@
#include "third_party/blink/renderer/core/css/binary_data_font_face_source.h"
#include "third_party/blink/renderer/core/css/css_font_face.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/platform/fonts/font_custom_platform_data.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
......@@ -11,10 +13,20 @@
namespace blink {
BinaryDataFontFaceSource::BinaryDataFontFaceSource(SharedBuffer* data,
BinaryDataFontFaceSource::BinaryDataFontFaceSource(CSSFontFace* css_font_face,
SharedBuffer* data,
String& ots_parse_message)
: custom_platform_data_(
FontCustomPlatformData::Create(data, ots_parse_message)) {}
FontCustomPlatformData::Create(data, ots_parse_message)) {
if (!css_font_face || !css_font_face->GetFontFace())
return;
FontFace* font_face = css_font_face->GetFontFace();
ExecutionContext* context = font_face->GetExecutionContext();
if (!context)
return;
probe::FontsUpdated(context, font_face, String(),
custom_platform_data_.get());
}
BinaryDataFontFaceSource::~BinaryDataFontFaceSource() = default;
......
......@@ -10,11 +10,12 @@
namespace blink {
class CSSFontFace;
class FontCustomPlatformData;
class BinaryDataFontFaceSource final : public CSSFontFaceSource {
public:
BinaryDataFontFaceSource(SharedBuffer*, String&);
BinaryDataFontFaceSource(CSSFontFace*, SharedBuffer*, String&);
~BinaryDataFontFaceSource() override;
bool IsValid() const override;
......
......@@ -773,8 +773,8 @@ void FontFace::InitCSSFontFace(const unsigned char* data, size_t size) {
scoped_refptr<SharedBuffer> buffer = SharedBuffer::Create(data, size);
BinaryDataFontFaceSource* source =
MakeGarbageCollected<BinaryDataFontFaceSource>(buffer.get(),
ots_parse_message_);
MakeGarbageCollected<BinaryDataFontFaceSource>(
css_font_face_, buffer.get(), ots_parse_message_);
if (source->IsValid()) {
SetLoadStatus(kLoaded);
} else {
......
......@@ -770,7 +770,7 @@ void InspectorCSSAgent::FontsUpdated(
const FontCustomPlatformData* fontCustomPlatformData) {
FlushPendingProtocolNotifications();
if (!(font && src && fontCustomPlatformData)) {
if (!(font && fontCustomPlatformData)) {
GetFrontend()->fontsUpdated();
return;
}
......
Verifies that CSS.fontsUpdated events are sent as the web font is loaded by font data buffer.
Ahem
normal
normal
normal
normal
U+0-10FFFF
Ahem
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(`Verifies that CSS.fontsUpdated events are sent as the web font is loaded by font data buffer.`);
await dp.DOM.enable();
await dp.CSS.enable();
session.evaluate(`
const script = document.createElement('script');
script.src = '../../resources/ahem.js';
document.head.appendChild(script);
`);
event = await dp.CSS.onceFontsUpdated(
event => typeof event.params.font !== 'undefined' &&
event.params.font.fontFamily === 'Ahem');
const font = event.params.font;
testRunner.log(font.fontFamily); // Ahem
testRunner.log(font.fontStyle); // normal
testRunner.log(font.fontVariant); // normal
testRunner.log(font.fontWeight); // normal
testRunner.log(font.fontStretch); // normal
testRunner.log(font.unicodeRange); // U+0-10FFFF
testRunner.log(font.platformFontFamily); // Ahem
testRunner.log(font.src); // Empty
testRunner.completeTest();
});
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