summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc61
1 files changed, 48 insertions, 13 deletions
diff --git a/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc b/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc
index 43a3834692e..8653ca0ef2f 100644
--- a/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc
+++ b/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter.cc
@@ -22,6 +22,7 @@
#include "third_party/blink/renderer/core/paint/highlight_painting_utils.h"
#include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/paint_timing_detector.h"
+#include "third_party/blink/renderer/core/paint/selection_bounds_recorder.h"
#include "third_party/blink/renderer/core/paint/text_decoration_info.h"
#include "third_party/blink/renderer/core/paint/text_painter.h"
#include "third_party/blink/renderer/platform/graphics/dom_node_id.h"
@@ -34,6 +35,8 @@
namespace blink {
+class HTMLAnchorElement;
+
namespace {
// If an inline text box is truncated by an ellipsis, text box markers paint
@@ -131,7 +134,8 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
DCHECK(!ShouldPaintSelfOutline(paint_info.phase) &&
!ShouldPaintDescendantOutlines(paint_info.phase));
- bool is_printing = paint_info.IsPrinting();
+ bool is_printing =
+ inline_text_box_.GetLineLayoutItem().GetDocument().Printing();
// Determine whether or not we're selected.
bool have_selection = !is_printing &&
@@ -150,18 +154,6 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
physical_overflow.Move(paint_offset);
IntRect visual_rect = EnclosingIntRect(physical_overflow);
- // The text clip phase already has a DrawingRecorder. Text clips are initiated
- // only in BoxPainter::PaintFillLayer, which is already within a
- // DrawingRecorder.
- base::Optional<DrawingRecorder> recorder;
- if (paint_info.phase != PaintPhase::kTextClip) {
- if (DrawingRecorder::UseCachedDrawingIfPossible(
- paint_info.context, inline_text_box_, paint_info.phase))
- return;
- recorder.emplace(paint_info.context, inline_text_box_, paint_info.phase,
- visual_rect);
- }
-
GraphicsContext& context = paint_info.context;
PhysicalOffset box_origin =
inline_text_box_.PhysicalLocation() + paint_offset;
@@ -179,6 +171,49 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
PhysicalSize(inline_text_box_.LogicalWidth(),
inline_text_box_.LogicalHeight()));
+ base::Optional<SelectionBoundsRecorder> selection_recorder;
+ if (have_selection && paint_info.phase == PaintPhase::kForeground &&
+ !is_printing) {
+ const FrameSelection& frame_selection =
+ InlineLayoutObject().GetFrame()->Selection();
+ SelectionState selection_state =
+ frame_selection.ComputeLayoutSelectionStateForInlineTextBox(
+ inline_text_box_);
+ if (SelectionBoundsRecorder::ShouldRecordSelection(frame_selection,
+ selection_state)) {
+ PhysicalRect selection_rect =
+ GetSelectionRect<InlineTextBoxPainter::PaintOptions::kNormal>(
+ context, box_rect, style_to_use, style_to_use.GetFont());
+
+ TextDirection direction = inline_text_box_.IsLeftToRightDirection()
+ ? TextDirection::kLtr
+ : TextDirection::kRtl;
+ // We need to account for vertical writing mode rotation - for the
+ // actual painting of the selection_rect, this is done below by
+ // concatenating a rotation matrix on the context.
+ if (!style_to_use.IsHorizontalWritingMode()) {
+ FloatRect rotated_selection =
+ TextPainterBase::Rotation(box_rect, TextPainterBase::kClockwise)
+ .MapRect(static_cast<FloatRect>(selection_rect));
+ selection_rect = PhysicalRect::EnclosingRect(rotated_selection);
+ }
+ selection_recorder.emplace(selection_state, selection_rect,
+ context.GetPaintController(), direction,
+ style_to_use.GetWritingMode());
+ }
+ }
+
+ // The text clip phase already has a DrawingRecorder. Text clips are initiated
+ // only in BoxPainter::PaintFillLayer, which is already within a
+ // DrawingRecorder.
+ base::Optional<DrawingRecorder> recorder;
+ if (paint_info.phase != PaintPhase::kTextClip) {
+ if (DrawingRecorder::UseCachedDrawingIfPossible(context, inline_text_box_,
+ paint_info.phase))
+ return;
+ recorder.emplace(context, inline_text_box_, paint_info.phase, visual_rect);
+ }
+
unsigned length = inline_text_box_.Len();
const String& layout_item_string =
inline_text_box_.GetLineLayoutItem().GetText();