Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (223679 => 223680)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-10-19 06:07:36 UTC (rev 223679)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-10-19 06:35:30 UTC (rev 223680)
@@ -1,5 +1,27 @@
2017-10-18 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r221921. rdar://problem/35041482
+
+ 2017-09-12 Daniel Bates <daba...@apple.com>
+
+ REGRESSION (r215784): The title of right-to-left pages are empty
+ https://bugs.webkit.org/show_bug.cgi?id=176746
+ <rdar://problem/34211419>
+
+ Reviewed by Brent Fulgham.
+
+ Left truncate a long right-to-left title.
+
+ Right-to-left text represents the visual ordering of text. Internally WebKit stores
+ right-to-left text identically to left-to-right text in memory. So, we can use the
+ same string operation to truncate right-to-left text as we do to truncate left-to-right
+ text.
+
+ * platform/text/StringWithDirection.h:
+ (WebCore::truncateFromEnd):
+
+2017-10-18 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r223589. rdar://problem/34771462
2017-10-17 Myles C. Maxfield <mmaxfi...@apple.com>
Modified: branches/safari-604-branch/Source/WebCore/platform/text/StringWithDirection.h (223679 => 223680)
--- branches/safari-604-branch/Source/WebCore/platform/text/StringWithDirection.h 2017-10-19 06:07:36 UTC (rev 223679)
+++ branches/safari-604-branch/Source/WebCore/platform/text/StringWithDirection.h 2017-10-19 06:35:30 UTC (rev 223680)
@@ -65,9 +65,7 @@
inline StringWithDirection truncateFromEnd(const StringWithDirection& string, unsigned maxLength)
{
- if (string.direction == LTR)
- return StringWithDirection(string.string.left(maxLength), LTR);
- return StringWithDirection(string.string.right(maxLength), RTL);
+ return { string.string.left(maxLength), string.direction };
}
}
Modified: branches/safari-604-branch/Tools/ChangeLog (223679 => 223680)
--- branches/safari-604-branch/Tools/ChangeLog 2017-10-19 06:07:36 UTC (rev 223679)
+++ branches/safari-604-branch/Tools/ChangeLog 2017-10-19 06:35:30 UTC (rev 223680)
@@ -1,3 +1,21 @@
+2017-10-18 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r221921. rdar://problem/35041482
+
+ 2017-09-12 Daniel Bates <daba...@apple.com>
+
+ REGRESSION (r215784): The title of right-to-left pages are empty
+ https://bugs.webkit.org/show_bug.cgi?id=176746
+ <rdar://problem/34211419>
+
+ Reviewed by Brent Fulgham.
+
+ Add unit test to ensure we do not regress StringWithDirection.truncateFromEnd().
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/StringWithDirection.cpp: Added.
+ (TestWebKitAPI::TEST):
+
2017-10-10 Jason Marcell <jmarc...@apple.com>
Cherry-pick r223084. rdar://problem/34857469
Modified: branches/safari-604-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (223679 => 223680)
--- branches/safari-604-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-10-19 06:07:36 UTC (rev 223679)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-10-19 06:35:30 UTC (rev 223680)
@@ -625,6 +625,7 @@
CE3524F81B1431F60028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */; };
CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */; };
CE3524FA1B1443890028A7C5 /* input-focus-blur.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */; };
+ CE4D5DE71F6743BA0072CFC6 /* StringWithDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */; };
CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; };
CEBABD491B71687C0051210A /* should-open-external-schemes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBABD481B71687C0051210A /* should-open-external-schemes.html */; };
CEBCA12F1E3A660100C73293 /* OverrideContentSecurityPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = CEBCA12E1E3A660100C73293 /* OverrideContentSecurityPolicy.mm */; };
@@ -1609,6 +1610,7 @@
CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextFieldDidBeginAndEndEditing.cpp; sourceTree = "<group>"; };
CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextFieldDidBeginAndEndEditing_Bundle.cpp; sourceTree = "<group>"; };
CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "input-focus-blur.html"; sourceTree = "<group>"; };
+ CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StringWithDirection.cpp; sourceTree = "<group>"; };
CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionSet.cpp; sourceTree = "<group>"; };
CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenAndCloseWindow.mm; sourceTree = "<group>"; };
CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "open-and-close-window.html"; sourceTree = "<group>"; };
@@ -2000,6 +2002,7 @@
A17991891E1CA24100A505ED /* SharedBufferTest.cpp */,
A179918A1E1CA24100A505ED /* SharedBufferTest.h */,
ECA680CD1E68CC0900731D20 /* StringUtilities.mm */,
+ CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */,
CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */,
440A1D3814A0103A008A66F2 /* URL.cpp */,
@@ -3241,6 +3244,7 @@
83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */,
7CCE7ED11A411A7E00447C4C /* StringTruncator.mm in Sources */,
ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */,
+ CE4D5DE71F6743BA0072CFC6 /* StringWithDirection.cpp in Sources */,
7CCE7ED21A411A7E00447C4C /* SubresourceErrorCrash.mm in Sources */,
7CCE7EA81A411A1900447C4C /* SyntheticBackingScaleFactorWindow.m in Sources */,
7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */,
Added: branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebCore/StringWithDirection.cpp (0 => 223680)
--- branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebCore/StringWithDirection.cpp (rev 0)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebCore/StringWithDirection.cpp 2017-10-19 06:35:30 UTC (rev 223680)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017 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 "Test.h"
+#include "WTFStringUtilities.h"
+#include <WebCore/StringWithDirection.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST(StringWithDirection, TruncateAtEndWithLeftToRightString)
+{
+ StringWithDirection string { "Cappuccino", LTR };
+ StringWithDirection result;
+
+ result = truncateFromEnd(string, 0);
+ EXPECT_EQ(LTR, result.direction);
+ EXPECT_EQ("", result.string);
+
+ result = truncateFromEnd(string, 1);
+ EXPECT_EQ(LTR, result.direction);
+ EXPECT_EQ("C", result.string);
+
+ result = truncateFromEnd(string, 2);
+ EXPECT_EQ(LTR, result.direction);
+ EXPECT_EQ("Ca", result.string);
+
+ result = truncateFromEnd(string, 1000);
+ EXPECT_EQ(LTR, result.direction);
+ EXPECT_EQ("Cappuccino", result.string);
+}
+
+TEST(StringWithDirection, TruncateAtEndWithRightToLeftString)
+{
+ StringWithDirection string { String::fromUTF8("קָפּוּצִ'ינוֹ"), RTL };
+ StringWithDirection result;
+
+ result = truncateFromEnd(string, 0);
+ EXPECT_EQ(RTL, result.direction);
+ EXPECT_EQ("", result.string);
+
+ result = truncateFromEnd(string, 1);
+ EXPECT_EQ(RTL, result.direction);
+ EXPECT_EQ(String::fromUTF8("ק"), result.string);
+
+ result = truncateFromEnd(string, 2);
+ EXPECT_EQ(RTL, result.direction);
+ EXPECT_EQ(String::fromUTF8("קָ"), result.string);
+
+ result = truncateFromEnd(string, 1000);
+ EXPECT_EQ(RTL, result.direction);
+ EXPECT_EQ(String::fromUTF8("קָפּוּצִ'ינוֹ"), result.string);
+}
+
+} // namespace TestWebKitAPI