<!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>[215054] trunk</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/215054">215054</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2017-04-06 13:03:55 -0700 (Thu, 06 Apr 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simple line layout: Hittest always returns the first renderer in the block.
https://bugs.webkit.org/show_bug.cgi?id=170520
<rdar://problem/30979175>
Reviewed by Antti Koivisto.
Source/WebCore:
This is incorrect now with <br> support (multiple renderers within the same block flow).
Test: fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html
* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint): Related fix. We don't yet support positionForPoint with multiple renderes.
* rendering/SimpleLineLayoutFlowContents.h:
(WebCore::SimpleLineLayout::FlowContents::segmentForRun): Empty runs are all valid.
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::hitTestFlow):
(WebCore::SimpleLineLayout::collectFlowOverflow):
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::LineResolver::Iterator::operator*): This should eventually return a list of renderes.
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::flowContents):
LayoutTests:
* fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html: Added.
* fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextcpp">trunk/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsh">trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFunctionscpp">trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutResolvercpp">trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutResolverh">trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomDocumentCaretRangeFromPointsimplelinelayouthittestwithcaretrangefrompointexpectedhtml">trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastdomDocumentCaretRangeFromPointsimplelinelayouthittestwithcaretrangefrompointhtml">trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/LayoutTests/ChangeLog        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-04-06 Zalan Bujtas <zalan@apple.com>
+
+ Simple line layout: Hittest always returns the first renderer in the block.
+ https://bugs.webkit.org/show_bug.cgi?id=170520
+ <rdar://problem/30979175>
+
+ Reviewed by Antti Koivisto.
+
+ * fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html: Added.
+ * fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html: Added.
+
</ins><span class="cx"> 2017-03-31 Jiewen Tan <jiewen_tan@apple.com>
</span><span class="cx">
</span><span class="cx"> [WebCrypto] Add support for AES-CTR
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomDocumentCaretRangeFromPointsimplelinelayouthittestwithcaretrangefrompointexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html (0 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple line layout hittest finds the same offset as normal line layout hittest.</title>
+<style>
+body {
+ margin: 0px;
+}
+
+div {
+ line-height: 20px;
+}
+</style>
+<script>
+if (window.internals)
+ internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+</head>
+<body>
+<div>f</div>
+<div>f<br>fo</div>
+<div>f<br>fo<br>foo</div>
+<div>f<br>fo<br>foo<br>foob</div>
+<div>f<br>fo<br>foo<br>foob<br>fooba</div>
+<div>f<br>fo<br>foo<br>foob<br>fooba<br>foobar</div>
+<script>
+var hittestResults = "";
+hittestResults += document.caretRangeFromPoint(5, 10).startOffset;
+hittestResults += document.caretRangeFromPoint(10, 50).startOffset;
+hittestResults += document.caretRangeFromPoint(12, 90).startOffset;
+hittestResults += document.caretRangeFromPoint(20, 190).startOffset;
+hittestResults += document.caretRangeFromPoint(25, 270).startOffset;
+hittestResults += document.caretRangeFromPoint(30, 410).startOffset;
+document.body.innerText = hittestResults
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomDocumentCaretRangeFromPointsimplelinelayouthittestwithcaretrangefrompointhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html (0 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple line layout hittest finds the same offset as normal line layout hittest.</title>
+<style>
+body {
+ margin: 0px;
+}
+
+div {
+ line-height: 20px;
+}
+</style>
+</head>
+<body>
+<div>f</div>
+<div>f<br>fo</div>
+<div>f<br>fo<br>foo</div>
+<div>f<br>fo<br>foo<br>foob</div>
+<div>f<br>fo<br>foo<br>foob<br>fooba</div>
+<div>f<br>fo<br>foo<br>foob<br>fooba<br>foobar</div>
+<script>
+var hittestResults = "";
+hittestResults += document.caretRangeFromPoint(5, 10).startOffset;
+hittestResults += document.caretRangeFromPoint(10, 50).startOffset;
+hittestResults += document.caretRangeFromPoint(12, 90).startOffset;
+hittestResults += document.caretRangeFromPoint(20, 190).startOffset;
+hittestResults += document.caretRangeFromPoint(25, 270).startOffset;
+hittestResults += document.caretRangeFromPoint(30, 410).startOffset;
+document.body.innerText = hittestResults
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/Source/WebCore/ChangeLog        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2017-04-06 Zalan Bujtas <zalan@apple.com>
+
+ Simple line layout: Hittest always returns the first renderer in the block.
+ https://bugs.webkit.org/show_bug.cgi?id=170520
+ <rdar://problem/30979175>
+
+ Reviewed by Antti Koivisto.
+
+ This is incorrect now with <br> support (multiple renderers within the same block flow).
+
+ Test: fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html
+
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::positionForPoint): Related fix. We don't yet support positionForPoint with multiple renderes.
+ * rendering/SimpleLineLayoutFlowContents.h:
+ (WebCore::SimpleLineLayout::FlowContents::segmentForRun): Empty runs are all valid.
+ * rendering/SimpleLineLayoutFunctions.cpp:
+ (WebCore::SimpleLineLayout::hitTestFlow):
+ (WebCore::SimpleLineLayout::collectFlowOverflow):
+ * rendering/SimpleLineLayoutResolver.cpp:
+ (WebCore::SimpleLineLayout::LineResolver::Iterator::operator*): This should eventually return a list of renderes.
+ * rendering/SimpleLineLayoutResolver.h:
+ (WebCore::SimpleLineLayout::RunResolver::flowContents):
+
</ins><span class="cx"> 2017-04-06 Jon Davis <jond@apple.com>
</span><span class="cx">
</span><span class="cx"> Updates feature status for recently shipped features
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.cpp (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.cpp        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/Source/WebCore/rendering/RenderText.cpp        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -443,8 +443,8 @@
</span><span class="cx">
</span><span class="cx"> Position RenderText::positionForPoint(const LayoutPoint& point)
</span><span class="cx"> {
</span><del>- if (auto* layout = simpleLineLayout()) {
- auto position = Position(textNode(), SimpleLineLayout::textOffsetForPoint(point, *this, *layout));
</del><ins>+ if (simpleLineLayout() && parent()->firstChild() == parent()->lastChild()) {
+ auto position = Position(textNode(), SimpleLineLayout::textOffsetForPoint(point, *this, *simpleLineLayout()));
</ins><span class="cx"> ASSERT(position == positionForPoint(point, nullptr).deepEquivalent());
</span><span class="cx"> return position;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">
</span><span class="cx"> inline const FlowContents::Segment& FlowContents::segmentForRun(unsigned start, unsigned end) const
</span><span class="cx"> {
</span><del>- ASSERT(start < end);
</del><ins>+ ASSERT(start <= end);
</ins><span class="cx"> auto& lastSegment = m_segments[m_lastSegmentIndex];
</span><span class="cx"> if (lastSegment.start <= start && end <= lastSegment.end)
</span><span class="cx"> return m_segments[m_lastSegmentIndex];
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFunctionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -148,20 +148,20 @@
</span><span class="cx"> if (style.visibility() != VISIBLE || style.pointerEvents() == PE_NONE)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- RenderObject& renderer = *flow.firstChild();
</del><span class="cx"> LayoutRect rangeRect = locationInContainer.boundingBox();
</span><span class="cx"> rangeRect.moveBy(-accumulatedOffset);
</span><del>-
</del><span class="cx"> auto resolver = lineResolver(flow, layout);
</span><del>- for (FloatRect lineRect : resolver.rangeForRect(rangeRect)) {
</del><ins>+ auto range = resolver.rangeForRect(rangeRect);
+ for (auto it = range.begin(), end = range.end(); it != end; ++it) {
+ auto lineRect = *it;
</ins><span class="cx"> lineRect.moveBy(accumulatedOffset);
</span><span class="cx"> if (!locationInContainer.intersects(lineRect))
</span><span class="cx"> continue;
</span><ins>+ auto& renderer = const_cast<RenderObject&>(it.renderer());
</ins><span class="cx"> renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
</span><span class="cx"> if (!result.addNodeToRectBasedTestResult(renderer.node(), request, locationInContainer, lineRect))
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -272,7 +272,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-const FloatRect LineResolver::Iterator::operator*() const
</del><ins>+FloatRect LineResolver::Iterator::operator*() const
</ins><span class="cx"> {
</span><span class="cx"> unsigned currentLine = m_runIterator.lineIndex();
</span><span class="cx"> auto it = m_runIterator;
</span><span class="lines">@@ -282,6 +282,13 @@
</span><span class="cx"> return rect;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+const RenderObject& LineResolver::Iterator::renderer() const
+{
+ // FIXME: This works as long as we've got only one renderer per line.
+ auto run = *m_runIterator;
+ return m_runIterator.resolver().flowContents().segmentForRun(run.start(), run.end()).renderer;
+}
+
</ins><span class="cx"> LineResolver::LineResolver(const RenderBlockFlow& flow, const Layout& layout)
</span><span class="cx"> : m_runResolver(flow, layout)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (215053 => 215054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h        2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h        2017-04-06 20:03:55 UTC (rev 215054)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> RunResolver(const RenderBlockFlow&, const Layout&);
</span><span class="cx">
</span><span class="cx"> const RenderBlockFlow& flow() const { return m_flowRenderer; }
</span><ins>+ const FlowContents& flowContents() const { return m_flowContents; }
</ins><span class="cx"> Iterator begin() const;
</span><span class="cx"> Iterator end() const;
</span><span class="cx">
</span><span class="lines">@@ -125,8 +126,6 @@
</span><span class="cx">
</span><span class="cx"> class LineResolver {
</span><span class="cx"> public:
</span><del>- class Iterator;
-
</del><span class="cx"> class Iterator {
</span><span class="cx"> public:
</span><span class="cx"> explicit Iterator(RunResolver::Iterator);
</span><span class="lines">@@ -135,11 +134,12 @@
</span><span class="cx"> bool operator==(const Iterator&) const;
</span><span class="cx"> bool operator!=(const Iterator&) const;
</span><span class="cx">
</span><del>- const FloatRect operator*() const;
</del><ins>+ FloatRect operator*() const;
+ // FIXME: Use a list to support multiple renderers per line.
+ const RenderObject& renderer() const;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> RunResolver::Iterator m_runIterator;
</span><del>- LayoutRect m_rect;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> LineResolver(const RenderBlockFlow&, const Layout&);
</span></span></pre>
</div>
</div>
</body>
</html>