Commit 9e9b1635 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Add LayoutNGFullPositionForPoint feature.

This fully enables NGPhysicalBoxFragment::PositionForPoint(). If it's
disabled, we'll typically only use the aforementioned method in inline
formatting contexts. Correct support for block children is work in
progress.

The plan is to fix the remaining issues over the next few days, and
enable LayoutNGFullPositionForPoint for stable. We can disable it again
if it turns out that it causes regressions not covered by any tests.
There will be some behavior changes, most notably the fact that we'll
always use the nearest box (and calculate this accurately - as opposed
to what we do in LayoutBlock::PositionForPoint()).

Bug: 1150362
Change-Id: Ic4e9257a70fbbb7ff321f3ee5d417186a9a67839
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550833Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830099}
parent 7ae89aef
......@@ -168,7 +168,8 @@ PositionWithAffinity HitTestResult::GetPosition() const {
return PositionWithAffinity(MostForwardCaretPosition(
Position(inner_node_, PositionAnchorType::kBeforeChildren)));
}
if (box_fragment_ && NGPhysicalBoxFragment::SupportsPositionForPoint())
if (box_fragment_ &&
RuntimeEnabledFeatures::LayoutNGFullPositionForPointEnabled())
return box_fragment_->PositionForPoint(LocalPoint());
return layout_object->PositionForPoint(LocalPoint());
}
......@@ -184,7 +185,8 @@ PositionWithAffinity HitTestResult::GetPositionForInnerNodeOrImageMapImage()
if (!layout_object)
return PositionWithAffinity();
PositionWithAffinity position;
if (box_fragment_ && NGPhysicalBoxFragment::SupportsPositionForPoint() &&
if (box_fragment_ &&
RuntimeEnabledFeatures::LayoutNGFullPositionForPointEnabled() &&
layout_object == GetLayoutObject())
position = box_fragment_->PositionForPoint(LocalPoint());
else
......@@ -292,7 +294,7 @@ void HitTestResult::SetInnerNode(Node* n) {
}
}
if (NGPhysicalBoxFragment::SupportsPositionForPoint()) {
if (RuntimeEnabledFeatures::LayoutNGFullPositionForPointEnabled()) {
if (const LayoutBox* layout_box = n->GetLayoutBox()) {
// Fragmentation-aware code will set the correct box fragment on its own,
// but sometimes we enter legacy layout code when hit-testing, e.g. for
......
......@@ -1417,7 +1417,7 @@ PositionWithAffinity LayoutBlock::PositionForPoint(
NOT_DESTROYED();
if (IsLayoutNGObject() && PhysicalFragmentCount() &&
NGPhysicalBoxFragment::SupportsPositionForPoint()) {
RuntimeEnabledFeatures::LayoutNGFullPositionForPointEnabled()) {
// Layout engine boundary. Enter NG PositionForPoint(). Assert
// that we're not block-fragmented here.
DCHECK_EQ(PhysicalFragmentCount(), 1u);
......
......@@ -273,12 +273,6 @@ class CORE_EXPORT NGPhysicalBoxFragment final
return *ComputeRareDataAddress()->mathml_paint_info;
}
// Temporary while stabilizing PositionForPoint support in
// NGPhysicalBoxFragment.
static bool SupportsPositionForPoint() {
return RuntimeEnabledFeatures::LayoutNGBlockFragmentationEnabled();
}
private:
static size_t ByteSize(wtf_size_t num_fragment_items,
wtf_size_t num_children,
......
......@@ -1076,6 +1076,12 @@
name: "LayoutNGFragmentTraversal",
implied_by: ["LayoutNGBlockFragmentation"],
},
{
// Full support for PositionForPoint in NGPhysicalFragment. Without this
// enabled, we'll typically fall back to legacy code for block children.
name: "LayoutNGFullPositionForPoint",
implied_by: ["LayoutNGBlockFragmentation", "LayoutNGFragmentTraversal"],
},
{
name: "LayoutNGGrid",
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment