Source/WebCore: WebCore part of <rdar://problem/12446507> [mac] WebKit clients cannot...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Oct 2012 18:37:38 +0000 (18:37 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Oct 2012 18:37:38 +0000 (18:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98601

Reviewed by Darin Adler.

* WebCore.exp.in: Exported Font::setDefaultTypesettingFeatures().
* platform/graphics/Font.cpp:
(WebCore::Font::s_defaultTypesettingFeatures): Defined this static.
(WebCore::Font::setDefaultTypesettingFeatures): Added this setter.
(WebCore::Font::defaultTypesettingFeatures): Added this getter.
* platform/graphics/Font.h:
(WebCore::Font::typesettingFeatures): Changed to use the value of the new static member
s_defaultTypesettingFeatures, rather than 0, if text-redering is set to auto.

Source/WebKit/mac: WebKit/mac part of <rdar://problem/12446507> [mac] WebKit clients cannot change the behavior of text-rendering: auto
https://bugs.webkit.org/show_bug.cgi?id=98601

Reviewed by Darin Adler.

* WebView/WebView.mm:
(+[WebView initialize]): Added a call to Font::setDefaultTypesettingFeatures() to enable
kerning and ligatures if the WebKitKerningAndLigaturesEnabledByDefault user default key has
the value YES.

Source/WebKit2: WebKit2 part of <rdar://problem/12446507> [mac] WebKit clients cannot change the behavior of text-rendering: auto
https://bugs.webkit.org/show_bug.cgi?id=98601

Reviewed by Darin Adler.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::WebProcessCreationParameters): Added initializer for
to shouldEnableKerningAndLigaturesByDefault. The initial value is false.
(WebKit::WebProcessCreationParameters::encode): Added encoding of
shouldEnableKerningAndLigaturesByDefault.
(WebKit::WebProcessCreationParameters::decode): Added decoding of
shouldEnableKerningAndLigaturesByDefault.
* Shared/WebProcessCreationParameters.h:
(WebProcessCreationParameters): Added shouldEnableKerningAndLigaturesByDefault boolean
member variable.
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::platformInitializeWebProcess): Changed to set
shouldEnableKerningAndLigaturesByDefault in the process creation parameters according to
the value of the WebKitKerningAndLigaturesEnabledByDefault user defaults key.
* WebProcess/mac/WebProcessMac.mm:
(WebKit::WebProcess::platformInitializeWebProcess): Added a call to
Font::setDefaultTypesettingFeatures() to enable kerning and ligatures if requested in the
process creation parameters.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130585 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/mac/WebContextMac.mm
Source/WebKit2/WebProcess/mac/WebProcessMac.mm

index 0a92f99..8bbf9ef 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-06  Dan Bernstein  <mitz@apple.com>
+
+        WebCore part of <rdar://problem/12446507> [mac] WebKit clients cannot change the behavior of text-rendering: auto
+        https://bugs.webkit.org/show_bug.cgi?id=98601
+
+        Reviewed by Darin Adler.
+
+        * WebCore.exp.in: Exported Font::setDefaultTypesettingFeatures().
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::s_defaultTypesettingFeatures): Defined this static.
+        (WebCore::Font::setDefaultTypesettingFeatures): Added this setter.
+        (WebCore::Font::defaultTypesettingFeatures): Added this getter.
+        * platform/graphics/Font.h:
+        (WebCore::Font::typesettingFeatures): Changed to use the value of the new static member
+        s_defaultTypesettingFeatures, rather than 0, if text-redering is set to auto.
+
 2012-10-04  Geoffrey Garen  <ggaren@apple.com>
 
         If Node X is reachable from JavaScript, all Nodes in the same tree should be kept alive
index 5f87aab..761476f 100644 (file)
@@ -647,6 +647,7 @@ __ZN7WebCore47attributedStringByStrippingAttachmentCharactersEP18NSAttributedStr
 __ZN7WebCore4Font11setCodePathENS0_8CodePathE
 __ZN7WebCore4Font18shouldUseSmoothingEv
 __ZN7WebCore4Font21setShouldUseSmoothingEb
