Diff
Modified: trunk/LayoutTests/ChangeLog (215053 => 215054)
--- trunk/LayoutTests/ChangeLog 2017-04-06 19:51:25 UTC (rev 215053)
+++ trunk/LayoutTests/ChangeLog 2017-04-06 20:03:55 UTC (rev 215054)
@@ -1,3 +1,14 @@
+2017-04-06 Zalan Bujtas <za...@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.
+
2017-03-31 Jiewen Tan <jiewen_...@apple.com>
[WebCrypto] Add support for AES-CTR
Added: trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point-expected.html (0 => 215054)
--- 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)
@@ -0,0 +1,37 @@
+<!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>
Added: trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html (0 => 215054)
--- 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)
@@ -0,0 +1,33 @@
+<!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>
Modified: trunk/Source/WebCore/ChangeLog (215053 => 215054)
--- 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)
@@ -1,3 +1,27 @@
+2017-04-06 Zalan Bujtas <za...@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):
+
2017-04-06 Jon Davis <j...@apple.com>
Updates feature status for recently shipped features
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (215053 => 215054)
--- 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)
@@ -443,8 +443,8 @@
Position RenderText::positionForPoint(const LayoutPoint& point)
{
- if (auto* layout = simpleLineLayout()) {
- auto position = Position(textNode(), SimpleLineLayout::textOffsetForPoint(point, *this, *layout));
+ if (simpleLineLayout() && parent()->firstChild() == parent()->lastChild()) {
+ auto position = Position(textNode(), SimpleLineLayout::textOffsetForPoint(point, *this, *simpleLineLayout()));
ASSERT(position == positionForPoint(point, nullptr).deepEquivalent());
return position;
}
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h (215053 => 215054)
--- 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)
@@ -63,7 +63,7 @@
inline const FlowContents::Segment& FlowContents::segmentForRun(unsigned start, unsigned end) const
{
- ASSERT(start < end);
+ ASSERT(start <= end);
auto& lastSegment = m_segments[m_lastSegmentIndex];
if (lastSegment.start <= start && end <= lastSegment.end)
return m_segments[m_lastSegmentIndex];
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (215053 => 215054)
--- 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)
@@ -148,20 +148,20 @@
if (style.visibility() != VISIBLE || style.pointerEvents() == PE_NONE)
return false;
- RenderObject& renderer = *flow.firstChild();
LayoutRect rangeRect = locationInContainer.boundingBox();
rangeRect.moveBy(-accumulatedOffset);
-
auto resolver = lineResolver(flow, layout);
- for (FloatRect lineRect : resolver.rangeForRect(rangeRect)) {
+ auto range = resolver.rangeForRect(rangeRect);
+ for (auto it = range.begin(), end = range.end(); it != end; ++it) {
+ auto lineRect = *it;
lineRect.moveBy(accumulatedOffset);
if (!locationInContainer.intersects(lineRect))
continue;
+ auto& renderer = const_cast<RenderObject&>(it.renderer());
renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
if (!result.addNodeToRectBasedTestResult(renderer.node(), request, locationInContainer, lineRect))
return true;
}
-
return false;
}
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (215053 => 215054)
--- 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)
@@ -272,7 +272,7 @@
{
}
-const FloatRect LineResolver::Iterator::operator*() const
+FloatRect LineResolver::Iterator::operator*() const
{
unsigned currentLine = m_runIterator.lineIndex();
auto it = m_runIterator;
@@ -282,6 +282,13 @@
return rect;
}
+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;
+}
+
LineResolver::LineResolver(const RenderBlockFlow& flow, const Layout& layout)
: m_runResolver(flow, layout)
{
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (215053 => 215054)
--- 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)
@@ -98,6 +98,7 @@
RunResolver(const RenderBlockFlow&, const Layout&);
const RenderBlockFlow& flow() const { return m_flowRenderer; }
+ const FlowContents& flowContents() const { return m_flowContents; }
Iterator begin() const;
Iterator end() const;
@@ -125,8 +126,6 @@
class LineResolver {
public:
- class Iterator;
-
class Iterator {
public:
explicit Iterator(RunResolver::Iterator);
@@ -135,11 +134,12 @@
bool operator==(const Iterator&) const;
bool operator!=(const Iterator&) const;
- const FloatRect operator*() const;
+ FloatRect operator*() const;
+ // FIXME: Use a list to support multiple renderers per line.
+ const RenderObject& renderer() const;
private:
RunResolver::Iterator m_runIterator;
- LayoutRect m_rect;
};
LineResolver(const RenderBlockFlow&, const Layout&);