Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Unified Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2392443009: reflow comments in core/paint (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
index 1539441652f57ee2782bb63eda7347b136d3bed0..c38e8de6367fa8ced0c3b31eacfaa9566c72efcb 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -96,8 +96,9 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo,
return;
}
- // The text clip phase already has a LayoutObjectDrawingRecorder. Text clips are initiated only in BoxPainter::paintFillLayer,
- // which is already within a LayoutObjectDrawingRecorder.
+ // The text clip phase already has a LayoutObjectDrawingRecorder. Text clips
+ // are initiated only in BoxPainter::paintFillLayer, which is already within a
+ // LayoutObjectDrawingRecorder.
Optional<DrawingRecorder> drawingRecorder;
if (paintInfo.phase != PaintPhaseTextClip) {
if (DrawingRecorder::useCachedDrawingIfPossible(
@@ -188,8 +189,8 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo,
LayoutPoint textOrigin(boxOrigin.x(),
boxOrigin.y() + font.getFontMetrics().ascent());
- // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection
- // and composition highlights.
+ // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
+ // include selection and composition highlights.
if (paintInfo.phase != PaintPhaseSelection &&
paintInfo.phase != PaintPhaseTextClip && !isPrinting) {
paintDocumentMarkers(paintInfo, boxOrigin, styleToUse, font,
@@ -207,7 +208,8 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo,
}
}
- // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
+ // 2. Now paint the foreground, including text and decorations like
+ // underline/overline (in quirks mode only).
int selectionStart = 0;
int selectionEnd = 0;
if (paintSelectedTextOnly || paintSelectedTextSeparately)
@@ -244,8 +246,9 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo,
startOffset = selectionEnd;
endOffset = selectionStart;
}
- // Where the text and its flow have opposite directions then our offset into the text given by |truncation| is at
- // the start of the part that will be visible.
+ // Where the text and its flow have opposite directions then our offset into
+ // the text given by |truncation| is at the start of the part that will be
+ // visible.
if (m_inlineTextBox.truncation() != cNoTruncation &&
m_inlineTextBox.getLineLayoutItem()
.containingBlock()
@@ -402,12 +405,14 @@ void InlineTextBoxPainter::paintDocumentMarkers(
m_inlineTextBox.getLineLayoutItem().node());
DocumentMarkerVector::const_iterator markerIt = markers.begin();
- // Give any document markers that touch this run a chance to draw before the text has been drawn.
- // Note end() points at the last char, not one past it like endOffset and ranges do.
+ // Give any document markers that touch this run a chance to draw before the
+ // text has been drawn. Note end() points at the last char, not one past it
+ // like endOffset and ranges do.
for (; markerIt != markers.end(); ++markerIt) {
DocumentMarker* marker = *markerIt;
- // Paint either the background markers or the foreground markers, but not both
+ // Paint either the background markers or the foreground markers, but not
+ // both.
switch (marker->type()) {
case DocumentMarker::Grammar:
case DocumentMarker::Spelling:
@@ -422,8 +427,9 @@ void InlineTextBoxPainter::paintDocumentMarkers(
}
if (marker->endOffset() <= m_inlineTextBox.start()) {
- // marker is completely before this run. This might be a marker that sits before the
- // first run we draw, or markers that were within runs we skipped due to truncation.
+ // marker is completely before this run. This might be a marker that sits
+ // before the first run we draw, or markers that were within runs we
+ // skipped due to truncation.
continue;
}
if (marker->startOffset() > m_inlineTextBox.end()) {
@@ -537,12 +543,14 @@ void InlineTextBoxPainter::paintDocumentMarker(GraphicsContext& context,
width = LayoutUnit(markerRect.width());
}
- // IMPORTANT: The misspelling underline is not considered when calculating the text bounds, so we have to
- // make sure to fit within those bounds. This means the top pixel(s) of the underline will overlap the
- // bottom pixel(s) of the glyphs in smaller font sizes. The alternatives are to increase the line spacing (bad!!)
- // or decrease the underline thickness. The overlap is actually the most useful, and matches what AppKit does.
- // So, we generally place the underline at the bottom of the text, but in larger fonts that's not so good so
- // we pin to two pixels under the baseline.
+ // IMPORTANT: The misspelling underline is not considered when calculating the
+ // text bounds, so we have to make sure to fit within those bounds. This
+ // means the top pixel(s) of the underline will overlap the bottom pixel(s) of
+ // the glyphs in smaller font sizes. The alternatives are to increase the
+ // line spacing (bad!!) or decrease the underline thickness. The overlap is
+ // actually the most useful, and matches what AppKit does. So, we generally
+ // place the underline at the bottom of the text, but in larger fonts that's
+ // not so good so we pin to two pixels under the baseline.
int lineThickness = misspellingLineThickness;
int baseline = m_inlineTextBox.getLineLayoutItem()
.style(m_inlineTextBox.isFirstLineStyle())
@@ -554,7 +562,8 @@ void InlineTextBoxPainter::paintDocumentMarker(GraphicsContext& context,
// Place the underline at the very bottom of the text in small/medium fonts.
underlineOffset = (m_inlineTextBox.logicalHeight() - lineThickness).toInt();
} else {
- // In larger fonts, though, place the underline up near the baseline to prevent a big gap.
+ // In larger fonts, though, place the underline up near the baseline to
+ // prevent a big gap.
underlineOffset = baseline + 2;
}
context.drawLineForDocumentMarker(
@@ -580,8 +589,8 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context,
if (!c.alpha())
return;
- // If the text color ends up being the same as the selection background, invert the selection
- // background.
+ // If the text color ends up being the same as the selection background,
+ // invert the selection background.
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
@@ -615,7 +624,8 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context,
if (options == InlineTextBoxPainter::PaintOptions::CombinedText) {
ASSERT(combinedText);
- // We can't use the height of m_inlineTextBox because LayoutTextCombine's inlineTextBox is horizontal within vertical flow
+ // We can't use the height of m_inlineTextBox because LayoutTextCombine's
+ // inlineTextBox is horizontal within vertical flow
combinedText->transformToInlineCoordinates(context, boxRect, true);
context.drawHighlightForText(font, textRun, FloatPoint(boxRect.location()),
boxRect.height().toInt(), c, sPos, ePos);
@@ -636,7 +646,8 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context,
LayoutRect selectionRect = LayoutRect(
font.selectionRectForText(textRun, localOrigin, selHeight, sPos, ePos));
if (m_inlineTextBox.hasWrappedSelectionNewline()
- // For line breaks, just painting a selection where the line break itself is rendered is sufficient.
+ // For line breaks, just painting a selection where the line break itself
+ // is rendered is sufficient.
&& !m_inlineTextBox.isLineBreak())
expandToIncludeNewlineForSelection(selectionRect);
@@ -676,8 +687,8 @@ static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition,
// Underline position of zero means draw underline on Baseline Position,
// in Blink we need at least 1-pixel gap to adding following check.
// Positive underline Position means underline should be drawn above baselin e
- // and negative value means drawing below baseline, negating the value as in Blink
- // downward Y-increases.
+ // and negative value means drawing below baseline, negating the value as in
+ // Blink downward Y-increases.
if (fontMetrics.underlinePosition())
gap = -fontMetrics.underlinePosition();
@@ -690,7 +701,8 @@ static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition,
return fontMetrics.ascent() +
gap; // Position underline near the alphabetic baseline.
case TextUnderlinePositionUnder: {
- // Position underline relative to the under edge of the lowest element's content box.
+ // Position underline relative to the under edge of the lowest element's
+ // content box.
const LayoutUnit offset =
inlineTextBox->root().maxLogicalTop() - inlineTextBox->logicalTop();
if (offset > 0)
@@ -760,9 +772,9 @@ static void adjustStepToDecorationLength(float& step,
}
/*
- * Draw one cubic Bezier curve and repeat the same pattern long the the decoration's axis.
- * The start point (p1), controlPoint1, controlPoint2 and end point (p2) of the Bezier curve
- * form a diamond shape:
+ * Draw one cubic Bezier curve and repeat the same pattern long the the
+ * decoration's axis. The start point (p1), controlPoint1, controlPoint2 and
+ * end point (p2) of the Bezier curve form a diamond shape:
*
* step
* |-----------|
@@ -797,9 +809,10 @@ static void strokeWavyTextDecoration(GraphicsContext& context,
path.moveTo(p1);
// Distance between decoration's axis and Bezier curve's control points.
- // The height of the curve is based on this distance. Use a minimum of 6 pixels distance since
- // the actual curve passes approximately at half of that distance, that is 3 pixels.
- // The minimum height of the curve is also approximately 3 pixels. Increases the curve's height
+ // The height of the curve is based on this distance. Use a minimum of 6
+ // pixels distance since the actual curve passes approximately at half of that
+ // distance, that is 3 pixels. The minimum height of the curve is also
+ // approximately 3 pixels. Increases the curve's height
// as strockThickness increases to make the curve looks better.
float controlPointDistance = 3 * std::max<float>(2, strokeThickness);
@@ -942,10 +955,12 @@ void InlineTextBoxPainter::paintDecoration(const PaintInfo& paintInfo,
textBoxLayoutObject.styleRef(m_inlineTextBox.isFirstLineStyle());
float baseline = styleToUse.getFontMetrics().ascent();
- // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px.
- // Using computedFontSize should take care of zoom as well.
+ // Set the thick of the line to be 10% (or something else ?)of the computed
+ // font size and not less than 1px. Using computedFontSize should take care
+ // of zoom as well.
- // Update Underline thickness, in case we have Faulty Font Metrics calculating underline thickness by old method.
+ // Update Underline thickness, in case we have Faulty Font Metrics calculating
+ // underline thickness by old method.
float textDecorationThickness =
styleToUse.getFontMetrics().underlineThickness();
int fontHeightInt = (int)(styleToUse.getFontMetrics().floatHeight() + 0.5);
@@ -1026,16 +1041,17 @@ void InlineTextBoxPainter::paintCompositionUnderline(
paintFrom, paintLength, LayoutUnit(m_inlineTextBox.textPos() + start),
flowIsLTR ? LTR : RTL, m_inlineTextBox.isFirstLineStyle());
}
- // In RTL mode, start and width are computed from the right end of the text box:
- // starting at |logicalWidth| - |start| and continuing left by |width| to
- // |logicalWidth| - |start| - |width|. We will draw that line, but
- // backwards: |logicalWidth| - |start| - |width| to |logicalWidth| - |start|.
+ // In RTL mode, start and width are computed from the right end of the text
+ // box: starting at |logicalWidth| - |start| and continuing left by |width| to
+ // |logicalWidth| - |start| - |width|. We will draw that line, but backwards:
+ // |logicalWidth| - |start| - |width| to |logicalWidth| - |start|.
if (!flowIsLTR)
start = m_inlineTextBox.logicalWidth().toFloat() - width - start;
- // Thick marked text underlines are 2px thick as long as there is room for the 2px line under the baseline.
- // All other marked text underlines are 1px thick.
- // If there's not enough space the underline will touch or overlap characters.
+ // Thick marked text underlines are 2px thick as long as there is room for the
+ // 2px line under the baseline. All other marked text underlines are 1px
+ // thick. If there's not enough space the underline will touch or overlap
+ // characters.
int lineThickness = 1;
int baseline = m_inlineTextBox.getLineLayoutItem()
.style(m_inlineTextBox.isFirstLineStyle())
@@ -1044,8 +1060,10 @@ void InlineTextBoxPainter::paintCompositionUnderline(
if (underline.thick() && m_inlineTextBox.logicalHeight() - baseline >= 2)
lineThickness = 2;
- // We need to have some space between underlines of subsequent clauses, because some input methods do not use different underline styles for those.
- // We make each line shorter, which has a harmless side effect of shortening the first and last clauses, too.
+ // We need to have some space between underlines of subsequent clauses,
+ // because some input methods do not use different underline styles for those.
+ // We make each line shorter, which has a harmless side effect of shortening
+ // the first and last clauses, too.
start += 1;
width -= 2;
@@ -1068,7 +1086,8 @@ void InlineTextBoxPainter::paintTextMatchMarkerForeground(
if (!inlineLayoutObject().frame()->editor().markedTextMatchesAreHighlighted())
return;
- // TODO(ramya.v): Extract this into a helper function and share many copies of this code.
+ // TODO(ramya.v): Extract this into a helper function and share many copies of
+ // this code.
int sPos =
std::max(marker->startOffset() - m_inlineTextBox.start(), (unsigned)0);
int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(),

Powered by Google App Engine
This is Rietveld 408576698