chromium/third_party/blink/renderer/core/paint/box_fragment_painter.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/paint/box_fragment_painter.h"

#include "base/containers/adapters.h"
#include "base/ranges/algorithm.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/editing/drag_caret.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/pagination_state.h"
#include "third_party/blink/renderer/core/layout/background_bleed_avoidance.h"
#include "third_party/blink/renderer/core/layout/block_break_token.h"
#include "third_party/blink/renderer/core/layout/fragmentation_utils.h"
#include "third_party/blink/renderer/core/layout/geometry/box_strut.h"
#include "third_party/blink/renderer/core/layout/hit_test_location.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/inline/fragment_items.h"
#include "third_party/blink/renderer/core/layout/inline/inline_cursor.h"
#include "third_party/blink/renderer/core/layout/inline/physical_line_box_fragment.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_text_combine.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/outline_utils.h"
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/pointer_events_hit_rules.h"
#include "third_party/blink/renderer/core/layout/table/layout_table.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_cell.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/box_background_paint_context.h"
#include "third_party/blink/renderer/core/paint/box_border_painter.h"
#include "third_party/blink/renderer/core/paint/box_decoration_data.h"
#include "third_party/blink/renderer/core/paint/box_painter.h"
#include "third_party/blink/renderer/core/paint/fieldset_painter.h"
#include "third_party/blink/renderer/core/paint/fragment_painter.h"
#include "third_party/blink/renderer/core/paint/frame_set_painter.h"
#include "third_party/blink/renderer/core/paint/inline_box_fragment_painter.h"
#include "third_party/blink/renderer/core/paint/mathml_painter.h"
#include "third_party/blink/renderer/core/paint/object_painter.h"
#include "third_party/blink/renderer/core/paint/paint_auto_dark_mode.h"
#include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/paint/paint_phase.h"
#include "third_party/blink/renderer/core/paint/rounded_border_geometry.h"
#include "third_party/blink/renderer/core/paint/scoped_paint_state.h"
#include "third_party/blink/renderer/core/paint/scoped_svg_paint_state.h"
#include "third_party/blink/renderer/core/paint/scrollable_area_painter.h"
#include "third_party/blink/renderer/core/paint/table_painters.h"
#include "third_party/blink/renderer/core/paint/text_combine_painter.h"
#include "third_party/blink/renderer/core/paint/text_fragment_painter.h"
#include "third_party/blink/renderer/core/paint/theme_painter.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing_detector.h"
#include "third_party/blink/renderer/core/paint/url_metadata_utils.h"
#include "third_party/blink/renderer/core/paint/view_painter.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item_cache_skipper.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h"
#include "third_party/blink/renderer/platform/graphics/paint/scoped_display_item_fragment.h"

