diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-16 05:40:41 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-16 05:40:41 +0000 |
commit | a553b670f031c696a7d8c456d78670e0a0f7db87 (patch) | |
tree | 3ad9502acfa24a6ada8042e1e103ee41b47fd687 /content/shell/renderer/shell_content_renderer_client.cc | |
parent | 5273d8ec81d472ed23562968650b304a6874b0d8 (diff) | |
download | chromium_src-a553b670f031c696a7d8c456d78670e0a0f7db87.zip chromium_src-a553b670f031c696a7d8c456d78670e0a0f7db87.tar.gz chromium_src-a553b670f031c696a7d8c456d78670e0a0f7db87.tar.bz2 |
Support sideloaded fonts via command line option for blink layout_tests
Blink side is: https://codereview.chromium.org/235553003/ which
must land and roll first.
Adds support for --register-font-files which adds the given
file(s) to the sandbox policy (readonly), creates and warms up
the font, and passes it to blink.
Also, modify the setup code for layout tests so "Ahem" will be
found correctly.
R=jschuh@chromium.org,eae@chromium.org
BUG=333029
TEST=out\debug\content_shell d:\src\tmp\a.html --enable-direct-write --register-font-files=D:\src\cr3\src\content\shell\renderer\test_runner\resources\fonts\AHEM____.TTF
TEST=ninja -C out\Debug blink_tests && webkit\tools\layout_tests\run_webkit_tests fast/parser/fonts.html --debug --nocheck-sys-deps (with directwrite forced on)
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=263842
Review URL: https://codereview.chromium.org/231763003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/renderer/shell_content_renderer_client.cc')
-rw-r--r-- | content/shell/renderer/shell_content_renderer_client.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/content/shell/renderer/shell_content_renderer_client.cc b/content/shell/renderer/shell_content_renderer_client.cc index 341fc23..1ab6e23 100644 --- a/content/shell/renderer/shell_content_renderer_client.cc +++ b/content/shell/renderer/shell_content_renderer_client.cc @@ -7,11 +7,13 @@ #include "base/callback.h" #include "base/command_line.h" #include "base/debug/debugger.h" +#include "content/common/sandbox_win.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_view.h" #include "content/public/test/layouttest_support.h" #include "content/shell/common/shell_switches.h" +#include "content/shell/common/webkit_test_helpers.h" #include "content/shell/renderer/shell_render_frame_observer.h" #include "content/shell/renderer/shell_render_process_observer.h" #include "content/shell/renderer/shell_render_view_observer.h" @@ -25,6 +27,12 @@ #include "third_party/WebKit/public/web/WebView.h" #include "v8/include/v8.h" +#if defined(OS_WIN) +#include "content/public/renderer/render_font_warmup_win.h" +#include "third_party/WebKit/public/web/win/WebFontRendering.h" +#include "third_party/skia/include/ports/SkFontMgr.h" +#endif + using blink::WebAudioDevice; using blink::WebClipboard; using blink::WebLocalFrame; @@ -43,12 +51,36 @@ using WebTestRunner::WebTestProxyBase; namespace content { +#if defined(OS_WIN) +namespace { + +// DirectWrite only has access to %WINDIR%\Fonts by default. For developer +// side-loading, support kRegisterFontFiles to allow access to additional fonts. +void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { + std::vector<std::string> files = GetSideloadFontFiles(); + for (std::vector<std::string>::const_iterator i(files.begin()); + i != files.end(); + ++i) { + SkTypeface* typeface = fontmgr->createFromFile(i->c_str()); + DoPreSandboxWarmupForTypeface(typeface); + blink::WebFontRendering::addSideloadedFontForTesting(typeface); + } +} + +} // namespace +#endif // OS_WIN + ShellContentRendererClient::ShellContentRendererClient() { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { EnableWebTestProxyCreation( base::Bind(&ShellContentRendererClient::WebTestProxyCreated, base::Unretained(this))); } + +#if defined(OS_WIN) + if (ShouldUseDirectWrite()) + RegisterSideloadedTypefaces(GetPreSandboxWarmupFontMgr()); +#endif } ShellContentRendererClient::~ShellContentRendererClient() { |