Title: [173943] trunk
Revision
173943
Author
[email protected]
Date
2014-09-24 19:53:48 -0700 (Wed, 24 Sep 2014)

Log Message

Old Turkic characters behave as left-to-right instead of right-to-left, because they are encoded as surrogate pairs.
https://bugs.webkit.org/show_bug.cgi?id=70029

Reviewed by Dan Bernstein.

Source/WebCore:

Test: fast/text/international/old-turkic-direction.html

* CMakeLists.txt: Added InlineIterator.cpp.
* WebCore.vcxproj/WebCore.vcxproj: Ditto.
* WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* rendering/RenderingAllInOne.cpp: Ditto.

* rendering/InlineIterator.cpp: Added.
(WebCore::InlineIterator::surrogateTextDirection): New function used to compute the direction
when a surrogate pair is involved.
* rendering/InlineIterator.h: Made the characterAt function private.
(WebCore::InlineIterator::previousInSameNode): Took out unneeded range check. A zero will underflow
and become a large number and the characterAt function will return 0 in that case.
(WebCore::InlineIterator::direction): Added code to check U16_IS_SINGLE before calling
u_charDirection, and call surrogateTextDirection instead.

LayoutTests:

* fast/text/international/old-turkic-direction.html: Added.
* fast/text/international/old-turkic-direction-expected.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (173942 => 173943)


--- trunk/LayoutTests/ChangeLog	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/LayoutTests/ChangeLog	2014-09-25 02:53:48 UTC (rev 173943)
@@ -1,3 +1,13 @@
+2014-09-24  Darin Adler  <[email protected]>
+
+        Old Turkic characters behave as left-to-right instead of right-to-left, because they are encoded as surrogate pairs.
+        https://bugs.webkit.org/show_bug.cgi?id=70029
+
+        Reviewed by Dan Bernstein.
+
+        * fast/text/international/old-turkic-direction.html: Added.
+        * fast/text/international/old-turkic-direction-expected.html: Added.
+
 2014-09-22  Myles C. Maxfield  <[email protected]>
 
         REGRESSION: Text with a zero offset, zero blur shadow vanishes

Added: trunk/LayoutTests/fast/text/international/old-turkic-direction-expected.html (0 => 173943)


--- trunk/LayoutTests/fast/text/international/old-turkic-direction-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/international/old-turkic-direction-expected.html	2014-09-25 02:53:48 UTC (rev 173943)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<body>
+<p>Test that checks that at least one Old Turkic character has RTL direction.</p>
+<p>Word that starts with an Old Turkic character, with and without RTL override:</p>
+<p dir="rtl" style="width:100px"><bdo dir="rtl">&#x10C00;a</bdo></p>
+<p dir="rtl" style="width:100px"><bdo dir="rtl">&#x10C00;a</bdo></p>
+<p>Word that has an Old Turkic character in the middle, with and without RTL override:</p>
+<p dir="rtl" style="width:100px"><bdo dir="rtl">b&#x10C00;c</bdo></p>
+<p dir="rtl" style="width:100px"><bdo dir="rtl">b&#x10C00;c</bdo></p>
+</body>
Property changes on: trunk/LayoutTests/fast/text/international/old-turkic-direction-expected.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:eol-style

Added: trunk/LayoutTests/fast/text/international/old-turkic-direction.html (0 => 173943)


--- trunk/LayoutTests/fast/text/international/old-turkic-direction.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/international/old-turkic-direction.html	2014-09-25 02:53:48 UTC (rev 173943)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<body>
+<p>Test that checks that at least one Old Turkic character has RTL direction.</p>
+<p>Word that starts with an Old Turkic character, with and without RTL override:</p>
+<p dir="rtl" style="width:100px">&#x10C00;a</p>
+<p dir="rtl" style="width:100px"><bdo dir="rtl">&#x10C00;a</bdo></p>
+<p>Word that has an Old Turkic character in the middle, with and without RTL override:</p>
+<p dir="rtl" style="width:100px">b&#x10C00;c</p>
+<p dir="rtl" style="width:100px"><bdo dir="rtl">b&#x10C00;c</bdo></p>
+</body>
Property changes on: trunk/LayoutTests/fast/text/international/old-turkic-direction.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:eol-style

Modified: trunk/Source/WebCore/CMakeLists.txt (173942 => 173943)


--- trunk/Source/WebCore/CMakeLists.txt	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/CMakeLists.txt	2014-09-25 02:53:48 UTC (rev 173943)
@@ -2281,6 +2281,7 @@
     rendering/InlineBox.cpp
     rendering/InlineElementBox.cpp
     rendering/InlineFlowBox.cpp
