Bug 1504924 - Avoid nsIFrame::IsSelected() call in nsDisplayText::CanApplyOpacity() r=mats

Differential Revision: https://phabricator.services.mozilla.com/D12750

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Miko Mynttinen 2018-11-26 16:06:00 +00:00
Родитель a59d3605be
Коммит da20c7650e
2 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -4986,11 +4986,11 @@ public:
bool CanApplyOpacity() const final
{
nsTextFrame* f = static_cast<nsTextFrame*>(mFrame);
if (f->IsSelected()) {
if (IsSelected()) {
return false;
}
nsTextFrame* f = static_cast<nsTextFrame*>(mFrame);
const nsStyleText* textStyle = f->StyleText();
if (textStyle->mTextShadow) {
return false;
@ -6983,12 +6983,12 @@ nsTextFrame::PaintText(const PaintTextParams& aParams,
return;
PropertyProvider provider(this, iter, nsTextFrame::eInflated);
if (aItem.mIsFrameSelected.isNothing()) {
aItem.mIsFrameSelected.emplace(IsSelected());
}
const bool isSelected = aItem.IsSelected();
// Trim trailing whitespace, unless we're painting a selection highlight,
// which should include trailing spaces if present (bug 1146754).
provider.InitializeForDisplay(!aItem.mIsFrameSelected.value());
provider.InitializeForDisplay(!isSelected);
const bool reversed = mTextRun->IsInlineReversed();
const bool verticalRun = mTextRun->IsVertical();
@ -7032,7 +7032,7 @@ nsTextFrame::PaintText(const PaintTextParams& aParams,
textPaintStyle.SetResolveColors(!aParams.callbacks);
// Fork off to the (slower) paint-with-selection path if necessary.
if (aItem.mIsFrameSelected.value() &&
if (isSelected &&
(aParams.IsPaintBGColor() || ShouldDrawSelection(this->GetParent()))) {
MOZ_ASSERT(aOpacity == 1.0f, "We don't support opacity with selections!");
gfxSkipCharsIterator tmp(provider.GetStart());

Просмотреть файл

@ -7767,6 +7767,15 @@ public:
: nullptr;
}
bool IsSelected() const
{
if (mIsFrameSelected.isNothing()) {
mIsFrameSelected.emplace(mFrame->IsSelected());
}
return mIsFrameSelected.value();
}
// Lengths measured from the visual inline start and end sides
// (i.e. left and right respectively in horizontal writing modes,
// regardless of bidi directionality; top and bottom in vertical modes).