Merge pull request #270 from electron/pdf_rendering

Link necessary pdf libraries and load pdf ui resources
This commit is contained in:
Cheng Zhao 2017-03-10 08:35:00 +09:00 committed by GitHub
commit b15123938c
4 changed files with 71 additions and 13 deletions

View file

@ -99,6 +99,32 @@
'<(libchromiumcontent_dir)/libyuv.a',
'<(libchromiumcontent_dir)/librenderer.a',
'<(libchromiumcontent_dir)/libsecurity_state.a',
# Friends of libpdf.a:
# On Linux we have to use "--whole-archive" to include
# all symbols, otherwise there will be plenty of
# unresolved symbols errors.
'-Wl,--whole-archive',
'<(libchromiumcontent_dir)/libpdf.a',
'<(libchromiumcontent_dir)/libppapi_cpp_objects.a',
'<(libchromiumcontent_dir)/libppapi_internal_module.a',
'<(libchromiumcontent_dir)/libjpeg.a',
'<(libchromiumcontent_dir)/libpdfium.a',
'<(libchromiumcontent_dir)/libfdrm.a',
'<(libchromiumcontent_dir)/libformfiller.a',
'<(libchromiumcontent_dir)/libfpdfapi.a',
'<(libchromiumcontent_dir)/libfpdfdoc.a',
'<(libchromiumcontent_dir)/libfpdftext.a',
'<(libchromiumcontent_dir)/libfxcodec.a',
'<(libchromiumcontent_dir)/libfxedit.a',
'<(libchromiumcontent_dir)/libfxge.a',
'<(libchromiumcontent_dir)/libfxjs.a',
'<(libchromiumcontent_dir)/libjavascript.a',
'<(libchromiumcontent_dir)/libpdfwindow.a',
'<(libchromiumcontent_dir)/libfx_agg.a',
'<(libchromiumcontent_dir)/libfx_lcms2.a',
'<(libchromiumcontent_dir)/libfx_libopenjpeg.a',
'<(libchromiumcontent_dir)/libfx_zlib.a',
'-Wl,--no-whole-archive',
],
},
}, {
@ -152,6 +178,29 @@
'<(libchromiumcontent_dir)/libyuv.a',
'<(libchromiumcontent_dir)/librenderer.a',
'<(libchromiumcontent_dir)/libsecurity_state.a',
# Friends of libpdf.a:
'<(libchromiumcontent_dir)/libpdf.a',
'<(libchromiumcontent_dir)/libppapi_cpp_objects.a',
'<(libchromiumcontent_dir)/libppapi_internal_module.a',
'<(libchromiumcontent_dir)/libjpeg.a',
'<(libchromiumcontent_dir)/libpdfium.a',
'<(libchromiumcontent_dir)/libfdrm.a',
'<(libchromiumcontent_dir)/libformfiller.a',
'<(libchromiumcontent_dir)/libfpdfapi.a',
'<(libchromiumcontent_dir)/libfpdfdoc.a',
'<(libchromiumcontent_dir)/libfpdftext.a',
'<(libchromiumcontent_dir)/libfxcodec.a',
'<(libchromiumcontent_dir)/libfxcrt.a',
'<(libchromiumcontent_dir)/libfxedit.a',
'<(libchromiumcontent_dir)/libfxge.a',
'<(libchromiumcontent_dir)/libfxjs.a',
'<(libchromiumcontent_dir)/libjavascript.a',
'<(libchromiumcontent_dir)/libpdfwindow.a',
'<(libchromiumcontent_dir)/libfx_agg.a',
'<(libchromiumcontent_dir)/libfx_freetype.a',
'<(libchromiumcontent_dir)/libfx_lcms2.a',
'<(libchromiumcontent_dir)/libfx_libopenjpeg.a',
'<(libchromiumcontent_dir)/libfx_zlib.a',
],
},
}, {

View file

@ -49,18 +49,18 @@ void InitializeResourceBundle(const std::string& locale) {
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
// Load other resource files.
base::FilePath path;
#if defined(OS_MACOSX)
path = GetResourcesPakFilePath();
LoadCommonResources();
#else
base::FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir);
path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
#endif
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
bundle.AddDataPackFromPath(path, ui::GetSupportedScaleFactors()[0]);
#if !defined(OS_MACOSX)
PathService::Get(base::DIR_MODULE, &pak_dir);
bundle.AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")),
ui::GetSupportedScaleFactors()[0]);
bundle.AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")),
ui::GetSupportedScaleFactors()[0]);
bundle.AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("blink_image_resources_200_percent.pak")),
ui::SCALE_FACTOR_200P);

View file

@ -24,7 +24,7 @@ class BrowserClient;
class ContentClient;
void InitializeResourceBundle(const std::string& locale);
base::FilePath GetResourcesPakFilePath();
void LoadCommonResources();
class MainDelegate : public content::ContentMainDelegate {
public:

View file

@ -16,6 +16,7 @@
#include "base/strings/sys_string_conversions.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
namespace brightray {
@ -25,11 +26,19 @@ base::FilePath GetFrameworksPath() {
return MainApplicationBundlePath().Append("Contents").Append("Frameworks");
}
base::FilePath GetResourcesPakFilePath(NSString* name) {
auto path = [base::mac::FrameworkBundle() pathForResource:name ofType:@"pak"];
return base::mac::NSStringToFilePath(path);
}
base::FilePath GetResourcesPakFilePath() {
auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"];
return base::mac::NSStringToFilePath(path);
} // namespace
void LoadCommonResources() {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"content_shell"),
ui::GetSupportedScaleFactors()[0]);
bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"pdf_viewer_resources"),
ui::GetSupportedScaleFactors()[0]);
}
void MainDelegate::OverrideFrameworkBundlePath() {
@ -47,4 +56,4 @@ void MainDelegate::OverrideChildProcessPath() {
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
}
}
} // namespace brightray