+    rendering/InlineIterator.cpp
     rendering/InlineTextBox.cpp
     rendering/LayoutRepainter.cpp
     rendering/LayoutState.cpp

Modified: trunk/Source/WebCore/ChangeLog (173942 => 173943)


--- trunk/Source/WebCore/ChangeLog	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/ChangeLog	2014-09-25 02:53:48 UTC (rev 173943)
@@ -1,3 +1,27 @@
+2014-09-24  Darin Adler  <[email protected]>
+
+        Old Turkic characters behave as left-to-right instead of right-to-left, because they are encoded as surrogate pairs.
+        https://bugs.webkit.org/show_bug.cgi?id=70029
+
+        Reviewed by Dan Bernstein.
+
+        Test: fast/text/international/old-turkic-direction.html
+
+        * CMakeLists.txt: Added InlineIterator.cpp.
+        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
+        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * rendering/RenderingAllInOne.cpp: Ditto.
+
+        * rendering/InlineIterator.cpp: Added.
+        (WebCore::InlineIterator::surrogateTextDirection): New function used to compute the direction
+        when a surrogate pair is involved.
+        * rendering/InlineIterator.h: Made the characterAt function private.
+        (WebCore::InlineIterator::previousInSameNode): Took out unneeded range check. A zero will underflow
+        and become a large number and the characterAt function will return 0 in that case.
+        (WebCore::InlineIterator::direction): Added code to check U16_IS_SINGLE before calling
+        u_charDirection, and call surrogateTextDirection instead.
+
 2014-09-24  Christophe Dumez  <[email protected]>
 
         Unreviewed build fix after r173941.

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (173942 => 173943)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2014-09-25 02:53:48 UTC (rev 173943)
@@ -10076,6 +10076,20 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\rendering\InlineIterator.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\rendering\InlineTextBox.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (173942 => 173943)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2014-09-25 02:53:48 UTC (rev 173943)
@@ -2400,6 +2400,9 @@
     <ClCompile Include="..\rendering\InlineFlowBox.cpp">
       <Filter>rendering</Filter>
     </ClCompile>
+    <ClCompile Include="..\rendering\InlineIterator.cpp">
+      <Filter>rendering</Filter>
+    </ClCompile>
     <ClCompile Include="..\rendering\InlineTextBox.cpp">
       <Filter>rendering</Filter>
     </ClCompile>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (173942 => 173943)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-09-25 02:53:48 UTC (rev 173943)
@@ -3117,6 +3117,7 @@
 		9307F1D70AF2D59000DBA31A /* HitTestResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9307F1D50AF2D59000DBA31A /* HitTestResult.cpp */; };
 		9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 9307F1D60AF2D59000DBA31A /* HitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		930908910AF7EDE40081DF01 /* HitTestRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 930908900AF7EDE40081DF01 /* HitTestRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		930C90DD19CF965300D6C21A /* InlineIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930C90DC19CF965300D6C21A /* InlineIterator.cpp */; };
 		930FC68A1072B9280045293E /* TextRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 930FC6891072B9280045293E /* TextRenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93153BCD1417FBBF00FCF5BE /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 93153BCC1417FBBF00FCF5BE /* [email protected] */; };
 		93153BCF1417FBDB00FCF5BE /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 93153BCE1417FBDB00FCF5BE /* [email protected] */; };
@@ -10237,6 +10238,7 @@
 		9307F1D50AF2D59000DBA31A /* HitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResult.cpp; sourceTree = "<group>"; };
 		9307F1D60AF2D59000DBA31A /* HitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HitTestResult.h; sourceTree = "<group>"; };
 		930908900AF7EDE40081DF01 /* HitTestRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HitTestRequest.h; sourceTree = "<group>"; };
+		930C90DC19CF965300D6C21A /* InlineIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineIterator.cpp; sourceTree = "<group>"; };
 		930FC6891072B9280045293E /* TextRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextRenderingMode.h; sourceTree = "<group>"; };
 		93153BCC1417FBBF00FCF5BE /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
 		93153BCE1417FBDB00FCF5BE /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -22216,6 +22218,7 @@
 				A8CFF5DD0A155A05000A4234 /* InlineFlowBox.cpp */,
 				A8CFF5DC0A155A05000A4234 /* InlineFlowBox.h */,
 				BCE789151120D6080060ECE5 /* InlineIterator.h */,
+				930C90DC19CF965300D6C21A /* InlineIterator.cpp */,
 				BCEA481A097D93020094C9E4 /* InlineTextBox.cpp */,
 				BCEA481B097D93020094C9E4 /* InlineTextBox.h */,
 				A120ACA113F9984600FE4AC7 /* LayoutRepainter.cpp */,
