Bug 1399564 - properly thread through selection-specific decorations to WR. r?jrmuizel
MozReview-Commit-ID: 7prde0BsOFL
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -6103,48 +6103,56 @@ nsTextFrame::PaintDecorationLine(const P
}
/**
* This, plus kSelectionTypesWithDecorations, encapsulates all knowledge
* about drawing text decoration for selections.
*/
void
nsTextFrame::DrawSelectionDecorations(gfxContext* aContext,
+ TextDrawTarget* aTextDrawer,
const LayoutDeviceRect& aDirtyRect,
SelectionType aSelectionType,
nsTextPaintStyle& aTextPaintStyle,
const TextRangeStyle &aRangeStyle,
const Point& aPt,
gfxFloat aICoordInFrame,
gfxFloat aWidth,
gfxFloat aAscent,
const gfxFont::Metrics& aFontMetrics,
DrawPathCallbacks* aCallbacks,
bool aVertical,
gfxFloat aDecorationOffsetDir,
uint8_t aDecoration)
{
PaintDecorationLineParams params;
params.context = aContext;
+ params.textDrawer = aTextDrawer;
params.dirtyRect = aDirtyRect;
params.pt = aPt;
params.lineSize.width = aWidth;
params.ascent = aAscent;
params.offset = aDecoration == NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE ?
aFontMetrics.underlineOffset : aFontMetrics.maxAscent;
params.decoration = aDecoration;
params.decorationType = DecorationType::Selection;
params.callbacks = aCallbacks;
params.vertical = aVertical;
params.descentLimit =
ComputeDescentLimitForSelectionUnderline(aTextPaintStyle.PresContext(),
aFontMetrics);
float relativeSize;
+ // Since this happens after text, all we *should* be allowed to do is strikeThrough.
+ // If this isn't true, we're at least bug-compatible with gecko!
+ if (aTextDrawer) {
+ aTextDrawer->StartDrawing(TextDrawTarget::Phase::eLineThrough);
+ }
+
switch (aSelectionType) {
case SelectionType::eIMERawClause:
case SelectionType::eIMESelectedRawClause:
case SelectionType::eIMEConvertedClause:
case SelectionType::eIMESelectedClause:
case SelectionType::eSpellCheck: {
int32_t index = nsTextPaintStyle::
GetUnderlineStyleIndexForSelectionType(aSelectionType);
@@ -6803,17 +6811,17 @@ nsTextFrame::PaintTextSelectionDecoratio
(mTextRun->IsInlineReversed() ? advance : 0)) / app;
} else {
pt.x = (aParams.framePt.x + iOffset -
(mTextRun->IsInlineReversed() ? advance : 0)) / app;
}
gfxFloat width = Abs(advance) / app;
gfxFloat xInFrame = pt.x - (aParams.framePt.x / app);
DrawSelectionDecorations(
- aParams.context, aParams.dirtyRect, aSelectionType,
+ aParams.context, aParams.textDrawer, aParams.dirtyRect, aSelectionType,
*aParams.textPaintStyle, selectedStyle, pt, xInFrame,
width, mAscent / app, decorationMetrics, aParams.callbacks,
verticalRun, decorationOffsetDir, kDecoration);
}
iterator.UpdateWithAdvance(advance);
}
}
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -823,16 +823,17 @@ protected:
// If the result rect is larger than the given rect, this returns true.
bool CombineSelectionUnderlineRect(nsPresContext* aPresContext,
nsRect& aRect);
/**
* Utility methods to paint selection.
*/
void DrawSelectionDecorations(gfxContext* aContext,
+ TextDrawTarget* aTextDrawer,
const LayoutDeviceRect& aDirtyRect,
mozilla::SelectionType aSelectionType,
nsTextPaintStyle& aTextPaintStyle,
const TextRangeStyle& aRangeStyle,
const Point& aPt,
gfxFloat aICoordInFrame,
gfxFloat aWidth,
gfxFloat aAscent,