Commit a14cdad8 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Revert "Connect Linux Font Unique Name Lookup to Blink"

This reverts commit 5bc5a4c5.

Reason for revert: Test passes only flakily on Linux

Original change's description:
> Connect Linux Font Unique Name Lookup to Blink
> 
> Provide a new subclass for font unique name lookup for Linux. Connect
> via WebSandboxSupport to FontLoader which provides the out of process
> fontconfig calls for us. Tested by content_browsertests with a DevTools
> based test checking used fonts. This test was previously active on
> Android and is enabled for Linux in this CL.
> 
> Bug: 880832
> Change-Id: I04d72fc1cfcfa55a01a9877ac8a3a45dbff38771
> Reviewed-on: https://chromium-review.googlesource.com/1206337
> Commit-Queue: Dominik Röttsches <drott@chromium.org>
> Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
> Reviewed-by: Emil A Eklund <eae@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#589482}

TBR=dgozman@chromium.org,eae@chromium.org,drott@chromium.org

Change-Id: I811960048b2f37130e4be4cb9c693dc90040f30d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 880832
Reviewed-on: https://chromium-review.googlesource.com/1213168Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589500}
parent 31fba9dc
...@@ -210,12 +210,9 @@ void FontServiceApp::MatchFontByPostscriptNameOrFullFontName( ...@@ -210,12 +210,9 @@ void FontServiceApp::MatchFontByPostscriptNameOrFullFontName(
base::Optional<FontConfigLocalMatching::FontConfigMatchResult> match_result = base::Optional<FontConfigLocalMatching::FontConfigMatchResult> match_result =
FontConfigLocalMatching::FindFontByPostscriptNameOrFullFontName(family); FontConfigLocalMatching::FindFontByPostscriptNameOrFullFontName(family);
if (match_result) { if (match_result) {
uint32_t fontconfig_interface_id = mojom::FontIdentityPtr font_identity = mojom::FontIdentityPtr(
FindOrAddPath(SkString(match_result->file_path.value().c_str())); mojom::FontIdentity::New(0, match_result->ttc_index,
mojom::FontIdentityPtr font_identity = match_result->file_path.AsUTF8Unsafe()));
mojom::FontIdentityPtr(mojom::FontIdentity::New(
fontconfig_interface_id, match_result->ttc_index,
match_result->file_path.value()));
std::move(callback).Run(std::move(font_identity)); std::move(callback).Run(std::move(font_identity));
return; return;
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
namespace content { namespace content {
namespace { namespace {
#if defined(OS_ANDROID)
const char* kExpectedFontFamilyNames[] = {"AndroidClock", const char* kExpectedFontFamilyNames[] = {"AndroidClock",
"Roboto", "Roboto",
"Droid Sans Mono", "Droid Sans Mono",
...@@ -60,34 +59,6 @@ const char* kExpectedFontFamilyNames[] = {"AndroidClock", ...@@ -60,34 +59,6 @@ const char* kExpectedFontFamilyNames[] = {"AndroidClock",
"Roboto Condensed", "Roboto Condensed",
"Roboto Condensed", "Roboto Condensed",
"Roboto"}; "Roboto"};
#elif defined(OS_LINUX)
const char* kExpectedFontFamilyNames[] = {"Ahem",
"Arimo",
"Arimo",
"Arimo",
"Arimo",
"Cousine",
"Cousine",
"Cousine",
"Cousine",
"DejaVu Sans",
"DejaVu Sans",
"Garuda",
"Gelasio",
"Gelasio",
"Gelasio",
"Gelasio",
"Lohit Devanagari",
"Lohit Gurmukhi",
"Lohit Tamil",
"Noto Sans Khmer",
"Tinos",
"Tinos",
"Tinos",
"Tinos",
"Mukti Narrow",
"Tinos"};
#endif
} // namespace } // namespace
...@@ -109,9 +80,13 @@ class FontUniqueNameBrowserTest : public DevToolsProtocolTest { ...@@ -109,9 +80,13 @@ class FontUniqueNameBrowserTest : public DevToolsProtocolTest {
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
}; };
// TODO(drott): Enable this on all platforms. #if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_LINUX) #define MAYBE_ContentLocalFontsMatching ContentLocalFontsMatching
IN_PROC_BROWSER_TEST_F(FontUniqueNameBrowserTest, ContentLocalFontsMatching) { #else
#define MAYBE_ContentLocalFontsMatching DISABLED_ContentLocalFontsMatching
#endif
IN_PROC_BROWSER_TEST_F(FontUniqueNameBrowserTest,
MAYBE_ContentLocalFontsMatching) {
LoadAndWait("/font_src_local_matching.html"); LoadAndWait("/font_src_local_matching.html");
Attach(); Attach();
...@@ -161,6 +136,5 @@ IN_PROC_BROWSER_TEST_F(FontUniqueNameBrowserTest, ContentLocalFontsMatching) { ...@@ -161,6 +136,5 @@ IN_PROC_BROWSER_TEST_F(FontUniqueNameBrowserTest, ContentLocalFontsMatching) {
ASSERT_EQ(first_font_name->GetString(), kExpectedFontFamilyNames[i]); ASSERT_EQ(first_font_name->GetString(), kExpectedFontFamilyNames[i]);
} }
} }
#endif
} // namespace content } // namespace content
...@@ -94,23 +94,4 @@ void GetRenderStyleForStrike(sk_sp<font_service::FontLoader> font_loader, ...@@ -94,23 +94,4 @@ void GetRenderStyleForStrike(sk_sp<font_service::FontLoader> font_loader,
static_cast<char>(font_render_style->use_subpixel_positioning); static_cast<char>(font_render_style->use_subpixel_positioning);
} }
void MatchFontByPostscriptNameOrFullFontName(
sk_sp<font_service::FontLoader> font_loader,
const char* font_unique_name,
blink::OutOfProcessFont* fallback_font) {
font_service::mojom::FontIdentityPtr font_identity;
std::string family_name;
if (!font_loader->MatchFontByPostscriptNameOrFullFontName(font_unique_name,
&font_identity)) {
LOG(ERROR) << "FontService unique font name matching request did not "
"receive a response.";
return;
}
fallback_font->fontconfig_interface_id = font_identity->id;
fallback_font->filename.Assign(font_identity->str_representation.c_str(),
font_identity->str_representation.length());
fallback_font->ttc_index = font_identity->ttc_index;
}
} // namespace content } // namespace content
...@@ -38,16 +38,6 @@ void GetRenderStyleForStrike(sk_sp<font_service::FontLoader> font_loader, ...@@ -38,16 +38,6 @@ void GetRenderStyleForStrike(sk_sp<font_service::FontLoader> font_loader,
float device_scale_factor, float device_scale_factor,
blink::WebFontRenderStyle* out); blink::WebFontRenderStyle* out);
// Matches a font uniquely by postscript name or full font name. Used in Blink
// for @font-face { src: local(arg) } matching. Provide full font name or
// postscript name as argument font_unique_name in UTF-8. fallback_font contains
// a filename and fontconfig interface id if a match was found. The filename is
// empty and the interface id is zero if no match is found.
void MatchFontByPostscriptNameOrFullFontName(
sk_sp<font_service::FontLoader> font_loader,
const char* font_unique_name,
blink::OutOfProcessFont* uniquely_matched_font);
}; // namespace content }; // namespace content
#endif // CONTENT_CHILD_CHILD_PROCESS_SANDBOX_SUPPORT_IMPL_LINUX_H_ #endif // CONTENT_CHILD_CHILD_PROCESS_SANDBOX_SUPPORT_IMPL_LINUX_H_
...@@ -54,9 +54,6 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport { ...@@ -54,9 +54,6 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport {
WebUChar32 character, WebUChar32 character,
const char* preferred_locale, const char* preferred_locale,
blink::OutOfProcessFont* fallbackFont) override; blink::OutOfProcessFont* fallbackFont) override;
void MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
blink::OutOfProcessFont* fallback_font) override;
void GetWebFontRenderStyleForStrike(const char* family, void GetWebFontRenderStyleForStrike(const char* family,
int size, int size,
bool is_bold, bool is_bold,
...@@ -127,14 +124,6 @@ void PpapiBlinkPlatformImpl::SandboxSupport::GetWebFontRenderStyleForStrike( ...@@ -127,14 +124,6 @@ void PpapiBlinkPlatformImpl::SandboxSupport::GetWebFontRenderStyleForStrike(
device_scale_factor, out); device_scale_factor, out);
} }
void PpapiBlinkPlatformImpl::SandboxSupport::
MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
blink::OutOfProcessFont* uniquely_matched_font) {
content::MatchFontByPostscriptNameOrFullFontName(
font_loader_, font_unique_name, uniquely_matched_font);
}
#endif #endif
#endif // !defined(OS_ANDROID) && !defined(OS_WIN) #endif // !defined(OS_ANDROID) && !defined(OS_WIN)
......
...@@ -223,9 +223,6 @@ class RendererBlinkPlatformImpl::SandboxSupport ...@@ -223,9 +223,6 @@ class RendererBlinkPlatformImpl::SandboxSupport
blink::WebUChar32 character, blink::WebUChar32 character,
const char* preferred_locale, const char* preferred_locale,
blink::OutOfProcessFont* fallbackFont) override; blink::OutOfProcessFont* fallbackFont) override;
void MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
blink::OutOfProcessFont* fallback_font) override;
void GetWebFontRenderStyleForStrike(const char* family, void GetWebFontRenderStyleForStrike(const char* family,
int size, int size,
bool is_bold, bool is_bold,
...@@ -630,14 +627,6 @@ void RendererBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter( ...@@ -630,14 +627,6 @@ void RendererBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter(
unicode_font_families_.insert(std::make_pair(character, *fallbackFont)); unicode_font_families_.insert(std::make_pair(character, *fallbackFont));
} }
void RendererBlinkPlatformImpl::SandboxSupport::
MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
blink::OutOfProcessFont* fallback_font) {
content::MatchFontByPostscriptNameOrFullFontName(
font_loader_, font_unique_name, fallback_font);
}
void RendererBlinkPlatformImpl::SandboxSupport::GetWebFontRenderStyleForStrike( void RendererBlinkPlatformImpl::SandboxSupport::GetWebFontRenderStyleForStrike(
const char* family, const char* family,
int size, int size,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<body> <body>
<script> <script>
function getFontsWithTestCharsForOS() { function getFontsWithTestCharsForOS() {
if (navigator.userAgent.indexOf("Android") !== -1) { if (navigator.userAgent.indexOf("Android") !== -1)
// Intersection of available fonts of Android Kitkat to Oreo that kept the // Intersection of available fonts of Android Kitkat to Oreo that kept the
// same family names to compare against for these postscript or full font // same family names to compare against for these postscript or full font
// names. (RobotoThin* and RobotoLight* had differing family names on // names. (RobotoThin* and RobotoLight* had differing family names on
...@@ -54,37 +54,6 @@ function getFontsWithTestCharsForOS() { ...@@ -54,37 +54,6 @@ function getFontsWithTestCharsForOS() {
["RobotoCondensed-Regular", "0"], ["RobotoCondensed-Regular", "0"],
["Roboto-Italic", "0"], ["Roboto-Italic", "0"],
]; ];
} else if (navigator.userAgent.indexOf("Linux") !== -1
|| navigator.userAgent.indexOf("CrOS") !== -1) {
return [
["Ahem", "0"],
["Arimo-Bold", "0"],
["Arimo-BoldItalic", "0"],
["Arimo-Italic", "0"],
["Arimo-Regular", "0"],
["Cousine-Bold", "0"],
["Cousine-BoldItalic", "0"],
["Cousine-Italic", "0"],
["Cousine-Regular", "0"],
["DejaVuSans", "0"],
["DejaVuSans-Bold", "0"],
["Garuda", "0"],
["Gelasio-Bold", "0"],
["Gelasio-BoldItalic", "0"],
["Gelasio-Italic", "0"],
["Gelasio-Regular", "0"],
["Lohit-Devanagari", "0"],
["Lohit-Gurmukhi", "0"],
["Lohit-Tamil", "0"],
["NotoSansKhmer-Regular", ""],
["Tinos-Bold", "0"],
["Tinos-BoldItalic", "0"],
["Tinos-Italic", "0"],
["Tinos-Regular", "0"],
["muktinarrow", "0"],
["Tinos-Regular", "0"]
];
}
return []; return [];
} }
......
...@@ -45,9 +45,6 @@ class UtilityBlinkPlatformWithSandboxSupportImpl::SandboxSupport ...@@ -45,9 +45,6 @@ class UtilityBlinkPlatformWithSandboxSupportImpl::SandboxSupport
blink::WebUChar32 character, blink::WebUChar32 character,
const char* preferred_locale, const char* preferred_locale,
blink::OutOfProcessFont* fallbackFont) override; blink::OutOfProcessFont* fallbackFont) override;
void MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
blink::OutOfProcessFont* uniquely_matched_font) override;
void GetWebFontRenderStyleForStrike(const char* family, void GetWebFontRenderStyleForStrike(const char* family,
int size, int size,
bool is_bold, bool is_bold,
...@@ -136,14 +133,6 @@ void UtilityBlinkPlatformWithSandboxSupportImpl::SandboxSupport:: ...@@ -136,14 +133,6 @@ void UtilityBlinkPlatformWithSandboxSupportImpl::SandboxSupport::
device_scale_factor, out); device_scale_factor, out);
} }
void UtilityBlinkPlatformWithSandboxSupportImpl::SandboxSupport::
MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
blink::OutOfProcessFont* uniquely_matched_font) {
content::MatchFontByPostscriptNameOrFullFontName(
font_loader_, font_unique_name, uniquely_matched_font);
}
#endif #endif
} // namespace content } // namespace content
...@@ -58,17 +58,6 @@ class WebSandboxSupport { ...@@ -58,17 +58,6 @@ class WebSandboxSupport {
const char* preferred_locale, const char* preferred_locale,
OutOfProcessFont*) = 0; OutOfProcessFont*) = 0;
// Get a OutOfProcessFont specification for a font uniquely identified by full
// font name or postscript name. Specify full font name or postscript name as
// argument in UTF-8.
//
// The OutOfProcessFont out parameter will contain a filename, ttc index and
// fontconfig interface id, with the italic and bold members set always
// initialised to false.
virtual void MatchFontByPostscriptNameOrFullFontName(
const char* font_unique_name,
OutOfProcessFont*) = 0;
// Fill out the given WebFontRenderStyle with the user's preferences for // Fill out the given WebFontRenderStyle with the user's preferences for
// rendering the given font at the given size (in pixels), given weight and // rendering the given font at the given size (in pixels), given weight and
// given slant and given device scale factor. The device scale factor is // given slant and given device scale factor. The device scale factor is
......
...@@ -660,8 +660,6 @@ jumbo_component("platform") { ...@@ -660,8 +660,6 @@ jumbo_component("platform") {
"fonts/generic_font_family_settings.h", "fonts/generic_font_family_settings.h",
"fonts/glyph_metrics_map.h", "fonts/glyph_metrics_map.h",
"fonts/linux/font_cache_linux.cc", "fonts/linux/font_cache_linux.cc",
"fonts/linux/font_unique_name_lookup_linux.cc",
"fonts/linux/font_unique_name_lookup_linux.h",
"fonts/mac/core_text_variations_support.cc", "fonts/mac/core_text_variations_support.cc",
"fonts/mac/core_text_variations_support.h", "fonts/mac/core_text_variations_support.h",
"fonts/mac/font_cache_mac.mm", "fonts/mac/font_cache_mac.mm",
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "third_party/blink/renderer/platform/fonts/android/font_unique_name_lookup_android.h" #include "third_party/blink/renderer/platform/fonts/android/font_unique_name_lookup_android.h"
#elif defined(OS_LINUX)
#include "third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.h"
#endif #endif
namespace blink { namespace blink {
...@@ -21,8 +19,6 @@ std::unique_ptr<FontUniqueNameLookup> ...@@ -21,8 +19,6 @@ std::unique_ptr<FontUniqueNameLookup>
FontUniqueNameLookup::GetPlatformUniqueNameLookup() { FontUniqueNameLookup::GetPlatformUniqueNameLookup() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return std::make_unique<FontUniqueNameLookupAndroid>(); return std::make_unique<FontUniqueNameLookupAndroid>();
#elif defined(OS_LINUX)
return std::make_unique<FontUniqueNameLookupLinux>();
#else #else
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
......
// Copyright 2018 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/platform/fonts/linux/font_unique_name_lookup_linux.h"
#include "third_party/blink/public/platform/linux/out_of_process_font.h"
#include "third_party/blink/public/platform/linux/web_sandbox_support.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_typeface.h"
namespace blink {
FontUniqueNameLookupLinux::~FontUniqueNameLookupLinux() = default;
sk_sp<SkTypeface> FontUniqueNameLookupLinux::MatchUniqueName(
const String& font_unique_name) {
OutOfProcessFont uniquely_matched_font;
if (!Platform::Current()->GetSandboxSupport()) {
LOG(ERROR) << "@font-face src: local() instantiation only available when "
"connected to browser process.";
DCHECK(Platform::Current()->GetSandboxSupport());
return nullptr;
}
Platform::Current()
->GetSandboxSupport()
->MatchFontByPostscriptNameOrFullFontName(
font_unique_name.Utf8(WTF::kStrictUTF8Conversion).data(),
&uniquely_matched_font);
if (!uniquely_matched_font.filename.size())
return nullptr;
cc::PaintTypeface paint_typeface =
cc::PaintTypeface::FromFontConfigInterfaceIdAndTtcIndex(
uniquely_matched_font.fontconfig_interface_id,
uniquely_matched_font.ttc_index);
return paint_typeface.ToSkTypeface();
}
} // namespace blink
// Copyright 2018 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_PLATFORM_FONTS_LINUX_FONT_UNIQUE_NAME_LOOKUP_LINUX_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_LINUX_FONT_UNIQUE_NAME_LOOKUP_LINUX_H_
#include "third_party/blink/renderer/platform/fonts/font_unique_name_lookup.h"
#include <memory>
namespace blink {
class FontUniqueNameLookupLinux : public FontUniqueNameLookup {
public:
FontUniqueNameLookupLinux() = default;
~FontUniqueNameLookupLinux() override;
sk_sp<SkTypeface> MatchUniqueName(const String& font_unique_name) override;
private:
DISALLOW_COPY_AND_ASSIGN(FontUniqueNameLookupLinux);
};
} // namespace blink
#endif
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
namespace blink { namespace blink {
#if defined(OS_ANDROID) || defined(OS_LINUX) #if defined(OS_ANDROID)
namespace { namespace {
static PaintTypeface CreateTypefaceFromUniqueName( static PaintTypeface CreateTypefaceFromUniqueName(
...@@ -299,7 +299,7 @@ std::unique_ptr<FontPlatformData> FontCache::CreateFontPlatformData( ...@@ -299,7 +299,7 @@ std::unique_ptr<FontPlatformData> FontCache::CreateFontPlatformData(
CString name; CString name;
PaintTypeface paint_tf; PaintTypeface paint_tf;
#if defined(OS_ANDROID) || defined(OS_LINUX) #if defined(OS_ANDROID)
if (alternate_name == AlternateFontName::kLocalUniqueFace && if (alternate_name == AlternateFontName::kLocalUniqueFace &&
RuntimeEnabledFeatures::FontSrcLocalMatchingEnabled()) { RuntimeEnabledFeatures::FontSrcLocalMatchingEnabled()) {
paint_tf = CreateTypefaceFromUniqueName(creation_params, name); paint_tf = CreateTypefaceFromUniqueName(creation_params, name);
......
...@@ -477,8 +477,7 @@ ...@@ -477,8 +477,7 @@
}, },
{ {
name: "FontSrcLocalMatching", name: "FontSrcLocalMatching",
// No status, as the web platform runtime enabled feature is controlled by status: "test",
// a Chromium level feature.
}, },
// For simulating Android's overlay fullscreen video in layout tests on Linux. // For simulating Android's overlay fullscreen video in layout tests on Linux.
{ {
......
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