Title: [212235] trunk
Revision
212235
Author
mmaxfi...@apple.com
Date
2017-02-13 11:07:43 -0800 (Mon, 13 Feb 2017)

Log Message

Update custom line breaking iterators to the latest version of Unicode
https://bugs.webkit.org/show_bug.cgi?id=168182

Reviewed by Zalan Bujtas.

Source/WebCore:

Clean up our breaking code to be more descriptive about the difference between
line-break: auto vs line-break: loose | normal | strict. The only difference is
that we have some hardcoded tables to speed up character iteration for
line-break: auto.

Tests: TestWebKitAPI WebKit2.LineBreaking

* rendering/BreakLines.h:
(WebCore::nextBreakablePosition):
(WebCore::nextBreakablePositionIgnoringNBSP):
(WebCore::nextBreakablePositionWithoutShortcut):
(WebCore::nextBreakablePositionIgnoringNBSPWithoutShortcut):
(WebCore::isBreakable):
(WebCore::nextBreakablePositionNonLoosely): Deleted.
(WebCore::nextBreakablePositionLoosely): Deleted.
(WebCore::nextBreakablePositionLoose): Deleted.
(WebCore::nextBreakablePositionIgnoringNBSPLoose): Deleted.
* rendering/RenderText.cpp:
(WebCore::RenderText::computePreferredLogicalWidths):
* rendering/SimpleLineLayoutTextFragmentIterator.cpp:
(WebCore::SimpleLineLayout::nextBreakablePositionInSegment):
* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleText):
(WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord):

Source/WTF:

ICU 55.1 supports loose / normal / strict line breaking rules. The oldest platform we ship
on has a version of ICU >= that one. Therefore, we don't need to compile our own rules;
we can just use ICU's rules.

