Commit 1de8a4ce authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Support 'visibility' in NGTextFragmentPainter

This patch supports the CSS 'visibility' property in
NGTextFragmentPainter, in the same manner as InlineTextBoxPainter.

The logic for line break painting is copied, but to be verified
when selection is supported in LayoutNGPaintFragments.

Bug: 714962
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I2334fa2af6588257c77cdc26b0f58daf39d48b63
Reviewed-on: https://chromium-review.googlesource.com/810305Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522462}
parent ea0512ee
......@@ -17,6 +17,29 @@
namespace blink {
namespace {
inline bool ShouldPaintTextFragment(const NGPhysicalTextFragment& text_fragment,
const ComputedStyle& style) {
if (style.Visibility() != EVisibility::kVisible)
return false;
// When painting selection, we want to include a highlight when the
// selection spans line breaks. In other cases such as invisible elements
// or those with no text that are not line breaks, we can skip painting
// wholesale.
// TODO(wkorman): Constrain line break painting to appropriate paint phase.
// This code path is only called in PaintPhaseForeground whereas we would
// expect PaintPhaseSelection. The existing haveSelection logic in paint()
// tests for != PaintPhaseTextClip.
if (!text_fragment.Length() || !text_fragment.TextShapeResult())
return false;
return true;
}
} // namespace
NGTextFragmentPainter::NGTextFragmentPainter(
const NGPaintFragment& text_fragment)
: fragment_(text_fragment) {
......@@ -26,8 +49,13 @@ NGTextFragmentPainter::NGTextFragmentPainter(
void NGTextFragmentPainter::Paint(const Document& document,
const PaintInfo& paint_info,
const LayoutPoint& paint_offset) {
const NGPhysicalTextFragment& text_fragment =
ToNGPhysicalTextFragment(fragment_.PhysicalFragment());
const ComputedStyle& style = fragment_.Style();
if (!ShouldPaintTextFragment(text_fragment, style))
return;
NGPhysicalSize size_;
NGPhysicalOffset offset_;
......@@ -79,9 +107,6 @@ void NGTextFragmentPainter::Paint(const Document& document,
int selection_start = 0;
int selection_end = 0;
const NGPhysicalTextFragment& text_fragment =
ToNGPhysicalTextFragment(fragment_.PhysicalFragment());
LayoutRect box_rect(box_origin, fragment_.Size().ToLayoutSize());
Optional<GraphicsContextStateSaver> state_saver;
NGLineOrientation orientation = text_fragment.LineOrientation();
......
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