Title: [129664] trunk/Source
Revision
129664
Author
msab...@apple.com
Date
2012-09-26 10:26:18 -0700 (Wed, 26 Sep 2012)

Log Message

Update ComplexTextController for 8 bit TextRun changes
https://bugs.webkit.org/show_bug.cgi?id=97378

Reviewed by Geoffrey Garen.

Source/WebCore: 

Since the ComplextTextController code is primarily used for UChar data, just upconvert an 8 bit
TextRun into a new String and hold on to the String with a vector for the life of the controller.

No change in functionality, therefore no new tests.

* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::ComplexTextController):
(WebCore::ComplexTextController::collectComplexTextRuns):
* platform/graphics/mac/ComplexTextController.h:
(ComplexTextController):

Source/WTF: 

Add a new create method to make a 16 bit string from 8 bit source data.  This is used in 
ComplexTextController when we have LChar* + length text data, but we really want 16 bit
data for the complex text rendering code.

* wtf/text/WTFString.cpp:
(WTF::String::make16BitFrom8BitSource):
(WTF):
* wtf/text/WTFString.h:
(String):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (129663 => 129664)


--- trunk/Source/WTF/ChangeLog	2012-09-26 17:24:48 UTC (rev 129663)
+++ trunk/Source/WTF/ChangeLog	2012-09-26 17:26:18 UTC (rev 129664)
@@ -1,3 +1,20 @@
+2012-09-26  Michael Saboff  <msab...@apple.com>
+
+        Update ComplexTextController for 8 bit TextRun changes
+        https://bugs.webkit.org/show_bug.cgi?id=97378
+
+        Reviewed by Geoffrey Garen.
+
+        Add a new create method to make a 16 bit string from 8 bit source data.  This is used in 
+        ComplexTextController when we have LChar* + length text data, but we really want 16 bit
+        data for the complex text rendering code.
+
+        * wtf/text/WTFString.cpp:
+        (WTF::String::make16BitFrom8BitSource):
+        (WTF):
+        * wtf/text/WTFString.h:
+        (String):
+
 2012-09-26  Ilya Tikhonovsky  <loi...@chromium.org>
 
         Web Inspector: NMI: replace manual JS external resources counting with MemoryInstrumentation

Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (129663 => 129664)


--- trunk/Source/WTF/wtf/text/WTFString.cpp	2012-09-26 17:24:48 UTC (rev 129663)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp	2012-09-26 17:26:18 UTC (rev 129664)
@@ -778,6 +778,19 @@
     return result;
 }
 
+String String::make16BitFrom8BitSource(const LChar* source, size_t length)
+{
+    if (!length)
+        return String();
+    
+    UChar* destination;
+    String result = String::createUninitialized(length, destination);
+    
+    StringImpl::copyChars(destination, source, length);
+    
+    return result;
+}
+
 String String::fromUTF8(const LChar* stringStart, size_t length)
 {
     if (length > numeric_limits<unsigned>::max())

Modified: trunk/Source/WTF/wtf/text/WTFString.h (129663 => 129664)


--- trunk/Source/WTF/wtf/text/WTFString.h	2012-09-26 17:24:48 UTC (rev 129663)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2012-09-26 17:26:18 UTC (rev 129664)
@@ -414,6 +414,7 @@
 #endif
 
     WTF_EXPORT_STRING_API static String make8BitFrom16BitSource(const UChar*, size_t);
+    WTF_EXPORT_STRING_API static String make16BitFrom8BitSource(const LChar*, size_t);
 
     // String::fromUTF8 will return a null string if
     // the input data contains invalid UTF-8 sequences.

Modified: trunk/Source/WebCore/ChangeLog (129663 => 129664)


--- trunk/Source/WebCore/ChangeLog	2012-09-26 17:24:48 UTC (rev 129663)
+++ trunk/Source/WebCore/ChangeLog	2012-09-26 17:26:18 UTC (rev 129664)
@@ -1,5 +1,23 @@
 2012-09-26  Michael Saboff  <msab...@apple.com>
 
+        Update ComplexTextController for 8 bit TextRun changes
+        https://bugs.webkit.org/show_bug.cgi?id=97378
+
+        Reviewed by Geoffrey Garen.
+
+        Since the ComplextTextController code is primarily used for UChar data, just upconvert an 8 bit
+        TextRun into a new String and hold on to the String with a vector for the life of the controller.
+
+        No change in functionality, therefore no new tests.
+
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::ComplexTextController):
+        (WebCore::ComplexTextController::collectComplexTextRuns):
+        * platform/graphics/mac/ComplexTextController.h:
+        (ComplexTextController):
+
+2012-09-26  Michael Saboff  <msab...@apple.com>
+
         Add Latin-1 Line Break Iterator to TextBreakIteratorICU.cpp
         https://bugs.webkit.org/show_bug.cgi?id=96935
 

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (129663 => 129664)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2012-09-26 17:24:48 UTC (rev 129663)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2012-09-26 17:26:18 UTC (rev 129664)
@@ -142,7 +142,11 @@
         m_expansionPerOpportunity = 0;
     else {
         bool isAfterExpansion = m_afterExpansion;
-        unsigned expansionOpportunityCount = Font::expansionOpportunityCount(m_run.characters16(), m_end, m_run.ltr() ? LTR : RTL, isAfterExpansion);
+        unsigned expansionOpportunityCount;
+        if (m_run.is8Bit())
+            expansionOpportunityCount = Font::expansionOpportunityCount(m_run.characters8(), m_end, m_run.ltr() ? LTR : RTL, isAfterExpansion);
+         else
+             expansionOpportunityCount = Font::expansionOpportunityCount(m_run.characters16(), m_end, m_run.ltr() ? LTR : RTL, isAfterExpansion);
         if (isAfterExpansion && !m_run.allowsTrailingExpansion())
             expansionOpportunityCount--;
 
@@ -284,8 +288,15 @@
         return;
 
     // We break up glyph run generation for the string by FontData.
-    const UChar* cp = m_run.characters16();
+    const UChar* cp;
 
+    if (m_run.is8Bit()) {
+        String stringFor8BitRun = String::make16BitFrom8BitSource(m_run.characters8(), m_run.length());
+        cp = stringFor8BitRun.characters16();
+        m_stringsFor8BitRuns.append(stringFor8BitRun);
+    } else
+        cp = m_run.characters16();
+
     if (m_font.isSmallCaps())
         m_smallCapsBuffer.resize(m_end);
 

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h (129663 => 129664)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h	2012-09-26 17:24:48 UTC (rev 129663)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h	2012-09-26 17:26:18 UTC (rev 129664)
@@ -31,6 +31,7 @@
 #include <wtf/RefCounted.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
 #include <wtf/unicode/Unicode.h>
 
 typedef unsigned short CGGlyph;
@@ -143,6 +144,7 @@
     bool m_mayUseNaturalWritingDirection;
     bool m_forTextEmphasis;
 
+    Vector<String> m_stringsFor8BitRuns;
     Vector<UChar, 256> m_smallCapsBuffer;
 
     // Retain lines rather than their runs for better performance.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to