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

[LayoutNG] Add rudimental scroll support to NGBoxFragmentPainter

Based on the existing Slimming Paint 1.75 implementation in BoxPainter.

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: Iab68c32f6f681b6775e07b0a10d960dbd0be3aaa
Reviewed-on: https://chromium-review.googlesource.com/875149
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530639}
parent 1068c4a0
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "core/paint/PaintInfo.h" #include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
#include "core/paint/PaintPhase.h" #include "core/paint/PaintPhase.h"
#include "core/paint/ScrollRecorder.h"
#include "core/paint/ScrollableAreaPainter.h" #include "core/paint/ScrollableAreaPainter.h"
#include "core/paint/ng/ng_box_clipper.h" #include "core/paint/ng/ng_box_clipper.h"
#include "core/paint/ng/ng_fragment_painter.h" #include "core/paint/ng/ng_fragment_painter.h"
...@@ -172,26 +173,52 @@ void NGBoxFragmentPainter::PaintObject(const PaintInfo& paint_info, ...@@ -172,26 +173,52 @@ void NGBoxFragmentPainter::PaintObject(const PaintInfo& paint_info,
// ObjectPainter(box_fragment_) // ObjectPainter(box_fragment_)
// .AddPDFURLRectIfNeeded(paint_info, paint_offset); // .AddPDFURLRectIfNeeded(paint_info, paint_offset);
// TODO(layout-dev): Add support for scrolling. if (paint_phase != PaintPhase::kSelfOutlineOnly) {
Optional<PaintInfo> scrolled_paint_info; // TODO(layout-dev): Figure out where paint properties should live.
const auto& layout_object = *box_fragment_.GetLayoutObject();
Optional<PaintInfo> scrolled_paint_info;
if (const auto* fragment = paint_info.FragmentToPaint(layout_object)) {
Optional<ScopedPaintChunkProperties> scoped_scroll_property;
Optional<ScrollRecorder> scroll_recorder;
DCHECK(RuntimeEnabledFeatures::SlimmingPaintV175Enabled());
const auto* object_properties = fragment->PaintProperties();
auto* scroll_translation =
object_properties ? object_properties->ScrollTranslation() : nullptr;
if (scroll_translation) {
scoped_scroll_property.emplace(
paint_info.context.GetPaintController(), scroll_translation,
box_fragment_, DisplayItem::PaintPhaseToScrollType(paint_phase));
scrolled_paint_info.emplace(paint_info);
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
scrolled_paint_info->UpdateCullRectForScrollingContents(
EnclosingIntRect(box_fragment_.OverflowClipRect(
paint_offset, kIgnorePlatformOverlayScrollbarSize)),
scroll_translation->Matrix().ToAffineTransform());
} else {
scrolled_paint_info->UpdateCullRect(
scroll_translation->Matrix().ToAffineTransform());
}
}
}
const PaintInfo& contents_paint_info = const PaintInfo& contents_paint_info =
scrolled_paint_info ? *scrolled_paint_info : paint_info; scrolled_paint_info ? *scrolled_paint_info : paint_info;
// Paint our background, border and box-shadow. // Paint our background, border and box-shadow.
// TODO(eae): We should only paint box-decorations during the foreground phase // TODO(eae): We should only paint box-decorations during the foreground
// for inline boxes. Split this method into PaintBlock and PaintInline once we // phase for inline boxes. Split this method into PaintBlock and PaintInline
// can tell the two types of fragments apart or we've eliminated the extra // once we can tell the two types of fragments apart or we've eliminated the
// block wrapper fragments. // extra block wrapper fragments.
if (paint_info.phase == PaintPhase::kForeground && is_inline_) if (paint_info.phase == PaintPhase::kForeground && is_inline_)
PaintBoxDecorationBackground(paint_info, paint_offset); PaintBoxDecorationBackground(paint_info, paint_offset);
PaintContents(contents_paint_info, paint_offset); PaintContents(contents_paint_info, paint_offset);
if (paint_phase == PaintPhase::kFloat || if (paint_phase == PaintPhase::kFloat ||
paint_phase == PaintPhase::kSelection || paint_phase == PaintPhase::kSelection ||
paint_phase == PaintPhase::kTextClip) paint_phase == PaintPhase::kTextClip)
PaintFloats(contents_paint_info, paint_offset); PaintFloats(contents_paint_info, paint_offset);
}
if (ShouldPaintSelfOutline(paint_phase)) if (ShouldPaintSelfOutline(paint_phase))
NGFragmentPainter(box_fragment_).PaintOutline(paint_info, paint_offset); NGFragmentPainter(box_fragment_).PaintOutline(paint_info, paint_offset);
......
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