<!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>[199307] trunk/Source/WebCore</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/199307">199307</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2016-04-11 12:52:35 -0700 (Mon, 11 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simplify InlineTextBox::selectionStartEnd()
https://bugs.webkit.org/show_bug.cgi?id=156459
Reviewed by Darin Adler.
No change in functionality.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionState):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::selectionStartEnd):
(WebCore::InlineTextBox::paintSelection):
(WebCore::InlineTextBox::paintCompositionBackground):
* rendering/InlineTextBox.h:
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paintSelectionBackground):
(WebCore::SVGInlineTextBox::paintText):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxh">trunk/Source/WebCore/rendering/InlineTextBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGInlineTextBoxcpp">trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199306 => 199307)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-11 19:37:01 UTC (rev 199306)
+++ trunk/Source/WebCore/ChangeLog        2016-04-11 19:52:35 UTC (rev 199307)
</span><span class="lines">@@ -1,5 +1,25 @@
</span><span class="cx"> 2016-04-11 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><ins>+ Simplify InlineTextBox::selectionStartEnd()
+ https://bugs.webkit.org/show_bug.cgi?id=156459
+
+ Reviewed by Darin Adler.
+
+ No change in functionality.
+
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::selectionState):
+ (WebCore::InlineTextBox::paint):
+ (WebCore::InlineTextBox::selectionStartEnd):
+ (WebCore::InlineTextBox::paintSelection):
+ (WebCore::InlineTextBox::paintCompositionBackground):
+ * rendering/InlineTextBox.h:
+ * rendering/svg/SVGInlineTextBox.cpp:
+ (WebCore::SVGInlineTextBox::paintSelectionBackground):
+ (WebCore::SVGInlineTextBox::paintText):
+
+2016-04-11 Zalan Bujtas <zalan@apple.com>
+
</ins><span class="cx"> REGRESSION (r193857): Text selection causes text to disappear.
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=156448
</span><span class="cx"> rdar://problem/25578952
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (199306 => 199307)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp        2016-04-11 19:37:01 UTC (rev 199306)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp        2016-04-11 19:52:35 UTC (rev 199307)
</span><span class="lines">@@ -165,13 +165,14 @@
</span><span class="cx"> if (m_truncation != cNoTruncation && root().ellipsisBox()) {
</span><span class="cx"> EllipsisBox* ellipsis = root().ellipsisBox();
</span><span class="cx"> if (state != RenderObject::SelectionNone) {
</span><del>- int start, end;
- selectionStartEnd(start, end);
</del><ins>+ int selectionStart;
+ int selectionEnd;
+ std::tie(selectionStart, selectionEnd) = selectionStartEnd();
</ins><span class="cx"> // The ellipsis should be considered to be selected if the end of
</span><span class="cx"> // the selection is past the beginning of the truncation and the
</span><span class="cx"> // beginning of the selection is before or at the beginning of the
</span><span class="cx"> // truncation.
</span><del>- ellipsis->setSelectionState(end >= m_truncation && start <= m_truncation ?
</del><ins>+ ellipsis->setSelectionState(selectionEnd >= m_truncation && selectionStart <= m_truncation ?
</ins><span class="cx"> RenderObject::SelectionInside : RenderObject::SelectionNone);
</span><span class="cx"> } else
</span><span class="cx"> ellipsis->setSelectionState(RenderObject::SelectionNone);
</span><span class="lines">@@ -519,7 +520,7 @@
</span><span class="cx"> int selectionStart = 0;
</span><span class="cx"> int selectionEnd = 0;
</span><span class="cx"> if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately))
</span><del>- selectionStartEnd(selectionStart, selectionEnd);
</del><ins>+ std::tie(selectionStart, selectionEnd) = selectionStartEnd();
</ins><span class="cx">
</span><span class="cx"> if (m_truncation != cNoTruncation) {
</span><span class="cx"> selectionStart = std::min<int>(selectionStart, m_truncation);
</span><span class="lines">@@ -595,22 +596,20 @@
</span><span class="cx"> context.concatCTM(rotation(boxRect, Counterclockwise));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void InlineTextBox::selectionStartEnd(int& sPos, int& ePos)
</del><ins>+std::pair<int, int> InlineTextBox::selectionStartEnd() const
</ins><span class="cx"> {
</span><del>- int startPos, endPos;
- if (renderer().selectionState() == RenderObject::SelectionInside) {
- startPos = 0;
- endPos = renderer().textLength();
- } else {
- renderer().selectionStartEnd(startPos, endPos);
- if (renderer().selectionState() == RenderObject::SelectionStart)
- endPos = renderer().textLength();
- else if (renderer().selectionState() == RenderObject::SelectionEnd)
- startPos = 0;
- }
-
- sPos = std::max(startPos - m_start, 0);
- ePos = std::min(endPos - m_start, (int)m_len);
</del><ins>+ auto selectionState = renderer().selectionState();
+ if (selectionState == RenderObject::SelectionInside)
+ return {0, m_len};
+
+ int start;
+ int end;
+ renderer().selectionStartEnd(start, end);
+ if (selectionState == RenderObject::SelectionStart)
+ end = renderer().textLength();
+ else if (selectionState == RenderObject::SelectionEnd)
+ start = 0;
+ return { std::max(start - m_start, 0), std::min<int>(end - m_start, m_len) };
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void InlineTextBox::paintSelection(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const FontCascade& font, Color textColor)
</span><span class="lines">@@ -620,9 +619,10 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // See if we have a selection to paint at all.
</span><del>- int sPos, ePos;
- selectionStartEnd(sPos, ePos);
- if (sPos >= ePos)
</del><ins>+ int selectionStart;
+ int selectionEnd;
+ std::tie(selectionStart, selectionEnd) = selectionStartEnd();
+ if (selectionStart >= selectionEnd)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> Color c = renderer().selectionBackgroundColor();
</span><span class="lines">@@ -648,10 +648,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String hyphenatedStringBuffer;
</span><del>- bool respectHyphen = ePos == length && hasHyphen();
</del><ins>+ bool respectHyphen = selectionEnd == length && hasHyphen();
</ins><span class="cx"> TextRun textRun = constructTextRun(style, string, renderer().textLength() - m_start, respectHyphen ? &hyphenatedStringBuffer : nullptr);
</span><span class="cx"> if (respectHyphen)
</span><del>- ePos = textRun.length();
</del><ins>+ selectionEnd = textRun.length();
</ins><span class="cx">
</span><span class="cx"> const RootInlineBox& rootBox = root();
</span><span class="cx"> LayoutUnit selectionBottom = rootBox.selectionBottom();
</span><span class="lines">@@ -661,7 +661,7 @@
</span><span class="cx"> LayoutUnit selectionHeight = std::max<LayoutUnit>(0, selectionBottom - selectionTop);
</span><span class="cx">
</span><span class="cx"> LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selectionHeight);
</span><del>- font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
</del><ins>+ font.adjustSelectionRectForText(textRun, selectionRect, selectionStart, selectionEnd);
</ins><span class="cx"> context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), c);
</span><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(context);
</span><span class="lines">@@ -675,10 +675,9 @@
</span><span class="cx"> void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const FontCascade& font, int startPos, int endPos)
</span><span class="cx"> {
</span><span class="cx"> int offset = m_start;
</span><del>- int sPos = std::max(startPos - offset, 0);
- int ePos = std::min(endPos - offset, (int)m_len);
-
- if (sPos >= ePos)
</del><ins>+ int selectionStart = std::max(startPos - offset, 0);
+ int selectionEnd = std::min<int>(endPos - offset, m_len);
+ if (selectionStart >= selectionEnd)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> GraphicsContextStateSaver stateSaver(context);
</span><span class="lines">@@ -688,7 +687,7 @@
</span><span class="cx"> LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
</span><span class="cx"> LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, 0, selectionHeight());
</span><span class="cx"> TextRun textRun = constructTextRun(style);
</span><del>- font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
</del><ins>+ font.adjustSelectionRectForText(textRun, selectionRect, selectionStart, selectionEnd);
</ins><span class="cx"> context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), compositionColor);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (199306 => 199307)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.h        2016-04-11 19:37:01 UTC (rev 199306)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h        2016-04-11 19:52:35 UTC (rev 199307)
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx">
</span><span class="cx"> virtual LayoutRect localSelectionRect(int startPos, int endPos) const;
</span><span class="cx"> bool isSelected(int startPos, int endPos) const;
</span><del>- void selectionStartEnd(int& sPos, int& ePos);
</del><ins>+ std::pair<int, int> selectionStartEnd() const;
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (199306 => 199307)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2016-04-11 19:37:01 UTC (rev 199306)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2016-04-11 19:52:35 UTC (rev 199307)
</span><span class="lines">@@ -203,8 +203,9 @@
</span><span class="cx">
</span><span class="cx"> RenderStyle& style = parentRenderer.style();
</span><span class="cx">
</span><del>- int startPosition, endPosition;
- selectionStartEnd(startPosition, endPosition);
</del><ins>+ int startPosition;
+ int endPosition;
+ std::tie(startPosition, endPosition) = selectionStartEnd();
</ins><span class="cx">
</span><span class="cx"> int fragmentStartPosition = 0;
</span><span class="cx"> int fragmentEndPosition = 0;
</span><span class="lines">@@ -592,7 +593,7 @@
</span><span class="cx"> int startPosition = 0;
</span><span class="cx"> int endPosition = 0;
</span><span class="cx"> if (hasSelection) {
</span><del>- selectionStartEnd(startPosition, endPosition);
</del><ins>+ std::tie(startPosition, endPosition) = selectionStartEnd();
</ins><span class="cx"> hasSelection = mapStartEndPositionsIntoFragmentCoordinates(fragment, startPosition, endPosition);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>