* wtf/text/LineBreakIteratorPoolICU.h:
(WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
(WTF::LineBreakIteratorPool::take):
* wtf/text/TextBreakIterator.cpp:
(WTF::acquireLineBreakIterator):
(WTF::openLineBreakIterator):
(WTF::mapLineIteratorModeToRules): Deleted.
(WTF::isCJKLocale): Deleted.
* wtf/text/TextBreakIterator.h:
(WTF::LazyLineBreakIterator::LazyLineBreakIterator):
(WTF::LazyLineBreakIterator::mode):
(WTF::LazyLineBreakIterator::get):
(WTF::LazyLineBreakIterator::resetStringAndReleaseIterator):
(WTF::LazyLineBreakIterator::isLooseCJKMode): Deleted.

Tools:

Treat the system's ICU as the source of truth to compare breaking positions against.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/LineBreaking.mm: Added.
(generateJavaScriptForTest):
(breakingLocationsFromICU):
(testAFewStrings):
(TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/AllAhem.svg: Renamed from LayoutTests/css3/line-break/resources/AllAhem.svg.
* TestWebKitAPI/Tests/WebKit2Cocoa/LineBreaking.html: Added.

LayoutTests:

Migrated to TestWebKitAPI.

* css3/line-break/line-break-auto-centered-2-expected.html: Removed.
* css3/line-break/line-break-auto-centered-2.html: Removed.
* css3/line-break/line-break-auto-centered-expected.html: Removed.
* css3/line-break/line-break-auto-centered.html: Removed.
* css3/line-break/line-break-auto-half-kana-2-expected.html: Removed.
* css3/line-break/line-break-auto-half-kana-2.html: Removed.
* css3/line-break/line-break-auto-half-kana-3-expected.html: Removed.
* css3/line-break/line-break-auto-half-kana-3.html: Removed.
* css3/line-break/line-break-auto-half-kana-4-expected.html: Removed.
* css3/line-break/line-break-auto-half-kana-4.html: Removed.
* css3/line-break/line-break-auto-half-kana-5-expected.html: Removed.
* css3/line-break/line-break-auto-half-kana-5.html: Removed.
* css3/line-break/line-break-auto-half-kana-expected.html: Removed.
* css3/line-break/line-break-auto-half-kana.html: Removed.
* css3/line-break/line-break-auto-hyphens-expected.html: Removed.
* css3/line-break/line-break-auto-hyphens.html: Removed.
* css3/line-break/line-break-auto-inseparables-expected.html: Removed.
* css3/line-break/line-break-auto-inseparables.html: Removed.
* css3/line-break/line-break-auto-iteration-marks-expected.html: Removed.
* css3/line-break/line-break-auto-iteration-marks.html: Removed.
* css3/line-break/line-break-auto-postfixes-expected.html: Removed.
* css3/line-break/line-break-auto-postfixes.html: Removed.
* css3/line-break/line-break-auto-prefixes-expected.html: Removed.
* css3/line-break/line-break-auto-prefixes.html: Removed.
* css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
* css3/line-break/line-break-auto-sound-marks.html: Removed.
* css3/line-break/line-break-loose-centered-2-expected.html: Removed.
* css3/line-break/line-break-loose-centered-2.html: Removed.
* css3/line-break/line-break-loose-centered-expected.html: Removed.
* css3/line-break/line-break-loose-centered.html: Removed.
* css3/line-break/line-break-loose-half-kana-2-expected.html: Removed.
* css3/line-break/line-break-loose-half-kana-2.html: Removed.
* css3/line-break/line-break-loose-half-kana-3-expected.html: Removed.
* css3/line-break/line-break-loose-half-kana-3.html: Removed.
* css3/line-break/line-break-loose-half-kana-4-expected.html: Removed.
* css3/line-break/line-break-loose-half-kana-4.html: Removed.
* css3/line-break/line-break-loose-half-kana-5-expected.html: Removed.
* css3/line-break/line-break-loose-half-kana-5.html: Removed.
* css3/line-break/line-break-loose-half-kana-expected.html: Removed.
* css3/line-break/line-break-loose-half-kana.html: Removed.
* css3/line-break/line-break-loose-hyphens-expected.html: Removed.
* css3/line-break/line-break-loose-hyphens.html: Removed.
* css3/line-break/line-break-loose-inseparables-expected.html: Removed.
* css3/line-break/line-break-loose-inseparables.html: Removed.
* css3/line-break/line-break-loose-iteration-marks-expected.html: Removed.
* css3/line-break/line-break-loose-iteration-marks.html: Removed.
* css3/line-break/line-break-loose-postfixes-expected.html: Removed.
* css3/line-break/line-break-loose-postfixes.html: Removed.
* css3/line-break/line-break-loose-prefixes-expected.html: Removed.
* css3/line-break/line-break-loose-prefixes.html: Removed.
* css3/line-break/line-break-loose-sound-marks-expected.html: Removed.
* css3/line-break/line-break-loose-sound-marks.html: Removed.
* css3/line-break/line-break-normal-centered-2-expected.html: Removed.
* css3/line-break/line-break-normal-centered-2.html: Removed.
* css3/line-break/line-break-normal-centered-expected.html: Removed.
* css3/line-break/line-break-normal-centered.html: Removed.
* css3/line-break/line-break-normal-half-kana-2-expected.html: Removed.
* css3/line-break/line-break-normal-half-kana-2.html: Removed.
* css3/line-break/line-break-normal-half-kana-3-expected.html: Removed.
* css3/line-break/line-break-normal-half-kana-3.html: Removed.
* css3/line-break/line-break-normal-half-kana-4-expected.html: Removed.
* css3/line-break/line-break-normal-half-kana-4.html: Removed.
* css3/line-break/line-break-normal-half-kana-5-expected.html: Removed.
* css3/line-break/line-break-normal-half-kana-5.html: Removed.
* css3/line-break/line-break-normal-half-kana-expected.html: Removed.
* css3/line-break/line-break-normal-half-kana.html: Removed.
* css3/line-break/line-break-normal-hyphens-expected.html: Removed.
* css3/line-break/line-break-normal-hyphens.html: Removed.
* css3/line-break/line-break-normal-inseparables-expected.html: Removed.
* css3/line-break/line-break-normal-inseparables.html: Removed.
* css3/line-break/line-break-normal-iteration-marks-expected.html: Removed.
* css3/line-break/line-break-normal-iteration-marks.html: Removed.
* css3/line-break/line-break-normal-postfixes-expected.html: Removed.
* css3/line-break/line-break-normal-postfixes.html: Removed.
* css3/line-break/line-break-normal-prefixes-expected.html: Removed.
* css3/line-break/line-break-normal-prefixes.html: Removed.
* css3/line-break/line-break-normal-sound-marks-expected.html: Removed.
* css3/line-break/line-break-normal-sound-marks.html: Removed.
* css3/line-break/line-break-strict-centered-2-expected.html: Removed.
* css3/line-break/line-break-strict-centered-2.html: Removed.
* css3/line-break/line-break-strict-centered-expected.html: Removed.
* css3/line-break/line-break-strict-centered.html: Removed.
* css3/line-break/line-break-strict-half-kana-2-expected.html: Removed.
* css3/line-break/line-break-strict-half-kana-2.html: Removed.
* css3/line-break/line-break-strict-half-kana-3-expected.html: Removed.
* css3/line-break/line-break-strict-half-kana-3.html: Removed.
* css3/line-break/line-break-strict-half-kana-4-expected.html: Removed.
* css3/line-break/line-break-strict-half-kana-4.html: Removed.
* css3/line-break/line-break-strict-half-kana-5-expected.html: Removed.
* css3/line-break/line-break-strict-half-kana-5.html: Removed.
* css3/line-break/line-break-strict-half-kana-expected.html: Removed.
* css3/line-break/line-break-strict-half-kana.html: Removed.
* css3/line-break/line-break-strict-hyphens-expected.html: Removed.
* css3/line-break/line-break-strict-hyphens.html: Removed.
* css3/line-break/line-break-strict-inseparables-expected.html: Removed.
* css3/line-break/line-break-strict-inseparables.html: Removed.
* css3/line-break/line-break-strict-iteration-marks-expected.html: Removed.
* css3/line-break/line-break-strict-iteration-marks.html: Removed.
* css3/line-break/line-break-strict-postfixes-expected.html: Removed.
* css3/line-break/line-break-strict-postfixes.html: Removed.
* css3/line-break/line-break-strict-prefixes-expected.html: Removed.
* css3/line-break/line-break-strict-prefixes.html: Removed.
* css3/line-break/line-break-strict-sound-marks-expected.html: Removed.
* css3/line-break/line-break-strict-sound-marks.html: Removed.
* platform/ios-simulator-wk1/TestExpectations:
* platform/ios-simulator/TestExpectations:

Modified Paths

Added Paths

Removed Paths

  • trunk/LayoutTests/css3/line-break/

Diff

Modified: trunk/LayoutTests/ChangeLog (212234 => 212235)


--- trunk/LayoutTests/ChangeLog	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/LayoutTests/ChangeLog	2017-02-13 19:07:43 UTC (rev 212235)
@@ -1,3 +1,119 @@
+2017-02-13  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Update custom line breaking iterators to the latest version of Unicode
+        https://bugs.webkit.org/show_bug.cgi?id=168182
+
+        Reviewed by Zalan Bujtas.
+
+        Migrated to TestWebKitAPI.
+
+        * css3/line-break/line-break-auto-centered-2-expected.html: Removed.
+        * css3/line-break/line-break-auto-centered-2.html: Removed.
+        * css3/line-break/line-break-auto-centered-expected.html: Removed.
+        * css3/line-break/line-break-auto-centered.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-2-expected.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-2.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-3-expected.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-3.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-4-expected.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-4.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-5-expected.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-5.html: Removed.
+        * css3/line-break/line-break-auto-half-kana-expected.html: Removed.
+        * css3/line-break/line-break-auto-half-kana.html: Removed.
+        * css3/line-break/line-break-auto-hyphens-expected.html: Removed.
+        * css3/line-break/line-break-auto-hyphens.html: Removed.
+        * css3/line-break/line-break-auto-inseparables-expected.html: Removed.
+        * css3/line-break/line-break-auto-inseparables.html: Removed.
+        * css3/line-break/line-break-auto-iteration-marks-expected.html: Removed.
+        * css3/line-break/line-break-auto-iteration-marks.html: Removed.
+        * css3/line-break/line-break-auto-postfixes-expected.html: Removed.
+        * css3/line-break/line-break-auto-postfixes.html: Removed.
+        * css3/line-break/line-break-auto-prefixes-expected.html: Removed.
+        * css3/line-break/line-break-auto-prefixes.html: Removed.
+        * css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
+        * css3/line-break/line-break-auto-sound-marks.html: Removed.
+        * css3/line-break/line-break-loose-centered-2-expected.html: Removed.
+        * css3/line-break/line-break-loose-centered-2.html: Removed.
+        * css3/line-break/line-break-loose-centered-expected.html: Removed.
+        * css3/line-break/line-break-loose-centered.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-2-expected.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-2.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-3-expected.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-3.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-4-expected.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-4.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-5-expected.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-5.html: Removed.
+        * css3/line-break/line-break-loose-half-kana-expected.html: Removed.
+        * css3/line-break/line-break-loose-half-kana.html: Removed.
+        * css3/line-break/line-break-loose-hyphens-expected.html: Removed.
+        * css3/line-break/line-break-loose-hyphens.html: Removed.
+        * css3/line-break/line-break-loose-inseparables-expected.html: Removed.
+        * css3/line-break/line-break-loose-inseparables.html: Removed.
+        * css3/line-break/line-break-loose-iteration-marks-expected.html: Removed.
+        * css3/line-break/line-break-loose-iteration-marks.html: Removed.
+        * css3/line-break/line-break-loose-postfixes-expected.html: Removed.
+        * css3/line-break/line-break-loose-postfixes.html: Removed.
+        * css3/line-break/line-break-loose-prefixes-expected.html: Removed.
+        * css3/line-break/line-break-loose-prefixes.html: Removed.
+        * css3/line-break/line-break-loose-sound-marks-expected.html: Removed.
+        * css3/line-break/line-break-loose-sound-marks.html: Removed.
+        * css3/line-break/line-break-normal-centered-2-expected.html: Removed.
+        * css3/line-break/line-break-normal-centered-2.html: Removed.
+        * css3/line-break/line-break-normal-centered-expected.html: Removed.
+        * css3/line-break/line-break-normal-centered.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-2-expected.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-2.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-3-expected.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-3.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-4-expected.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-4.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-5-expected.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-5.html: Removed.
+        * css3/line-break/line-break-normal-half-kana-expected.html: Removed.
+        * css3/line-break/line-break-normal-half-kana.html: Removed.
+        * css3/line-break/line-break-normal-hyphens-expected.html: Removed.
+        * css3/line-break/line-break-normal-hyphens.html: Removed.
+        * css3/line-break/line-break-normal-inseparables-expected.html: Removed.
+        * css3/line-break/line-break-normal-inseparables.html: Removed.
+        * css3/line-break/line-break-normal-iteration-marks-expected.html: Removed.
+        * css3/line-break/line-break-normal-iteration-marks.html: Removed.
+        * css3/line-break/line-break-normal-postfixes-expected.html: Removed.
+        * css3/line-break/line-break-normal-postfixes.html: Removed.
+        * css3/line-break/line-break-normal-prefixes-expected.html: Removed.
+        * css3/line-break/line-break-normal-prefixes.html: Removed.
+        * css3/line-break/line-break-normal-sound-marks-expected.html: Removed.
+        * css3/line-break/line-break-normal-sound-marks.html: Removed.
+        * css3/line-break/line-break-strict-centered-2-expected.html: Removed.
+        * css3/line-break/line-break-strict-centered-2.html: Removed.
+        * css3/line-break/line-break-strict-centered-expected.html: Removed.
+        * css3/line-break/line-break-strict-centered.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-2-expected.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-2.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-3-expected.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-3.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-4-expected.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-4.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-5-expected.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-5.html: Removed.
+        * css3/line-break/line-break-strict-half-kana-expected.html: Removed.
+        * css3/line-break/line-break-strict-half-kana.html: Removed.
+        * css3/line-break/line-break-strict-hyphens-expected.html: Removed.
+        * css3/line-break/line-break-strict-hyphens.html: Removed.
+        * css3/line-break/line-break-strict-inseparables-expected.html: Removed.
+        * css3/line-break/line-break-strict-inseparables.html: Removed.
+        * css3/line-break/line-break-strict-iteration-marks-expected.html: Removed.
+        * css3/line-break/line-break-strict-iteration-marks.html: Removed.
+        * css3/line-break/line-break-strict-postfixes-expected.html: Removed.
+        * css3/line-break/line-break-strict-postfixes.html: Removed.
+        * css3/line-break/line-break-strict-prefixes-expected.html: Removed.
+        * css3/line-break/line-break-strict-prefixes.html: Removed.
+        * css3/line-break/line-break-strict-sound-marks-expected.html: Removed.
+        * css3/line-break/line-break-strict-sound-marks.html: Removed.
+        * platform/ios-simulator-wk1/TestExpectations:
+        * platform/ios-simulator/TestExpectations:
+
 2017-02-13  Ryan Haddad  <ryanhad...@apple.com>
 
         TestExpectations gardening for imported/w3c/web-platform-tests/html/semantics/text-level-semantics/the-a-element/a-download-click.html.

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (212234 => 212235)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-02-13 19:07:43 UTC (rev 212235)
@@ -2335,13 +2335,6 @@
 webkit.org/b/148806 imported/w3c/css/css-multicol-1/multicol-span-all-block-sibling-003.xht [ ImageOnlyFailure ]
 webkit.org/b/148806 imported/w3c/css/css-multicol-1/multicol-span-all-margin-nested-firstchild-001.xht [ ImageOnlyFailure ]
 
-# Flaky tests ( these tests were affected by https://bugs.webkit.org/show_bug.cgi?id=149320 )
-
-css3/line-break/line-break-loose-centered.html [ ImageOnlyFailure Pass ]
-css3/line-break/line-break-loose-postfixes.html [ ImageOnlyFailure Pass ]
-css3/line-break/line-break-loose-sound-marks.html [ ImageOnlyFailure Pass ]
-css3/line-break/line-break-normal-sound-marks.html [ ImageOnlyFailure Pass ]
-
 # Enable "aria-current" test for iOS
 webkit.org/b/149297 accessibility/aria-current.html [ Pass ]
 

Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (212234 => 212235)


--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2017-02-13 19:07:43 UTC (rev 212235)
@@ -673,7 +673,6 @@
 css3/filters/backdrop/backdrop-filter-with-border-radius-and-reflection.html [ ImageOnlyFailure ]
 css3/filters/backdrop/backdrop-filter-with-clip-path.html [ ImageOnlyFailure ]
 css3/flexbox/content-height-with-scrollbars.html [ ImageOnlyFailure ]
-css3/line-break/line-break-auto-centered-2.html [ ImageOnlyFailure ]
 css3/masking/mask-repeat-space-border.html [ ImageOnlyFailure ]
 
 # CSS tests that pass:

Modified: trunk/Source/WTF/ChangeLog (212234 => 212235)


--- trunk/Source/WTF/ChangeLog	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WTF/ChangeLog	2017-02-13 19:07:43 UTC (rev 212235)
@@ -1,3 +1,29 @@
+2017-02-13  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Update custom line breaking iterators to the latest version of Unicode
+        https://bugs.webkit.org/show_bug.cgi?id=168182
+
+        Reviewed by Zalan Bujtas.
+
+        ICU 55.1 supports loose / normal / strict line breaking rules. The oldest platform we ship
+        on has a version of ICU >= that one. Therefore, we don't need to compile our own rules;
+        we can just use ICU's rules.
+
+        * wtf/text/LineBreakIteratorPoolICU.h:
+        (WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
+        (WTF::LineBreakIteratorPool::take):
+        * wtf/text/TextBreakIterator.cpp:
+        (WTF::acquireLineBreakIterator):
+        (WTF::openLineBreakIterator):
+        (WTF::mapLineIteratorModeToRules): Deleted.
+        (WTF::isCJKLocale): Deleted.
+        * wtf/text/TextBreakIterator.h:
+        (WTF::LazyLineBreakIterator::LazyLineBreakIterator):
+        (WTF::LazyLineBreakIterator::mode):
+        (WTF::LazyLineBreakIterator::get):
+        (WTF::LazyLineBreakIterator::resetStringAndReleaseIterator):
+        (WTF::LazyLineBreakIterator::isLooseCJKMode): Deleted.
+
 2017-02-10  Dan Bernstein  <m...@apple.com>
 
         [Xcode] WTF installs extra copies of two headers outside /usr/local/include/wtf

Modified: trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h (212234 => 212235)


--- trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h	2017-02-13 19:07:43 UTC (rev 212235)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "TextBreakIterator.h"
+#include <unicode/uloc.h>
 #include <wtf/HashMap.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/ThreadSpecific.h>
@@ -46,21 +47,46 @@
 
     static AtomicString makeLocaleWithBreakKeyword(const AtomicString& locale, LineBreakIteratorMode mode)
     {
+        // The uloc functions model locales as char*, so we have to downconvert our AtomicString.
+        auto utf8Locale = locale.string().utf8();
+        if (!utf8Locale.length())
+            return locale;
+        Vector<char> scratchBuffer(utf8Locale.length() + 11, 0);
+        memcpy(scratchBuffer.data(), utf8Locale.data(), utf8Locale.length());
+
+        const char* keywordValue = nullptr;
         switch (mode) {
         case LineBreakIteratorMode::Default:
-            return locale;
+            // nullptr will cause any existing values to be removed.
+            break;
         case LineBreakIteratorMode::Loose:
-            return makeString(locale, "@break=loose");
+            keywordValue = "loose";
+            break;
         case LineBreakIteratorMode::Normal:
-            return makeString(locale, "@break=normal");
+            keywordValue = "normal";
+            break;
         case LineBreakIteratorMode::Strict:
-            return makeString(locale, "@break=strict");
+            keywordValue = "strict";
+            break;
         }
-        ASSERT_NOT_REACHED();
+
+        UErrorCode status = U_ZERO_ERROR;
+        int32_t lengthNeeded = uloc_setKeywordValue("lb", keywordValue, scratchBuffer.data(), scratchBuffer.size(), &status);
+        if (U_SUCCESS(status))
+            return AtomicString::fromUTF8(scratchBuffer.data(), lengthNeeded);
+        if (status == U_BUFFER_OVERFLOW_ERROR) {
+            scratchBuffer.grow(lengthNeeded + 1);
+            memset(scratchBuffer.data() + utf8Locale.length(), 0, scratchBuffer.size() - utf8Locale.length());
+            status = U_ZERO_ERROR;
+            int32_t lengthNeeded2 = uloc_setKeywordValue("lb", keywordValue, scratchBuffer.data(), scratchBuffer.size(), &status);
+            if (!U_SUCCESS(status) || lengthNeeded != lengthNeeded2)
+                return locale;
+            return AtomicString::fromUTF8(scratchBuffer.data(), lengthNeeded);
+        }
         return locale;
     }
 
-    UBreakIterator* take(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
+    UBreakIterator* take(const AtomicString& locale, LineBreakIteratorMode mode)
     {
         auto localeWithOptionalBreakKeyword = makeLocaleWithBreakKeyword(locale, mode);
 
@@ -74,7 +100,7 @@
         }
 
         if (!iterator) {
-            iterator = openLineBreakIterator(localeWithOptionalBreakKeyword, mode, isCJK);
+            iterator = openLineBreakIterator(localeWithOptionalBreakKeyword);
             if (!iterator)
                 return nullptr;
         }

Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.cpp (212234 => 212235)


--- trunk/Source/WTF/wtf/text/TextBreakIterator.cpp	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WTF/wtf/text/TextBreakIterator.cpp	2017-02-13 19:07:43 UTC (rev 212235)
@@ -303,9 +303,9 @@
     return setTextForIterator(*staticCursorMovementIterator, string);
 }
 
-UBreakIterator* acquireLineBreakIterator(StringView string, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode mode, bool isCJK)
+UBreakIterator* acquireLineBreakIterator(StringView string, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode mode)
 {
-    UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale, mode, isCJK);
+    UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale, mode);
     if (!iterator)
         return nullptr;
 
@@ -319,479 +319,11 @@
     LineBreakIteratorPool::sharedPool().put(iterator);
 }
 
-static const char* uax14Prologue =
-    "!!chain;"
-    "!!LBCMNoChain;"
-    "!!lookAheadHardBreak;";
-
-static const char* uax14AssignmentsBefore =
-    // explicitly enumerate $CJ since ICU versions prior to 49 don't support :LineBreak=Conditional_Japanese_Starter:
-    "$CJ = ["
-#if (U_ICU_VERSION_MAJOR_NUM >= 4) && (U_ICU_VERSION_MINOR_NUM >= 9)
-    ":LineBreak=Conditional_Japanese_Starter:"
-#else
-    "\\u3041\\u3043\\u3045\\u3047\\u3049\\u3063\\u3083\\u3085\\u3087\\u308E\\u3095\\u3096\\u30A1\\u30A3\\u30A5\\u30A7"
-    "\\u30A9\\u30C3\\u30E3\\u30E5\\u30E7\\u30EE\\u30F5\\u30F6\\u30FC"
-    "\\u31F0\\u31F1\\u31F2\\u31F3\\u31F4\\u31F5\\u31F6\\u31F7\\u31F8\\u31F9\\u31FA\\u31FB\\u31FC\\u31FD\\u31FE\\u31FF"
-    "\\uFF67\\uFF68\\uFF69\\uFF6A\\uFF6B\\uFF6C\\uFF6D\\uFF6E\\uFF6F\\uFF70"
-#endif
-    "];";
-
-static const char* uax14AssignmentsCustomLooseCJK =
-    "$BA_SUB = [\\u2010\\u2013];"
-    "$EX_SUB = [\\u0021\\u003F\\uFF01\\uFF1F];"
-    "$ID_SUB = '';"
-    "$IN_SUB = [\\u2025\\u2026];"
-    "$IS_SUB = [\\u003A\\u003B];"
-    "$NS_SUB = [\\u203C\\u2047\\u2048\\u2049\\u3005\\u301C\\u303B\\u309D\\u309E\\u30A0\\u30FB\\u30FD\\u30FE\\uFF1A\\uFF1B\\uFF65];"
-    "$PO_SUB = [\\u0025\\u00A2\\u00B0\\u2030\\u2032\\u2033\\u2103\\uFF05\\uFFE0];"
-    "$PR_SUB = [\\u0024\\u00A3\\u00A5\\u20AC\\u2116\\uFF04\\uFFE1\\uFFE5];"
-    "$ID_ADD = [$CJ $BA_SUB $EX_SUB $IN_SUB $IS_SUB $NS_SUB $PO_SUB $PR_SUB];"
-    "$NS_ADD = '';";
-
-static const char* uax14AssignmentsCustomLooseNonCJK =
-    "$BA_SUB = '';"
-    "$EX_SUB = '';"
-    "$ID_SUB = '';"
-    "$IN_SUB = [\\u2025\\u2026];"
-    "$IS_SUB = '';"
-    "$NS_SUB = [\\u3005\\u303B\\u309D\\u309E\\u30FD\\u30FE];"
-    "$PO_SUB = '';"
-    "$PR_SUB = '';"
-    "$ID_ADD = [$CJ $IN_SUB $NS_SUB];"
-    "$NS_ADD = '';";
-
-static const char* uax14AssignmentsCustomNormalCJK =
-    "$BA_SUB = [\\u2010\\u2013];"
-    "$EX_SUB = '';"
-    "$IN_SUB = '';"
-    "$ID_SUB = '';"
-    "$IS_SUB = '';"
-    "$NS_SUB = [\\u301C\\u30A0];"
-    "$PO_SUB = '';"
-    "$PR_SUB = '';"
-    "$ID_ADD = [$CJ $BA_SUB $NS_SUB];"
-    "$NS_ADD = '';";
-
-static const char* uax14AssignmentsCustomNormalNonCJK =
-    "$BA_SUB = '';"
-    "$EX_SUB = '';"
-    "$ID_SUB = '';"
-    "$IN_SUB = '';"
-    "$IS_SUB = '';"
-    "$NS_SUB = '';"
-    "$PO_SUB = '';"
-    "$PR_SUB = '';"
-    "$ID_ADD = [$CJ];"
-    "$NS_ADD = '';";
-
-static const char* uax14AssignmentsCustomStrictCJK =
-    "$BA_SUB = '';"
-    "$EX_SUB = '';"
-    "$ID_SUB = '';"
-    "$IN_SUB = '';"
-    "$IS_SUB = '';"
-    "$NS_SUB = '';"
-    "$PO_SUB = '';"
-    "$PR_SUB = '';"
-    "$ID_ADD = '';"
-    "$NS_ADD = [$CJ];";
-
-#define uax14AssignmentsCustomStrictNonCJK      uax14AssignmentsCustomStrictCJK
-#define uax14AssignmentsCustomDefaultCJK        uax14AssignmentsCustomNormalCJK
-#define uax14AssignmentsCustomDefaultNonCJK     uax14AssignmentsCustomStrictNonCJK
-
-static const char* uax14AssignmentsAfter =
-    "$AI = [:LineBreak = Ambiguous:];"
-    "$AL = [:LineBreak = Alphabetic:];"
-    "$BA = [[:LineBreak = Break_After:] - $BA_SUB];"
-    "$BB = [:LineBreak = Break_Before:];"
-    "$BK = [:LineBreak = Mandatory_Break:];"
-    "$B2 = [:LineBreak = Break_Both:];"
-    "$CB = [:LineBreak = Contingent_Break:];"
-    "$CL = [:LineBreak = Close_Punctuation:];"
-    "$CM = [:LineBreak = Combining_Mark:];"
-    "$CP = [:LineBreak = Close_Parenthesis:];"
-    "$CR = [:LineBreak = Carriage_Return:];"
-    "$EX = [[:LineBreak = Exclamation:] - $EX_SUB];"
-    "$GL = [:LineBreak = Glue:];"
-#if (U_ICU_VERSION_MAJOR_NUM >= 4) && (U_ICU_VERSION_MINOR_NUM >= 9)
-    "$HL = [:LineBreak = Hebrew_Letter:];"
-#else
-    "$HL = [[:Hebrew:] & [:Letter:]];"
-#endif
-    "$HY = [:LineBreak = Hyphen:];"
-    "$H2 = [:LineBreak = H2:];"
-    "$H3 = [:LineBreak = H3:];"
-    "$ID = [[[[:LineBreak = Ideographic:] - $CJ] $ID_ADD] - $ID_SUB];"
-    "$IN = [[:LineBreak = Inseparable:] - $IN_SUB];"
-    "$IS = [[:LineBreak = Infix_Numeric:] - $IS_SUB];"
-    "$JL = [:LineBreak = JL:];"
-    "$JV = [:LineBreak = JV:];"
-    "$JT = [:LineBreak = JT:];"
-    "$LF = [:LineBreak = Line_Feed:];"
-    "$NL = [:LineBreak = Next_Line:];"
-    "$NS = [[[[:LineBreak = Nonstarter:] - $CJ] $NS_ADD] - $NS_SUB];"
-    "$NU = [:LineBreak = Numeric:];"
-    "$OP = [:LineBreak = Open_Punctuation:];"
-    "$PO = [[:LineBreak = Postfix_Numeric:] - $PO_SUB];"
-    "$PR = [[:LineBreak = Prefix_Numeric:] - $PR_SUB];"
-    "$QU = [:LineBreak = Quotation:];"
-    "$RI = [\\U0001F1E6-\\U0001F1FF];"
-    "$SA = [:LineBreak = Complex_Context:];"
-    "$SG = [:LineBreak = Surrogate:];"
-    "$SP = [:LineBreak = Space:];"
-    "$SY = [:LineBreak = Break_Symbols:];"
-    "$WJ = [:LineBreak = Word_Joiner:];"
-    "$XX = [:LineBreak = Unknown:];"
-    "$ZW = [:LineBreak = ZWSpace:];"
-    "$ZWJ = \\u200D;"
-    "$EmojiVar = \\uFE0F;"
-#if ADDITIONAL_EMOJI_SUPPORT
-    "$EmojiForSeqs = [\\u2640 \\u2642 \\u26F9 \\u2764 \\U0001F308 \\U0001F3C3-\\U0001F3C4 \\U0001F3CA-\\U0001F3CC \\U0001F3F3 \\U0001F441 \\U0001F466-\\U0001F469 \\U0001F46E-\\U0001F46F \\U0001F471 \\U0001F473 \\U0001F477 \\U0001F481-\\U0001F482 \\U0001F486-\\U0001F487 \\U0001F48B \\U0001F575 \\U0001F5E8 \\U0001F645-\\U0001F647 \\U0001F64B \\U0001F64D-\\U0001F64E \\U0001F6A3 \\U0001F6B4-\\U0001F6B6 \\u2695-\\u2696 \\u2708 \\U0001F33E \\U0001F373 \\U0001F393 \\U0001F3A4 \\U0001F3A8 \\U0001F3EB \\U0001F3ED \\U0001F4BB-\\U0001F4BC \\U0001F527 \\U0001F52C \\U0001F680 \\U0001F692 \\U0001F926 \\U0001F937-\\U0001F939 \\U0001F93C-\\U0001F93E];" // Emoji that participate in ZWJ sequences
-    "$EmojiForMods = [\\u261D \\u26F9 \\u270A-\\u270D \\U0001F385 \\U0001F3C3-\\U0001F3C4 \\U0001F3CA \\U0001F3CB \\U0001F442-\\U0001F443 \\U0001F446-\\U0001F450 \\U0001F466-\\U0001F478 \\U0001F47C \\U0001F481-\\U0001F483 \\U0001F485-\\U0001F487 \\U0001F4AA \\U0001F575 \\U0001F590 \\U0001F595 \\U0001F596 \\U0001F645-\\U0001F647 \\U0001F64B-\\U0001F64F \\U0001F6A3 \\U0001F6B4-\\U0001F6B6 \\U0001F6C0 \\U0001F918 \\U0001F3C2 \\U0001F3C7 \\U0001F3CC \\U0001F574 \\U0001F57A \\U0001F6CC \\U0001F919-\\U0001F91E \\U0001F926 \\U0001F930 \\U0001F933-\\U0001F939 \\U0001F93C-\\U0001F93E] ;" // Emoji that take Fitzpatrick modifiers
-#else
-    "$EmojiForSeqs = [\\u2764 \\U0001F466-\\U0001F469 \\U0001F48B];"
-    "$EmojiForMods = [\\u261D \\u270A-\\u270C \\U0001F385 \\U0001F3C3-\\U0001F3C4 \\U0001F3C7 \\U0001F3CA \\U0001F442-\\U0001F443 \\U0001F446-\\U0001F450 \\U0001F466-\\U0001F469 \\U0001F46E-\\U0001F478 \\U0001F47C \\U0001F481-\\U0001F483 \\U0001F485-\\U0001F487 \\U0001F4AA \\U0001F596 \\U0001F645-\\U0001F647 \\U0001F64B-\\U0001F64F \\U0001F6A3 \\U0001F6B4-\\U0001F6B6 \\U0001F6C0] ;" // Emoji that take Fitzpatrick modifiers
-#endif
-    "$EmojiMods = [\\U0001F3FB-\\U0001F3FF];"
-    "$dictionary = [:LineBreak = Complex_Context:];"
-    "$ALPlus = [$AL $AI $SA $SG $XX];"
-    "$ALcm = $ALPlus $CM*;"
-    "$BAcm = $BA $CM*;"
-    "$BBcm = $BB $CM*;"
-    "$B2cm = $B2 $CM*;"
-    "$CLcm = $CL $CM*;"
-    "$CPcm = $CP $CM*;"
-    "$EXcm = $EX $CM*;"
-    "$GLcm = $GL $CM*;"
-    "$HLcm = $HL $CM*;"
-    "$HYcm = $HY $CM*;"
-    "$H2cm = $H2 $CM*;"
-    "$H3cm = $H3 $CM*;"
-    "$IDcm = $ID $CM*;"
-    "$INcm = $IN $CM*;"
-    "$IScm = $IS $CM*;"
-    "$JLcm = $JL $CM*;"
-    "$JVcm = $JV $CM*;"
-    "$JTcm = $JT $CM*;"
-    "$NScm = $NS $CM*;"
-    "$NUcm = $NU $CM*;"
-    "$OPcm = $OP $CM*;"
-    "$POcm = $PO $CM*;"
-    "$PRcm = $PR $CM*;"
-    "$QUcm = $QU $CM*;"
-    "$RIcm = $RI $CM*;"
-    "$SYcm = $SY $CM*;"
-    "$WJcm = $WJ $CM*;";
-
-static const char* uax14Forward =
-    "!!forward;"
-    "$CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM];"
-    "$CANT_CM = [$SP $BK $CR $LF $NL $ZW $CM];"
-    "$AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP];"
-    "$AL_FOLLOW_CM = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HY $NS $IN $NU $ALPlus];"
-    "$AL_FOLLOW = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM];"
-    "$LB4Breaks = [$BK $CR $LF $NL];"
-    "$LB4NonBreaks = [^$BK $CR $LF $NL];"
-    "$LB8Breaks = [$LB4Breaks $ZW];"
-    "$LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];"
-    "$LB18NonBreaks = [$LB8NonBreaks - [$SP]];"
-    "$LB18Breaks = [$LB8Breaks $SP];"
-    "$LB20NonBreaks = [$LB18NonBreaks - $CB];"
-    "$ALPlus $CM+;"
-    "$BA $CM+;"
-    "$BB $CM+;"
-    "$B2 $CM+;"
-    "$CL $CM+;"
-    "$CP $CM+;"
-    "$EX $CM+;"
-    "$GL $CM+;"
-    "$HL $CM+;"
-    "$HY $CM+;"
-    "$H2 $CM+;"
-    "$H3 $CM+;"
-    "$ID $CM+;"
-    "$IN $CM+;"
-    "$IS $CM+;"
-    "$JL $CM+;"
-    "$JV $CM+;"
-    "$JT $CM+;"
-    "$NS $CM+;"
-    "$NU $CM+;"
-    "$OP $CM+;"
-    "$PO $CM+;"
-    "$PR $CM+;"
-    "$QU $CM+;"
-    "$RI $CM+;"
-    "$SY $CM+;"
-    "$WJ $CM+;"
-    "$CR $LF {100};"
-    "$LB4NonBreaks? $LB4Breaks {100};"
-    "$CAN_CM $CM* $LB4Breaks {100};"
-    "$CM+ $LB4Breaks {100};"
-    "$LB4NonBreaks [$SP $ZW];"
-    "$CAN_CM $CM* [$SP $ZW];"
-    "$CM+ [$SP $ZW];"
-    "$EmojiForSeqs $EmojiVar? $EmojiMods? $ZWJ $EmojiForSeqs;"
-    "$CAN_CM $CM+;"
-    "$CM+;"
-    "$CAN_CM $CM* $WJcm;"
-    "$LB8NonBreaks $WJcm;"
-    "$CM+ $WJcm;"
-    "$WJcm $CANT_CM;"
-    "$WJcm $CAN_CM $CM*;"
-    "$GLcm $CAN_CM $CM*;"
-    "$GLcm $CANT_CM;"
-    "[[$LB8NonBreaks] - [$SP $BA $HY]] $CM* $GLcm;"
-    "$CM+ GLcm;"
-    "$LB8NonBreaks $CL;"
-    "$CAN_CM $CM* $CL;"
-    "$CM+ $CL;"
-    "$LB8NonBreaks $CP;"
-    "$CAN_CM $CM* $CP;"
-    "$CM+ $CP;"
-    "$LB8NonBreaks $EX;"
-    "$CAN_CM $CM* $EX;"
-    "$CM+ $EX;"
-    "$LB8NonBreaks $IS;"
-    "$CAN_CM $CM* $IS;"
-    "$CM+ $IS;"
-    "$LB8NonBreaks $SY;"
-    "$CAN_CM $CM* $SY;"
-    "$CM+ $SY;"
-    "$OPcm $SP* $CAN_CM $CM*;"
-    "$OPcm $SP* $CANT_CM;"
-    "$OPcm $SP+ $CM+ $AL_FOLLOW?;"
-    "$QUcm $SP* $OPcm;"
-    "($CLcm | $CPcm) $SP* $NScm;"
-    "$B2cm $SP* $B2cm;"
-    "$LB18NonBreaks $CM* $QUcm;"
-    "$CM+ $QUcm;"
-    "$QUcm .?;"
-    "$QUcm $LB18NonBreaks $CM*;"
-    "$LB20NonBreaks $CM* ($BAcm | $HYcm | $NScm); "
-    "$BBcm [^$CB];"
-    "$BBcm $LB20NonBreaks $CM*;"
-    "$HLcm ($HYcm | $BAcm) [^$CB]?;"
-    "$SYcm $HLcm;"
-    "($ALcm | $HLcm) $INcm;"
-    "$CM+ $INcm;"
-    "$EXcm $INcm;"
-    "$IDcm $INcm;"
-    "$INcm $INcm;"
-    "$NUcm $INcm;"
-    "$IDcm $POcm;"
-    "$ALcm $NUcm;"
-    "$HLcm $NUcm;"
-    "$CM+ $NUcm;"
-    "$NUcm $ALcm;"
-    "$NUcm $HLcm;"
-    "$PRcm $IDcm;"
-    "$PRcm ($ALcm | $HLcm);"
-    "$POcm ($ALcm | $HLcm);"
-    "($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?;"
-    "$JLcm ($JLcm | $JVcm | $H2cm | $H3cm);"
-    "($JVcm | $H2cm) ($JVcm | $JTcm);"
-    "($JTcm | $H3cm) $JTcm;"
-    "($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm;"
-    "($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm;"
-    "$PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm);"
-    "($ALcm | $HLcm) ($ALcm | $HLcm);"
-    "$CM+ ($ALcm | $HLcm);"
-    "$IScm ($ALcm | $HLcm);"
-    "($ALcm | $HLcm | $NUcm) $OPcm;"
-    "$CM+ $OPcm;"
-    "$CPcm ($ALcm | $HLcm | $NUcm);"
-#if ADDITIONAL_EMOJI_SUPPORT
-    "$RIcm $RIcm;"
-#endif
-    "$EmojiForMods $EmojiVar? $EmojiMods;";
-
-static const char* uax14Reverse =
-    "!!reverse;"
-    "$CM+ $ALPlus;"
-    "$CM+ $BA;"
-    "$CM+ $BB;"
-    "$CM+ $B2;"
-    "$CM+ $CL;"
-    "$CM+ $CP;"
-    "$CM+ $EX;"
-    "$CM+ $GL;"
-    "$CM+ $HL;"
-    "$CM+ $HY;"
-    "$CM+ $H2;"
-    "$CM+ $H3;"
-    "$CM+ $ID;"
-    "$CM+ $IN;"
-    "$CM+ $IS;"
-    "$CM+ $JL;"
-    "$CM+ $JV;"
-    "$CM+ $JT;"
-    "$CM+ $NS;"
-    "$CM+ $NU;"
-    "$CM+ $OP;"
-    "$CM+ $PO;"
-    "$CM+ $PR;"
-    "$CM+ $QU;"
-#if ADDITIONAL_EMOJI_SUPPORT
-    "$CM+ $RI;"
-#endif
-    "$CM+ $SY;"
-    "$CM+ $WJ;"
-    "$CM+;"
-    "$AL_FOLLOW $CM+ / ([$BK $CR $LF $NL $ZW {eof}] | $SP+ $CM+ $SP | $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}]));"
-    "[$PR] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];"
-    "$LB4Breaks [$LB4NonBreaks-$CM];"
-    "$LB4Breaks $CM+ $CAN_CM;"
-    "$LF $CR;"
-    "[$SP $ZW] [$LB4NonBreaks-$CM];"
-    "[$SP $ZW] $CM+ $CAN_CM;"
-    "$EmojiForSeqs $ZWJ $EmojiMods? $EmojiVar? $EmojiForSeqs;"
-    "$CM+ $CAN_CM;"
-    "$CM* $WJ $CM* $CAN_CM;"
-    "$CM* $WJ [$LB8NonBreaks-$CM];"
-    "$CANT_CM $CM* $WJ;"
-    "$CM* $CAN_CM $CM* $WJ;"
-    "$CM* $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $HY]];"
-    "$CANT_CM $CM* $GL;"
-    "$CM* $CAN_CM $CM* $GL;"
-    "$CL $CM+ $CAN_CM;"
-    "$CP $CM+ $CAN_CM;"
-    "$EX $CM+ $CAN_CM;"
-    "$IS $CM+ $CAN_CM;"
-    "$SY $CM+ $CAN_CM;"
-    "$CL [$LB8NonBreaks-$CM];"
-    "$CP [$LB8NonBreaks-$CM];"
-    "$EX [$LB8NonBreaks-$CM];"
-    "$IS [$LB8NonBreaks-$CM];"
-    "$SY [$LB8NonBreaks-$CM];"
-    "[$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP; "
-    "$CM* $CAN_CM $SP* $CM* $OP;"
-    "$CANT_CM $SP* $CM* $OP;"
-    "$AL_FOLLOW? $CM+ $SP $SP* $CM* $OP;"
-    "$AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;"
-    "$CM* $AL_FOLLOW_CM $CM+ $SP+ $CM* $OP;"
-    "$SY $CM $SP+ $OP;"
-    "$CM* $OP $SP* $CM* $QU;"
-    "$CM* $NS $SP* $CM* ($CL | $CP);"
-    "$CM* $B2 $SP* $CM* $B2;"
-    "$CM* $QU $CM* $CAN_CM;"
-    "$CM* $QU $LB18NonBreaks;"
-    "$CM* $CAN_CM $CM* $QU;"
-    "$CANT_CM $CM* $QU;"
-    "$CM* ($BA | $HY | $NS) $CM* [$LB20NonBreaks-$CM];"
-    "$CM* [$LB20NonBreaks-$CM] $CM* $BB;"
-    "[^$CB] $CM* $BB;"
-    "[^$CB] $CM* ($HY | $BA) $CM* $HL;"
-    "$CM* $HL $CM* $SY;"
-    "$CM* $IN $CM* ($ALPlus | $HL);"
-    "$CM* $IN $CM* $EX;"
-    "$CM* $IN $CM* $ID;"
-    "$CM* $IN $CM* $IN;"
-    "$CM* $IN $CM* $NU;"
-    "$CM* $PO $CM* $ID;"
-    "$CM* $NU $CM* ($ALPlus | $HL);"
-    "$CM* ($ALPlus | $HL) $CM* $NU;"
-    "$CM* $ID $CM* $PR;"
-    "$CM* ($ALPlus | $HL) $CM* $PR;"
-    "$CM* ($ALPlus | $HL) $CM* $PO;"
-    "($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?;"
-    "$CM* ($H3 | $H2 | $JV | $JL) $CM* $JL;"
-    "$CM* ($JT | $JV) $CM* ($H2 | $JV);"
-    "$CM* $JT $CM* ($H3 | $JT);"
-    "$CM* $IN $CM* ($H3 | $H2 | $JT | $JV | $JL);"
-    "$CM* $PO $CM* ($H3 | $H2 | $JT | $JV | $JL);"
-    "$CM* ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR;"
-    "$CM* ($ALPlus | $HL) $CM* ($ALPlus | $HL);"
-    "$CM* ($ALPlus | $HL) $CM* $IS;"
-    "$CM* $OP $CM* ($ALPlus | $HL | $NU);"
-    "$CM* ($ALPlus | $HL | $NU) $CM* $CP;"
-#if ADDITIONAL_EMOJI_SUPPORT
-    "$CM* $RI $CM* $RI;"
-#endif
-    "$EmojiMods $EmojiVar? $EmojiForMods;";
-
-static const char* uax14SafeForward =
-    "!!safe_forward;"
-    "[$CM $OP $QU $CL $CP $B2 $PR $HY $BA $SP $dictionary]+ [^$CM $OP $QU $CL $CP $B2 $PR $HY $BA $dictionary];"
-    "$dictionary $dictionary;";
-
-static const char* uax14SafeReverse =
-    "!!safe_reverse;"
-    "$CM+ [^$CM $BK $CR $LF $NL $ZW $SP];"
-    "$CM+ $SP / .;"
-    "$SP+ $CM* $OP;"
-    "$SP+ $CM* $QU;"
-    "$SP+ $CM* ($CL | $CP);"
-    "$SP+ $CM* $B2;"
-    "$CM* ($HY | $BA) $CM* $HL;"
-    "($CM* ($IS | $SY))+ $CM* $NU;"
-    "($CL | $CP) $CM* ($NU | $IS | $SY);"
-    "$dictionary $dictionary;";
-
-static String mapLineIteratorModeToRules(LineBreakIteratorMode mode, bool isCJK)
+UBreakIterator* openLineBreakIterator(const AtomicString& locale)
 {
-    StringBuilder rulesBuilder;
-    rulesBuilder.append(uax14Prologue);
-    rulesBuilder.append(uax14AssignmentsBefore);
-    switch (mode) {
-    case LineBreakIteratorMode::Default:
-        rulesBuilder.append(isCJK ? uax14AssignmentsCustomDefaultCJK : uax14AssignmentsCustomDefaultNonCJK);
-        break;
-    case LineBreakIteratorMode::Loose:
-        rulesBuilder.append(isCJK ? uax14AssignmentsCustomLooseCJK : uax14AssignmentsCustomLooseNonCJK);
-        break;
-    case LineBreakIteratorMode::Normal:
-        rulesBuilder.append(isCJK ? uax14AssignmentsCustomNormalCJK : uax14AssignmentsCustomNormalNonCJK);
-        break;
-    case LineBreakIteratorMode::Strict:
-        rulesBuilder.append(isCJK ? uax14AssignmentsCustomStrictCJK : uax14AssignmentsCustomStrictNonCJK);
-        break;
-    }
-    rulesBuilder.append(uax14AssignmentsAfter);
-    rulesBuilder.append(uax14Forward);
-    rulesBuilder.append(uax14Reverse);
-    rulesBuilder.append(uax14SafeForward);
-    rulesBuilder.append(uax14SafeReverse);
-    return rulesBuilder.toString();
-}
-
-// Recognize BCP47 compliant primary language values of 'zh', 'ja', 'ko'
-// (in any combination of case), optionally followed by subtags. Don't
-// recognize 3-letter variants 'chi'/'zho', 'jpn', or 'kor' since BCP47
-// requires use of shortest language tag.
-bool isCJKLocale(const AtomicString& locale)
-{
-    size_t length = locale.length();
-    if (length < 2)
-        return false;
-    auto c1 = locale[0];
-    auto c2 = locale[1];
-    auto c3 = length == 2 ? 0 : locale[2];
-    if (!c3 || c3 == '-' || c3 == '_' || c3 == '@') {
-        if (c1 == 'z' || c1 == 'Z')
-            return c2 == 'h' || c2 == 'H';
-        if (c1 == 'j' || c1 == 'J')
-            return c2 == 'a' || c2 == 'A';
-        if (c1 == 'k' || c1 == 'K')
-            return c2 == 'o' || c2 == 'O';
-    }
-    return false;
-}
-
-UBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
-{
-    UBreakIterator* ubrkIter;
+    bool localeIsEmpty = locale.isEmpty();
     UErrorCode openStatus = U_ZERO_ERROR;
-    bool localeIsEmpty = locale.isEmpty();
-    if (mode == LineBreakIteratorMode::Default)
-        ubrkIter = ubrk_open(UBRK_LINE, localeIsEmpty ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
-    else {
-        UParseError parseStatus;
-        auto rules = mapLineIteratorModeToRules(mode, isCJK);
-        ubrkIter = ubrk_openRules(StringView(rules).upconvertedCharacters(), rules.length(), 0, 0, &parseStatus, &openStatus);
-    }
+    UBreakIterator* ubrkIter = ubrk_open(UBRK_LINE, localeIsEmpty ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
     // locale comes from a web page and it can be invalid, leading ICU
     // to fail, in which case we fall back to the default locale.
     if (!localeIsEmpty && U_FAILURE(openStatus)) {

Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.h (212234 => 212235)


--- trunk/Source/WTF/wtf/text/TextBreakIterator.h	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WTF/wtf/text/TextBreakIterator.h	2017-02-13 19:07:43 UTC (rev 212235)
@@ -38,15 +38,13 @@
 WTF_EXPORT_PRIVATE UBreakIterator* wordBreakIterator(StringView);
 WTF_EXPORT_PRIVATE UBreakIterator* sentenceBreakIterator(StringView);
 
-WTF_EXPORT_PRIVATE UBreakIterator* acquireLineBreakIterator(StringView, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode, bool isCJK);
+WTF_EXPORT_PRIVATE UBreakIterator* acquireLineBreakIterator(StringView, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode);
 WTF_EXPORT_PRIVATE void releaseLineBreakIterator(UBreakIterator*);
-UBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode, bool isCJK);
+UBreakIterator* openLineBreakIterator(const AtomicString& locale);
 void closeLineBreakIterator(UBreakIterator*&);
 
 WTF_EXPORT_PRIVATE bool isWordTextBreak(UBreakIterator*);
 
-WTF_EXPORT_PRIVATE bool isCJKLocale(const AtomicString&);
-
 class LazyLineBreakIterator {
 public:
     LazyLineBreakIterator()
@@ -58,7 +56,6 @@
         : m_stringView(stringView)
         , m_locale(locale)
         , m_mode(mode)
-        , m_isCJK(isCJKLocale(locale))
     {
         resetPriorContext();
     }
@@ -70,7 +67,7 @@
     }
 
     StringView stringView() const { return m_stringView; }
-    bool isLooseCJKMode() const { return m_isCJK && m_mode == LineBreakIteratorMode::Loose; }
+    LineBreakIteratorMode mode() const { return m_mode; }
 
     UChar lastCharacter() const
     {
@@ -125,7 +122,7 @@
         ASSERT(priorContextLength <= priorContextCapacity);
         const UChar* priorContext = priorContextLength ? &m_priorContext[priorContextCapacity - priorContextLength] : 0;
         if (!m_iterator) {
-            m_iterator = acquireLineBreakIterator(m_stringView, m_locale, priorContext, priorContextLength, m_mode, m_isCJK);
+            m_iterator = acquireLineBreakIterator(m_stringView, m_locale, priorContext, priorContextLength, m_mode);
             m_cachedPriorContext = priorContext;
             m_cachedPriorContextLength = priorContextLength;
         } else if (priorContext != m_cachedPriorContext || priorContextLength != m_cachedPriorContextLength) {
@@ -144,7 +141,6 @@
         m_iterator = nullptr;
         m_cachedPriorContext = nullptr;
         m_mode = mode;
-        m_isCJK = isCJKLocale(locale);
         m_cachedPriorContextLength = 0;
     }
 
@@ -157,7 +153,6 @@
     LineBreakIteratorMode m_mode { LineBreakIteratorMode::Default };
     unsigned m_cachedPriorContextLength { 0 };
     UChar m_priorContext[priorContextCapacity];
-    bool m_isCJK { false };
 };
 
 // Iterates over "extended grapheme clusters", as defined in UAX #29.

Modified: trunk/Source/WebCore/ChangeLog (212234 => 212235)


--- trunk/Source/WebCore/ChangeLog	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WebCore/ChangeLog	2017-02-13 19:07:43 UTC (rev 212235)
@@ -1,3 +1,35 @@
+2017-02-13  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Update custom line breaking iterators to the latest version of Unicode
+        https://bugs.webkit.org/show_bug.cgi?id=168182
+
+        Reviewed by Zalan Bujtas.
+
+        Clean up our breaking code to be more descriptive about the difference between
+        line-break: auto vs line-break: loose | normal | strict. The only difference is
+        that we have some hardcoded tables to speed up character iteration for
+        line-break: auto.
+
+        Tests: TestWebKitAPI WebKit2.LineBreaking
+
+        * rendering/BreakLines.h:
+        (WebCore::nextBreakablePosition):
+        (WebCore::nextBreakablePositionIgnoringNBSP):
+        (WebCore::nextBreakablePositionWithoutShortcut):
+        (WebCore::nextBreakablePositionIgnoringNBSPWithoutShortcut):
+        (WebCore::isBreakable):
+        (WebCore::nextBreakablePositionNonLoosely): Deleted.
+        (WebCore::nextBreakablePositionLoosely): Deleted.
+        (WebCore::nextBreakablePositionLoose): Deleted.
+        (WebCore::nextBreakablePositionIgnoringNBSPLoose): Deleted.
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::computePreferredLogicalWidths):
+        * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
+        (WebCore::SimpleLineLayout::nextBreakablePositionInSegment):
+        * rendering/line/BreakingContext.h:
+        (WebCore::BreakingContext::handleText):
+        (WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord):
+
 2017-02-13  Youenn Fablet  <you...@apple.com>
 
         Remove @getUserMedia identifier

Modified: trunk/Source/WebCore/rendering/BreakLines.h (212234 => 212235)


--- trunk/Source/WebCore/rendering/BreakLines.h	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WebCore/rendering/BreakLines.h	2017-02-13 19:07:43 UTC (rev 212235)
@@ -40,6 +40,11 @@
     TreatNonBreakingSpaceAsBreak,
 };
 
+enum class CanUseShortcut {
+    Yes,
+    No
+};
+
 template<NonBreakingSpaceBehavior nonBreakingSpaceBehavior>
 static inline bool isBreakableSpace(UChar character)
 {
@@ -82,8 +87,8 @@
 }
 
 // When in non-loose mode, we can use the ASCII shortcut table.
-template<typename CharacterType, NonBreakingSpaceBehavior nonBreakingSpaceBehavior>
-inline unsigned nextBreakablePositionNonLoosely(LazyLineBreakIterator& lazyBreakIterator, const CharacterType* string, unsigned length, unsigned startPosition)
+template<typename CharacterType, NonBreakingSpaceBehavior nonBreakingSpaceBehavior, CanUseShortcut canUseShortcut>
+inline unsigned nextBreakablePosition(LazyLineBreakIterator& lazyBreakIterator, const CharacterType* string, unsigned length, unsigned startPosition)
 {
     std::optional<unsigned> nextBreak;
 
@@ -93,12 +98,10 @@
     for (unsigned i = startPosition; i < length; i++) {
         CharacterType character = string[i];
 
-        // Non-loose mode, so use ASCII shortcut (shouldBreakAfter) if not breakable space.
-        if (isBreakableSpace<nonBreakingSpaceBehavior>(character) || shouldBreakAfter(lastLastCharacter, lastCharacter, character))
+        if (isBreakableSpace<nonBreakingSpaceBehavior>(character) || (canUseShortcut == CanUseShortcut::Yes && shouldBreakAfter(lastLastCharacter, lastCharacter, character)))
             return i;
 
-        // Non-loose mode, so conditionally use break iterator.
-        if (needsLineBreakIterator<nonBreakingSpaceBehavior>(character) || needsLineBreakIterator<nonBreakingSpaceBehavior>(lastCharacter)) {
+        if (canUseShortcut == CanUseShortcut::No || needsLineBreakIterator<nonBreakingSpaceBehavior>(character) || needsLineBreakIterator<nonBreakingSpaceBehavior>(lastCharacter)) {
             if (!nextBreak || nextBreak.value() < i) {
                 // Don't break if positioned at start of primary context and there is no prior context.
                 if (i || priorContextLength) {
@@ -126,51 +129,7 @@
     return length;
 }
 
-// When in loose mode, we can't use the ASCII shortcut table since loose mode allows "$100" to break after '$' in content marked as CJK.
-// N.B. It should be possible to combine the following with the non-loose version above by adding a LooseBehavior template parameter;
-// however, when doing this, a 10% performance regression appeared on chromium-win (https://bugs.webkit.org/show_bug.cgi?id=89235#c112).
 template<typename CharacterType, NonBreakingSpaceBehavior nonBreakingSpaceBehavior>
-static inline unsigned nextBreakablePositionLoosely(LazyLineBreakIterator& lazyBreakIterator, const CharacterType* string, unsigned length, unsigned startPosition)
-{
-    std::optional<unsigned> nextBreak;
-
-    CharacterType lastCharacter = startPosition > 0 ? string[startPosition - 1] : static_cast<CharacterType>(lazyBreakIterator.lastCharacter());
-    unsigned priorContextLength = lazyBreakIterator.priorContextLength();
-    for (unsigned i = startPosition; i < length; i++) {
-        CharacterType character = string[i];
-
-        // Always loose mode, so don't use ASCII shortcut (shouldBreakAfter).
-        if (isBreakableSpace<nonBreakingSpaceBehavior>(character))
-            return i;
-
-        // Always use line break iterator in loose mode.
-        if (!nextBreak || nextBreak.value() < i) {
-            // Don't break if positioned at start of primary context and there is no prior context.
-            if (i || priorContextLength) {
-                UBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
-                if (breakIterator) {
-                    ASSERT(i + priorContextLength >= 1);
-                    int candidate = ubrk_following(breakIterator, i + priorContextLength - 1);
-                    if (candidate == UBRK_DONE)
-                        nextBreak = std::nullopt;
-                    else {
-                        unsigned result = candidate;
-                        ASSERT(result > priorContextLength);
-                        nextBreak = result - priorContextLength;
-                    }
-                }
-            }
-        }
-        if (i == nextBreak && !isBreakableSpace<nonBreakingSpaceBehavior>(lastCharacter))
-            return i;
-
-        lastCharacter = character;
-    }
-
-    return length;
-}
-
-template<typename CharacterType, NonBreakingSpaceBehavior nonBreakingSpaceBehavior>
 inline unsigned nextBreakablePositionKeepingAllWords(const CharacterType* string, unsigned length, unsigned startPosition)
 {
     for (unsigned i = startPosition; i < length; i++) {
@@ -200,8 +159,8 @@
 {
     auto stringView = iterator.stringView();
     if (stringView.is8Bit())
-        return nextBreakablePositionNonLoosely<LChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak>(iterator, stringView.characters8(), stringView.length(), startPosition);
-    return nextBreakablePositionNonLoosely<UChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak>(iterator, stringView.characters16(), stringView.length(), startPosition);
+        return nextBreakablePosition<LChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak, CanUseShortcut::Yes>(iterator, stringView.characters8(), stringView.length(), startPosition);
+    return nextBreakablePosition<UChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak, CanUseShortcut::Yes>(iterator, stringView.characters16(), stringView.length(), startPosition);
 }
 
 inline unsigned nextBreakablePositionIgnoringNBSP(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
@@ -208,27 +167,27 @@
 {
     auto stringView = lazyBreakIterator.stringView();
     if (stringView.is8Bit())
-        return nextBreakablePositionNonLoosely<LChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(lazyBreakIterator, stringView.characters8(), stringView.length(), startPosition);
-    return nextBreakablePositionNonLoosely<UChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(lazyBreakIterator, stringView.characters16(), stringView.length(), startPosition);
+        return nextBreakablePosition<LChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace, CanUseShortcut::Yes>(lazyBreakIterator, stringView.characters8(), stringView.length(), startPosition);
+    return nextBreakablePosition<UChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace, CanUseShortcut::Yes>(lazyBreakIterator, stringView.characters16(), stringView.length(), startPosition);
 }
 
-inline unsigned nextBreakablePositionLoose(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
+inline unsigned nextBreakablePositionWithoutShortcut(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
 {
     auto stringView = lazyBreakIterator.stringView();
     if (stringView.is8Bit())
-        return nextBreakablePositionLoosely<LChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak>(lazyBreakIterator, stringView.characters8(), stringView.length(), startPosition);
-    return nextBreakablePositionLoosely<UChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak>(lazyBreakIterator, stringView.characters16(), stringView.length(), startPosition);
+        return nextBreakablePosition<LChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak, CanUseShortcut::No>(lazyBreakIterator, stringView.characters8(), stringView.length(), startPosition);
+    return nextBreakablePosition<UChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak, CanUseShortcut::No>(lazyBreakIterator, stringView.characters16(), stringView.length(), startPosition);
 }
 
-inline unsigned nextBreakablePositionIgnoringNBSPLoose(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
+inline unsigned nextBreakablePositionIgnoringNBSPWithoutShortcut(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
 {
     auto stringView = lazyBreakIterator.stringView();
     if (stringView.is8Bit())
-        return nextBreakablePositionLoosely<LChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(lazyBreakIterator, stringView.characters8(), stringView.length(), startPosition);
-    return nextBreakablePositionLoosely<UChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(lazyBreakIterator, stringView.characters16(), stringView.length(), startPosition);
+        return nextBreakablePosition<LChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace, CanUseShortcut::No>(lazyBreakIterator, stringView.characters8(), stringView.length(), startPosition);
+    return nextBreakablePosition<UChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace, CanUseShortcut::No>(lazyBreakIterator, stringView.characters16(), stringView.length(), startPosition);
 }
 
-inline bool isBreakable(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition, std::optional<unsigned>& nextBreakable, bool breakNBSP, bool isLooseMode, bool keepAllWords)
+inline bool isBreakable(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition, std::optional<unsigned>& nextBreakable, bool breakNBSP, bool canUseShortcut, bool keepAllWords)
 {
     if (nextBreakable && nextBreakable.value() >= startPosition)
         return startPosition == nextBreakable;
@@ -238,11 +197,11 @@
             nextBreakable = nextBreakablePositionKeepingAllWords(lazyBreakIterator, startPosition);
         else
             nextBreakable = nextBreakablePositionKeepingAllWordsIgnoringNBSP(lazyBreakIterator, startPosition);
-    } else if (isLooseMode) {
+    } else if (!canUseShortcut) {
         if (breakNBSP)
-            nextBreakable = nextBreakablePositionLoose(lazyBreakIterator, startPosition);
+            nextBreakable = nextBreakablePositionWithoutShortcut(lazyBreakIterator, startPosition);
         else
-            nextBreakable = nextBreakablePositionIgnoringNBSPLoose(lazyBreakIterator, startPosition);
+            nextBreakable = nextBreakablePositionIgnoringNBSPWithoutShortcut(lazyBreakIterator, startPosition);
     } else {
         if (breakNBSP)
             nextBreakable = nextBreakablePosition(lazyBreakIterator, startPosition);

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (212234 => 212235)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2017-02-13 19:07:43 UTC (rev 212235)
@@ -797,7 +797,8 @@
     const FontCascade& font = style.fontCascade(); // FIXME: This ignores first-line.
     float wordSpacing = font.wordSpacing();
     unsigned len = textLength();
-    LazyLineBreakIterator breakIterator(m_text, style.locale(), mapLineBreakToIteratorMode(style.lineBreak()));
+    auto iteratorMode = mapLineBreakToIteratorMode(style.lineBreak());
+    LazyLineBreakIterator breakIterator(m_text, style.locale(), iteratorMode);
     bool needsWordSpacing = false;
     bool ignoringSpaces = false;
     bool isSpace = false;
@@ -834,7 +835,7 @@
     // word-break, but we support it as though it means break-all.
     bool breakAll = (style.wordBreak() == BreakAllWordBreak || style.wordBreak() == BreakWordBreak) && style.autoWrap();
     bool keepAllWords = style.wordBreak() == KeepAllWordBreak;
-    bool isLooseCJKMode = breakIterator.isLooseCJKMode();
+    bool canUseLineBreakShortcut = iteratorMode == LineBreakIteratorMode::Default;
 
     for (unsigned i = 0; i < len; i++) {
         UChar c = uncheckedCharacterAt(i);
@@ -880,7 +881,7 @@
             continue;
         }
 
-        bool hasBreak = breakAll || isBreakable(breakIterator, i, nextBreakable, breakNBSP, isLooseCJKMode, keepAllWords);
+        bool hasBreak = breakAll || isBreakable(breakIterator, i, nextBreakable, breakNBSP, canUseLineBreakShortcut, keepAllWords);
         bool betweenWords = true;
         unsigned j = i;
         while (c != '\n' && !isSpaceAccordingToStyle(c, style) && c != '\t' && (c != softHyphen || style.hyphens() == HyphensNone)) {
@@ -888,7 +889,7 @@
             if (j == len)
                 break;
             c = uncheckedCharacterAt(j);
-            if (isBreakable(breakIterator, j, nextBreakable, breakNBSP, isLooseCJKMode, keepAllWords) && characterAt(j - 1) != softHyphen)
+            if (isBreakable(breakIterator, j, nextBreakable, breakNBSP, canUseLineBreakShortcut, keepAllWords) && characterAt(j - 1) != softHyphen)
                 break;
             if (breakAll) {
                 betweenWords = false;

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (212234 => 212235)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp	2017-02-13 19:07:43 UTC (rev 212235)
@@ -127,15 +127,15 @@
         return nextBreakablePositionKeepingAllWordsIgnoringNBSP(lineBreakIterator, startPosition);
     }
 
-    if (lineBreakIterator.isLooseCJKMode()) {
+    if (lineBreakIterator.mode() == LineBreakIteratorMode::Default) {
         if (breakNBSP)
-            return nextBreakablePositionLoose(lineBreakIterator, startPosition);
-        return nextBreakablePositionIgnoringNBSPLoose(lineBreakIterator, startPosition);
+            return WebCore::nextBreakablePosition(lineBreakIterator, startPosition);
+        return nextBreakablePositionIgnoringNBSP(lineBreakIterator, startPosition);
     }
-        
+
     if (breakNBSP)
-        return WebCore::nextBreakablePosition(lineBreakIterator, startPosition);
-    return nextBreakablePositionIgnoringNBSP(lineBreakIterator, startPosition);
+        return nextBreakablePositionWithoutShortcut(lineBreakIterator, startPosition);
+    return nextBreakablePositionIgnoringNBSPWithoutShortcut(lineBreakIterator, startPosition);
 }
 
 unsigned TextFragmentIterator::nextBreakablePosition(const FlowContents::Segment& segment, unsigned startPosition)

Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (212234 => 212235)


--- trunk/Source/WebCore/rendering/line/BreakingContext.h	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h	2017-02-13 19:07:43 UTC (rev 212235)
@@ -804,7 +804,8 @@
     bool breakAll = m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap;
     bool keepAllWords = m_currentStyle->wordBreak() == KeepAllWordBreak;
     float hyphenWidth = 0;
-    bool isLooseCJKMode = false;
+    auto iteratorMode = mapLineBreakToIteratorMode(m_blockStyle.lineBreak());
+    bool canUseLineBreakShortcut = iteratorMode == LineBreakIteratorMode::Default;
     bool isLineEmpty = m_lineInfo.isEmpty();
 
     if (isSVGText) {
@@ -817,8 +818,7 @@
         m_renderTextInfo.text = &renderText;
         m_renderTextInfo.font = &font;
         m_renderTextInfo.layout = font.createLayout(renderText, m_width.currentWidth(), m_collapseWhiteSpace);
-        m_renderTextInfo.lineBreakIterator.resetStringAndReleaseIterator(renderText.text(), style.locale(), mapLineBreakToIteratorMode(m_blockStyle.lineBreak()));
-        isLooseCJKMode = m_renderTextInfo.lineBreakIterator.isLooseCJKMode();
+        m_renderTextInfo.lineBreakIterator.resetStringAndReleaseIterator(renderText.text(), style.locale(), iteratorMode);
     } else if (m_renderTextInfo.layout && m_renderTextInfo.font != &font) {
         m_renderTextInfo.font = &font;
         m_renderTextInfo.layout = font.createLayout(renderText, m_width.currentWidth(), m_collapseWhiteSpace);
@@ -869,7 +869,7 @@
         }
 
         std::optional<unsigned> nextBreakablePosition = m_current.nextBreakablePosition();
-        bool betweenWords = c == '\n' || (m_currWS != PRE && !m_atStart && isBreakable(m_renderTextInfo.lineBreakIterator, m_current.offset(), nextBreakablePosition, breakNBSP, isLooseCJKMode, keepAllWords)
+        bool betweenWords = c == '\n' || (m_currWS != PRE && !m_atStart && isBreakable(m_renderTextInfo.lineBreakIterator, m_current.offset(), nextBreakablePosition, breakNBSP, canUseLineBreakShortcut, keepAllWords)
             && (style.hyphens() != HyphensNone || (m_current.previousInSameNode() != softHyphen)));
         m_current.setNextBreakablePosition(nextBreakablePosition);
         
@@ -1332,10 +1332,10 @@
     // Don't even bother measuring if our remaining line has many characters
     if (renderText.textLength() == lineBreak.offset() || renderText.textLength() - lineBreak.offset() > longTrailingWordLength)
         return lineBreak;
-    bool isLooseCJKMode = m_renderTextInfo.text != &renderText && m_renderTextInfo.lineBreakIterator.isLooseCJKMode();
+    bool canUseLineBreakShortcut = m_renderTextInfo.lineBreakIterator.mode() == LineBreakIteratorMode::Default;
     bool breakNBSP = m_autoWrap && m_currentStyle->nbspMode() == SPACE;
     std::optional<unsigned> nextBreakablePosition = lineBreak.nextBreakablePosition();
-    isBreakable(m_renderTextInfo.lineBreakIterator, lineBreak.offset() + 1, nextBreakablePosition, breakNBSP, isLooseCJKMode, m_currentStyle->wordBreak() == KeepAllWordBreak);
+    isBreakable(m_renderTextInfo.lineBreakIterator, lineBreak.offset() + 1, nextBreakablePosition, breakNBSP, canUseLineBreakShortcut, m_currentStyle->wordBreak() == KeepAllWordBreak);
     if (!nextBreakablePosition || nextBreakablePosition.value() != renderText.textLength())
         return lineBreak;
     const RenderStyle& style = lineStyle(renderText, m_lineInfo);

Modified: trunk/Tools/ChangeLog (212234 => 212235)


--- trunk/Tools/ChangeLog	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Tools/ChangeLog	2017-02-13 19:07:43 UTC (rev 212235)
@@ -1,3 +1,21 @@
+2017-02-13  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Update custom line breaking iterators to the latest version of Unicode
+        https://bugs.webkit.org/show_bug.cgi?id=168182
+
+        Reviewed by Zalan Bujtas.
+
+        Treat the system's ICU as the source of truth to compare breaking positions against.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/LineBreaking.mm: Added.
+        (generateJavaScriptForTest):
+        (breakingLocationsFromICU):
+        (testAFewStrings):
+        (TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/AllAhem.svg: Renamed from LayoutTests/css3/line-break/resources/AllAhem.svg.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LineBreaking.html: Added.
+
 2017-02-12  Michael Catanzaro  <mcatanz...@igalia.com>
 
         [GTK] Several failing WebViewEditor API tests

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (212234 => 212235)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-02-13 18:58:32 UTC (rev 212234)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-02-13 19:07:43 UTC (rev 212235)
@@ -506,6 +506,9 @@
 		C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; };
 		C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
 		C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; };
+		C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */ = {isa = PBXBuildFile; fileRef = C25CCA051E51380B0026CB8A /* LineBreaking.mm */; };
+		C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C25CCA0A1E513F490026CB8A /* LineBreaking.html */; };
+		C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = C25CCA0C1E5140E50026CB8A /* AllAhem.svg */; };
 		C2CF975A16CEC7140054E99D /* JSContextBackForwardCache2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */; };
 		C2CF975B16CEC71B0054E99D /* JSContextBackForwardCache1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */; };
 		C5101C4F176B8D9200EE9B15 /* findRanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C5101C4E176B8BB900EE9B15 /* findRanges.html */; };
@@ -625,6 +628,8 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
+				C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */,
 				F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */,
 				C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */,
 				C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */,
@@ -1099,7 +1104,7 @@
 		7C83E0261D0A5B8D00FEBCF3 /* TestWTF.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = TestWTF.xcconfig; sourceTree = "<group>"; };
 		7C83E0271D0A5B8D00FEBCF3 /* TestWTFLibrary.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = TestWTFLibrary.xcconfig; sourceTree = "<group>"; };
 		7C83E0291D0A5CDF00FEBCF3 /* libWTF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWTF.a; path = ../../../../../Builds/Debug/libWTF.a; sourceTree = "<group>"; };
-		7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; };
+		7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = SDKROOT; };
 		7C83E0361D0A5F7000FEBCF3 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = "<group>"; };
 		7C83E0391D0A602700FEBCF3 /* UtilitiesCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = UtilitiesCocoa.mm; path = cocoa/UtilitiesCocoa.mm; sourceTree = "<group>"; };
 		7C882E031C80C624006BF731 /* UserContentWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserContentWorld.mm; sourceTree = "<group>"; };
@@ -1293,6 +1298,9 @@
 		C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
 		C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; };
 		C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
+		C25CCA051E51380B0026CB8A /* LineBreaking.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LineBreaking.mm; path = ../WebCore/LineBreaking.mm; sourceTree = "<group>"; };
+		C25CCA0A1E513F490026CB8A /* LineBreaking.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LineBreaking.html; sourceTree = "<group>"; };
+		C25CCA0C1E5140E50026CB8A /* AllAhem.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AllAhem.svg; sourceTree = "<group>"; };
 		C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSContextBackForwardCache1.html; sourceTree = "<group>"; };
 		C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSContextBackForwardCache2.html; sourceTree = "<group>"; };
 		C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewDidCreateJavaScriptContext.mm; sourceTree = "<group>"; };
@@ -1414,6 +1422,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				7C83E03F1D0A61A000FEBCF3 /* libicucore.dylib in Frameworks */,
 				7A010BCD1D877C0D00EDE72A /* QuartzCore.framework in Frameworks */,
 				7A010BCB1D877C0500EDE72A /* CoreGraphics.framework in Frameworks */,
 			);
@@ -1523,6 +1532,7 @@
 			isa = PBXGroup;
 			children = (
 				A16F66B81C40E9E100BD4D24 /* Resources */,
+				C25CCA051E51380B0026CB8A /* LineBreaking.mm */,
 				7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */,
 				A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
 				2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */,
@@ -1762,6 +1772,8 @@
 				515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */,
 				51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
 				51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
+				C25CCA0A1E513F490026CB8A /* LineBreaking.html */,
+				C25CCA0C1E5140E50026CB8A /* AllAhem.svg */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -2752,6 +2764,7 @@
 				7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */,
 				7CCE7EB01A411A4400447C4C /* URLExtras.mm in Sources */,
 				07492B3B1DF8B14C00633DE1 /* EnumerateMediaDevices.cpp in Sources */,
+				C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */,
 				7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */,
 				2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
 				5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/LineBreaking.mm (0 => 212235)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/LineBreaking.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/LineBreaking.mm	2017-02-13 19:07:43 UTC (rev 212235)
@@ -0,0 +1,338 @@
+/*
+ * 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"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
+#import <unicode/ubrk.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
+#import <wtf/text/WTFString.h>
+
+NSString *generateJavaScriptForTest(NSString *testContent, NSString *localeString, NSString *lineBreakValue)
+{
+    return [NSString stringWithFormat:@"runTest('%@', '%@', '%@')", testContent, localeString, lineBreakValue];
+}
+
+Vector<unsigned> breakingLocationsFromICU(const Vector<UInt16>& testString, const String& locale, const String lineBreakValue)
+{
+    constexpr int bufferSize = 100;
+    char buffer[bufferSize];
+    memset(buffer, 0, bufferSize);
+    auto utf8Locale = locale.utf8();
+    ASSERT(utf8Locale.length() < bufferSize);
+    memcpy(buffer, utf8Locale.data(), utf8Locale.length());
+    CString icuValue;
+    if (lineBreakValue != "auto")
+        icuValue = lineBreakValue.utf8();
+    UErrorCode status = U_ZERO_ERROR;
+    uloc_setKeywordValue("lb", icuValue.data(), buffer, bufferSize, &status);
+    ASSERT(U_SUCCESS(status));
+
+    UBreakIterator* iterator = ubrk_open(UBRK_LINE, buffer, testString.data(), testString.size(), &status);
+    ASSERT(U_SUCCESS(status));
+    ASSERT(iterator);
+
+    Vector<unsigned> result;
+    int32_t position = 0;
+    for (; position != UBRK_DONE; position = ubrk_next(iterator)) {
+        if (position)
+            result.append(position);
+    }
+    ubrk_close(iterator);
+    return result;
+}
+
+static void testAFewStrings(Vector<Vector<UInt16>> testStrings)
+{
+    Vector<String> locales = { "en", "ja", "ko", "zh" };
+
+    Vector<String> lineBreakValues = { "auto", "loose", "normal", "strict" };
+
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"LineBreaking" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    [webView _test_waitForDidFinishNavigation];
+
+    for (auto& testCodePoints : testStrings) {
+        NSString *testString = [NSString stringWithCharacters:testCodePoints.data() length:testCodePoints.size()];
+        for (auto& locale : locales) {
+            for (auto& lineBreakValue : lineBreakValues) {
+                __block bool didEvaluateJavaScript = false;
+                __block Vector<unsigned> webkitLocations;
+                [webView evaluateJavaScript:generateJavaScriptForTest(testString, locale, lineBreakValue) completionHandler:^(id value, NSError *error) {
+                    for (NSNumber *v in (NSArray *)value)
+                        webkitLocations.append(floor([v floatValue] + 0.5));
+                    didEvaluateJavaScript = true;
+                }];
+                TestWebKitAPI::Util::run(&didEvaluateJavaScript);
+
+                const auto& icuLocations = breakingLocationsFromICU(testCodePoints, locale, lineBreakValue);
+                EXPECT_EQ(icuLocations.size(), webkitLocations.size());
+                if (icuLocations.size() != webkitLocations.size())
+                    break;
+                for (size_t i = 0; i < icuLocations.size(); ++i)
+                    EXPECT_EQ(icuLocations[i], webkitLocations[i]);
+            }
+        }
+    }
+}
+
+// Split up the tests because they take too long otherwise and people start thinking their computer is hung.
+TEST(WebKit2, LineBreaking1)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x0024, 0x31, 0x32, 0x33},
+        {0x00a3, 0x31, 0x32, 0x33},
+        {0x00a5, 0x31, 0x32, 0x33},
+        {0x20ac, 0x31, 0x32, 0x33},
+        {0x2116, 0x31, 0x32, 0x33},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking2)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x2025, 0x2025},
+        {0x4e00, 0x2025, 0x2026},
+        {0x4e00, 0x2026, 0x2025},
+        {0x4e00, 0x2026, 0x2026},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x0021},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking3)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x0025},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x003a},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x003b},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x003f},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x00a2},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking4)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x00b0},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2010},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2013},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2030},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2032},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking5)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2033},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x203c},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2047},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2048},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2049},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking6)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x2103},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3005},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x301c},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x303b},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3041},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking7)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3043},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3045},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3047},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3049},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3063},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking8)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3083},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3085},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3087},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x308e},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3095},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking9)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x3096},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x309d},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x309e},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30a0},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30a1},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking10)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30a3},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30a5},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30a7},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30a9},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30c3},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking11)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30e3},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30e5},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30e7},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30ee},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30f5},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking12)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30f6},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30fb},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30fc},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30fd},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x30fe},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking13)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f0},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f1},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f2},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f3},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f4},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking14)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f5},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f6},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f7},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f8},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31f9},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking15)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31fa},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31fb},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31fc},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31fd},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31fe},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking16)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x31ff},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff01},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff05},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff1a},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff1b},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking17)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff1f},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff65},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff67},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff68},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff69},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking18)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff6a},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff6b},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff6c},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff6d},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff6e},
+    };
+    testAFewStrings(testStrings);
+}
+
+TEST(WebKit2, LineBreaking19)
+{
+    Vector<Vector<UInt16>> testStrings = {
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff6f},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xff70},
+        {0x4e00, 0x4e8c, 0x4e09, 0x56db, 0xffe0},
+        {0xff04, 0x31, 0x32, 0x33},
+        {0xffe1, 0x31, 0x32, 0x33},
+        {0xffe5, 0x31, 0x32, 0x33}
+    };
+    testAFewStrings(testStrings);
+}
+
+
+#endif

Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AllAhem.svg (from rev 212234, trunk/LayoutTests/css3/line-break/resources/AllAhem.svg) (0 => 212235)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AllAhem.svg	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AllAhem.svg	2017-02-13 19:07:43 UTC (rev 212235)
@@ -0,0 +1,111 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
+<svg xmlns="http://www.w3.org/2000/svg">
+<metadata></metadata>
+<defs>
+<font id="Litherum" horiz-adv-x="1024">
+<font-face units-per-em="1024" ascent="1024" descent="-1"/>
+<glyph unicode="1" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="2" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="3" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x0021;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x0024;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x0025;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x003a;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x003b;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x003f;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x00a2;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x00a3;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x00a5;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x00b0;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2010;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2013;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2025;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2026;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2030;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2032;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2033;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x203c;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2047;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2048;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2049;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x20ac;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2103;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x2116;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3005;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x301c;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x303b;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3041;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3043;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3045;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3047;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3049;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3063;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3083;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3085;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3087;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x308e;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3095;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x3096;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x309d;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x309e;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30a0;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30a1;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30a3;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30a5;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30a7;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30a9;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30c3;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30e3;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30e5;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30e7;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30ee;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30f5;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30f6;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30fb;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30fc;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30fd;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x30fe;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f0;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f1;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f2;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f3;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f4;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f5;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f6;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f7;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f8;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31f9;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31fa;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31fb;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31fc;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31fd;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31fe;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x31ff;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x4e00;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x4e09;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x4e8c;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#x56db;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff01;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff04;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff05;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff1a;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff1b;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff1f;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff65;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff67;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff68;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff69;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff6a;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff6b;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff6c;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff6d;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff6e;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff6f;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xff70;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xffe0;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xffe1;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+<glyph unicode="&#xffe5;" horiz-adv-x="1024" d="M0 0V1024H1024V0z"/>
+</font>
+</defs>
+</svg>

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LineBreaking.html (0 => 212235)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LineBreaking.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LineBreaking.html	2017-02-13 19:07:43 UTC (rev 212235)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<style>
+@font-face {
+    font-family: "AllAhem";
+    src: url("AllAhem.svg") format("svg");
+}
+
+#test {
+    font: 20px "AllAhem";
+}
+</style>
+<script>
+function runTest(testContent, localeString, lineBreakValue) {
+    var container = document.getElementById("container");
+    var test = document.getElementById("test");
+
+    test.textContent = testContent;
+    container.lang = localeString;
+    container.style.webkitLineBreak = lineBreakValue;
+
+    var current = 0;
+    var breakpoints = [];
+    var clientRectsLength = 2;
+    for (var i = 1; clientRectsLength > 1; i += 5) {
+        container.style.width = "" + i + "px";
+        var width = test.getClientRects()[0].width;
+        if (current != width) {
+            current = width;
+            breakpoints.push(width / 20);
+        }
+        clientRectsLength = test.getClientRects().length;
+    }
+    return breakpoints;
+}
+</script>
+</head>
+<body>
+<div id="container" style="width: 99999999px;">
+    <span id="test">Hello World</span>
+</div>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to