Commit 2e01a47c authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Clean up LineBoxListPainter AddURLRectsForInlineChildrenRecursively call

AddURLRectsForInlineChildrenRecursively() is currently called from
within LineBoxListPainter::ShouldPaint(), which seems like an odd place
since that's sounds like (and otherwise is) a predicate function.
Hoist the call out of ShouldPaint() and into the callers. Since
PaintBackplate() is only called in the kForcedColorsModeBackplate paint
phase we can drop it in that case.
Also drop the paint phase check in PaintBackplate() since it's caller
already checks it.

Change-Id: I4e28b126138f884dd411d0ef44ef949371173421
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080429
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745634}
parent 2f9e0c10
......@@ -74,9 +74,7 @@ void BuildBackplate(const InlineFlowBox* box,
}
}
} // anonymous namespace
static void AddURLRectsForInlineChildrenRecursively(
void AddURLRectsForInlineChildrenRecursively(
const LayoutObject& layout_object,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) {
......@@ -90,6 +88,8 @@ static void AddURLRectsForInlineChildrenRecursively(
}
}
} // anonymous namespace
bool LineBoxListPainter::ShouldPaint(const LayoutBoxModelObject& layout_object,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) const {
......@@ -100,12 +100,6 @@ bool LineBoxListPainter::ShouldPaint(const LayoutBoxModelObject& layout_object,
DCHECK(layout_object.IsLayoutBlock() ||
(layout_object.IsLayoutInline() && layout_object.HasLayer()));
if (paint_info.phase == PaintPhase::kForeground &&
paint_info.ShouldAddUrlMetadata()) {
AddURLRectsForInlineChildrenRecursively(layout_object, paint_info,
paint_offset);
}
// If we have no lines then we have no work to do.
if (!line_box_list_.First())
return false;
......@@ -128,6 +122,12 @@ void LineBoxListPainter::Paint(const LayoutBoxModelObject& layout_object,
paint_info.phase != PaintPhase::kMask)
return;
if (paint_info.phase == PaintPhase::kForeground &&
paint_info.ShouldAddUrlMetadata()) {
AddURLRectsForInlineChildrenRecursively(layout_object, paint_info,
paint_offset);
}
if (!ShouldPaint(layout_object, paint_info, paint_offset))
return;
......@@ -158,8 +158,9 @@ void LineBoxListPainter::PaintBackplate(
const LayoutBoxModelObject& layout_object,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) const {
if (paint_info.phase != PaintPhase::kForcedColorsModeBackplate ||
!ShouldPaint(layout_object, paint_info, paint_offset))
DCHECK_EQ(paint_info.phase, PaintPhase::kForcedColorsModeBackplate);
if (!ShouldPaint(layout_object, paint_info, paint_offset))
return;
// Only paint backplates behind text when forced-color-adjust is auto.
......
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