Commit af42cdfe authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

[LayoutNG] Implement local attachment bg painting

Implement NGBoxFragmentPainter::AdjustForScrolledContent among requisite
support methods. Falls back on the underlying layout object for overflow
computation for now as scrolling and overflow isn't supported by NG yet.

Test: fast/overflow/overflow-with-local-background-attachment.html
Bug: 714962
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_layout_ng;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Idd77f7ef5c55f320255325045ed5cc00d14fa159
Reviewed-on: https://chromium-review.googlesource.com/1062325Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559353}
parent 5171e8eb
...@@ -433,9 +433,12 @@ void NGBoxFragmentPainter::PaintBoxDecorationBackground( ...@@ -433,9 +433,12 @@ void NGBoxFragmentPainter::PaintBoxDecorationBackground(
} }
// TODO(layout-dev): Support theme painting. // TODO(layout-dev): Support theme painting.
bool theme_painted = false;
// TODO(eae): Support SkipRootBackground painting. bool should_paint_background =
bool should_paint_background = true; !theme_painted &&
(!paint_info.SkipRootBackground() ||
paint_info.PaintContainer() != box_fragment_.GetLayoutObject());
if (should_paint_background) { if (should_paint_background) {
PaintBackground(paint_info, paint_rect, PaintBackground(paint_info, paint_rect,
box_decoration_data.background_color, box_decoration_data.background_color,
...@@ -659,8 +662,12 @@ bool NGBoxFragmentPainter:: ...@@ -659,8 +662,12 @@ bool NGBoxFragmentPainter::
IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
const NGPaintFragment& fragment, const NGPaintFragment& fragment,
const PaintInfo& paint_info) { const PaintInfo& paint_info) {
// TODO(layout-dev): Implement once we have support for scrolling. // TODO(layout-dev): Change paint_info.PaintContainer to accept fragments
return false; // once LayoutNG supports scrolling containers.
return paint_info.PaintFlags() & kPaintLayerPaintingOverflowContents &&
!(paint_info.PaintFlags() &
kPaintLayerPaintingCompositingBackgroundPhase) &&
box_fragment_.GetLayoutObject() == paint_info.PaintContainer();
} }
// Clone of BlockPainter::PaintOverflowControlsIfNeeded // Clone of BlockPainter::PaintOverflowControlsIfNeeded
...@@ -725,10 +732,37 @@ void NGBoxFragmentPainter::PaintTextClipMask( ...@@ -725,10 +732,37 @@ void NGBoxFragmentPainter::PaintTextClipMask(
} }
LayoutRect NGBoxFragmentPainter::AdjustForScrolledContent( LayoutRect NGBoxFragmentPainter::AdjustForScrolledContent(
const PaintInfo&, const PaintInfo& paint_info,
const BoxPainterBase::FillLayerInfo&, const BoxPainterBase::FillLayerInfo& info,
const LayoutRect& rect) { const LayoutRect& rect) {
return rect; LayoutRect scrolled_paint_rect = rect;
GraphicsContext& context = paint_info.context;
if (info.is_clipped_with_local_scrolling &&
!IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
box_fragment_, paint_info)) {
// Clip to the overflow area.
// TODO(layout-dev): Get clip information from fragment (or paint fragment)
// once LayoutNG supports overflow.
if (box_fragment_.GetLayoutObject() &&
box_fragment_.GetLayoutObject()->IsBox()) {
const LayoutBox& legacy = ToLayoutBox(*box_fragment_.GetLayoutObject());
context.Clip(FloatRect(legacy.OverflowClipRect(rect.Location())));
}
// Adjust the paint rect to reflect a scrolled content box with borders at
// the ends.
// TODO(layout-dev): This should be the scrolled content offset.
IntSize offset;
scrolled_paint_rect.Move(-offset);
LayoutRectOutsets border = BorderOutsets(info);
// TODO(layout-dev): This should be ScrollSize, not Size.
scrolled_paint_rect.SetWidth(border.Left() + box_fragment_.Size().width +
border.Right());
scrolled_paint_rect.SetHeight(border.Top() + box_fragment_.Size().height +
border.Bottom());
}
return scrolled_paint_rect;
} }
BoxPainterBase::FillLayerInfo NGBoxFragmentPainter::GetFillLayerInfo( BoxPainterBase::FillLayerInfo NGBoxFragmentPainter::GetFillLayerInfo(
......
...@@ -77,8 +77,9 @@ class CORE_EXPORT NGPaintFragment : public DisplayItemClient, ...@@ -77,8 +77,9 @@ class CORE_EXPORT NGPaintFragment : public DisplayItemClient,
void SetVisualRect(const LayoutRect& rect) { visual_rect_ = rect; } void SetVisualRect(const LayoutRect& rect) { visual_rect_ = rect; }
LayoutRect VisualOverflowRect() const; LayoutRect VisualOverflowRect() const;
LayoutRect OverflowClipRect(const LayoutPoint& location, LayoutRect OverflowClipRect(const LayoutPoint& location,
OverlayScrollbarClipBehavior) const { OverlayScrollbarClipBehavior =
return {location, VisualRect().Size()}; kIgnorePlatformOverlayScrollbarSize) const {
return {location, Size().ToLayoutSize()};
} }
LayoutRect PartialInvalidationRect() const override; LayoutRect PartialInvalidationRect() const override;
......
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