@@ -28276,6 +28279,7 @@
 				1AE2AEC70A1D297B00B42B25 /* JSHTMLQuoteElement.cpp in Sources */,
 				1AE2ABAC0A1CE90500B42B25 /* JSHTMLScriptElement.cpp in Sources */,
 				E1E6EEA40B628DA8005F2F70 /* JSHTMLSelectElement.cpp in Sources */,
+				930C90DD19CF965300D6C21A /* InlineIterator.cpp in Sources */,
 				BC17F9660B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp in Sources */,
 				E446143B0CD689CC00FADA75 /* JSHTMLSourceElement.cpp in Sources */,
 				9752D38D1413104B003305BD /* JSHTMLSpanElement.cpp in Sources */,

Added: trunk/Source/WebCore/rendering/InlineIterator.cpp (0 => 173943)


--- trunk/Source/WebCore/rendering/InlineIterator.cpp	                        (rev 0)
+++ trunk/Source/WebCore/rendering/InlineIterator.cpp	2014-09-25 02:53:48 UTC (rev 173943)
@@ -0,0 +1,52 @@
+/*
+
+Copyright (C) 2014 Apple Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1.  Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+2.  Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#include "config.h"
+#include "InlineIterator.h"
+
+namespace WebCore {
+
+UCharDirection InlineIterator::surrogateTextDirection(UChar currentCodeUnit) const
+{
+    RenderText& text = toRenderText(*m_renderer);
+    UChar lead;
+    UChar trail;
+    if (U16_IS_LEAD(currentCodeUnit)) {
+        lead = currentCodeUnit;
+        trail = text.characterAt(m_pos + 1);
+        if (!U16_IS_TRAIL(trail))
+            return U_OTHER_NEUTRAL;
+    } else {
+        ASSERT(U16_IS_TRAIL(currentCodeUnit));
+        lead = text.characterAt(m_pos - 1);
+        if (!U16_IS_LEAD(lead))
+            return U_OTHER_NEUTRAL;
+        trail = currentCodeUnit;
+    }
+    return u_charDirection(U16_GET_SUPPLEMENTARY(lead, trail));
+}
+
+}
Property changes on: trunk/Source/WebCore/rendering/InlineIterator.cpp
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/rendering/InlineIterator.h (173942 => 173943)


--- trunk/Source/WebCore/rendering/InlineIterator.h	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/rendering/InlineIterator.h	2014-09-25 02:53:48 UTC (rev 173943)
@@ -94,12 +94,15 @@
         return (m_renderer && m_renderer->isBR()) || atTextParagraphSeparator();
     }
 
-    UChar characterAt(unsigned) const;
     UChar current() const;
     UChar previousInSameNode() const;
     ALWAYS_INLINE UCharDirection direction() const;
 
 private:
+    UChar characterAt(unsigned) const;
+
+    UCharDirection surrogateTextDirection(UChar currentCodeUnit) const;
+
     RenderElement* m_root;
     RenderObject* m_renderer;
 
@@ -419,18 +422,22 @@
 
 inline UChar InlineIterator::previousInSameNode() const
 {
-    if (!m_pos)
-        return 0;
-
     return characterAt(m_pos - 1);
 }
 
 ALWAYS_INLINE UCharDirection InlineIterator::direction() const
 {
-    if (UChar character = current())
-        return u_charDirection(character);
+    if (UNLIKELY(!m_renderer))
+        return U_OTHER_NEUTRAL;
 
-    if (m_renderer && m_renderer->isListMarker())
+    if (LIKELY(m_renderer->isText())) {
+        UChar codeUnit = toRenderText(*m_renderer).characterAt(m_pos);
+        if (LIKELY(U16_IS_SINGLE(codeUnit)))
+            return u_charDirection(codeUnit);
+        return surrogateTextDirection(codeUnit);
+    }
+
+    if (m_renderer->isListMarker())
         return m_renderer->style().isLeftToRightDirection() ? U_LEFT_TO_RIGHT : U_RIGHT_TO_LEFT;
 
     return U_OTHER_NEUTRAL;

Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (173942 => 173943)


--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp	2014-09-25 02:46:25 UTC (rev 173942)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp	2014-09-25 02:53:48 UTC (rev 173943)
@@ -25,7 +25,6 @@
 
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
-
 #include "AutoTableLayout.cpp"
 #include "BidiRun.cpp"
 #include "BorderEdge.cpp"
@@ -40,6 +39,7 @@
 #include "InlineBox.cpp"
 #include "InlineElementBox.cpp"
 #include "InlineFlowBox.cpp"
+#include "InlineIterator.cpp"
 #include "InlineTextBox.cpp"
 #include "LayoutRepainter.cpp"
 #include "LayoutState.cpp"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to