diff options
Diffstat (limited to 'layout/forms')
-rw-r--r-- | layout/forms/nsColorControlFrame.cpp | 7 | ||||
-rw-r--r-- | layout/forms/nsMeterFrame.cpp | 9 | ||||
-rw-r--r-- | layout/forms/nsNumberControlFrame.cpp | 33 | ||||
-rw-r--r-- | layout/forms/nsNumberControlFrame.h | 3 | ||||
-rw-r--r-- | layout/forms/nsProgressFrame.cpp | 7 | ||||
-rw-r--r-- | layout/forms/nsRangeFrame.cpp | 8 | ||||
-rw-r--r-- | layout/forms/nsTextControlFrame.cpp | 26 |
7 files changed, 20 insertions, 73 deletions
diff --git a/layout/forms/nsColorControlFrame.cpp b/layout/forms/nsColorControlFrame.cpp index e0bae43a98..63aee814aa 100644 --- a/layout/forms/nsColorControlFrame.cpp +++ b/layout/forms/nsColorControlFrame.cpp @@ -67,6 +67,7 @@ nsColorControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements) { nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc(); mColorContent = doc->CreateHTMLElement(nsGkAtoms::div); + mColorContent->SetPseudoElementType(CSSPseudoElementType::mozColorSwatch); // Mark the element to be native anonymous before setting any attributes. mColorContent->SetIsNativeAnonymousRoot(); @@ -74,11 +75,7 @@ nsColorControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements) nsresult rv = UpdateColor(); NS_ENSURE_SUCCESS(rv, rv); - CSSPseudoElementType pseudoType = CSSPseudoElementType::mozColorSwatch; - RefPtr<nsStyleContext> newStyleContext = PresContext()->StyleSet()-> - ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, - StyleContext(), mColorContent->AsElement()); - if (!aElements.AppendElement(ContentInfo(mColorContent, newStyleContext))) { + if (!aElements.AppendElement(mColorContent)) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index 1f3bd8022a..6ef362820f 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -75,14 +75,9 @@ nsMeterFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements) mBarDiv = doc->CreateHTMLElement(nsGkAtoms::div); // Associate ::-moz-meter-bar pseudo-element to the anonymous child. - CSSPseudoElementType pseudoType = CSSPseudoElementType::mozMeterBar; - RefPtr<nsStyleContext> newStyleContext = PresContext()->StyleSet()-> - ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, - StyleContext(), mBarDiv->AsElement()); + mBarDiv->SetPseudoElementType(CSSPseudoElementType::mozMeterBar); - if (!aElements.AppendElement(ContentInfo(mBarDiv, newStyleContext))) { - return NS_ERROR_OUT_OF_MEMORY; - } + aElements.AppendElement(mBarDiv); return NS_OK; } diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index 9724109cb1..64e3df0fe3 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -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, @@ -442,8 +428,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(); @@ -452,16 +437,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); return rv; } diff --git a/layout/forms/nsNumberControlFrame.h b/layout/forms/nsNumberControlFrame.h index 47e32ad65a..5396e71703 100644 --- a/layout/forms/nsNumberControlFrame.h +++ b/layout/forms/nsNumberControlFrame.h @@ -170,8 +170,7 @@ private: nsresult MakeAnonymousElement(Element** aResult, nsTArray<ContentInfo>& aElements, nsIAtom* aTagName, - CSSPseudoElementType aPseudoType, - nsStyleContext* aParentContext); + CSSPseudoElementType aPseudoType); class SyncDisabledStateEvent; friend class SyncDisabledStateEvent; diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index 2445defd35..6d6db7a1fd 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -72,12 +72,9 @@ nsProgressFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements) mBarDiv = doc->CreateHTMLElement(nsGkAtoms::div); // Associate ::-moz-progress-bar pseudo-element to the anonymous child. - CSSPseudoElementType pseudoType = CSSPseudoElementType::mozProgressBar; - RefPtr<nsStyleContext> newStyleContext = PresContext()->StyleSet()-> - ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, - StyleContext(), mBarDiv->AsElement()); + mBarDiv->SetPseudoElementType(CSSPseudoElementType::mozProgressBar); - if (!aElements.AppendElement(ContentInfo(mBarDiv, newStyleContext))) { + if (!aElements.AppendElement(mBarDiv)) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index 7590da066e..99faa6043b 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -119,13 +119,9 @@ nsRangeFrame::MakeAnonymousDiv(Element** aResult, RefPtr<Element> resultElement = doc->CreateHTMLElement(nsGkAtoms::div); // Associate the pseudo-element with the anonymous child. - RefPtr<nsStyleContext> newStyleContext = - PresContext()->StyleSet()->ResolvePseudoElementStyle(mContent->AsElement(), - aPseudoType, - StyleContext(), - resultElement); + resultElement->SetPseudoElementType(aPseudoType); - if (!aElements.AppendElement(ContentInfo(resultElement, newStyleContext))) { + if (!aElements.AppendElement(resultElement)) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index f8fdf3420a..aa3185d39a 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -352,32 +352,12 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements) // Create the placeholder anonymous content if needed. if (mUsePlaceholder) { - nsIContent* placeholderNode = txtCtrl->CreatePlaceholderNode(); + Element* placeholderNode = txtCtrl->CreatePlaceholderNode(); NS_ENSURE_TRUE(placeholderNode, NS_ERROR_OUT_OF_MEMORY); // Associate ::placeholder pseudo-element with the placeholder node. - CSSPseudoElementType pseudoType = CSSPseudoElementType::placeholder; - - // If this is a text input inside a number input then we want to use the - // main number input as the source of style for the placeholder frame. - nsIFrame* mainInputFrame = this; - if (StyleContext()->GetPseudoType() == CSSPseudoElementType::mozNumberText) { - do { - mainInputFrame = mainInputFrame->GetParent(); - } while (mainInputFrame && - mainInputFrame->GetType() != nsGkAtoms::numberControlFrame); - MOZ_ASSERT(mainInputFrame); - } - - RefPtr<nsStyleContext> placeholderStyleContext = - PresContext()->StyleSet()->ResolvePseudoElementStyle( - mainInputFrame->GetContent()->AsElement(), pseudoType, StyleContext(), - placeholderNode->AsElement()); - - if (!aElements.AppendElement(ContentInfo(placeholderNode, - placeholderStyleContext))) { - return NS_ERROR_OUT_OF_MEMORY; - } + placeholderNode->SetPseudoElementType(CSSPseudoElementType::placeholder); + aElements.AppendElement(placeholderNode); if (!IsSingleLineTextControl()) { // For textareas, UpdateValueDisplay doesn't initialize the visibility |