summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/paint/inline_box_painter_base.h
blob: 84520814e46c39ade8b6b1e0b2494df1c4c203d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_INLINE_BOX_PAINTER_BASE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_INLINE_BOX_PAINTER_BASE_H_

#include "third_party/blink/renderer/core/paint/box_painter_base.h"
#include "third_party/blink/renderer/core/style/shadow_data.h"
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"

namespace blink {

class Color;
class FillLayer;
class IntRect;
class LayoutPoint;
class LayoutRect;
struct PaintInfo;
class ComputedStyle;

// Common base class for InlineFlowBoxPainter and NGInlineBoxFragmentPainter.
// Implements layout agnostic inline box painting behavior.
class InlineBoxPainterBase {
  STACK_ALLOCATED();

 public:
  InlineBoxPainterBase(const ImageResourceObserver& image_observer,
                       const Document* document,
                       Node* node,
                       const ComputedStyle& style,
                       const ComputedStyle& line_style)
      : image_observer_(image_observer),
        document_(document),
        node_(node),
        style_(style),
        line_style_(line_style) {}

  void PaintBoxDecorationBackground(BoxPainterBase&,
                                    const PaintInfo&,
                                    const LayoutPoint& paint_offset,
                                    LayoutRect adjusted_frame_rect,
                                    BackgroundImageGeometry,
                                    bool object_has_multiple_boxes,
                                    bool include_logical_left_edge,
                                    bool include_logical_right_edge);

 protected:
  void PaintFillLayers(BoxPainterBase&,
                       const PaintInfo&,
                       const Color&,
                       const FillLayer&,
                       const LayoutRect&,
                       BackgroundImageGeometry& geometry,
                       bool object_has_multiple_boxes);
  void PaintFillLayer(BoxPainterBase&,
                      const PaintInfo&,
                      const Color&,
                      const FillLayer&,
                      const LayoutRect&,
                      BackgroundImageGeometry& geometry,
                      bool object_has_multiple_boxes);
  virtual void PaintNormalBoxShadow(const PaintInfo&,
                                    const ComputedStyle&,
                                    const LayoutRect& paint_rect) = 0;
  virtual void PaintInsetBoxShadow(const PaintInfo&,
                                   const ComputedStyle&,
                                   const LayoutRect& paint_rect) = 0;

  virtual LayoutRect PaintRectForImageStrip(const LayoutRect&,
                                            TextDirection direction) const = 0;

  enum BorderPaintingType {
    kDontPaintBorders,
    kPaintBordersWithoutClip,
    kPaintBordersWithClip
  };
  virtual BorderPaintingType GetBorderPaintType(
      const LayoutRect& adjusted_frame_rect,
      IntRect& adjusted_clip_rect,
      bool object_has_multiple_boxes) const = 0;

  const ImageResourceObserver& image_observer_;
  Member<const Document> document_;
  Member<Node> node_;

  // Style for the corresponding node.
  const ComputedStyle& style_;

  // Style taking ::first-line into account.
  const ComputedStyle& line_style_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_INLINE_BOX_PAINTER_BASE_H_