Diff
Modified: trunk/Source/WebCore/ChangeLog (253286 => 253287)
--- trunk/Source/WebCore/ChangeLog 2019-12-09 14:46:16 UTC (rev 253286)
+++ trunk/Source/WebCore/ChangeLog 2019-12-09 15:28:48 UTC (rev 253287)
@@ -1,3 +1,30 @@
+2019-12-09 Antti Koivisto <[email protected]>
+
+ [LFC][Integration] Hit testing
+ https://bugs.webkit.org/show_bug.cgi?id=205008
+
+ Reviewed by Zalan Bujtas.
+
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::paint):
+ (WebCore::LayoutIntegration::LineLayout::hitTest):
+
+ Hit test LFC.
+
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::LayoutTreeContent::addLayoutBoxForRenderer):
+
+ Add Layout::Box -> RenderObject map.
+
+ * layout/layouttree/LayoutTreeBuilder.h:
+ (WebCore::Layout::LayoutTreeContent::rendererForLayoutBox const):
+ (WebCore::Layout::LayoutTreeContent::addLayoutBoxForRenderer): Deleted.
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::hitTestInlineChildren):
+
+ Call into LFC hit test function.
+
2019-12-09 Zalan Bujtas <[email protected]>
[LFC][IFC] Fix fast/text/word-break.html
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (253286 => 253287)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2019-12-09 14:46:16 UTC (rev 253286)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2019-12-09 15:28:48 UTC (rev 253287)
@@ -30,6 +30,9 @@
#include "DisplayBox.h"
#include "EventRegion.h"
+#include "HitTestLocation.h"
+#include "HitTestRequest.h"
+#include "HitTestResult.h"
#include "InlineFormattingState.h"
#include "InvalidationState.h"
#include "LayoutContext.h"
@@ -240,7 +243,7 @@
auto& style = run.style();
if (style.visibility() != Visibility::Visible)
- return;
+ continue;
auto rect = Layout::toLayoutRect(run.logicalRect());
auto visualOverflowRect = computeVisualOverflow(style, rect, viewportSize);
@@ -286,6 +289,38 @@
}
}
+bool LineLayout::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
+{
+ if (hitTestAction != HitTestForeground)
+ return false;
+
+ if (!displayInlineContent())
+ return false;
+
+ auto& inlineContent = *displayInlineContent();
+
+ // FIXME: This should do something efficient to find the run range.
+ for (auto& run : inlineContent.runs) {
+ auto runRect = Layout::toLayoutRect(run.logicalRect());
+ runRect.moveBy(accumulatedOffset);
+
+ if (!locationInContainer.intersects(runRect))
+ continue;
+
+ auto& style = run.style();
+ if (style.visibility() != Visibility::Visible || style.pointerEvents() == PointerEvents::None)
+ continue;
+
+ auto& renderer = const_cast<RenderObject&>(*m_treeContent->rendererForLayoutBox(run.layoutBox()));
+
+ renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
+ if (result.addNodeToListBasedTestResult(renderer.node(), request, locationInContainer, runRect) == HitTestProgress::Stop)
+ return true;
+ }
+
+ return false;
+}
+
ShadowData* LineLayout::debugTextShadow()
{
if (!m_flow.settings().simpleLineLayoutDebugBordersEnabled())
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (253286 => 253287)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2019-12-09 14:46:16 UTC (rev 253286)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2019-12-09 15:28:48 UTC (rev 253287)
@@ -29,10 +29,14 @@
#include "LayoutPoint.h"
#include "LineLayoutTraversal.h"
+#include "RenderObjectEnums.h"
namespace WebCore {
class GraphicsContext;
+class HitTestLocation;
+class HitTestRequest;
+class HitTestResult;
class RenderBlockFlow;
class RenderLineBreak;
struct PaintInfo;
@@ -69,6 +73,7 @@
const Display::InlineContent* displayInlineContent() const;
void paint(PaintInfo&, const LayoutPoint& paintOffset);
+ bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction);
LineLayoutTraversal::TextBoxIterator textBoxesFor(const RenderText&) const;
LineLayoutTraversal::ElementBoxIterator elementBoxFor(const RenderLineBreak&) const;
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (253286 => 253287)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-12-09 14:46:16 UTC (rev 253286)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-12-09 15:28:48 UTC (rev 253287)
@@ -69,6 +69,14 @@
LayoutTreeContent::~LayoutTreeContent() = default;
+
+void LayoutTreeContent::addLayoutBoxForRenderer(const RenderObject& renderer, Box& layoutBox)
+{
+ m_renderObjectToLayoutBox.add(&renderer, &layoutBox);
+ m_layoutBoxToRenderObject.add(&layoutBox, &renderer);
+}
+
+
static void appendChild(Container& parent, Box& newChild)
{
if (!parent.hasChild()) {
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (253286 => 253287)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2019-12-09 14:46:16 UTC (rev 253286)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2019-12-09 15:28:48 UTC (rev 253287)
@@ -59,9 +59,11 @@
Box* layoutBoxForRenderer(const RenderObject& renderer) { return m_renderObjectToLayoutBox.get(&renderer); }
const Box* layoutBoxForRenderer(const RenderObject& renderer) const { return m_renderObjectToLayoutBox.get(&renderer); }
-
- void addLayoutBoxForRenderer(const RenderObject& renderer, Box& layoutBox) { m_renderObjectToLayoutBox.add(&renderer, &layoutBox); }
+ const RenderObject* rendererForLayoutBox(const Box& box) const { return m_layoutBoxToRenderObject.get(&box); }
+
+ void addLayoutBoxForRenderer(const RenderObject&, Box&);
+
private:
const RenderBox& m_rootRenderer;
std::unique_ptr<Container> m_rootLayoutBox;
@@ -68,6 +70,7 @@
HashSet<std::unique_ptr<Box>> m_boxes;
HashMap<const RenderObject*, Box*> m_renderObjectToLayoutBox;
+ HashMap<const Box*, const RenderObject*> m_layoutBoxToRenderObject;
};
class TreeBuilder {
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (253286 => 253287)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-12-09 14:46:16 UTC (rev 253286)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2019-12-09 15:28:48 UTC (rev 253287)
@@ -2955,9 +2955,14 @@
{
ASSERT(childrenInline());
- if (auto simpleLineLayout = this->simpleLineLayout())
- return SimpleLineLayout::hitTestFlow(*this, *simpleLineLayout, request, result, locationInContainer, accumulatedOffset, hitTestAction);
+ if (simpleLineLayout())
+ return SimpleLineLayout::hitTestFlow(*this, *simpleLineLayout(), request, result, locationInContainer, accumulatedOffset, hitTestAction);
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ if (layoutFormattingContextLineLayout())
+ return layoutFormattingContextLineLayout()->hitTest(request, result, locationInContainer, accumulatedOffset, hitTestAction);
+#endif
+
return complexLineLayout() && complexLineLayout()->lineBoxes().hitTest(this, request, result, locationInContainer, accumulatedOffset, hitTestAction);
}