<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[204531] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/204531">204531</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-08-16 15:39:10 -0700 (Tue, 16 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Migrate line breaking code from ints to Optional<unsigned>s
https://bugs.webkit.org/show_bug.cgi?id=160859
Reviewed by Darin Adler.
Source/WebCore:
Previously, we were using -1 to mean "before the beginning of the string". Now,
Nullopt means that.
This patch also renames break_lines.{h,cpp} to BreakLines.{h.cpp}. This file was
originally named during the KHTML days.
No new tests because there is no behavior change.
* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* rendering/BreakLines.cpp: Renamed from Source/WebCore/rendering/break_lines.cpp.
* rendering/BreakLines.h: Renamed from Source/WebCore/rendering/break_lines.h.
(WebCore::isBreakableSpace):
(WebCore::shouldBreakAfter):
(WebCore::needsLineBreakIterator):
(WebCore::nextBreakablePositionNonLoosely):
(WebCore::nextBreakablePositionLoosely):
(WebCore::nextBreakablePositionKeepingAllWords):
(WebCore::nextBreakablePositionKeepingAllWordsIgnoringNBSP):
(WebCore::nextBreakablePosition):
(WebCore::nextBreakablePositionIgnoringNBSP):
(WebCore::nextBreakablePositionLoose):
(WebCore::nextBreakablePositionIgnoringNBSPLoose):
(WebCore::isBreakable):
* rendering/InlineIterator.h:
(WebCore::InlineIterator::moveTo):
(WebCore::InlineIterator::nextBreakablePosition):
(WebCore::InlineIterator::setNextBreakablePosition):
(WebCore::InlineIterator::InlineIterator): Deleted.
* rendering/InlineTextBox.cpp:
* rendering/RenderText.cpp:
(WebCore::RenderText::computePreferredLogicalWidths):
* rendering/RenderingAllInOne.cpp:
* rendering/SimpleLineLayoutTextFragmentIterator.h:
* rendering/break_lines.h:
(WebCore::isBreakableSpace): Deleted.
(WebCore::shouldBreakAfter): Deleted.
(WebCore::needsLineBreakIterator): Deleted.
(WebCore::nextBreakablePositionNonLoosely): Deleted.
(WebCore::nextBreakablePositionLoosely): Deleted.
(WebCore::nextBreakablePositionKeepingAllWords): Deleted.
(WebCore::nextBreakablePositionKeepingAllWordsIgnoringNBSP): Deleted.
(WebCore::nextBreakablePosition): Deleted.
(WebCore::nextBreakablePositionIgnoringNBSP): Deleted.
(WebCore::nextBreakablePositionLoose): Deleted.
(WebCore::nextBreakablePositionIgnoringNBSPLoose): Deleted.
(WebCore::isBreakable): Deleted.
* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::commitLineBreakAtCurrentWidth):
(WebCore::BreakingContext::InlineIteratorHistory::nextBreakablePosition):
(WebCore::BreakingContext::InlineIteratorHistory::moveTo):
(WebCore::tryHyphenating):
(WebCore::BreakingContext::handleText):
(WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord):
Source/WebKit/ios:
* Misc/WebUIKitSupport.mm:
(WebKitGetLastLineBreakInBuffer):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtftextTextBreakIteratorh">trunk/Source/WTF/wtf/text/TextBreakIterator.h</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineIteratorh">trunk/Source/WebCore/rendering/InlineIterator.h</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextcpp">trunk/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderingAllInOnecpp">trunk/Source/WebCore/rendering/RenderingAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorcpp">trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorh">trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h</a></li>
<li><a href="#trunkSourceWebCorerenderinglineBreakingContexth">trunk/Source/WebCore/rendering/line/BreakingContext.h</a></li>
<li><a href="#trunkSourceWebKitiosChangeLog">trunk/Source/WebKit/ios/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitiosMiscWebUIKitSupportmm">trunk/Source/WebKit/ios/Misc/WebUIKitSupport.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorerenderingBreakLinescpp">trunk/Source/WebCore/rendering/BreakLines.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingBreakLinesh">trunk/Source/WebCore/rendering/BreakLines.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorerenderingbreak_linescpp">trunk/Source/WebCore/rendering/break_lines.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingbreak_linesh">trunk/Source/WebCore/rendering/break_lines.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFwtftextTextBreakIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.h (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/TextBreakIterator.h        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WTF/wtf/text/TextBreakIterator.h        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -78,8 +78,8 @@
</span><span class="cx"> resetPriorContext();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- LazyLineBreakIterator(String string, const AtomicString& locale = AtomicString(), LineBreakIteratorMode mode = LineBreakIteratorModeUAX14)
- : m_string(string)
</del><ins>+ LazyLineBreakIterator(StringView stringView, const AtomicString& locale = AtomicString(), LineBreakIteratorMode mode = LineBreakIteratorModeUAX14)
+ : m_stringView(stringView)
</ins><span class="cx"> , m_locale(locale)
</span><span class="cx"> , m_iterator(nullptr)
</span><span class="cx"> , m_cachedPriorContext(nullptr)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> releaseLineBreakIterator(m_iterator);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- String string() const { return m_string; }
</del><ins>+ StringView stringView() const { return m_stringView; }
</ins><span class="cx"> bool isLooseCJKMode() const { return m_isCJK && m_mode == LineBreakIteratorModeUAX14Loose; }
</span><span class="cx">
</span><span class="cx"> UChar lastCharacter() const
</span><span class="lines">@@ -152,21 +152,21 @@
</span><span class="cx"> ASSERT(priorContextLength <= priorContextCapacity);
</span><span class="cx"> const UChar* priorContext = priorContextLength ? &m_priorContext[priorContextCapacity - priorContextLength] : 0;
</span><span class="cx"> if (!m_iterator) {
</span><del>- m_iterator = acquireLineBreakIterator(m_string, m_locale, priorContext, priorContextLength, m_mode, m_isCJK);
</del><ins>+ m_iterator = acquireLineBreakIterator(m_stringView, m_locale, priorContext, priorContextLength, m_mode, m_isCJK);
</ins><span class="cx"> m_cachedPriorContext = priorContext;
</span><span class="cx"> m_cachedPriorContextLength = priorContextLength;
</span><span class="cx"> } else if (priorContext != m_cachedPriorContext || priorContextLength != m_cachedPriorContextLength) {
</span><del>- resetStringAndReleaseIterator(m_string, m_locale, m_mode);
</del><ins>+ resetStringAndReleaseIterator(m_stringView, m_locale, m_mode);
</ins><span class="cx"> return this->get(priorContextLength);
</span><span class="cx"> }
</span><span class="cx"> return m_iterator;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void resetStringAndReleaseIterator(String string, const AtomicString& locale, LineBreakIteratorMode mode)
</del><ins>+ void resetStringAndReleaseIterator(StringView stringView, const AtomicString& locale, LineBreakIteratorMode mode)
</ins><span class="cx"> {
</span><span class="cx"> if (m_iterator)
</span><span class="cx"> releaseLineBreakIterator(m_iterator);
</span><del>- m_string = string;
</del><ins>+ m_stringView = stringView;
</ins><span class="cx"> m_locale = locale;
</span><span class="cx"> m_iterator = nullptr;
</span><span class="cx"> m_cachedPriorContext = nullptr;
</span><span class="lines">@@ -177,7 +177,7 @@
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> static const unsigned priorContextCapacity = 2;
</span><del>- String m_string;
</del><ins>+ StringView m_stringView;
</ins><span class="cx"> AtomicString m_locale;
</span><span class="cx"> TextBreakIterator* m_iterator;
</span><span class="cx"> const UChar* m_cachedPriorContext;
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -2412,6 +2412,7 @@
</span><span class="cx"> rendering/AutoTableLayout.cpp
</span><span class="cx"> rendering/BidiRun.cpp
</span><span class="cx"> rendering/BorderEdge.cpp
</span><ins>+ rendering/BreakLines.cpp
</ins><span class="cx"> rendering/ClipRect.cpp
</span><span class="cx"> rendering/CounterNode.cpp
</span><span class="cx"> rendering/EllipsisBox.cpp
</span><span class="lines">@@ -2530,7 +2531,6 @@
</span><span class="cx"> rendering/TextDecorationPainter.cpp
</span><span class="cx"> rendering/TextPaintStyle.cpp
</span><span class="cx"> rendering/TextPainter.cpp
</span><del>- rendering/break_lines.cpp
</del><span class="cx">
</span><span class="cx"> rendering/line/LineBreaker.cpp
</span><span class="cx"> rendering/line/LineInfo.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/ChangeLog        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2016-08-16 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Migrate line breaking code from ints to Optional<unsigned>s
+ https://bugs.webkit.org/show_bug.cgi?id=160859
+
+ Reviewed by Darin Adler.
+
+ Previously, we were using -1 to mean "before the beginning of the string". Now,
+ Nullopt means that.
+
+ This patch also renames break_lines.{h,cpp} to BreakLines.{h.cpp}. This file was
+ originally named during the KHTML days.
+
+ No new tests because there is no behavior change.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/BreakLines.cpp: Renamed from Source/WebCore/rendering/break_lines.cpp.
+ * rendering/BreakLines.h: Renamed from Source/WebCore/rendering/break_lines.h.
+ (WebCore::isBreakableSpace):
+ (WebCore::shouldBreakAfter):
+ (WebCore::needsLineBreakIterator):
+ (WebCore::nextBreakablePositionNonLoosely):
+ (WebCore::nextBreakablePositionLoosely):
+ (WebCore::nextBreakablePositionKeepingAllWords):
+ (WebCore::nextBreakablePositionKeepingAllWordsIgnoringNBSP):
+ (WebCore::nextBreakablePosition):
+ (WebCore::nextBreakablePositionIgnoringNBSP):
+ (WebCore::nextBreakablePositionLoose):
+ (WebCore::nextBreakablePositionIgnoringNBSPLoose):
+ (WebCore::isBreakable):
+ * rendering/InlineIterator.h:
+ (WebCore::InlineIterator::moveTo):
+ (WebCore::InlineIterator::nextBreakablePosition):
+ (WebCore::InlineIterator::setNextBreakablePosition):
+ (WebCore::InlineIterator::InlineIterator): Deleted.
+ * rendering/InlineTextBox.cpp:
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::computePreferredLogicalWidths):
+ * rendering/RenderingAllInOne.cpp:
+ * rendering/SimpleLineLayoutTextFragmentIterator.h:
+ * rendering/break_lines.h:
+ (WebCore::isBreakableSpace): Deleted.
+ (WebCore::shouldBreakAfter): Deleted.
+ (WebCore::needsLineBreakIterator): Deleted.
+ (WebCore::nextBreakablePositionNonLoosely): Deleted.
+ (WebCore::nextBreakablePositionLoosely): Deleted.
+ (WebCore::nextBreakablePositionKeepingAllWords): Deleted.
+ (WebCore::nextBreakablePositionKeepingAllWordsIgnoringNBSP): Deleted.
+ (WebCore::nextBreakablePosition): Deleted.
+ (WebCore::nextBreakablePositionIgnoringNBSP): Deleted.
+ (WebCore::nextBreakablePositionLoose): Deleted.
+ (WebCore::nextBreakablePositionIgnoringNBSPLoose): Deleted.
+ (WebCore::isBreakable): Deleted.
+ * rendering/line/BreakingContext.h:
+ (WebCore::BreakingContext::commitLineBreakAtCurrentWidth):
+ (WebCore::BreakingContext::InlineIteratorHistory::nextBreakablePosition):
+ (WebCore::BreakingContext::InlineIteratorHistory::moveTo):
+ (WebCore::tryHyphenating):
+ (WebCore::BreakingContext::handleText):
+ (WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord):
+
</ins><span class="cx"> 2016-08-16 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> DOM4: getElementsByClassName should include non StyledElements
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -5671,8 +5671,7 @@
</span><span class="cx">                 BCEA478F097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA477C097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp */; };
</span><span class="cx">                 BCEA4790097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA477D097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 BCEA4852097D93020094C9E4 /* RenderBlockLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4813097D93020094C9E4 /* RenderBlockLineLayout.cpp */; };
</span><del>-                BCEA4854097D93020094C9E4 /* break_lines.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4815097D93020094C9E4 /* break_lines.cpp */; };
-                BCEA4855097D93020094C9E4 /* break_lines.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4816097D93020094C9E4 /* break_lines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><ins>+                BCEA4854097D93020094C9E4 /* BreakLines.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4815097D93020094C9E4 /* BreakLines.cpp */; };
</ins><span class="cx">                 BCEA4859097D93020094C9E4 /* InlineTextBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA481A097D93020094C9E4 /* InlineTextBox.cpp */; };
</span><span class="cx">                 BCEA485A097D93020094C9E4 /* InlineTextBox.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA481B097D93020094C9E4 /* InlineTextBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 BCEA485F097D93020094C9E4 /* RenderBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4820097D93020094C9E4 /* RenderBlock.cpp */; };
</span><span class="lines">@@ -5791,6 +5790,7 @@
</span><span class="cx">                 C280833F1C6DC26F001451B6 /* JSFontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = C280833E1C6DC22C001451B6 /* JSFontFace.h */; };
</span><span class="cx">                 C28083401C6DC275001451B6 /* JSFontFace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C280833D1C6DC22C001451B6 /* JSFontFace.cpp */; };
</span><span class="cx">                 C28083421C6DC96A001451B6 /* JSFontFaceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */; };
</span><ins>+                C2E1F43F1D6254E10094625C /* BreakLines.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4816097D93020094C9E4 /* BreakLines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 C33EE5C414FB49610002095A /* BaseClickableWithKeyInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */; };
</span><span class="cx">                 C33EE5C514FB49610002095A /* BaseClickableWithKeyInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */; };
</span><span class="lines">@@ -13490,8 +13490,8 @@
</span><span class="cx">                 BCEA4789097CAAC80094C9E4 /* CSSPropertyNames.in */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CSSPropertyNames.in; sourceTree = "<group>"; };
</span><span class="cx">                 BCEA478C097CAAC80094C9E4 /* CSSValueKeywords.in */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CSSValueKeywords.in; sourceTree = "<group>"; };
</span><span class="cx">                 BCEA4813097D93020094C9E4 /* RenderBlockLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderBlockLineLayout.cpp; sourceTree = "<group>"; };
</span><del>-                BCEA4815097D93020094C9E4 /* break_lines.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = break_lines.cpp; sourceTree = "<group>"; };
-                BCEA4816097D93020094C9E4 /* break_lines.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = break_lines.h; sourceTree = "<group>"; };
</del><ins>+                BCEA4815097D93020094C9E4 /* BreakLines.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = BreakLines.cpp; sourceTree = "<group>"; };
+                BCEA4816097D93020094C9E4 /* BreakLines.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = BreakLines.h; sourceTree = "<group>"; };
</ins><span class="cx">                 BCEA481A097D93020094C9E4 /* InlineTextBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextBox.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 BCEA481B097D93020094C9E4 /* InlineTextBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = InlineTextBox.h; sourceTree = "<group>"; };
</span><span class="cx">                 BCEA4820097D93020094C9E4 /* RenderBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderBlock.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -23634,8 +23634,8 @@
</span><span class="cx">                                 BCE789851120E7A60060ECE5 /* BidiRun.h */,
</span><span class="cx">                                 58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */,
</span><span class="cx">                                 589556EC18D4A44000764B03 /* BorderEdge.h */,
</span><del>-                                BCEA4815097D93020094C9E4 /* break_lines.cpp */,
-                                BCEA4816097D93020094C9E4 /* break_lines.h */,
</del><ins>+                                BCEA4815097D93020094C9E4 /* BreakLines.cpp */,
+                                BCEA4816097D93020094C9E4 /* BreakLines.h */,
</ins><span class="cx">                                 FB92DF4915FED08700994433 /* ClipPathOperation.h */,
</span><span class="cx">                                 5803715F1A66F00A00BAF519 /* ClipRect.cpp */,
</span><span class="cx">                                 580371601A66F00A00BAF519 /* ClipRect.h */,
</span><span class="lines">@@ -24918,7 +24918,6 @@
</span><span class="cx">                                 589556ED18D4A44000764B03 /* BorderEdge.h in Headers */,
</span><span class="cx">                                 BC5EB5DB0E81B7EA00B25965 /* BorderValue.h in Headers */,
</span><span class="cx">                                 6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */,
</span><del>-                                BCEA4855097D93020094C9E4 /* break_lines.h in Headers */,
</del><span class="cx">                                 93309DDB099E64920056E581 /* BreakBlockquoteCommand.h in Headers */,
</span><span class="cx">                                 599E759011055A1F00D904FA /* Bridge.h in Headers */,
</span><span class="cx">                                 59B5977511086579007159E8 /* BridgeJSC.h in Headers */,
</span><span class="lines">@@ -26119,6 +26118,7 @@
</span><span class="cx">                                 FDF09DC91399B62200688E5B /* JSBiquadFilterNode.h in Headers */,
</span><span class="cx">                                 2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */,
</span><span class="cx">                                 14DCF3B31B6BE2080062D4C3 /* JSByteLengthQueuingStrategy.h in Headers */,
</span><ins>+                                C2E1F43F1D6254E10094625C /* BreakLines.h in Headers */,
</ins><span class="cx">                                 1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */,
</span><span class="cx">                                 65DF323A09D1DE65000BE325 /* JSCanvasGradient.h in Headers */,
</span><span class="cx">                                 65DF323C09D1DE65000BE325 /* JSCanvasPattern.h in Headers */,
</span><span class="lines">@@ -28809,7 +28809,7 @@
</span><span class="cx">                                 976D6C7E122B8A3D001FD1F7 /* BlobURL.cpp in Sources */,
</span><span class="cx">                                 58AEE2F418D4BCCF0022E7FE /* BorderEdge.cpp in Sources */,
</span><span class="cx">                                 6ED8C379183BFF8C009E53BD /* BoxShape.cpp in Sources */,
</span><del>-                                BCEA4854097D93020094C9E4 /* break_lines.cpp in Sources */,
</del><ins>+                                BCEA4854097D93020094C9E4 /* BreakLines.cpp in Sources */,
</ins><span class="cx">                                 93309DDA099E64920056E581 /* BreakBlockquoteCommand.cpp in Sources */,
</span><span class="cx">                                 59B597731108656B007159E8 /* BridgeJSC.cpp in Sources */,
</span><span class="cx">                                 7A45032F18DB717200377B34 /* BufferedLineReader.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingBreakLinescppfromrev204530trunkSourceWebCorerenderingbreak_linescpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/rendering/BreakLines.cpp (from rev 204530, trunk/Source/WebCore/rendering/break_lines.cpp) (0 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/BreakLines.cpp         (rev 0)
+++ trunk/Source/WebCore/rendering/BreakLines.cpp        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+/*
+ * Copyright (C) 2005, 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BreakLines.h"
+
+#include <wtf/ASCIICType.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/unicode/CharacterNames.h>
+
+namespace WebCore {
+
+// Pack 8 bits into one byte
+#define B(a, b, c, d, e, f, g, h) \
+ ((a) | ((b) << 1) | ((c) << 2) | ((d) << 3) | ((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7))
+
+// Line breaking table row for each digit (0-9)
+#define DI { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+
+// Line breaking table row for ascii letters (a-z A-Z)
+#define AL { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+
+#define F 0xFF
+
+// Line breaking table for printable ASCII characters. Line breaking opportunities in this table are as below:
+// - before opening punctuations such as '(', '<', '[', '{' after certain characters (compatible with Firefox 3.6);
+// - after '-' and '?' (backward-compatible, and compatible with Internet Explorer).
+// Please refer to <https://bugs.webkit.org/show_bug.cgi?id=37698> for line breaking matrixes of different browsers
+// and the ICU standard.
+WEBCORE_EXPORT const unsigned char lineBreakTable[][lineBreakTableColumnCount] = {
+ // ! " # $ % & ' ( ) * + , - . / 0 1-8 9 : ; < = > ? @ A-X Y Z [ \ ] ^ _ ` a-x y z { | } ~ DEL
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // !
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // "
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // #
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // $
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // %
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // &
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // '
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // (
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // )
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // *
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // +
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ,
+ { B(1, 1, 1, 1, 1, 1, 1, 1), B(1, 1, 1, 1, 1, 0, 1, 0), 0, B(0, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1) }, // - Note: breaking before '0'-'9' is handled hard-coded in shouldBreakAfter().
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // .
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // /
+ DI, DI, DI, DI, DI, DI, DI, DI, DI, DI, // 0-9
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // :
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ;
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // <
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // =
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // >
+ { B(0, 0, 1, 1, 1, 1, 0, 1), B(0, 1, 1, 0, 1, 0, 0, 1), F, B(1, 0, 0, 1, 1, 1, 0, 1), F, F, F, B(1, 1, 1, 1, 0, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 0, 1, 1, 0) }, // ?
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // @
+ AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, // A-Z
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // [
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // '\'
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ]
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // ^
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // _
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // `
+ AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, // a-z
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // {
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // |
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // }
+ { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ~
+ { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // DEL
+};
+
+#undef B
+#undef F
+#undef DI
+#undef AL
+
+COMPILE_ASSERT(WTF_ARRAY_LENGTH(lineBreakTable) == lineBreakTableLastCharacter - lineBreakTableFirstCharacter + 1, TestLineBreakTableConsistency);
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingBreakLinesh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/rendering/BreakLines.h (0 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/BreakLines.h         (rev 0)
+++ trunk/Source/WebCore/rendering/BreakLines.h        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -0,0 +1,255 @@
</span><ins>+/*
+ * Copyright (C) 2005, 2007, 2010, 2013, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include <unicode/ubrk.h>
+#include <wtf/ASCIICType.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/TextBreakIterator.h>
+#include <wtf/unicode/CharacterNames.h>
+
+namespace WebCore {
+
+static const UChar lineBreakTableFirstCharacter = '!';
+static const UChar lineBreakTableLastCharacter = 127;
+static const unsigned lineBreakTableColumnCount = (lineBreakTableLastCharacter - lineBreakTableFirstCharacter) / 8 + 1;
+
+WEBCORE_EXPORT extern const unsigned char lineBreakTable[][lineBreakTableColumnCount];
+
+enum class NonBreakingSpaceBehavior {
+ IgnoreNonBreakingSpace,
+ TreatNonBreakingSpaceAsBreak,
+};
+
+template<NonBreakingSpaceBehavior nonBreakingSpaceBehavior>
+static inline bool isBreakableSpace(UChar character)
+{
+ switch (character) {
+ case ' ':
+ case '\n':
+ case '\t':
+ return true;
+ case noBreakSpace:
+ return nonBreakingSpaceBehavior == NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak;
+ default:
+ return false;
+ }
+}
+
+inline bool shouldBreakAfter(UChar lastCharacter, UChar character, UChar nextCharacter)
+{
+ // Don't allow line breaking between '-' and a digit if the '-' may mean a minus sign in the context,
+ // while allow breaking in 'ABCD-1234' and '1234-5678' which may be in long URLs.
+ if (character == '-' && isASCIIDigit(nextCharacter))
+ return isASCIIAlphanumeric(lastCharacter);
+
+ // If both ch and nextCh are ASCII characters, use a lookup table for enhanced speed and for compatibility
+ // with other browsers (see comments for asciiLineBreakTable for details).
+ if (character >= lineBreakTableFirstCharacter && character <= lineBreakTableLastCharacter && nextCharacter >= lineBreakTableFirstCharacter && nextCharacter <= lineBreakTableLastCharacter) {
+ const unsigned char* tableRow = lineBreakTable[character - lineBreakTableFirstCharacter];
+ unsigned nextCharacterIndex = nextCharacter - lineBreakTableFirstCharacter;
+ return tableRow[nextCharacterIndex / 8] & (1 << (nextCharacterIndex % 8));
+ }
+ // Otherwise defer to the Unicode algorithm by returning false.
+ return false;
+}
+
+template<NonBreakingSpaceBehavior nonBreakingSpaceBehavior>
+inline bool needsLineBreakIterator(UChar character)
+{
+ if (nonBreakingSpaceBehavior == NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak)
+ return character > lineBreakTableLastCharacter;
+ return character > lineBreakTableLastCharacter && character != noBreakSpace;
+}
+
+// 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)
+{
+ Optional<unsigned> nextBreak;
+
+ CharacterType lastLastCharacter = startPosition > 1 ? string[startPosition - 2] : static_cast<CharacterType>(lazyBreakIterator.secondToLastCharacter());
+ 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];
+
+ // Non-loose mode, so use ASCII shortcut (shouldBreakAfter) if not breakable space.
+ if (isBreakableSpace<nonBreakingSpaceBehavior>(character) || shouldBreakAfter(lastLastCharacter, lastCharacter, character))
+ return i;
+
+ // Non-loose mode, so conditionally use break iterator.
+ if (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) {
+ TextBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
+ if (breakIterator) {
+ int candidate = textBreakFollowing(breakIterator, i - 1 + priorContextLength);
+ if (candidate == TextBreakDone)
+ nextBreak = Nullopt;
+ else {
+ unsigned result = candidate;
+ ASSERT(result >= priorContextLength);
+ nextBreak = result - priorContextLength;
+ }
+ }
+ }
+ }
+ if (i == nextBreak && !isBreakableSpace<nonBreakingSpaceBehavior>(lastCharacter))
+ return i;
+ }
+
+ lastLastCharacter = lastCharacter;
+ lastCharacter = character;
+ }
+
+ 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)
+{
+ 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) {
+ TextBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
+ if (breakIterator) {
+ ASSERT(i + priorContextLength >= 1);
+ int candidate = textBreakFollowing(breakIterator, i + priorContextLength - 1);
+ if (candidate == TextBreakDone)
+ nextBreak = 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++) {
+ if (isBreakableSpace<nonBreakingSpaceBehavior>(string[i]))
+ return i;
+ }
+ return length;
+}
+
+inline unsigned nextBreakablePositionKeepingAllWords(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
+{
+ auto stringView = lazyBreakIterator.stringView();
+ if (stringView.is8Bit())
+ return nextBreakablePositionKeepingAllWords<LChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak>(stringView.characters8(), stringView.length(), startPosition);
+ return nextBreakablePositionKeepingAllWords<UChar, NonBreakingSpaceBehavior::TreatNonBreakingSpaceAsBreak>(stringView.characters16(), stringView.length(), startPosition);
+}
+
+inline unsigned nextBreakablePositionKeepingAllWordsIgnoringNBSP(LazyLineBreakIterator& iterator, unsigned startPosition)
+{
+ auto stringView = iterator.stringView();
+ if (stringView.is8Bit())
+ return nextBreakablePositionKeepingAllWords<LChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(stringView.characters8(), stringView.length(), startPosition);
+ return nextBreakablePositionKeepingAllWords<UChar, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(stringView.characters16(), stringView.length(), startPosition);
+}
+
+inline unsigned nextBreakablePosition(LazyLineBreakIterator& iterator, unsigned startPosition)
+{
+ 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);
+}
+
+inline unsigned nextBreakablePositionIgnoringNBSP(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition)
+{
+ 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);
+}
+
+inline unsigned nextBreakablePositionLoose(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);
+}
+
+inline unsigned nextBreakablePositionIgnoringNBSPLoose(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);
+}
+
+inline bool isBreakable(LazyLineBreakIterator& lazyBreakIterator, unsigned startPosition, Optional<unsigned>& nextBreakable, bool breakNBSP, bool isLooseMode, bool keepAllWords)
+{
+ if (nextBreakable && nextBreakable.value() >= startPosition)
+ return startPosition == nextBreakable;
+
+ if (keepAllWords) {
+ if (breakNBSP)
+ nextBreakable = nextBreakablePositionKeepingAllWords(lazyBreakIterator, startPosition);
+ else
+ nextBreakable = nextBreakablePositionKeepingAllWordsIgnoringNBSP(lazyBreakIterator, startPosition);
+ } else if (isLooseMode) {
+ if (breakNBSP)
+ nextBreakable = nextBreakablePositionLoose(lazyBreakIterator, startPosition);
+ else
+ nextBreakable = nextBreakablePositionIgnoringNBSPLoose(lazyBreakIterator, startPosition);
+ } else {
+ if (breakNBSP)
+ nextBreakable = nextBreakablePosition(lazyBreakIterator, startPosition);
+ else
+ nextBreakable = nextBreakablePositionIgnoringNBSP(lazyBreakIterator, startPosition);
+ }
+ return startPosition == nextBreakable;
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineIterator.h (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineIterator.h        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/InlineIterator.h        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -53,11 +53,6 @@
</span><span class="cx"> class InlineIterator {
</span><span class="cx"> public:
</span><span class="cx"> InlineIterator()
</span><del>- : m_root(nullptr)
- , m_renderer(nullptr)
- , m_nextBreakablePosition(-1)
- , m_pos(0)
- , m_refersToEndOfPreviousNode(false)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -64,7 +59,6 @@
</span><span class="cx"> InlineIterator(RenderElement* root, RenderObject* o, unsigned p)
</span><span class="cx"> : m_root(root)
</span><span class="cx"> , m_renderer(o)
</span><del>- , m_nextBreakablePosition(-1)
</del><span class="cx"> , m_pos(p)
</span><span class="cx"> , m_refersToEndOfPreviousNode(false)
</span><span class="cx"> {
</span><span class="lines">@@ -77,7 +71,7 @@
</span><span class="cx"> moveTo(object, 0);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void moveTo(RenderObject* object, unsigned offset, int nextBreak = -1)
</del><ins>+ void moveTo(RenderObject* object, unsigned offset, Optional<unsigned> nextBreak = Nullopt)
</ins><span class="cx"> {
</span><span class="cx"> setRenderer(object);
</span><span class="cx"> setOffset(offset);
</span><span class="lines">@@ -89,8 +83,8 @@
</span><span class="cx"> unsigned offset() const { return m_pos; }
</span><span class="cx"> void setOffset(unsigned position);
</span><span class="cx"> RenderElement* root() const { return m_root; }
</span><del>- int nextBreakablePosition() const { return m_nextBreakablePosition; }
- void setNextBreakablePosition(int position) { m_nextBreakablePosition = position; }
</del><ins>+ Optional<unsigned> nextBreakablePosition() const { return m_nextBreakablePosition; }
+ void setNextBreakablePosition(Optional<unsigned> position) { m_nextBreakablePosition = position; }
</ins><span class="cx"> bool refersToEndOfPreviousNode() const { return m_refersToEndOfPreviousNode; }
</span><span class="cx"> void setRefersToEndOfPreviousNode();
</span><span class="cx">
</span><span class="lines">@@ -118,11 +112,11 @@
</span><span class="cx">
</span><span class="cx"> UCharDirection surrogateTextDirection(UChar currentCodeUnit) const;
</span><span class="cx">
</span><del>- RenderElement* m_root;
- RenderObject* m_renderer;
</del><ins>+ RenderElement* m_root { nullptr };
+ RenderObject* m_renderer { nullptr };
</ins><span class="cx">
</span><del>- int m_nextBreakablePosition;
- unsigned m_pos;
</del><ins>+ Optional<unsigned> m_nextBreakablePosition;
+ unsigned m_pos { 0 };
</ins><span class="cx">
</span><span class="cx"> // There are a couple places where we want to decrement an InlineIterator.
</span><span class="cx"> // Usually this take the form of decrementing m_pos; however, m_pos might be 0.
</span><span class="lines">@@ -129,7 +123,7 @@
</span><span class="cx"> // However, we shouldn't ever need to decrement an InlineIterator more than
</span><span class="cx"> // once, so rather than implementing a decrement() function which traverses
</span><span class="cx"> // nodes, we can simply keep track of this state and handle it.
</span><del>- bool m_refersToEndOfPreviousNode;
</del><ins>+ bool m_refersToEndOfPreviousNode { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline bool operator==(const InlineIterator& it1, const InlineIterator& it2)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "InlineTextBox.h"
</span><span class="cx">
</span><ins>+#include "BreakLines.h"
</ins><span class="cx"> #include "Chrome.h"
</span><span class="cx"> #include "ChromeClient.h"
</span><span class="cx"> #include "DashArray.h"
</span><span class="lines">@@ -50,7 +51,6 @@
</span><span class="cx"> #include "TextDecorationPainter.h"
</span><span class="cx"> #include "TextPaintStyle.h"
</span><span class="cx"> #include "TextPainter.h"
</span><del>-#include "break_lines.h"
</del><span class="cx"> #include <stdio.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.cpp (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.cpp        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/RenderText.cpp        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include "RenderText.h"
</span><span class="cx">
</span><span class="cx"> #include "AXObjectCache.h"
</span><ins>+#include "BreakLines.h"
</ins><span class="cx"> #include "BreakingContext.h"
</span><span class="cx"> #include "CharacterProperties.h"
</span><span class="cx"> #include "EllipsisBox.h"
</span><span class="lines">@@ -46,7 +47,6 @@
</span><span class="cx"> #include <wtf/text/TextBreakIterator.h>
</span><span class="cx"> #include "TextResourceDecoder.h"
</span><span class="cx"> #include "VisiblePosition.h"
</span><del>-#include "break_lines.h"
</del><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/text/StringBuffer.h>
</span><span class="cx"> #include <wtf/text/StringBuilder.h>
</span><span class="lines">@@ -791,7 +791,7 @@
</span><span class="cx"> const RenderStyle& style = this->style();
</span><span class="cx"> const FontCascade& font = style.fontCascade(); // FIXME: This ignores first-line.
</span><span class="cx"> float wordSpacing = font.wordSpacing();
</span><del>- int len = textLength();
</del><ins>+ unsigned len = textLength();
</ins><span class="cx"> LazyLineBreakIterator breakIterator(m_text, style.locale(), mapLineBreakToIteratorMode(style.lineBreak()));
</span><span class="cx"> bool needsWordSpacing = false;
</span><span class="cx"> bool ignoringSpaces = false;
</span><span class="lines">@@ -798,8 +798,8 @@
</span><span class="cx"> bool isSpace = false;
</span><span class="cx"> bool firstWord = true;
</span><span class="cx"> bool firstLine = true;
</span><del>- int nextBreakable = -1;
- int lastWordBoundary = 0;
</del><ins>+ Optional<unsigned> nextBreakable;
+ unsigned lastWordBoundary = 0;
</ins><span class="cx">
</span><span class="cx"> // Non-zero only when kerning is enabled, in which case we measure words with their trailing
</span><span class="cx"> // space, then subtract its width.
</span><span class="lines">@@ -833,7 +833,7 @@
</span><span class="cx"> bool keepAllWords = style.wordBreak() == KeepAllWordBreak;
</span><span class="cx"> bool isLooseCJKMode = breakIterator.isLooseCJKMode();
</span><span class="cx">
</span><del>- for (int i = 0; i < len; i++) {
</del><ins>+ for (unsigned i = 0; i < len; i++) {
</ins><span class="cx"> UChar c = uncheckedCharacterAt(i);
</span><span class="cx">
</span><span class="cx"> bool previousCharacterIsSpace = isSpace;
</span><span class="lines">@@ -869,6 +869,7 @@
</span><span class="cx"> lastWordBoundary++;
</span><span class="cx"> continue;
</span><span class="cx"> } else if (c == softHyphen && style.hyphens() != HyphensNone) {
</span><ins>+ ASSERT(i >= lastWordBoundary);
</ins><span class="cx"> currMaxWidth += widthFromCache(font, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
</span><span class="cx"> if (!firstGlyphLeftOverflow)
</span><span class="cx"> firstGlyphLeftOverflow = glyphOverflow.left;
</span><span class="lines">@@ -878,7 +879,7 @@
</span><span class="cx">
</span><span class="cx"> bool hasBreak = breakAll || isBreakable(breakIterator, i, nextBreakable, breakNBSP, isLooseCJKMode, keepAllWords);
</span><span class="cx"> bool betweenWords = true;
</span><del>- int j = i;
</del><ins>+ unsigned j = i;
</ins><span class="cx"> while (c != '\n' && !isSpaceAccordingToStyle(c, style) && c != '\t' && (c != softHyphen || style.hyphens() == HyphensNone)) {
</span><span class="cx"> j++;
</span><span class="cx"> if (j == len)
</span><span class="lines">@@ -892,7 +893,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- int wordLen = j - i;
</del><ins>+ unsigned wordLen = j - i;
</ins><span class="cx"> if (wordLen) {
</span><span class="cx"> float currMinWidth = 0;
</span><span class="cx"> bool isSpace = (j < len) && isSpaceAccordingToStyle(c, style);
</span><span class="lines">@@ -936,8 +937,10 @@
</span><span class="cx"> if (betweenWords) {
</span><span class="cx"> if (lastWordBoundary == i)
</span><span class="cx"> currMaxWidth += w;
</span><del>- else
</del><ins>+ else {
+ ASSERT(j >= lastWordBoundary);
</ins><span class="cx"> currMaxWidth += widthFromCache(font, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
</span><ins>+ }
</ins><span class="cx"> lastWordBoundary = j;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderingAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "AutoTableLayout.cpp"
</span><span class="cx"> #include "BidiRun.cpp"
</span><span class="cx"> #include "BorderEdge.cpp"
</span><ins>+#include "BreakLines.cpp"
</ins><span class="cx"> #include "ClipRect.cpp"
</span><span class="cx"> #include "CounterNode.cpp"
</span><span class="cx"> #include "EllipsisBox.cpp"
</span><span class="lines">@@ -149,4 +150,3 @@
</span><span class="cx"> #include "TextDecorationPainter.cpp"
</span><span class="cx"> #include "TextPaintStyle.cpp"
</span><span class="cx"> #include "TextPainter.cpp"
</span><del>-#include "break_lines.cpp"
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -114,8 +114,9 @@
</span><span class="cx"> unsigned TextFragmentIterator::nextBreakablePosition(const FlowContents::Segment& segment, unsigned startPosition)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(startPosition < segment.end);
</span><del>- if (segment.text.impl() != m_lineBreakIterator.string().impl()) {
- const String& currentText = m_lineBreakIterator.string();
</del><ins>+ StringView currentText = m_lineBreakIterator.stringView();
+ StringView segmentText = StringView(segment.text);
+ if (segmentText != currentText) {
</ins><span class="cx"> unsigned textLength = currentText.length();
</span><span class="cx"> UChar lastCharacter = textLength > 0 ? currentText[textLength - 1] : 0;
</span><span class="cx"> UChar secondToLastCharacter = textLength > 1 ? currentText[textLength - 2] : 0;
</span><span class="lines">@@ -125,7 +126,7 @@
</span><span class="cx"> const auto* characters = segment.text.characters<CharacterType>();
</span><span class="cx"> unsigned segmentLength = segment.end - segment.start;
</span><span class="cx"> unsigned segmentPosition = startPosition - segment.start;
</span><del>- return segment.start + nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(m_lineBreakIterator, characters, segmentLength, segmentPosition);
</del><ins>+ return segment.start + nextBreakablePositionNonLoosely<CharacterType, NonBreakingSpaceBehavior::IgnoreNonBreakingSpace>(m_lineBreakIterator, characters, segmentLength, segmentPosition);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename CharacterType>
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -23,13 +23,12 @@
</span><span class="cx"> * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef SimpleLineLayoutTextFragmentIterator_h
-#define SimpleLineLayoutTextFragmentIterator_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><ins>+#include "BreakLines.h"
</ins><span class="cx"> #include "RenderLineBreak.h"
</span><span class="cx"> #include "SimpleLineLayoutFlowContents.h"
</span><span class="cx"> #include <wtf/text/TextBreakIterator.h>
</span><del>-#include "break_lines.h"
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -166,5 +165,3 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingbreak_linescpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/rendering/break_lines.cpp (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/break_lines.cpp        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/break_lines.cpp        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -1,100 +0,0 @@
</span><del>-/*
- * Copyright (C) 2005, 2007, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "break_lines.h"
-
-#include <wtf/ASCIICType.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/unicode/CharacterNames.h>
-
-namespace WebCore {
-
-// Pack 8 bits into one byte
-#define B(a, b, c, d, e, f, g, h) \
- ((a) | ((b) << 1) | ((c) << 2) | ((d) << 3) | ((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7))
-
-// Line breaking table row for each digit (0-9)
-#define DI { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
-
-// Line breaking table row for ascii letters (a-z A-Z)
-#define AL { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
-
-#define F 0xFF
-
-// Line breaking table for printable ASCII characters. Line breaking opportunities in this table are as below:
-// - before opening punctuations such as '(', '<', '[', '{' after certain characters (compatible with Firefox 3.6);
-// - after '-' and '?' (backward-compatible, and compatible with Internet Explorer).
-// Please refer to <https://bugs.webkit.org/show_bug.cgi?id=37698> for line breaking matrixes of different browsers
-// and the ICU standard.
-WEBCORE_EXPORT const unsigned char asciiLineBreakTable[][asciiLineBreakTableColumnCount] = {
- // ! " # $ % & ' ( ) * + , - . / 0 1-8 9 : ; < = > ? @ A-X Y Z [ \ ] ^ _ ` a-x y z { | } ~ DEL
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // !
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // "
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // #
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // $
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // %
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // &
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // '
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // (
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // )
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // *
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // +
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ,
- { B(1, 1, 1, 1, 1, 1, 1, 1), B(1, 1, 1, 1, 1, 0, 1, 0), 0, B(0, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1) }, // - Note: breaking before '0'-'9' is handled hard-coded in shouldBreakAfter().
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // .
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // /
- DI, DI, DI, DI, DI, DI, DI, DI, DI, DI, // 0-9
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // :
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ;
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // <
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // =
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // >
- { B(0, 0, 1, 1, 1, 1, 0, 1), B(0, 1, 1, 0, 1, 0, 0, 1), F, B(1, 0, 0, 1, 1, 1, 0, 1), F, F, F, B(1, 1, 1, 1, 0, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 0, 1, 1, 0) }, // ?
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // @
- AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, // A-Z
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // [
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // '\'
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ]
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // ^
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // _
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // `
- AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, // a-z
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // {
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // |
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // }
- { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // ~
- { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // DEL
-};
-
-#undef B
-#undef F
-#undef DI
-#undef AL
-
-COMPILE_ASSERT(WTF_ARRAY_LENGTH(asciiLineBreakTable) == asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar + 1, TestLineBreakTableConsistency);
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingbreak_linesh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/rendering/break_lines.h (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/break_lines.h        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/break_lines.h        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -1,248 +0,0 @@
</span><del>-/*
- * Copyright (C) 2005, 2007, 2010, 2013 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef break_lines_h
-#define break_lines_h
-
-#include <wtf/ASCIICType.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/TextBreakIterator.h>
-#include <wtf/unicode/CharacterNames.h>
-
-namespace WebCore {
-
-static const UChar asciiLineBreakTableFirstChar = '!';
-static const UChar asciiLineBreakTableLastChar = 127;
-static const unsigned asciiLineBreakTableColumnCount = (asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar) / 8 + 1;
-
-WEBCORE_EXPORT extern const unsigned char asciiLineBreakTable[][asciiLineBreakTableColumnCount];
-
-enum class NBSPBehavior {
- IgnoreNBSP,
- TreatNBSPAsBreak,
-};
-
-template<NBSPBehavior nbspBehavior>
-static inline bool isBreakableSpace(UChar ch)
-{
- switch (ch) {
- case ' ':
- case '\n':
- case '\t':
- return true;
- case noBreakSpace:
- return nbspBehavior == NBSPBehavior::TreatNBSPAsBreak;
- default:
- return false;
- }
-}
-
-inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh)
-{
- // Don't allow line breaking between '-' and a digit if the '-' may mean a minus sign in the context,
- // while allow breaking in 'ABCD-1234' and '1234-5678' which may be in long URLs.
- if (ch == '-' && isASCIIDigit(nextCh))
- return isASCIIAlphanumeric(lastCh);
-
- // If both ch and nextCh are ASCII characters, use a lookup table for enhanced speed and for compatibility
- // with other browsers (see comments for asciiLineBreakTable for details).
- if (ch >= asciiLineBreakTableFirstChar && ch <= asciiLineBreakTableLastChar && nextCh >= asciiLineBreakTableFirstChar && nextCh <= asciiLineBreakTableLastChar) {
- const unsigned char* tableRow = asciiLineBreakTable[ch - asciiLineBreakTableFirstChar];
- int nextChIndex = nextCh - asciiLineBreakTableFirstChar;
- return tableRow[nextChIndex / 8] & (1 << (nextChIndex % 8));
- }
- // Otherwise defer to the Unicode algorithm by returning false.
- return false;
-}
-
-template<NBSPBehavior nbspBehavior>
-inline bool needsLineBreakIterator(UChar ch)
-{
- if (nbspBehavior == NBSPBehavior::TreatNBSPAsBreak)
- return ch > asciiLineBreakTableLastChar;
- return ch > asciiLineBreakTableLastChar && ch != noBreakSpace;
-}
-
-// When in non-loose mode, we can use the ASCII shortcut table.
-template<typename CharacterType, NBSPBehavior nbspBehavior>
-inline int nextBreakablePositionNonLoosely(LazyLineBreakIterator& lazyBreakIterator, const CharacterType* str, unsigned length, int pos)
-{
- int len = static_cast<int>(length);
- int nextBreak = -1;
-
- CharacterType lastLastCh = pos > 1 ? str[pos - 2] : static_cast<CharacterType>(lazyBreakIterator.secondToLastCharacter());
- CharacterType lastCh = pos > 0 ? str[pos - 1] : static_cast<CharacterType>(lazyBreakIterator.lastCharacter());
- unsigned priorContextLength = lazyBreakIterator.priorContextLength();
- for (int i = pos; i < len; i++) {
- CharacterType ch = str[i];
-
- // Non-loose mode, so use ASCII shortcut (shouldBreakAfter) if not breakable space.
- if (isBreakableSpace<nbspBehavior>(ch) || shouldBreakAfter(lastLastCh, lastCh, ch))
- return i;
-
- // Non-loose mode, so conditionally use break iterator.
- if (needsLineBreakIterator<nbspBehavior>(ch) || needsLineBreakIterator<nbspBehavior>(lastCh)) {
- if (nextBreak < i) {
- // Don't break if positioned at start of primary context and there is no prior context.
- if (i || priorContextLength) {
- TextBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
- if (breakIterator) {
- nextBreak = textBreakFollowing(breakIterator, i - 1 + priorContextLength);
- if (nextBreak >= 0)
- nextBreak -= priorContextLength;
- }
- }
- }
- if (i == nextBreak && !isBreakableSpace<nbspBehavior>(lastCh))
- return i;
- }
-
- lastLastCh = lastCh;
- lastCh = ch;
- }
-
- return len;
-}
-
-// 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, NBSPBehavior nbspBehavior>
-static inline int nextBreakablePositionLoosely(LazyLineBreakIterator& lazyBreakIterator, const CharacterType* str, unsigned length, int pos)
-{
- int len = static_cast<int>(length);
- int nextBreak = -1;
-
- CharacterType lastCh = pos > 0 ? str[pos - 1] : static_cast<CharacterType>(lazyBreakIterator.lastCharacter());
- unsigned priorContextLength = lazyBreakIterator.priorContextLength();
- for (int i = pos; i < len; i++) {
- CharacterType ch = str[i];
-
- // Always loose mode, so don't use ASCII shortcut (shouldBreakAfter).
- if (isBreakableSpace<nbspBehavior>(ch))
- return i;
-
- // Always use line break iterator in loose mode.
- if (nextBreak < i) {
- // Don't break if positioned at start of primary context and there is no prior context.
- if (i || priorContextLength) {
- TextBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
- if (breakIterator) {
- nextBreak = textBreakFollowing(breakIterator, i - 1 + priorContextLength);
- if (nextBreak >= 0)
- nextBreak -= priorContextLength;
- }
- }
- }
- if (i == nextBreak && !isBreakableSpace<nbspBehavior>(lastCh))
- return i;
-
- lastCh = ch;
- }
-
- return len;
-}
-
-template<typename CharacterType, NBSPBehavior nbspBehavior>
-inline unsigned nextBreakablePositionKeepingAllWords(const CharacterType* string, unsigned length, unsigned startPosition)
-{
- for (unsigned i = startPosition; i < length; i++) {
- if (isBreakableSpace<nbspBehavior>(string[i]))
- return i;
- }
- return length;
-}
-
-inline unsigned nextBreakablePositionKeepingAllWords(LazyLineBreakIterator& lazyBreakIterator, int startPosition)
-{
- String string = lazyBreakIterator.string();
- if (string.is8Bit())
- return nextBreakablePositionKeepingAllWords<LChar, NBSPBehavior::TreatNBSPAsBreak>(string.characters8(), string.length(), startPosition);
- return nextBreakablePositionKeepingAllWords<UChar, NBSPBehavior::TreatNBSPAsBreak>(string.characters16(), string.length(), startPosition);
-}
-
-inline unsigned nextBreakablePositionKeepingAllWordsIgnoringNBSP(LazyLineBreakIterator& iterator, int startPosition)
-{
- String string = iterator.string();
- if (string.is8Bit())
- return nextBreakablePositionKeepingAllWords<LChar, NBSPBehavior::IgnoreNBSP>(string.characters8(), string.length(), startPosition);
- return nextBreakablePositionKeepingAllWords<UChar, NBSPBehavior::IgnoreNBSP>(string.characters16(), string.length(), startPosition);
-}
-
-inline int nextBreakablePosition(LazyLineBreakIterator& iterator, int pos)
-{
- String string = iterator.string();
- if (string.is8Bit())
- return nextBreakablePositionNonLoosely<LChar, NBSPBehavior::TreatNBSPAsBreak>(iterator, string.characters8(), string.length(), pos);
- return nextBreakablePositionNonLoosely<UChar, NBSPBehavior::TreatNBSPAsBreak>(iterator, string.characters16(), string.length(), pos);
-}
-
-inline int nextBreakablePositionIgnoringNBSP(LazyLineBreakIterator& lazyBreakIterator, int pos)
-{
- String string = lazyBreakIterator.string();
- if (string.is8Bit())
- return nextBreakablePositionNonLoosely<LChar, NBSPBehavior::IgnoreNBSP>(lazyBreakIterator, string.characters8(), string.length(), pos);
- return nextBreakablePositionNonLoosely<UChar, NBSPBehavior::IgnoreNBSP>(lazyBreakIterator, string.characters16(), string.length(), pos);
-}
-
-inline int nextBreakablePositionLoose(LazyLineBreakIterator& lazyBreakIterator, int pos)
-{
- String string = lazyBreakIterator.string();
- if (string.is8Bit())
- return nextBreakablePositionLoosely<LChar, NBSPBehavior::TreatNBSPAsBreak>(lazyBreakIterator, string.characters8(), string.length(), pos);
- return nextBreakablePositionLoosely<UChar, NBSPBehavior::TreatNBSPAsBreak>(lazyBreakIterator, string.characters16(), string.length(), pos);
-}
-
-inline int nextBreakablePositionIgnoringNBSPLoose(LazyLineBreakIterator& lazyBreakIterator, int pos)
-{
- String string = lazyBreakIterator.string();
- if (string.is8Bit())
- return nextBreakablePositionLoosely<LChar, NBSPBehavior::IgnoreNBSP>(lazyBreakIterator, string.characters8(), string.length(), pos);
- return nextBreakablePositionLoosely<UChar, NBSPBehavior::IgnoreNBSP>(lazyBreakIterator, string.characters16(), string.length(), pos);
-}
-
-inline bool isBreakable(LazyLineBreakIterator& lazyBreakIterator, int pos, int& nextBreakable, bool breakNBSP, bool isLooseMode, bool keepAllWords)
-{
- if (pos <= nextBreakable)
- return pos == nextBreakable;
-
- if (keepAllWords) {
- if (breakNBSP)
- nextBreakable = static_cast<int>(nextBreakablePositionKeepingAllWords(lazyBreakIterator, pos));
- else
- nextBreakable = static_cast<int>(nextBreakablePositionKeepingAllWordsIgnoringNBSP(lazyBreakIterator, pos));
- } else if (isLooseMode) {
- if (breakNBSP)
- nextBreakable = nextBreakablePositionLoose(lazyBreakIterator, pos);
- else
- nextBreakable = nextBreakablePositionIgnoringNBSPLoose(lazyBreakIterator, pos);
- } else {
- if (breakNBSP)
- nextBreakable = nextBreakablePosition(lazyBreakIterator, pos);
- else
- nextBreakable = nextBreakablePositionIgnoringNBSP(lazyBreakIterator, pos);
- }
- return pos == nextBreakable;
-}
-
-} // namespace WebCore
-
-#endif // break_lines_h
</del></span></pre></div>
<a id="trunkSourceWebCorerenderinglineBreakingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/line/BreakingContext.h        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -22,9 +22,9 @@
</span><span class="cx"> *
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef BreakingContext_h
-#define BreakingContext_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><ins>+#include "BreakLines.h"
</ins><span class="cx"> #include "Hyphenation.h"
</span><span class="cx"> #include "LineBreaker.h"
</span><span class="cx"> #include "LineInfo.h"
</span><span class="lines">@@ -38,7 +38,6 @@
</span><span class="cx"> #include "RenderRubyRun.h"
</span><span class="cx"> #include "RenderSVGInlineText.h"
</span><span class="cx"> #include "TrailingObjects.h"
</span><del>-#include "break_lines.h"
</del><span class="cx"> #include <wtf/Optional.h>
</span><span class="cx"> #include <wtf/text/StringView.h>
</span><span class="cx"> #include <wtf/unicode/CharacterNames.h>
</span><span class="lines">@@ -167,7 +166,7 @@
</span><span class="cx"> m_hangsAtEnd = false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void commitLineBreakAtCurrentWidth(RenderObject& object, unsigned offset = 0, int nextBreak = -1)
</del><ins>+ void commitLineBreakAtCurrentWidth(RenderObject& object, unsigned offset = 0, Optional<unsigned> nextBreak = Nullopt)
</ins><span class="cx"> {
</span><span class="cx"> m_width.commit();
</span><span class="cx"> m_lineBreakHistory.moveTo(&object, offset, nextBreak);
</span><span class="lines">@@ -204,7 +203,7 @@
</span><span class="cx">
</span><span class="cx"> RenderObject* renderer() const { return this->at(0).renderer(); }
</span><span class="cx"> unsigned offset() const { return this->at(0).offset(); }
</span><del>- int nextBreakablePosition() const { return this->at(0).nextBreakablePosition(); }
</del><ins>+ Optional<unsigned> nextBreakablePosition() const { return this->at(0).nextBreakablePosition(); }
</ins><span class="cx"> bool atTextParagraphSeparator() const { return this->at(0).atTextParagraphSeparator(); }
</span><span class="cx"> UChar previousInSameNode() const { return this->at(0).previousInSameNode(); }
</span><span class="cx"> const InlineIterator& get(size_t i) const { return this->at(i); };
</span><span class="lines">@@ -211,7 +210,7 @@
</span><span class="cx"> const InlineIterator& current() const { return get(0); }
</span><span class="cx"> size_t historyLength() const { return this->size(); }
</span><span class="cx">
</span><del>- void moveTo(RenderObject* object, unsigned offset, int nextBreak = -1)
</del><ins>+ void moveTo(RenderObject* object, unsigned offset, Optional<unsigned> nextBreak = Nullopt)
</ins><span class="cx"> {
</span><span class="cx"> push([&](InlineIterator& modifyMe) {
</span><span class="cx"> modifyMe.moveTo(object, offset, nextBreak);
</span><span class="lines">@@ -650,7 +649,7 @@
</span><span class="cx"> lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(0, textParagraphSeparator.renderer(), textParagraphSeparator.offset()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline void tryHyphenating(RenderText& text, const FontCascade& font, const AtomicString& localeIdentifier, unsigned consecutiveHyphenatedLines, int consecutiveHyphenatedLinesLimit, int minimumPrefixLimit, int minimumSuffixLimit, unsigned lastSpace, unsigned pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
</del><ins>+inline void tryHyphenating(RenderText& text, const FontCascade& font, const AtomicString& localeIdentifier, unsigned consecutiveHyphenatedLines, int consecutiveHyphenatedLinesLimit, int minimumPrefixLimit, int minimumSuffixLimit, unsigned lastSpace, unsigned pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, Optional<unsigned> nextBreakable, bool& hyphenated)
</ins><span class="cx"> {
</span><span class="cx"> // Map 'hyphenate-limit-{before,after}: auto;' to 2.
</span><span class="cx"> unsigned minimumPrefixLength;
</span><span class="lines">@@ -857,7 +856,7 @@
</span><span class="cx"> midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_width.availableWidth();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- int nextBreakablePosition = m_current.nextBreakablePosition();
</del><ins>+ Optional<unsigned> nextBreakablePosition = m_current.nextBreakablePosition();
</ins><span class="cx"> bool betweenWords = c == '\n' || (m_currWS != PRE && !m_atStart && isBreakable(m_renderTextInfo.lineBreakIterator, m_current.offset(), nextBreakablePosition, breakNBSP, isLooseCJKMode, keepAllWords)
</span><span class="cx"> && (style.hyphens() != HyphensNone || (m_current.previousInSameNode() != softHyphen)));
</span><span class="cx"> m_current.setNextBreakablePosition(nextBreakablePosition);
</span><span class="lines">@@ -959,14 +958,14 @@
</span><span class="cx"> }
</span><span class="cx"> // Check if the last breaking position is a soft-hyphen.
</span><span class="cx"> if (!hyphenated && style.hyphens() != HyphensNone) {
</span><del>- Optional<int> lastBreakingPositon;
</del><ins>+ Optional<unsigned> lastBreakingPositon;
</ins><span class="cx"> const RenderObject* rendererAtBreakingPosition = nullptr;
</span><del>- if (m_lineBreakHistory.offset() || m_lineBreakHistory.nextBreakablePosition() > -1) {
</del><ins>+ if (m_lineBreakHistory.offset() || m_lineBreakHistory.nextBreakablePosition()) {
</ins><span class="cx"> lastBreakingPositon = m_lineBreakHistory.offset();
</span><span class="cx"> rendererAtBreakingPosition = m_lineBreakHistory.renderer();
</span><del>- } else if (m_current.nextBreakablePosition() > -1 && (unsigned)m_current.nextBreakablePosition() <= m_current.offset()) {
</del><ins>+ } else if (m_current.nextBreakablePosition() && m_current.nextBreakablePosition().value() <= m_current.offset()) {
</ins><span class="cx"> // We might just be right after the soft-hyphen
</span><del>- lastBreakingPositon = m_current.nextBreakablePosition();
</del><ins>+ lastBreakingPositon = m_current.nextBreakablePosition().value();
</ins><span class="cx"> rendererAtBreakingPosition = m_current.renderer();
</span><span class="cx"> }
</span><span class="cx"> if (lastBreakingPositon) {
</span><span class="lines">@@ -977,7 +976,7 @@
</span><span class="cx"> characterBeforeBreakingPosition = lastCharacterFromPreviousRenderText;
</span><span class="cx"> else if (is<RenderText>(rendererAtBreakingPosition)) {
</span><span class="cx"> const auto& textRenderer = downcast<RenderText>(*rendererAtBreakingPosition);
</span><del>- ASSERT(textRenderer.textLength() > (unsigned)(lastBreakingPositon.value() - 1));
</del><ins>+ ASSERT(lastBreakingPositon.value() >= 1 && textRenderer.textLength() > (lastBreakingPositon.value() - 1));
</ins><span class="cx"> characterBeforeBreakingPosition = textRenderer.characterAt(lastBreakingPositon.value() - 1);
</span><span class="cx"> }
</span><span class="cx"> if (characterBeforeBreakingPosition)
</span><span class="lines">@@ -1315,9 +1314,9 @@
</span><span class="cx"> return lineBreak;
</span><span class="cx"> bool isLooseCJKMode = m_renderTextInfo.text != &renderText && m_renderTextInfo.lineBreakIterator.isLooseCJKMode();
</span><span class="cx"> bool breakNBSP = m_autoWrap && m_currentStyle->nbspMode() == SPACE;
</span><del>- int nextBreakablePosition = lineBreak.nextBreakablePosition();
</del><ins>+ Optional<unsigned> nextBreakablePosition = lineBreak.nextBreakablePosition();
</ins><span class="cx"> isBreakable(m_renderTextInfo.lineBreakIterator, lineBreak.offset() + 1, nextBreakablePosition, breakNBSP, isLooseCJKMode, m_currentStyle->wordBreak() == KeepAllWordBreak);
</span><del>- if (nextBreakablePosition < 0 || static_cast<unsigned>(nextBreakablePosition) != renderText.textLength())
</del><ins>+ if (!nextBreakablePosition || nextBreakablePosition.value() != renderText.textLength())
</ins><span class="cx"> return lineBreak;
</span><span class="cx"> const RenderStyle& style = lineStyle(renderText, m_lineInfo);
</span><span class="cx"> const FontCascade& font = style.fontCascade();
</span><span class="lines">@@ -1339,5 +1338,3 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> }
</span><del>-
-#endif // BreakingContext_h
</del></span></pre></div>
<a id="trunkSourceWebKitiosChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/ChangeLog (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/ChangeLog        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebKit/ios/ChangeLog        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-08-16 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Migrate line breaking code from ints to Optional<unsigned>s
+ https://bugs.webkit.org/show_bug.cgi?id=160859
+
+ Reviewed by Darin Adler.
+
+ * Misc/WebUIKitSupport.mm:
+ (WebKitGetLastLineBreakInBuffer):
+
</ins><span class="cx"> 2016-08-15 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove unused includes of wtf headers
</span></span></pre></div>
<a id="trunkSourceWebKitiosMiscWebUIKitSupportmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/Misc/WebUIKitSupport.mm (204530 => 204531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/Misc/WebUIKitSupport.mm        2016-08-16 22:33:32 UTC (rev 204530)
+++ trunk/Source/WebKit/ios/Misc/WebUIKitSupport.mm        2016-08-16 22:39:10 UTC (rev 204531)
</span><span class="lines">@@ -33,12 +33,12 @@
</span><span class="cx"> #import "WebPlatformStrategies.h"
</span><span class="cx"> #import "WebSystemInterface.h"
</span><span class="cx"> #import "WebViewPrivate.h"
</span><ins>+#import <WebCore/BreakLines.h>
</ins><span class="cx"> #import <WebCore/PathUtilities.h>
</span><span class="cx"> #import <WebCore/ResourceRequest.h>
</span><span class="cx"> #import <WebCore/Settings.h>
</span><span class="cx"> #import <WebCore/WebCoreSystemInterface.h>
</span><span class="cx"> #import <WebCore/WebCoreThreadSystemInterface.h>
</span><del>-#import <WebCore/break_lines.h>
</del><span class="cx"> #import <wtf/spi/darwin/dyldSPI.h>
</span><span class="cx"> #import <wtf/text/TextBreakIterator.h>
</span><span class="cx">
</span><span class="lines">@@ -89,12 +89,12 @@
</span><span class="cx">
</span><span class="cx"> int WebKitGetLastLineBreakInBuffer(UChar *characters, int position, int length)
</span><span class="cx"> {
</span><del>- int lastBreakPos = position;
- int breakPos = 0;
- LazyLineBreakIterator breakIterator(String(characters, length));
- while ((breakPos = nextBreakablePosition(breakIterator, breakPos)) < position)
</del><ins>+ unsigned lastBreakPos = position;
+ unsigned breakPos = 0;
+ LazyLineBreakIterator breakIterator(StringView(characters, length));
+ while (static_cast<int>(breakPos = nextBreakablePosition(breakIterator, breakPos)) < position)
</ins><span class="cx"> lastBreakPos = breakPos++;
</span><del>- return lastBreakPos < position ? (NSUInteger)lastBreakPos : INT_MAX;
</del><ins>+ return static_cast<int>(lastBreakPos) < position ? lastBreakPos : INT_MAX;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const char *WebKitPlatformSystemRootDirectory(void)
</span></span></pre>
</div>
</div>
</body>
</html>