зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1287705 - Part 2. Add more comments and construct PaintState in PaintTextParams. r=jfkthame
MozReview-Commit-ID: EzfOzRUU6PQ --HG-- extra : rebase_source : 1a7b96239b0d90f4e58be358629a7e3987b674ba
This commit is contained in:
Родитель
7128f1272f
Коммит
77db71816d
|
@ -4802,8 +4802,16 @@ nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
nsTextFrame::PaintTextParams params(aCtx->ThebesContext());
|
nsTextFrame::PaintTextParams params(aCtx->ThebesContext());
|
||||||
params.framePt = gfxPoint(framePt.x, framePt.y);
|
params.framePt = gfxPoint(framePt.x, framePt.y);
|
||||||
params.dirtyRect = extraVisible;
|
params.dirtyRect = extraVisible;
|
||||||
params.generateTextMask = aBuilder->IsForGenerateGlyphMask();
|
|
||||||
params.paintSelectionBackground = aBuilder->IsForPaintingSelectionBG();
|
if (aBuilder->IsForGenerateGlyphMask()) {
|
||||||
|
MOZ_ASSERT(!aBuilder->IsForPaintingSelectionBG());
|
||||||
|
params.state = nsTextFrame::PaintTextParams::GenerateTextMask;
|
||||||
|
} else if (aBuilder->IsForPaintingSelectionBG()) {
|
||||||
|
params.state = nsTextFrame::PaintTextParams::PaintTextBGColor;
|
||||||
|
} else {
|
||||||
|
params.state = nsTextFrame::PaintTextParams::PaintText;
|
||||||
|
}
|
||||||
|
|
||||||
f->PaintText(params, *this, mOpacity);
|
f->PaintText(params, *this, mOpacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6003,8 +6011,7 @@ nsTextFrame::PaintTextWithSelectionColors(
|
||||||
Range range; // in transformed string
|
Range range; // in transformed string
|
||||||
TextRangeStyle rangeStyle;
|
TextRangeStyle rangeStyle;
|
||||||
// Draw background colors
|
// Draw background colors
|
||||||
if (anyBackgrounds && (!aParams.generateTextMask ||
|
if (anyBackgrounds && !aParams.IsGenerateTextMask()) {
|
||||||
aParams.paintSelectionBackground)) {
|
|
||||||
int32_t appUnitsPerDevPixel =
|
int32_t appUnitsPerDevPixel =
|
||||||
aParams.textPaintStyle->PresContext()->AppUnitsPerDevPixel();
|
aParams.textPaintStyle->PresContext()->AppUnitsPerDevPixel();
|
||||||
SelectionIterator iterator(prevailingSelections, contentRange,
|
SelectionIterator iterator(prevailingSelections, contentRange,
|
||||||
|
@ -6037,7 +6044,7 @@ nsTextFrame::PaintTextWithSelectionColors(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aParams.paintSelectionBackground) {
|
if (aParams.IsPaintBGColor()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6063,7 +6070,7 @@ nsTextFrame::PaintTextWithSelectionColors(
|
||||||
while (iterator.GetNextSegment(&iOffset, &range, &hyphenWidth,
|
while (iterator.GetNextSegment(&iOffset, &range, &hyphenWidth,
|
||||||
&selectionType, &rangeStyle)) {
|
&selectionType, &rangeStyle)) {
|
||||||
nscolor foreground, background;
|
nscolor foreground, background;
|
||||||
if (aParams.generateTextMask) {
|
if (aParams.IsGenerateTextMask()) {
|
||||||
foreground = NS_RGBA(0, 0, 0, 255);
|
foreground = NS_RGBA(0, 0, 0, 255);
|
||||||
} else {
|
} else {
|
||||||
GetSelectionTextColors(selectionType, *aParams.textPaintStyle,
|
GetSelectionTextColors(selectionType, *aParams.textPaintStyle,
|
||||||
|
@ -6596,8 +6603,7 @@ nsTextFrame::PaintText(const PaintTextParams& aParams,
|
||||||
|
|
||||||
// Fork off to the (slower) paint-with-selection path if necessary.
|
// Fork off to the (slower) paint-with-selection path if necessary.
|
||||||
if (aItem.mIsFrameSelected.value() &&
|
if (aItem.mIsFrameSelected.value() &&
|
||||||
(aParams.paintSelectionBackground ||
|
(aParams.IsPaintBGColor() || ShouldDrawSelection(this->GetParent()))) {
|
||||||
ShouldDrawSelection(this->GetParent()))) {
|
|
||||||
MOZ_ASSERT(aOpacity == 1.0f, "We don't support opacity with selections!");
|
MOZ_ASSERT(aOpacity == 1.0f, "We don't support opacity with selections!");
|
||||||
gfxSkipCharsIterator tmp(provider.GetStart());
|
gfxSkipCharsIterator tmp(provider.GetStart());
|
||||||
Range contentRange(
|
Range contentRange(
|
||||||
|
@ -6613,11 +6619,11 @@ nsTextFrame::PaintText(const PaintTextParams& aParams,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aParams.paintSelectionBackground) {
|
if (aParams.IsPaintBGColor()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nscolor foregroundColor = aParams.generateTextMask
|
nscolor foregroundColor = aParams.IsGenerateTextMask()
|
||||||
? NS_RGBA(0, 0, 0, 255)
|
? NS_RGBA(0, 0, 0, 255)
|
||||||
: textPaintStyle.GetTextColor();
|
: textPaintStyle.GetTextColor();
|
||||||
if (aOpacity != 1.0f) {
|
if (aOpacity != 1.0f) {
|
||||||
|
@ -6626,7 +6632,7 @@ nsTextFrame::PaintText(const PaintTextParams& aParams,
|
||||||
foregroundColor = gfxColor.ToABGR();
|
foregroundColor = gfxColor.ToABGR();
|
||||||
}
|
}
|
||||||
|
|
||||||
nscolor textStrokeColor = aParams.generateTextMask
|
nscolor textStrokeColor = aParams.IsGenerateTextMask()
|
||||||
? NS_RGBA(0, 0, 0, 255)
|
? NS_RGBA(0, 0, 0, 255)
|
||||||
: textPaintStyle.GetWebkitTextStrokeColor();
|
: textPaintStyle.GetWebkitTextStrokeColor();
|
||||||
if (aOpacity != 1.0f) {
|
if (aOpacity != 1.0f) {
|
||||||
|
@ -6636,7 +6642,7 @@ nsTextFrame::PaintText(const PaintTextParams& aParams,
|
||||||
}
|
}
|
||||||
|
|
||||||
range = Range(startOffset, startOffset + maxLength);
|
range = Range(startOffset, startOffset + maxLength);
|
||||||
if (!aParams.callbacks && !aParams.generateTextMask) {
|
if (!aParams.callbacks && aParams.IsPaintText()) {
|
||||||
const nsStyleText* textStyle = StyleText();
|
const nsStyleText* textStyle = StyleText();
|
||||||
PaintShadowParams shadowParams(aParams);
|
PaintShadowParams shadowParams(aParams);
|
||||||
shadowParams.range = range;
|
shadowParams.range = range;
|
||||||
|
|
|
@ -395,9 +395,21 @@ public:
|
||||||
LayoutDeviceRect dirtyRect;
|
LayoutDeviceRect dirtyRect;
|
||||||
gfxTextContextPaint* contextPaint = nullptr;
|
gfxTextContextPaint* contextPaint = nullptr;
|
||||||
DrawPathCallbacks* callbacks = nullptr;
|
DrawPathCallbacks* callbacks = nullptr;
|
||||||
bool generateTextMask = false;
|
enum {
|
||||||
bool paintSelectionBackground = false;
|
PaintText, // Normal text painting.
|
||||||
|
PaintTextBGColor, // Only paint background color of the selected text
|
||||||
|
// range in this state.
|
||||||
|
GenerateTextMask // To generate a mask from a text frame. Should
|
||||||
|
// only paint text itself with opaque color.
|
||||||
|
// Text shadow, text selection color and text
|
||||||
|
// decoration are all discarded in this state.
|
||||||
|
};
|
||||||
|
uint8_t state = PaintText;
|
||||||
explicit PaintTextParams(gfxContext* aContext) : context(aContext) {}
|
explicit PaintTextParams(gfxContext* aContext) : context(aContext) {}
|
||||||
|
|
||||||
|
bool IsPaintText() const { return state == PaintText; }
|
||||||
|
bool IsGenerateTextMask() const { return state == GenerateTextMask; }
|
||||||
|
bool IsPaintBGColor() const { return state == PaintTextBGColor; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PaintTextSelectionParams : PaintTextParams
|
struct PaintTextSelectionParams : PaintTextParams
|
||||||
|
|
Загрузка…
Ссылка в новой задаче