Bug 1449401 - Remove moz-math-anonymous ua-only pseudo. r=heycam

We do not expose it nor ever style it. Just use the parent style all the
time. This avoids problematic style resolution calls during reflow.

Differential Revision: https://phabricator.services.mozilla.com/D84358
This commit is contained in:
Emilio Cobos Álvarez 2020-07-21 22:35:46 +00:00
Родитель a33994587b
Коммит 5adefab54c
17 изменённых файлов: 32 добавлений и 218 удалений

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

@ -763,9 +763,6 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
return this._nodeIsTextfieldLike(node);
case ":-moz-focus-inner":
return this._nodeIsButtonLike(node);
case ":-moz-math-anonymous":
// This one should be internal, really.
return false;
case ":-moz-meter-bar":
return node.nodeName == "METER";
case ":-moz-progress-bar":

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

@ -23,7 +23,6 @@
":-moz-color-swatch",
":-moz-focus-inner",
":-moz-focus-outer",
":-moz-math-anonymous",
":-moz-meter-bar",
":-moz-placeholder",
":-moz-progress-bar",

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

@ -208,14 +208,6 @@ mtable[framespacing] > mtr > mtd {
padding: 0px;
}
/**************************************************************************/
/* This rule is used to give a ComputedStyle suitable for nsMathMLChars.
We don't actually style -moz-math-anonymous by default. */
/*
::-moz-math-anonymous {
}
*/
/**********************************************************************/
/* This is used when wrapping non-MathML inline elements inside math. */
*|*::-moz-mathml-anonymous-block {

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

@ -1806,41 +1806,17 @@ void nsDisplayMathMLCharDebug::Paint(nsDisplayListBuilder* aBuilder,
void nsMathMLChar::Display(nsDisplayListBuilder* aBuilder, nsIFrame* aForFrame,
const nsDisplayListSet& aLists, uint32_t aIndex,
const nsRect* aSelectedRect) {
bool usingParentStyle = false;
ComputedStyle* computedStyle = mComputedStyle;
if (mDraw == DRAW_NORMAL) {
// normal drawing if there is nothing special about this char
// Use our parent element's style
usingParentStyle = true;
computedStyle = aForFrame->Style();
}
if (!computedStyle->StyleVisibility()->IsVisible()) {
return;
}
const bool isSelected = aSelectedRect && !aSelectedRect->IsEmpty();
// if the leaf computed style that we use for stretchy chars has a background
// color we use it -- this feature is mostly used for testing and debugging
// purposes. Normally, users will set the background on the container frame.
// paint the selection background -- beware MathML frames overlap a lot
if (isSelected) {
aLists.BorderBackground()->AppendNewToTop<nsDisplayMathMLSelectionRect>(
aBuilder, aForFrame, *aSelectedRect);
} else if (mRect.width && mRect.height) {
if (!usingParentStyle &&
NS_GET_A(computedStyle->StyleBackground()->BackgroundColor(
computedStyle)) > 0) {
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, aForFrame, mRect + aBuilder->ToReferenceFrame(aForFrame),
aLists.BorderBackground(),
/* aAllowWillPaintBorderOptimization */ true, computedStyle);
}
// else
// our container frame will take care of painting its background
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
// for visual debug
aLists.BorderBackground()->AppendNewToTop<nsDisplayMathMLCharDebug>(

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

@ -86,23 +86,6 @@ nsMathMLFrame::UpdatePresentationData(uint32_t aFlagsValues,
return NS_OK;
}
// Helper to give a ComputedStyle suitable for doing the stretching of
// a MathMLChar. Frame classes that use this should ensure that the
// extra leaf ComputedStyle given to the MathMLChars are accessible to
// the Style System via the Get/Set AdditionalComputedStyle() APIs.
/* static */
void nsMathMLFrame::ResolveMathMLCharStyle(nsPresContext* aPresContext,
nsIContent* aContent,
ComputedStyle* aParentComputedStyle,
nsMathMLChar* aMathMLChar) {
PseudoStyleType pseudoType = PseudoStyleType::mozMathAnonymous; // savings
RefPtr<ComputedStyle> newComputedStyle;
newComputedStyle = aPresContext->StyleSet()->ResolvePseudoElementStyle(
*aContent->AsElement(), pseudoType, aParentComputedStyle);
aMathMLChar->SetComputedStyle(newComputedStyle);
}
/* static */
void nsMathMLFrame::GetEmbellishDataFrom(nsIFrame* aFrame,
nsEmbellishData& aEmbellishData) {

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

@ -90,13 +90,6 @@ class nsMathMLFrame : public nsIMathMLFrame {
bool IsMrowLike() override { return false; }
// helper to give a ComputedStyle suitable for doing the stretching to the
// MathMLChar. Frame classes that use this should make the extra ComputedStyle
// accessible to the Style System via Get/Set AdditionalmComputedStyle.
static void ResolveMathMLCharStyle(
nsPresContext* aPresContext, nsIContent* aContent,
mozilla::ComputedStyle* aParenComputedStyle, nsMathMLChar* aMathMLChar);
// helper to get the mEmbellishData of a frame
// The MathML REC precisely defines an "embellished operator" as:
// - an <mo> element;

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

@ -85,10 +85,8 @@ nsresult nsMathMLmencloseFrame::AllocateMathMLChar(nsMencloseNotation mask) {
mRadicalCharIndex = i;
}
nsPresContext* presContext = PresContext();
mMathMLChar[i].SetData(Char);
ResolveMathMLCharStyle(presContext, mContent, mComputedStyle,
&mMathMLChar[i]);
mMathMLChar[i].SetComputedStyle(Style());
return NS_OK;
}
@ -694,24 +692,14 @@ nsresult nsMathMLmencloseFrame::AttributeChanged(int32_t aNameSpaceID,
aModType);
}
//////////////////
// the Style System will use these to pass the proper ComputedStyle to our
// MathMLChar
ComputedStyle* nsMathMLmencloseFrame::GetAdditionalComputedStyle(
int32_t aIndex) const {
int32_t len = mMathMLChar.Length();
if (aIndex >= 0 && aIndex < len)
return mMathMLChar[aIndex].GetComputedStyle();
else
return nullptr;
void nsMathMLmencloseFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
nsMathMLContainerFrame::DidSetComputedStyle(aOldStyle);
for (auto& ch : mMathMLChar) {
ch.SetComputedStyle(Style());
}
}
void nsMathMLmencloseFrame::SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) {
int32_t len = mMathMLChar.Length();
if (aIndex >= 0 && aIndex < len)
mMathMLChar[aIndex].SetComputedStyle(aComputedStyle);
}
//////////////////
class nsDisplayNotation final : public nsPaintedDisplayItem {
public:

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

@ -63,10 +63,7 @@ class nsMathMLmencloseFrame : public nsMathMLContainerFrame {
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
int32_t aModType) override;
virtual void SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) override;
virtual ComputedStyle* GetAdditionalComputedStyle(
int32_t aIndex) const override;
void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;

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

@ -105,7 +105,7 @@ void nsMathMLmfencedFrame::CreateFencesAndSeparators(
if (!value.IsEmpty()) {
mOpenChar = new nsMathMLChar;
mOpenChar->SetData(value);
ResolveMathMLCharStyle(aPresContext, mContent, mComputedStyle, mOpenChar);
mOpenChar->SetComputedStyle(Style());
}
//////////////
@ -120,7 +120,7 @@ void nsMathMLmfencedFrame::CreateFencesAndSeparators(
if (!value.IsEmpty()) {
mCloseChar = new nsMathMLChar;
mCloseChar->SetData(value);
ResolveMathMLCharStyle(aPresContext, mContent, mComputedStyle, mCloseChar);
mCloseChar->SetComputedStyle(Style());
}
//////////////
@ -145,8 +145,7 @@ void nsMathMLmfencedFrame::CreateFencesAndSeparators(
sepChar = value[mSeparatorsCount - 1];
}
mSeparatorsChar[i].SetData(sepChar);
ResolveMathMLCharStyle(aPresContext, mContent, mComputedStyle,
&mSeparatorsChar[i]);
mSeparatorsChar[i].SetComputedStyle(Style());
}
mSeparatorsCount = sepCount;
} else {
@ -630,60 +629,16 @@ nscoord nsMathMLmfencedFrame::FixInterFrameSpacing(ReflowOutput& aDesiredSize) {
return gap;
}
// ----------------------
// the Style System will use these to pass the proper ComputedStyle to our
// MathMLChar
ComputedStyle* nsMathMLmfencedFrame::GetAdditionalComputedStyle(
int32_t aIndex) const {
int32_t openIndex = -1;
int32_t closeIndex = -1;
int32_t lastIndex = mSeparatorsCount - 1;
void nsMathMLmfencedFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
nsMathMLContainerFrame::DidSetComputedStyle(aOldStyle);
if (mOpenChar) {
lastIndex++;
openIndex = lastIndex;
mOpenChar->SetComputedStyle(Style());
}
if (mCloseChar) {
lastIndex++;
closeIndex = lastIndex;
mCloseChar->SetComputedStyle(Style());
}
if (aIndex < 0 || aIndex > lastIndex) {
return nullptr;
}
if (aIndex < mSeparatorsCount) {
return mSeparatorsChar[aIndex].GetComputedStyle();
} else if (aIndex == openIndex) {
return mOpenChar->GetComputedStyle();
} else if (aIndex == closeIndex) {
return mCloseChar->GetComputedStyle();
}
return nullptr;
}
void nsMathMLmfencedFrame::SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) {
int32_t openIndex = -1;
int32_t closeIndex = -1;
int32_t lastIndex = mSeparatorsCount - 1;
if (mOpenChar) {
lastIndex++;
openIndex = lastIndex;
}
if (mCloseChar) {
lastIndex++;
closeIndex = lastIndex;
}
if (aIndex < 0 || aIndex > lastIndex) {
return;
}
if (aIndex < mSeparatorsCount) {
mSeparatorsChar[aIndex].SetComputedStyle(aComputedStyle);
} else if (aIndex == openIndex) {
mOpenChar->SetComputedStyle(aComputedStyle);
} else if (aIndex == closeIndex) {
mCloseChar->SetComputedStyle(aComputedStyle);
for (int32_t i = 0; i < mSeparatorsCount; ++i) {
mSeparatorsChar[i].SetComputedStyle(Style());
}
}

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

@ -30,10 +30,7 @@ class nsMathMLmfencedFrame final : public nsMathMLContainerFrame {
void DestroyFrom(nsIFrame* aDestructRoot,
PostDestroyData& aPostDestroyData) override;
virtual void SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) override;
virtual ComputedStyle* GetAdditionalComputedStyle(
int32_t aIndex) const override;
void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
NS_IMETHOD
InheritAutomaticData(nsIFrame* aParent) override;

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

@ -19,9 +19,6 @@ using namespace mozilla;
// <mo> -- operator, fence, or separator - implementation
//
// additional ComputedStyle to be used by our MathMLChar.
#define NS_MATHML_CHAR_STYLE_CONTEXT_INDEX 0
nsIFrame* NS_NewMathMLmoFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
return new (aPresShell) nsMathMLmoFrame(aStyle, aPresShell->GetPresContext());
}
@ -109,11 +106,10 @@ void nsMathMLmoFrame::ProcessTextData() {
}
// don't bother doing anything special if we don't have a single child
nsPresContext* presContext = PresContext();
if (mFrames.GetLength() != 1) {
data.Truncate(); // empty data to reset the char
mMathMLChar.SetData(data);
ResolveMathMLCharStyle(presContext, mContent, mComputedStyle, &mMathMLChar);
mMathMLChar.SetComputedStyle(Style());
return;
}
@ -168,7 +164,7 @@ void nsMathMLmoFrame::ProcessTextData() {
(mEmbellishData.direction != NS_STRETCH_DIRECTION_UNSUPPORTED);
if (isMutable) mFlags |= NS_MATHML_OPERATOR_MUTABLE;
ResolveMathMLCharStyle(presContext, mContent, mComputedStyle, &mMathMLChar);
mMathMLChar.SetComputedStyle(Style());
}
// get our 'form' and lookup in the Operator Dictionary to fetch
@ -1052,25 +1048,7 @@ nsresult nsMathMLmoFrame::AttributeChanged(int32_t aNameSpaceID,
aModType);
}
// ----------------------
// No need to track the ComputedStyle given to our MathML char.
// the Style System will use these to pass the proper ComputedStyle to our
// MathMLChar
ComputedStyle* nsMathMLmoFrame::GetAdditionalComputedStyle(
int32_t aIndex) const {
switch (aIndex) {
case NS_MATHML_CHAR_STYLE_CONTEXT_INDEX:
return mMathMLChar.GetComputedStyle();
default:
return nullptr;
}
}
void nsMathMLmoFrame::SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) {
switch (aIndex) {
case NS_MATHML_CHAR_STYLE_CONTEXT_INDEX:
mMathMLChar.SetComputedStyle(aComputedStyle);
break;
}
void nsMathMLmoFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
nsMathMLTokenFrame::DidSetComputedStyle(aOldStyle);
mMathMLChar.SetComputedStyle(Style());
}

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

@ -26,15 +26,12 @@ class nsMathMLmoFrame final : public nsMathMLTokenFrame {
friend nsIFrame* NS_NewMathMLmoFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle);
virtual eMathMLFrameType GetMathMLFrameType() override;
eMathMLFrameType GetMathMLFrameType() override;
virtual void SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) override;
virtual ComputedStyle* GetAdditionalComputedStyle(
int32_t aIndex) const override;
void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
NS_IMETHOD
InheritAutomaticData(nsIFrame* aParent) override;

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