namespace blink {

namespace {

inline bool HasSelection(const LayoutObject* layout_object) {}

inline bool IsVisibleToPaint(const PhysicalFragment& fragment,
                             const ComputedStyle& style) {}

inline bool IsVisibleToPaint(const FragmentItem& item,
                             const ComputedStyle& style) {}

inline bool IsVisibleToHitTest(const ComputedStyle& style,
                               const HitTestRequest& request) {}

inline bool IsVisibleToHitTest(const FragmentItem& item,
                               const HitTestRequest& request) {}

inline bool IsVisibleToHitTest(const PhysicalFragment& fragment,
                               const HitTestRequest& request) {}

// Hit tests inline ancestor elements of |fragment| who do not have their own
// box fragments.
// @param physical_offset Physical offset of |fragment| in the paint layer.
bool HitTestCulledInlineAncestors(
    HitTestResult& result,
    const InlineCursor& parent_cursor,
    const LayoutObject* current,
    const LayoutObject* limit,
    const InlineCursorPosition& previous_sibling,
    const HitTestLocation& hit_test_location,
    const PhysicalOffset fallback_accumulated_offset) {}

bool HitTestCulledInlineAncestors(HitTestResult& result,
                                  const PhysicalBoxFragment& container,
                                  const InlineCursor& parent_cursor,
                                  const FragmentItem& item,
                                  const InlineCursorPosition& previous_sibling,
                                  const HitTestLocation& hit_test_location,
                                  const PhysicalOffset& physical_offset) {}

// Returns a vector of backplates that surround the paragraphs of text within
// line_boxes.
//
// This function traverses descendants of an inline formatting context in
// pre-order DFS and build up backplates behind inline text boxes, each split at
// the paragraph level. Store the results in paragraph_backplates.
Vector<PhysicalRect> BuildBackplate(InlineCursor* descendants,
                                    const PhysicalOffset& paint_offset) {}

bool HitTestAllPhasesInFragment(const PhysicalBoxFragment& fragment,
                                const HitTestLocation& hit_test_location,
                                PhysicalOffset accumulated_offset,
                                HitTestResult* result) {}

bool NodeAtPointInFragment(const PhysicalBoxFragment& fragment,
                           const HitTestLocation& hit_test_location,
                           PhysicalOffset accumulated_offset,
                           HitTestPhase phase,
                           HitTestResult* result) {}

// Return an ID for this fragmentainer, which is unique within the fragmentation
// context. We need to provide this ID when block-fragmenting, so that we can
// cache the painting of each individual fragment.
unsigned FragmentainerUniqueIdentifier(const PhysicalBoxFragment& fragment) {}

bool ShouldPaintCursorCaret(const PhysicalBoxFragment& fragment) {}

bool ShouldPaintDragCaret(const PhysicalBoxFragment& fragment) {}

bool ShouldPaintCarets(const PhysicalBoxFragment& fragment) {}

PaintInfo FloatPaintInfo(const PaintInfo& paint_info) {}

// Helper function for painting a child fragment, when there's any likelihood
// that we need legacy fallback. If it's guaranteed that legacy fallback won't
// be necessary, on the other hand, there's no need to call this function. In
// such cases, call sites may just as well invoke BoxFragmentPainter::Paint()
// on their own.
void PaintFragment(const PhysicalBoxFragment& fragment,
                   const PaintInfo& paint_info) {}

}  // anonymous namespace

PhysicalRect BoxFragmentPainter::InkOverflowIncludingFilters() const {}

InlinePaintContext& BoxFragmentPainter::EnsureInlineContext() {}

void BoxFragmentPainter::Paint(const PaintInfo& paint_info) {}

void BoxFragmentPainter::PaintInternal(const PaintInfo& paint_info) {}

bool BoxFragmentPainter::PaintOverflowControls(
    const PaintInfo& paint_info,
    const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::RecordScrollHitTestData(
    const PaintInfo& paint_info,
    const DisplayItemClient& background_client) {}

bool BoxFragmentPainter::ShouldRecordHitTestData(const PaintInfo& paint_info) {}

void BoxFragmentPainter::PaintObject(const PaintInfo& paint_info,
                                     const PhysicalOffset& paint_offset,
                                     bool suppress_box_decoration_background) {}

void BoxFragmentPainter::PaintCaretsIfNeeded(
    const ScopedPaintState& paint_state,
    const PaintInfo& paint_info,
    const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::PaintLineBoxes(const PaintInfo& paint_info,
                                        const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::PaintBlockChildren(const PaintInfo& paint_info,
                                            PhysicalOffset paint_offset) {}

void BoxFragmentPainter::PaintBlockChild(
    const PhysicalFragmentLink& child,
    const PaintInfo& paint_info,
    const PaintInfo& paint_info_for_descendants,
    PhysicalOffset paint_offset) {}

void BoxFragmentPainter::PaintFloatingItems(const PaintInfo& paint_info,
                                            InlineCursor* cursor) {}

void BoxFragmentPainter::PaintFloatingChildren(
    const PhysicalFragment& container,
    const PaintInfo& paint_info) {}

void BoxFragmentPainter::PaintFloats(const PaintInfo& paint_info) {}

void BoxFragmentPainter::PaintMask(const PaintInfo& paint_info,
                                   const PhysicalOffset& paint_offset) {}

// TODO(kojii): This logic is kept in sync with BoxPainter. Not much efforts to
// eliminate LayoutObject dependency were done yet.
void BoxFragmentPainter::PaintBoxDecorationBackground(
    const PaintInfo& paint_info,
    const PhysicalOffset& paint_offset,
    bool suppress_box_decoration_background) {}

void BoxFragmentPainter::PaintBoxDecorationBackgroundWithRect(
    const PaintInfo& paint_info,
    const gfx::Rect& visual_rect,
    const PhysicalRect& paint_rect,
    const DisplayItemClient& background_client) {}

void BoxFragmentPainter::PaintCompositeBackgroundAttachmentFixed(
    const PaintInfo& paint_info,
    const DisplayItemClient& background_client,
    const BoxDecorationData& box_decoration_data) {}

void BoxFragmentPainter::PaintBoxDecorationBackgroundWithDecorationData(
    const PaintInfo& paint_info,
    const gfx::Rect& visual_rect,
    const PhysicalRect& paint_rect,
    const DisplayItemClient& background_client,
    DisplayItem::Type display_item_type,
    const BoxDecorationData& box_decoration_data) {}

// TODO(kojii): This logic is kept in sync with BoxPainter. Not much efforts to
// eliminate LayoutObject dependency were done yet.
void BoxFragmentPainter::PaintBoxDecorationBackgroundWithRectImpl(
    const PaintInfo& paint_info,
    const PhysicalRect& paint_rect,
    const BoxDecorationData& box_decoration_data) {}

void BoxFragmentPainter::PaintBoxDecorationBackgroundForBlockInInline(
    InlineCursor* children,
    const PaintInfo& paint_info,
    const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::PaintColumnRules(const PaintInfo& paint_info,
                                          const PhysicalOffset& paint_offset) {}

// TODO(kojii): This logic is kept in sync with BoxPainter. Not much efforts to
// eliminate LayoutObject dependency were done yet.
void BoxFragmentPainter::PaintBackground(
    const PaintInfo& paint_info,
    const PhysicalRect& paint_rect,
    const Color& background_color,
    BackgroundBleedAvoidance bleed_avoidance) {}

void BoxFragmentPainter::PaintAllPhasesAtomically(const PaintInfo& paint_info) {}

void BoxFragmentPainter::PaintInlineItems(const PaintInfo& paint_info,
                                          const PhysicalOffset& paint_offset,
                                          const PhysicalOffset& parent_offset,
                                          InlineCursor* cursor) {}

// Paint a line box. This function records hit test data of the line box in
// case the line box overflows the container or the line box is in a different
// chunk from the hit test data recorded for the container box's background.
// It also paints the backgrounds of the `::first-line` line box. Other line
// boxes don't have their own background.
inline void BoxFragmentPainter::PaintLineBox(
    const PhysicalFragment& line_box_fragment,
    const DisplayItemClient& display_item_client,
    const FragmentItem& line_box_item,
    const PaintInfo& paint_info,
    const PhysicalOffset& child_offset) {}

void BoxFragmentPainter::PaintLineBoxChildItems(
    InlineCursor* children,
    const PaintInfo& paint_info,
    const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::PaintBackplate(InlineCursor* line_boxes,
                                        const PaintInfo& paint_info,
                                        const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::PaintTextItem(const InlineCursor& cursor,
                                       const PaintInfo& paint_info,
                                       const PhysicalOffset& paint_offset,
                                       const PhysicalOffset& parent_offset) {}

// Paint non-culled box item.
void BoxFragmentPainter::PaintBoxItem(const FragmentItem& item,
                                      const PhysicalBoxFragment& child_fragment,
                                      const InlineCursor& cursor,
                                      const PaintInfo& paint_info,
                                      const PhysicalOffset& paint_offset) {}

void BoxFragmentPainter::PaintBoxItem(const FragmentItem& item,
                                      const InlineCursor& cursor,
                                      const PaintInfo& paint_info,
                                      const PhysicalOffset& paint_offset,
                                      const PhysicalOffset& parent_offset) {}

bool BoxFragmentPainter::ShouldPaint(
    const ScopedPaintState& paint_state) const {}

void BoxFragmentPainter::PaintTextClipMask(const PaintInfo& paint_info,
                                           const gfx::Rect& mask_rect,
                                           const PhysicalOffset& paint_offset,
                                           bool object_has_multiple_boxes) {}

void BoxFragmentPainter::PaintTextClipMask(
    const PaintInfo& paint_info,
    PhysicalOffset paint_offset,
    InlineBoxFragmentPainter* inline_box_painter) {}

PhysicalRect BoxFragmentPainter::AdjustRectForScrolledContent(
    GraphicsContext& context,
    const PhysicalBoxStrut& borders,
    const PhysicalRect& rect) const {}

BoxPainterBase::FillLayerInfo BoxFragmentPainter::GetFillLayerInfo(
    const Color& color,
    const FillLayer& bg_layer,
    BackgroundBleedAvoidance bleed_avoidance,
    bool is_painting_background_in_contents_space) const {}

template <typename T>
bool BoxFragmentPainter::HitTestContext::AddNodeToResult(
    Node* node,
    const PhysicalBoxFragment* box_fragment,
    const T& bounds_rect,
    const PhysicalOffset& offset) const {}

template <typename T>
bool BoxFragmentPainter::HitTestContext::AddNodeToResultWithContentOffset(
    Node* node,
    const PhysicalBoxFragment& container,
    const T& bounds_rect,
    PhysicalOffset offset) const {}

bool BoxFragmentPainter::NodeAtPoint(HitTestResult& result,
                                     const HitTestLocation& hit_test_location,
                                     const PhysicalOffset& physical_offset,
                                     HitTestPhase phase) {}

bool BoxFragmentPainter::NodeAtPoint(HitTestResult& result,
                                     const HitTestLocation& hit_test_location,
                                     const PhysicalOffset& physical_offset,
                                     const PhysicalOffset& inline_root_offset,
                                     HitTestPhase phase) {}

bool BoxFragmentPainter::NodeAtPoint(const HitTestContext& hit_test,
                                     const PhysicalOffset& physical_offset) {}

bool BoxFragmentPainter::UpdateHitTestResultForView(
    const PhysicalRect& bounds_rect,
    const HitTestContext& hit_test) const {}

bool BoxFragmentPainter::HitTestAllPhases(
    HitTestResult& result,
    const HitTestLocation& hit_test_location,
    const PhysicalOffset& accumulated_offset) {}

bool BoxFragmentPainter::HitTestTextItem(const HitTestContext& hit_test,
                                         const FragmentItem& text_item,
                                         const InlineBackwardCursor& cursor) {}

bool BoxFragmentPainter::HitTestLineBoxFragment(
    const HitTestContext& hit_test,
    const PhysicalLineBoxFragment& fragment,
    const InlineBackwardCursor& cursor,
    const PhysicalOffset& physical_offset) {}

bool BoxFragmentPainter::HitTestInlineChildBoxFragment(
    const HitTestContext& hit_test,
    const PhysicalBoxFragment& fragment,
    const InlineBackwardCursor& backward_cursor,
    const PhysicalOffset& physical_offset) {}

bool BoxFragmentPainter::HitTestChildBoxItem(
    const HitTestContext& hit_test,
    const PhysicalBoxFragment& container,
    const FragmentItem& item,
    const InlineBackwardCursor& cursor) {}

bool BoxFragmentPainter::HitTestChildren(
    const HitTestContext& hit_test,
    const PhysicalOffset& accumulated_offset) {}

bool BoxFragmentPainter::HitTestChildren(
    const HitTestContext& hit_test,
    const PhysicalBoxFragment& container,
    const InlineCursor& children,
    const PhysicalOffset& accumulated_offset) {}

bool BoxFragmentPainter::HitTestBlockChildren(
    HitTestResult& result,
    const HitTestLocation& hit_test_location,
    PhysicalOffset accumulated_offset,
    HitTestPhase phase) {}

// static
bool BoxFragmentPainter::ShouldHitTestCulledInlineAncestors(
    const HitTestContext& hit_test,
    const FragmentItem& item) {}

bool BoxFragmentPainter::HitTestItemsChildren(
    const HitTestContext& hit_test,
    const PhysicalBoxFragment& container,
    const InlineCursor& children) {}

bool BoxFragmentPainter::HitTestFloatingChildren(
    const HitTestContext& hit_test,
    const PhysicalFragment& container,
    const PhysicalOffset& accumulated_offset) {}

bool BoxFragmentPainter::HitTestFloatingChildItems(
    const HitTestContext& hit_test,
    const InlineCursor& children,
    const PhysicalOffset& accumulated_offset) {}

bool BoxFragmentPainter::HitTestClippedOutByBorder(
    const HitTestLocation& hit_test_location,
    const PhysicalOffset& border_box_location) const {}

bool BoxFragmentPainter::HitTestOverflowControl(
    const HitTestContext& hit_test,
    PhysicalOffset accumulated_offset) {}

gfx::Rect BoxFragmentPainter::VisualRect(const PhysicalOffset& paint_offset) {}

}  // namespace blink