Add support for 8 bit TextRuns on Chromium Linux & Mac
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 18:56:53 +0000 (18:56 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 18:56:53 +0000 (18:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99393

Reviewed by Eric Seidel.

Source/WebCore:

Adding support for 8 bit TextRuns for Mac and Linux Chromium. To accomplish this,
8 bit text runs are upconverted to 16 bit in the complex text path during string
normalization, as HarfBuzz operates on UChars.

Windows has platfom assumptions that TextRuns are 16 bit that need to be addressed
before enabling this optimization.

No new tests. No change in behavior.

(WebCore::HarfBuzzShaperBase::setNormalizedBuffer):
* platform/graphics/harfbuzz/HarfBuzzShaperBase.h:
* platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
(WebCore::normalizeCharacters):
(WebCore::HarfBuzzShaper::HarfBuzzShaper):

Source/WebKit/chromium:

Enabling 8 bit text runs for Linux and Mac platforms.

* features.gypi:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/features.gypi

index 9a90fd7..13180c3 100644 (file)
@@ -1,3 +1,25 @@
+2013-03-04  Levi Weintraub  <leviw@chromium.org>
+
+        Add support for 8 bit TextRuns on Chromium Linux & Mac
+        https://bugs.webkit.org/show_bug.cgi?id=99393
+
+        Reviewed by Eric Seidel.
+
+        Adding support for 8 bit TextRuns for Mac and Linux Chromium. To accomplish this,
+        8 bit text runs are upconverted to 16 bit in the complex text path during string
+        normalization, as HarfBuzz operates on UChars.
+
+        Windows has platfom assumptions that TextRuns are 16 bit that need to be addressed
+        before enabling this optimization.
+
+        No new tests. No change in behavior.
+
+        (WebCore::HarfBuzzShaperBase::setNormalizedBuffer):
+        * platform/graphics/harfbuzz/HarfBuzzShaperBase.h:
+        * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
+        (WebCore::normalizeCharacters):
+        (WebCore::HarfBuzzShaper::HarfBuzzShaper):
+
 2013-03-04  Alexis Menard  <alexis@webkit.org>
 
         transition-property property and transition shorthand property doesn't accept "all, all".
index 69ba6ff..51568fc 100644 (file)
@@ -156,10 +156,18 @@ float HarfBuzzShaper::HarfBuzzRun::xPositionForOffset(unsigned offset)
     return position;
 }
 
-static void normalizeCharacters(const UChar* source, UChar* destination, int length)
+static void normalizeCharacters(const TextRun& run, UChar* destination, int length)
 {
     int position = 0;
     bool error = false;
+    const UChar* source;
+    String stringFor8BitRun;
+    if (run.is8Bit()) {
+        stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length());
+        source = stringFor8BitRun.characters16();
+    } else
+        source = run.characters16();
+
     while (position < length) {
         UChar32 character;
         int nextPosition = position;
@@ -182,7 +190,7 @@ HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run)
 {
     m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]);
     m_normalizedBufferLength = m_run.length();
-    normalizeCharacters(m_run.characters16(), m_normalizedBuffer.get(), m_normalizedBufferLength);
+    normalizeCharacters(m_run, m_normalizedBuffer.get(), m_normalizedBufferLength);
     setPadding(m_run.expansion());
     setFontFeatures();
 }
index 1b9b7d3..c13dc9f 100644 (file)
@@ -94,10 +94,18 @@ void HarfBuzzShaperBase::setNormalizedBuffer(NormalizeMode normalizeMode)
     icu::UnicodeString normalizedString;
     UErrorCode error = U_ZERO_ERROR;
 
+    const UChar* runCharacters;
+    String stringFor8BitRun;
+    if (m_run.is8Bit()) {
+        stringFor8BitRun = String::make16BitFrom8BitSource(m_run.characters8(), m_run.length());
+        runCharacters = stringFor8BitRun.characters16();
+    } else
+        runCharacters = m_run.characters16();
+
     for (int i = 0; i < m_run.length(); ++i) {
-        UChar ch = m_run[i];
+        UChar ch = runCharacters[i];
         if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) {
-            icu::Normalizer::normalize(icu::UnicodeString(m_run.characters16(),
+            icu::Normalizer::normalize(icu::UnicodeString(runCharacters,
                                        m_run.length()), UNORM_NFC, 0 /* no options */,
                                        normalizedString, error);
             if (U_FAILURE(error))
@@ -109,7 +117,7 @@ void HarfBuzzShaperBase::setNormalizedBuffer(NormalizeMode normalizeMode)
     const UChar* sourceText;
     if (normalizedString.isEmpty()) {
         m_normalizedBufferLength = m_run.length();
-        sourceText = m_run.characters16();
+        sourceText = runCharacters;
     } else {
         m_normalizedBufferLength = normalizedString.length();
         sourceText = normalizedString.getBuffer();
index fd6cd69..aea98af 100644 (file)
@@ -1,3 +1,14 @@
+2013-03-04  Levi Weintraub  <leviw@chromium.org>
+
+        Add support for 8 bit TextRuns on Chromium Linux & Mac
+        https://bugs.webkit.org/show_bug.cgi?id=99393
+
+        Reviewed by Eric Seidel.
+
+        Enabling 8 bit text runs for Linux and Mac platforms.
+
+        * features.gypi:
+
 2013-03-04  Peter Beverloo  <peter@chromium.org>
 
         [Chromium] Add a new dependency on jsr-305 for Android
index aca8bee..c03dc5e 100644 (file)
       }],
       ['OS=="linux" or OS=="mac"', {
         'feature_defines': [
+          # 8Bit text runs should be enabled for all platforms webkit.org/b/111348
+          'ENABLE_8BIT_TEXTRUN=1',
           'ENABLE_BINDING_INTEGRITY=1',
         ],
       }, { # OS!="linux"