@ -18,9 +18,6 @@ using namespace mozilla;
// <mroot> -- form a radical - implementation
//
// additional ComputedStyle to be used by our MathMLChar.
#define NS_SQR_CHAR_STYLE_CONTEXT_INDEX 0
static const char16_t kSqrChar = char16_t(0x221A);
nsIFrame* NS_NewMathMLmrootFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
@ -42,15 +39,10 @@ void nsMathMLmrootFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) {
nsMathMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
nsPresContext* presContext = PresContext();
// No need to track the ComputedStyle given to our MathML char.
// The Style System will use Get/SetAdditionalComputedStyle() to keep it
// up-to-date if dynamic changes arise.
nsAutoString sqrChar;
sqrChar.Assign(kSqrChar);
mSqrChar.SetData(sqrChar);
ResolveMathMLCharStyle(presContext, mContent, mComputedStyle, &mSqrChar);
mSqrChar.SetComputedStyle(Style());
}
NS_IMETHODIMP
@ -373,24 +365,7 @@ void nsMathMLmrootFrame::GetIntrinsicISizeMetrics(gfxContext* aRenderingContext,
aDesiredSize.mBoundingMetrics.rightBearing = width;
}
// ----------------------
// the Style System will use these to pass the proper ComputedStyle to our
// MathMLChar
ComputedStyle* nsMathMLmrootFrame::GetAdditionalComputedStyle(
int32_t aIndex) const {
switch (aIndex) {
case NS_SQR_CHAR_STYLE_CONTEXT_INDEX:
return mSqrChar.GetComputedStyle();
default:
return nullptr;
}
}
void nsMathMLmrootFrame::SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) {
switch (aIndex) {
case NS_SQR_CHAR_STYLE_CONTEXT_INDEX:
mSqrChar.SetComputedStyle(aComputedStyle);
break;
}
void nsMathMLmrootFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
nsMathMLContainerFrame::DidSetComputedStyle(aOldStyle);
mSqrChar.SetComputedStyle(Style());
}

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

