0

Move content::GetFontTable() to pdf/.

It is only used PDF, as Flash has been deprecated. Move it out of
content/, to avoid a new content/ dependency in the near future.

Bug: 1139079
Change-Id: Ia3bc4e04037d236de62980664e2972ef50180c08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2967218
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894322}
This commit is contained in:
Lei Zhang
2021-06-21 18:47:54 +00:00
committed by Chromium LUCI CQ
parent 9ceb82bf10
commit aee2ce91e2
8 changed files with 40 additions and 27 deletions

@ -280,6 +280,10 @@ static_library("renderer") {
"//components/pdf/renderer",
"//pdf/mojom",
]
if (is_linux || is_chromeos) {
deps += [ "//pdf:font_table_linux" ]
}
}
if (is_chromeos_ash) {

@ -2,6 +2,7 @@ include_rules = [
"+components/nacl/common",
"+components/nacl/renderer",
"+components/services/font",
"+pdf/font_table_linux.h",
"+ppapi/c",
"+ppapi/host",
"+ppapi/proxy",

@ -18,7 +18,7 @@
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OPENBSD)
#include "components/services/font/public/cpp/font_loader.h"
#include "content/public/common/common_sandbox_support_linux.h"
#include "pdf/font_table_linux.h"
#elif defined(OS_WIN)
#include "third_party/skia/include/core/SkFontMgr.h"
#endif
@ -77,9 +77,9 @@ bool PepperFlashFontFileHost::GetFontData(uint32_t table,
bool result = false;
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
if (font_file_.IsValid()) {
result = content::GetFontTable(font_file_.GetPlatformFile(), table,
0 /* offset */,
reinterpret_cast<uint8_t*>(buffer), length);
result =
pdf::GetFontTable(font_file_.GetPlatformFile(), table, /*offset=*/0,
reinterpret_cast<uint8_t*>(buffer), length);
}
#elif defined(OS_WIN)
if (typeface_) {

@ -340,7 +340,6 @@ source_set("common") {
if (is_linux || is_chromeos) {
sources += [
"common_sandbox_support_linux.cc",
"sandbox_init_linux.cc",
"zygote/sandbox_support_linux.cc",
"zygote/send_zygote_child_ping_linux.cc",

@ -176,10 +176,6 @@ source_set("common_sources") {
]
}
if (is_linux || is_chromeos) {
sources += [ "common_sandbox_support_linux.h" ]
}
configs += [
"//build/config:precompiled_headers",
"//content:content_implementation",

@ -208,6 +208,8 @@ if (enable_pdf) {
"pdfium/pdfium_font_linux.cc",
"pdfium/pdfium_font_linux.h",
]
deps += [ ":font_table_linux" ]
}
}
@ -401,6 +403,20 @@ if (enable_pdf) {
]
}
if (is_linux || is_chromeos) {
# TODO(crbug.com/702993): After PPAPI deprecation, there will only be one
# caller left. Move inside the file with the caller.
static_library("font_table_linux") {
sources = [ "font_table_linux.cc" ]
configs += [ ":strict" ]
public = [ "font_table_linux.h" ]
deps = [ "//base" ]
}
}
test("pdf_unittests") {
testonly = true

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/common/common_sandbox_support_linux.h"
#include "pdf/font_table_linux.h"
#include <sys/stat.h>
@ -13,11 +13,10 @@
#include "base/posix/eintr_wrapper.h"
#include "base/sys_byteorder.h"
namespace content {
namespace pdf {
// TODO(drott): This should be removed once we don't need to support PPAPI
// TrueType functionality anymore, and before that, it should be replaced with
// using FreeType for the purpose instead of reimplementing table parsing.
// TODO(drott): This should be should be replaced with using FreeType for the
// purpose instead of reimplementing table parsing.
bool GetFontTable(int fd,
uint32_t table_tag,
off_t offset,
@ -93,4 +92,4 @@ bool GetFontTable(int fd,
return true;
}
} // namespace content
} // namespace pdf

@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_
#define CONTENT_PUBLIC_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_
#ifndef PDF_FONT_TABLE_LINUX_H_
#define PDF_FONT_TABLE_LINUX_H_
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "content/common/content_export.h"
namespace content {
namespace pdf {
// GetFontTable loads a specified font table from an open SFNT file.
// fd: a file descriptor to the SFNT file. The position doesn't matter.
@ -23,12 +21,12 @@ namespace content {
// output_length: size of output, if it's not 0.
//
// returns: true on success.
CONTENT_EXPORT bool GetFontTable(int fd,
uint32_t table_tag,
off_t offset,
uint8_t* output,
size_t* output_length);
bool GetFontTable(int fd,
uint32_t table_tag,
off_t offset,
uint8_t* output,
size_t* output_length);
} // namespace content
} // namespace pdf
#endif // CONTENT_PUBLIC_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_
#endif // PDF_FONT_TABLE_LINUX_H_