Skip to content

Commit

Permalink
Merge r173943 - Old Turkic characters behave as left-to-right instead…
Browse files Browse the repository at this point in the history
… 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.

Canonical link: https://commits.webkit.org/154760.49@webkitgtk/2.6
git-svn-id: https://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.6@174436 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
darinadler authored and carlosgcampos committed Oct 8, 2014
1 parent ca0e5a7 commit 03f2a89
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 8 deletions.
10 changes: 10 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
2014-09-24 Darin Adler <darin@apple.com>

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 <mmaxfield@apple.com>

REGRESSION: Text with a zero offset, zero blur shadow vanishes
Expand Down
@@ -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>
10 changes: 10 additions & 0 deletions LayoutTests/fast/text/international/old-turkic-direction.html
@@ -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>
1 change: 1 addition & 0 deletions Source/WebCore/CMakeLists.txt
Expand Up @@ -2281,6 +2281,7 @@ set(WebCore_SOURCES
rendering/InlineBox.cpp
rendering/InlineElementBox.cpp
rendering/InlineFlowBox.cpp
rendering/InlineIterator.cpp
rendering/InlineTextBox.cpp
rendering/LayoutRepainter.cpp
rendering/LayoutState.cpp
Expand Down
24 changes: 24 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,27 @@
2014-09-24 Darin Adler <darin@apple.com>

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 <cdumez@apple.com>

Unreviewed build fix after r173941.
Expand Down
14 changes: 14 additions & 0 deletions Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -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 /* deleteButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 93153BCC1417FBBF00FCF5BE /* deleteButton@2x.png */; };
93153BCF1417FBDB00FCF5BE /* deleteButtonPressed@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 93153BCE1417FBDB00FCF5BE /* deleteButtonPressed@2x.png */; };
Expand Down Expand Up @@ -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 /* deleteButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "deleteButton@2x.png"; sourceTree = "<group>"; };
93153BCE1417FBDB00FCF5BE /* deleteButtonPressed@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "deleteButtonPressed@2x.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
52 changes: 52 additions & 0 deletions Source/WebCore/rendering/InlineIterator.cpp
@@ -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));
}

}
21 changes: 14 additions & 7 deletions Source/WebCore/rendering/InlineIterator.h
Expand Up @@ -94,12 +94,15 @@ class InlineIterator {
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;

Expand Down Expand Up @@ -419,18 +422,22 @@ inline UChar InlineIterator::current() const

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 (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 && m_renderer->isListMarker())
if (m_renderer->isListMarker())
return m_renderer->style().isLeftToRightDirection() ? U_LEFT_TO_RIGHT : U_RIGHT_TO_LEFT;

return U_OTHER_NEUTRAL;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderingAllInOne.cpp
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 03f2a89

Please sign in to comment.