Bug 1331322 - Allow tagging of pseudo-implementing native anonymous content with the pseudo type at creation time

* Stop using a node bit for HasExplicitBaseURI
* Move MAY_HAVE_CLASS to mBoolFlags
* Add a flag to indicate that a node is native anonymous content
* Allow tagging of pseudo-implementing native anonymous content with the pseudo type at creation time, and eliminate explicit style contexts in nsIAnonymousContentCreator::ContentInfo

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-16 16:37:28 -04:00 committed by Roy Tam
commit b723a5c8c4
25 changed files with 267 additions and 128 deletions

View file

@ -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