Guest User

Untitled

a guest
May 17th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.44 KB | None | 0 0
  1. commit 612bea95ea8a0bb09046d9d7c459e6fec8bc5e54
  2. Author: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
  3. Date: Mon Dec 14 16:37:48 2009 +0100
  4.  
  5. Make the Qt DRT use a fixed set of SVG fonts for all text rendering
  6.  
  7. Reviewed by Simon Hausmann.
  8.  
  9. On startup we load a set of SVG fonts for the generic font families
  10. and instruct the DRT to use only these fonts, even when asked for
  11. families where there's a system font available.
  12.  
  13. Hopefully this should give us cross-platform DRT results between Mac,
  14. Linux and Windows, and possibly other platforms, without variations in
  15. font metrics based on the underlying font engines on each platform.
  16.  
  17. WebCore:
  18.  
  19. * platform/graphics/qt/FontCacheQt.cpp:
  20.  
  21. WebKit/qt:
  22.  
  23. * QtLauncher/QtLauncher.pro:
  24. * QtLauncher/main.cpp:
  25.  
  26. WebKitTools:
  27.  
  28. * DumpRenderTree/qt/DumpRenderTree.cpp:
  29. * DumpRenderTree/qt/DumpRenderTree.h:
  30. * DumpRenderTree/qt/main.cpp:
  31. * Scripts/run-webkit-tests:
  32.  
  33. diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
  34. index 8f380a8..e61473c 100644
  35. --- a/WebCore/ChangeLog
  36. +++ b/WebCore/ChangeLog
  37. @@ -1,3 +1,19 @@
  38. +2009-12-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
  39. +
  40. + Reviewed by Simon Hausmann.
  41. +
  42. + Make the Qt DRT use a fixed set of SVG fonts for all text rendering
  43. +
  44. + On startup we load a set of SVG fonts for the generic font families
  45. + and instruct the DRT to use only these fonts, even when asked for
  46. + families where there's a system font available.
  47. +
  48. + Hopefully this should give us cross-platform DRT results between Mac,
  49. + Linux and Windows, and possibly other platforms, without variations in
  50. + font metrics based on the underlying font engines on each platform.
  51. +
  52. + * platform/graphics/qt/FontCacheQt.cpp:
  53. +
  54. 2009-12-07 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
  55.  
  56. Reviewed by Simon Hausmann.
  57. diff --git a/WebCore/platform/graphics/qt/FontCacheQt.cpp b/WebCore/platform/graphics/qt/FontCacheQt.cpp
  58. index 82fb709..2f393c2 100644
  59. --- a/WebCore/platform/graphics/qt/FontCacheQt.cpp
  60. +++ b/WebCore/platform/graphics/qt/FontCacheQt.cpp
  61. @@ -35,6 +35,7 @@
  62. #include <wtf/StdLibExtras.h>
  63.  
  64. #include <QFont>
  65. +#include "qwebpage_p.h"
  66.  
  67. using namespace WTF;
  68.  
  69. @@ -66,6 +67,9 @@ void FontCache::getTraitsInFamily(const AtomicString&, Vector<unsigned>&)
  70.  
  71. FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
  72. {
  73. + if (QWebPagePrivate::drtRun)
  74. + return 0; // TODO: Special-case loading of DRT-specific fonts such as Ahem.ttf
  75. +
  76. return new FontPlatformData(fontDescription, familyName);
  77. }
  78.  
  79. diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
  80. index 9ef13f1..5372ba4 100644
  81. --- a/WebKit/qt/ChangeLog
  82. +++ b/WebKit/qt/ChangeLog
  83. @@ -1,3 +1,20 @@
  84. +2009-12-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
  85. +
  86. + Reviewed by Simon Hausmann.
  87. +
  88. + Make the Qt DRT use a fixed set of SVG fonts for all text rendering
  89. +
  90. + On startup we load a set of SVG fonts for the generic font families
  91. + and instruct the DRT to use only these fonts, even when asked for
  92. + families where there's a system font available.
  93. +
  94. + Hopefully this should give us cross-platform DRT results between Mac,
  95. + Linux and Windows, and possibly other platforms, without variations in
  96. + font metrics based on the underlying font engines on each platform.
  97. +
  98. + * QtLauncher/QtLauncher.pro:
  99. + * QtLauncher/main.cpp:
  100. +
  101. 2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
  102.  
  103. Reviewed by Kenneth Rohde Christiansen.
  104. diff --git a/WebKit/qt/QtLauncher/QtLauncher.pro b/WebKit/qt/QtLauncher/QtLauncher.pro
  105. index 133869c..b71c5a9 100644
  106. --- a/WebKit/qt/QtLauncher/QtLauncher.pro
  107. +++ b/WebKit/qt/QtLauncher/QtLauncher.pro
  108. @@ -6,6 +6,9 @@ DESTDIR = ../../../bin
  109.  
  110. include(../../../WebKit.pri)
  111.  
  112. +# For common font initialization code
  113. +INCLUDEPATH += ../../../WebKitTools/DumpRenderTree/qt
  114. +
  115. QT += network
  116. macx:QT+=xml
  117. QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
  118. diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp
  119. index 2286712..0fd499c 100644
  120. --- a/WebKit/qt/QtLauncher/main.cpp
  121. +++ b/WebKit/qt/QtLauncher/main.cpp
  122. @@ -54,11 +54,14 @@
  123. #include <qwebsettings.h>
  124. #include <qwebview.h>
  125.  
  126. +#include <SharedInitialization.h>
  127.  
  128. #ifndef NDEBUG
  129. void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
  130. #endif
  131.  
  132. +extern void qt_drt_run(bool b);
  133. +
  134. static QUrl urlFromUserInput(const QString& input)
  135. {
  136. #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
  137. @@ -599,6 +602,12 @@ int launcherMain(const QApplication& app)
  138.  
  139. int main(int argc, char **argv)
  140. {
  141. +#if QT_VERSION >= 0x040500
  142. + for (int i = 0; i < argc; ++i)
  143. + if (!qstrcmp(argv[i], "--like-drt"))
  144. + QApplication::setGraphicsSystem("raster");
  145. +#endif
  146. +
  147. QApplication app(argc, argv);
  148. QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));
  149.  
  150. @@ -619,6 +628,12 @@ int main(int argc, char **argv)
  151.  
  152. const QStringList args = app.arguments();
  153.  
  154. + if (args.contains(QLatin1String("--like-drt"))) {
  155. + QApplication::setStyle(new QWindowsStyle);
  156. + WebCore::initializeDRTFonts();
  157. + qt_drt_run(true);
  158. + }
  159. +
  160. if (args.contains(QLatin1String("-r"))) {
  161. // robotized
  162. QString listFile = args.at(2);
  163. diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
  164. index 0b30710..57564be 100644
  165. --- a/WebKitTools/ChangeLog
  166. +++ b/WebKitTools/ChangeLog
  167. @@ -1,3 +1,22 @@
  168. +2009-12-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
  169. +
  170. + Reviewed by Simon Hausmann.
  171. +
  172. + Make the Qt DRT use a fixed set of SVG fonts for all text rendering
  173. +
  174. + On startup we load a set of SVG fonts for the generic font families
  175. + and instruct the DRT to use only these fonts, even when asked for
  176. + families where there's a system font available.
  177. +
  178. + Hopefully this should give us cross-platform DRT results between Mac,
  179. + Linux and Windows, and possibly other platforms, without variations in
  180. + font metrics based on the underlying font engines on each platform.
  181. +
  182. + * DumpRenderTree/qt/DumpRenderTree.cpp:
  183. + * DumpRenderTree/qt/DumpRenderTree.h:
  184. + * DumpRenderTree/qt/main.cpp:
  185. + * Scripts/run-webkit-tests:
  186. +
  187. 2009-12-07 Dirk Schulze <krit@webkit.org>
  188.  
  189. Not reviewed, adding myself to the reviewers list.
  190. diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
  191. index 6d466bf..71ee09c 100644
  192. --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
  193. +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
  194. @@ -438,11 +438,6 @@ void DumpRenderTree::open(const QUrl& aurl)
  195. QFocusEvent ev(QEvent::FocusIn);
  196. m_page->event(&ev);
  197.  
  198. - QFontDatabase::removeAllApplicationFonts();
  199. -#if defined(Q_WS_X11)
  200. - initializeFonts();
  201. -#endif
  202. -
  203. qt_dump_frame_loader(url.toString().contains("loading/"));
  204. setTextOutputEnabled(true);
  205. m_page->mainFrame()->load(url);
  206. @@ -750,44 +745,4 @@ int DumpRenderTree::windowCount() const
  207. return windows.count() + 1;
  208. }
  209.  
  210. -#if defined(Q_WS_X11)
  211. -void DumpRenderTree::initializeFonts()
  212. -{
  213. - static int numFonts = -1;
  214. -
  215. - // Some test cases may add or remove application fonts (via @font-face).
  216. - // Make sure to re-initialize the font set if necessary.
  217. - FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication);
  218. - if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts)
  219. - return;
  220. -
  221. - QByteArray fontDir = getenv("WEBKIT_TESTFONTS");
  222. - if (fontDir.isEmpty() || !QDir(fontDir).exists()) {
  223. - fprintf(stderr,
  224. - "\n\n"
  225. - "----------------------------------------------------------------------\n"
  226. - "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
  227. - "This variable has to point to the directory containing the fonts\n"
  228. - "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"
  229. - "----------------------------------------------------------------------\n"
  230. - );
  231. - exit(1);
  232. - }
  233. - char currentPath[PATH_MAX+1];
  234. - if (!getcwd(currentPath, PATH_MAX))
  235. - qFatal("Couldn't get current working directory");
  236. - QByteArray configFile = currentPath;
  237. - FcConfig *config = FcConfigCreate();
  238. - configFile += "/WebKitTools/DumpRenderTree/qt/fonts.conf";
  239. - if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true))
  240. - qFatal("Couldn't load font configuration file");
  241. - if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data()))
  242. - qFatal("Couldn't add font dir!");
  243. - FcConfigSetCurrent(config);
  244. -
  245. - appFontSet = FcConfigGetFonts(config, FcSetApplication);
  246. - numFonts = appFontSet->nfont;
  247. -}
  248. -#endif
  249. -
  250. }
  251. diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
  252. index ab229fe..cd5d508 100644
  253. --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
  254. +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
  255. @@ -91,11 +91,6 @@ public:
  256.  
  257. WebPage *webPage() const { return m_page; }
  258.  
  259. -
  260. -#if defined(Q_WS_X11)
  261. - static void initializeFonts();
  262. -#endif
  263. -
  264. public Q_SLOTS:
  265. void initJSObjects();
  266. void readStdin(int);
  267. diff --git a/WebKitTools/DumpRenderTree/qt/SharedInitialization.h b/WebKitTools/DumpRenderTree/qt/SharedInitialization.h
  268. new file mode 100644
  269. index 0000000..6ac4df8
  270. --- /dev/null
  271. +++ b/WebKitTools/DumpRenderTree/qt/SharedInitialization.h
  272. @@ -0,0 +1,66 @@
  273. +/*
  274. + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
  275. +
  276. + This library is free software; you can redistribute it and/or
  277. + modify it under the terms of the GNU Library General Public
  278. + License as published by the Free Software Foundation; either
  279. + version 2 of the License, or (at your option) any later version.
  280. +
  281. + This library is distributed in the hope that it will be useful,
  282. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  283. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  284. + Library General Public License for more details.
  285. +
  286. + You should have received a copy of the GNU Library General Public License
  287. + along with this library; see the file COPYING.LIB. If not, write to
  288. + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  289. + Boston, MA 02110-1301, USA.
  290. +*/
  291. +
  292. +#ifndef SHAREDINITIALIZATION_H
  293. +#define SHAREDINITIALIZATION_H
  294. +
  295. +#include <QDir>
  296. +#include <QResource>
  297. +#include <QFont>
  298. +#include <QFile>
  299. +
  300. +#include <qwebsecurityorigin.h>
  301. +
  302. +namespace WebCore {
  303. +
  304. +void initializeDRTFonts()
  305. +{
  306. + QByteArray fontsDir = qgetenv("WEBKIT_TESTFONTS");
  307. + if (fontsDir.isEmpty() || !QDir(fontsDir).exists()) {
  308. + fprintf(stderr, "\n\n"
  309. + "----------------------------------------------------------------------\n"
  310. + "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
  311. + "This variable has to point to the directory containing the fonts\n"
  312. + "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"
  313. + "----------------------------------------------------------------------\n");
  314. + exit(1);
  315. + }
  316. +
  317. + if (!QResource::registerResource(fontsDir + QLatin1String("/fonts.bin")))
  318. + qFatal("Could not load $WEBKIT_TESTFONTS/fonts.bin");
  319. +
  320. + QFile fontsCssFile(":/fonts.css");
  321. + if (!fontsCssFile.open(QFile::ReadOnly))
  322. + qFatal("Failed to read fonts.css from binary resource 'fonts.bin'");
  323. +
  324. + QWebSettings::globalSettings()->setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64,"
  325. + + fontsCssFile.readAll().toBase64()));
  326. +
  327. + QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, QLatin1String("-webkit-standard"));
  328. +
  329. + // Lets us load the SVG fonts using qrc from both data: and non-file URLs
  330. + QWebSecurityOrigin::removeLocalScheme("qrc");
  331. +
  332. + // While still allowing local content such as files to load the SVG fonts
  333. + QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
  334. +}
  335. +
  336. +} // WebCore
  337. +
  338. +#endif // SHAREDINITIALIZATION_H
  339. diff --git a/WebKitTools/DumpRenderTree/qt/main.cpp b/WebKitTools/DumpRenderTree/qt/main.cpp
  340. index 719315f..a714a86 100644
  341. --- a/WebKitTools/DumpRenderTree/qt/main.cpp
  342. +++ b/WebKitTools/DumpRenderTree/qt/main.cpp
  343. @@ -42,6 +42,8 @@
  344. #include <qdesktopservices.h>
  345. #include <qwindowsstyle.h>
  346.  
  347. +#include "SharedInitialization.h"
  348. +
  349. #ifdef Q_WS_X11
  350. #include <qx11info_x11.h>
  351. #include <fontconfig/fontconfig.h>
  352. @@ -98,10 +100,7 @@ static NO_RETURN void crashHandler(int sig)
  353.  
  354. int main(int argc, char* argv[])
  355. {
  356. -#ifdef Q_WS_X11
  357. - FcInit();
  358. - WebCore::DumpRenderTree::initializeFonts();
  359. -#endif
  360. + WebCore::initializeDRTFonts();
  361.  
  362. #if QT_VERSION >= 0x040500
  363. QApplication::setGraphicsSystem("raster");
  364. diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests
  365. index 6dd8339..b04ba4f 100755
  366. --- a/WebKitTools/Scripts/run-webkit-tests
  367. +++ b/WebKitTools/Scripts/run-webkit-tests
  368. @@ -1024,7 +1024,7 @@ my @configurationArgs = argumentsForConfiguration();
  369. if (isGtk()) {
  370. system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari;
  371. } elsif (isQt()) {
  372. - unshift @configurationArgs, qw(-graphicssystem raster -style windows);
  373. + unshift @configurationArgs, qw(--like-drt);
  374. system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari;
  375. } elsif (isCygwin()) {
  376. system "cygstart", $testResults if $launchSafari;
Add Comment
Please, Sign In to add comment