+__ZN7WebCore4Font29setDefaultTypesettingFeaturesEj
 __ZN7WebCore4FontC1ERKNS_16FontPlatformDataEbNS_17FontSmoothingModeE
 __ZN7WebCore4FontC1Ev
 __ZN7WebCore4FontaSERKS0_
index afeab5d..ee9dc75 100644 (file)
@@ -64,6 +64,8 @@ const uint8_t Font::s_roundingHackCharacterTable[256] = {
 
 Font::CodePath Font::s_codePath = Auto;
 
+TypesettingFeatures Font::s_defaultTypesettingFeatures = 0;
+
 // ============================================================================================
 // Font Implementation (Cross-Platform Portion)
 // ============================================================================================
@@ -289,6 +291,16 @@ Font::CodePath Font::codePath()
     return s_codePath;
 }
 
+void Font::setDefaultTypesettingFeatures(TypesettingFeatures typesettingFeatures)
+{
+    s_defaultTypesettingFeatures = typesettingFeatures;
+}
+
+TypesettingFeatures Font::defaultTypesettingFeatures()
+{
+    return s_defaultTypesettingFeatures;
+}
+
 Font::CodePath Font::codePath(const TextRun& run) const
 {
     if (s_codePath != Auto)
index 73e1c3b..0f294ee 100644 (file)
@@ -124,7 +124,19 @@ public:
     TypesettingFeatures typesettingFeatures() const
     {
         TextRenderingMode textRenderingMode = m_fontDescription.textRenderingMode();
-        TypesettingFeatures features = textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? Kerning | Ligatures : 0;
+        TypesettingFeatures features = s_defaultTypesettingFeatures;
+
+        switch(textRenderingMode) {
+        case AutoTextRendering:
+            break;
+        case OptimizeSpeed:
+            features &= ~(Kerning | Ligatures);
+            break;
+        case GeometricPrecision:
+        case OptimizeLegibility:
+            features |= Kerning | Ligatures;
+            break;
+        }
 
         switch (m_fontDescription.kerning()) {
         case FontDescription::NoneKerning:
@@ -234,6 +246,9 @@ public:
     static CodePath codePath();
     static CodePath s_codePath;
 
+    static void setDefaultTypesettingFeatures(TypesettingFeatures);
+    static TypesettingFeatures defaultTypesettingFeatures();
+
     static const uint8_t s_roundingHackCharacterTable[256];
     static bool isRoundingHackCharacter(UChar32 c)
     {
@@ -273,6 +288,8 @@ private:
     void initFormatForTextLayout(QTextLayout*) const;
 #endif
 
+    static TypesettingFeatures s_defaultTypesettingFeatures;
+
     FontDescription m_fontDescription;
     mutable RefPtr<FontFallbackList> m_fontFallbackList;
     short m_letterSpacing;
index b491cc0..416ca20 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-06  Dan Bernstein  <mitz@apple.com>
+
+        WebKit/mac part of <rdar://problem/12446507> [mac] WebKit clients cannot change the behavior of text-rendering: auto
+        https://bugs.webkit.org/show_bug.cgi?id=98601
+
+        Reviewed by Darin Adler.
+
+        * WebView/WebView.mm:
+        (+[WebView initialize]): Added a call to Font::setDefaultTypesettingFeatures() to enable
+        kerning and ligatures if the WebKitKerningAndLigaturesEnabledByDefault user default key has
+        the value YES.
+
 2012-10-05  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r130556 and r130564.
index 783fc7e..7e19669 100644 (file)
@@ -3116,6 +3116,8 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
     continuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled];
     grammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled];
 
+    Font::setDefaultTypesettingFeatures([[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitKerningAndLigaturesEnabledByDefault"] ? Kerning | Ligatures : 0);
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     automaticQuoteSubstitutionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticQuoteSubstitutionEnabled];
     automaticLinkDetectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticLinkDetectionEnabled];
index 131a34d..bae53f1 100644 (file)
@@ -1,3 +1,29 @@
+2012-10-06  Dan Bernstein  <mitz@apple.com>
+
+        WebKit2 part of <rdar://problem/12446507> [mac] WebKit clients cannot change the behavior of text-rendering: auto
+        https://bugs.webkit.org/show_bug.cgi?id=98601
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::WebProcessCreationParameters): Added initializer for
+        to shouldEnableKerningAndLigaturesByDefault. The initial value is false.
+        (WebKit::WebProcessCreationParameters::encode): Added encoding of
+        shouldEnableKerningAndLigaturesByDefault.
+        (WebKit::WebProcessCreationParameters::decode): Added decoding of
+        shouldEnableKerningAndLigaturesByDefault.
+        * Shared/WebProcessCreationParameters.h:
+        (WebProcessCreationParameters): Added shouldEnableKerningAndLigaturesByDefault boolean
+        member variable.
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::platformInitializeWebProcess): Changed to set
+        shouldEnableKerningAndLigaturesByDefault in the process creation parameters according to
+        the value of the WebKitKerningAndLigaturesEnabledByDefault user defaults key.
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess): Added a call to
+        Font::setDefaultTypesettingFeatures() to enable kerning and ligatures if requested in the
+        process creation parameters.
+
 2012-10-05  Sudarsana Nagineni  <sudarsana.nagineni@intel.com>
 
         [WK2][WTR] WebKitTestRunner needs testRunner.setSerializeHTTPLoads