@ -26,10 +26,7 @@ class nsMathMLmrootFrame final : public nsMathMLContainerFrame {
friend nsIFrame* NS_NewMathMLmrootFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle);
virtual void SetAdditionalComputedStyle(
int32_t aIndex, ComputedStyle* aComputedStyle) override;
virtual ComputedStyle* GetAdditionalComputedStyle(
int32_t aIndex) const override;
void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) override;

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

@ -55,14 +55,6 @@ CSS_PSEUDO_ELEMENT(selection, ":selection",
CSS_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner", 0)
CSS_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer", 0)
// FIXME(emilio): It's unclear why this needs to exist at all, we don't ever
// style them.
//
// This is a pseudo instead of an anon box because of how the
// AdditionalComputedStyle APIs work.
CSS_PSEUDO_ELEMENT(mozMathAnonymous, ":-moz-math-anonymous",
CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS)
// HTML5 Forms pseudo elements
CSS_PSEUDO_ELEMENT(mozNumberWrapper, ":-moz-number-wrapper",
CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE |

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

@ -9,7 +9,6 @@ const NON_CONTENT_ACCESIBLE_PSEUDOS = [
"::-moz-number-spin-down",
"::-moz-number-spin-box",
"::-moz-number-text",
"::-moz-math-anonymous",
":-moz-native-anonymous",
":-moz-use-shadow-tree-root",

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

@ -2463,7 +2463,6 @@ STATIC_ATOMS = [
PseudoElementAtom("PseudoElement_selection", ":selection"),
PseudoElementAtom("PseudoElement_mozFocusInner", ":-moz-focus-inner"),
PseudoElementAtom("PseudoElement_mozFocusOuter", ":-moz-focus-outer"),
PseudoElementAtom("PseudoElement_mozMathAnonymous", ":-moz-math-anonymous"),
PseudoElementAtom("PseudoElement_mozNumberWrapper", ":-moz-number-wrapper"),
PseudoElementAtom("PseudoElement_mozNumberSpinBox", ":-moz-number-spin-box"),
PseudoElementAtom("PseudoElement_mozNumberSpinUp", ":-moz-number-spin-up"),