Bug 1331322 - Allow tagging of pseudo-implementing native anonymous content with the pseudo type at creation time, and eliminate explicit style contexts in nsIAnonymousContentCreator::ContentInfo. r=bholley
MozReview-Commit-ID: LO0t92orjWZ
This commit is contained in:
@@ -325,27 +325,15 @@ nsresult
|
||||
nsNumberControlFrame::MakeAnonymousElement(Element** aResult,
|
||||
nsTArray<ContentInfo>& aElements,
|
||||
nsIAtom* aTagName,
|
||||
CSSPseudoElementType aPseudoType,
|
||||
nsStyleContext* aParentContext)
|
||||
CSSPseudoElementType aPseudoType)
|
||||
{
|
||||
// Get the NodeInfoManager and tag necessary to create the anonymous divs.
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
|
||||
RefPtr<Element> resultElement = doc->CreateHTMLElement(aTagName);
|
||||
resultElement->SetPseudoElementType(aPseudoType);
|
||||
|
||||
// If we legitimately fail this assertion and need to allow
|
||||
// non-pseudo-element anonymous children, then we'll need to add a branch
|
||||
// that calls ResolveStyleFor((*aResult)->AsElement(), aParentContext)") to
|
||||
// set newStyleContext.
|
||||
NS_ASSERTION(aPseudoType != CSSPseudoElementType::NotPseudo,
|
||||
"Expecting anonymous children to all be pseudo-elements");
|
||||
// Associate the pseudo-element with the anonymous child
|
||||
RefPtr<nsStyleContext> newStyleContext =
|
||||
PresContext()->StyleSet()->ResolvePseudoElementStyle(mContent->AsElement(),
|
||||
aPseudoType,
|
||||
aParentContext,
|
||||
resultElement);
|
||||
|
||||
if (!aElements.AppendElement(ContentInfo(resultElement, newStyleContext))) {
|
||||
if (!aElements.AppendElement(resultElement)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@@ -382,8 +370,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
rv = MakeAnonymousElement(getter_AddRefs(mOuterWrapper),
|
||||
aElements,
|
||||
nsGkAtoms::div,
|
||||
CSSPseudoElementType::mozNumberWrapper,
|
||||
mStyleContext);
|
||||
CSSPseudoElementType::mozNumberWrapper);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ContentInfo& outerWrapperCI = aElements.LastElement();
|
||||
@@ -392,8 +379,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
rv = MakeAnonymousElement(getter_AddRefs(mTextField),
|
||||
outerWrapperCI.mChildren,
|
||||
nsGkAtoms::input,
|
||||
CSSPseudoElementType::mozNumberText,
|
||||
outerWrapperCI.mStyleContext);
|
||||
CSSPseudoElementType::mozNumberText);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
|
||||
@@ -440,8 +426,7 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
|
||||
outerWrapperCI.mChildren,
|
||||
nsGkAtoms::div,
|
||||
CSSPseudoElementType::mozNumberSpinBox,
|
||||
outerWrapperCI.mStyleContext);
|
||||
CSSPseudoElementType::mozNumberSpinBox);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ContentInfo& spinBoxCI = outerWrapperCI.mChildren.LastElement();
|
||||
@@ -450,16 +435,14 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
rv = MakeAnonymousElement(getter_AddRefs(mSpinUp),
|
||||
spinBoxCI.mChildren,
|
||||
nsGkAtoms::div,
|
||||
CSSPseudoElementType::mozNumberSpinUp,
|
||||
spinBoxCI.mStyleContext);
|
||||
CSSPseudoElementType::mozNumberSpinUp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Create the ::-moz-number-spin-down pseudo-element:
|
||||
rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
|
||||
spinBoxCI.mChildren,
|
||||
nsGkAtoms::div,
|
||||
CSSPseudoElementType::mozNumberSpinDown,
|
||||
spinBoxCI.mStyleContext);
|
||||
CSSPseudoElementType::mozNumberSpinDown);
|
||||
|
||||
SyncDisabledState();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user