index 336ba0d..80030ac 100644 (file)
@@ -42,6 +42,7 @@ WebProcessCreationParameters::WebProcessCreationParameters()
     , nsURLCacheMemoryCapacity(0)
     , nsURLCacheDiskCapacity(0)
     , shouldForceScreenFontSubstitution(false)
+    , shouldEnableKerningAndLigaturesByDefault(false)
 #elif PLATFORM(WIN)
     , shouldPaintNativeControls(false)
 #endif
@@ -90,6 +91,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(uiProcessBundleResourcePath);
     encoder->encode(uiProcessBundleResourcePathExtensionHandle);
     encoder->encode(shouldForceScreenFontSubstitution);
+    encoder->encode(shouldEnableKerningAndLigaturesByDefault);
 #elif PLATFORM(WIN)
     encoder->encode(shouldPaintNativeControls);
     encoder->encode(cfURLCachePath);
@@ -193,6 +195,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
     if (!decoder->decode(parameters.shouldForceScreenFontSubstitution))
         return false;
+    if (!decoder->decode(parameters.shouldEnableKerningAndLigaturesByDefault))
+        return false;
 #elif PLATFORM(WIN)
     if (!decoder->decode(parameters.shouldPaintNativeControls))
         return false;
index e432a13..0d543fa 100644 (file)
@@ -112,6 +112,7 @@ struct WebProcessCreationParameters {
     SandboxExtension::Handle uiProcessBundleResourcePathExtensionHandle;
 
     bool shouldForceScreenFontSubstitution;
+    bool shouldEnableKerningAndLigaturesByDefault;
 #elif PLATFORM(WIN)
     String cfURLCachePath;
     uint64_t cfURLCacheDiskCapacity;
index 459ed05..15aa050 100644 (file)
@@ -100,6 +100,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     parameters.shouldForceScreenFontSubstitution = [[NSUserDefaults standardUserDefaults] boolForKey:@"NSFontDefaultScreenFontSubstitutionEnabled"];
 #endif
+    parameters.shouldEnableKerningAndLigaturesByDefault = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitKerningAndLigaturesEnabledByDefault"];
 
 #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION)
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
index ff75ceb..519d62b 100644 (file)
@@ -33,6 +33,7 @@
 #import "WebProcessCreationParameters.h"
 #import "WebProcessProxyMessages.h"
 #import <WebCore/FileSystem.h>
+#import <WebCore/Font.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/MemoryCache.h>
 #import <WebCore/PageCache.h>
@@ -272,6 +273,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     }
 
     m_shouldForceScreenFontSubstitution = parameters.shouldForceScreenFontSubstitution;
+    Font::setDefaultTypesettingFeatures(parameters.shouldEnableKerningAndLigaturesByDefault ? Kerning | Ligatures : 0);
 
     m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();