Bug 1640917 - Remove XBL mentions in layout. r=mats

Differential Revision: https://phabricator.services.mozilla.com/D76846
This commit is contained in:
Emilio Cobos Álvarez 2020-05-26 16:16:32 +00:00
parent 717cc8b65a
commit ce1947b502
10 changed files with 71 additions and 83 deletions

View File

@ -1823,8 +1823,7 @@ void Element::UnbindFromTree(bool aNullParent) {
for (nsIContent* child = GetFirstChild(); child;
child = child->GetNextSibling()) {
// Note that we pass false for aNullParent here, since we don't want
// the kids to forget us. We _do_ want them to forget their binding
// parent, though, since this only walks non-anonymous kids.
// the kids to forget us.
child->UnbindFromTree(false);
}

View File

@ -2969,8 +2969,10 @@ void RestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags) {
presContext->RefreshDriver()->MostRecentRefresh();
// Perform the Servo traversal, and the post-traversal if required. We do this
// in a loop because certain rare paths in the frame constructor (like
// uninstalling XBL bindings) can trigger additional style validations.
// in a loop because certain rare paths in the frame constructor can trigger
// additional style invalidations.
//
// FIXME(emilio): Confirm whether that's still true now that XBL is gone.
mInStyleRefresh = true;
if (mHaveNonAnimationRestyles) {
++mAnimationGeneration;

View File

@ -3322,9 +3322,9 @@ nsCSSFrameConstructor::FindHTMLData(const Element& aElement,
aStyle.StyleDisplay()->IsAbsolutelyPositionedStyle())) {
// <legend> is only special inside fieldset, we only check the frame tree
// parent because the content tree parent may not be a <fieldset> due to
// display:contents, Shadow DOM, or XBL. For floated or absolutely
// positioned legends we want to construct by display type and
// not do special legend stuff.
// display:contents, or Shadow DOM. For floated or absolutely positioned
// legends we want to construct by display type and not do special legend
// stuff.
return nullptr;
}
@ -4618,17 +4618,11 @@ already_AddRefed<ComputedStyle> nsCSSFrameConstructor::ResolveComputedStyle(
Element* parent = aContent->GetFlattenedTreeParentElement();
MOZ_ASSERT(parent, "Text out of the flattened tree?");
// FIXME(emilio): We can't use ResolveServoStyle properly because this text
// node can come from non-lazy frame construction, in which case the style we
// inherit from can indeed be out-of-date. After an eventual XBL removal, this
// can go. Note that this is not a correctness issue, since we'll restyle
// later in any case.
//
// Do NOT add new callers to this function in this file, ever, or I'll find
// out.
//
// FIXME(emilio): The const_cast is unfortunate, but it's not worse than what
// we did before.
//
// We could use ResolveServoStyle, but that would involve extra unnecessary
// refcount traffic...
auto* parentStyle =
const_cast<ComputedStyle*>(Servo_Element_GetMaybeOutOfDateStyle(parent));
MOZ_ASSERT(parentStyle,
@ -5159,7 +5153,6 @@ void nsCSSFrameConstructor::AddFrameConstructionItems(
//
// Never create frames for non-option/optgroup kids of <select> and non-option
// kids of <optgroup> inside a <select>.
// XXXbz it's not clear how this should best work with XBL.
static bool ShouldSuppressFrameInSelect(const nsIContent* aParent,
const nsIContent& aChild) {
if (!aParent ||
@ -5364,7 +5357,7 @@ void nsCSSFrameConstructor::AddFrameConstructionItemsInternal(
AddFrameConstructionItems(aState, child, aSuppressWhiteSpaceOptimizations,
insertion, aItems, aFlags);
}
aItems.SetParentHasNoXBLChildren(!iter.ShadowDOMInvolved());
aItems.SetParentHasNoShadowDOM(!iter.ShadowDOMInvolved());
CreateGeneratedContentItem(aState, aParentFrame, *aContent->AsElement(),
*aComputedStyle, PseudoStyleType::after, aItems);
@ -5593,14 +5586,14 @@ void nsCSSFrameConstructor::ConstructFramesFromItem(
// (We check mAdditionalStateBits because only the generated content
// container's frame construction item is marked with
// mIsGeneratedContent, and we might not have an aParentFrame.)
// We don't do it for content that may have XBL anonymous siblings,
// because they make it difficult to correctly create the frame
// due to dynamic changes.
// We don't do it for content that may have Shadow DOM siblings / insertion
// points, because they make it difficult to correctly create the frame due
// to dynamic changes.
// We don't do it for SVG text, since we might need to position and
// measure the white space glyphs due to x/y/dx/dy attributes.
if (AtLineBoundary(aIter) &&
!computedStyle->StyleText()->WhiteSpaceOrNewlineIsSignificant() &&
aIter.List()->ParentHasNoXBLChildren() &&
aIter.List()->ParentHasNoShadowDOM() &&
!(aState.mAdditionalStateBits & NS_FRAME_GENERATED_CONTENT) &&
(item.mFCData->mBits & FCDATA_IS_LINE_PARTICIPANT) &&
!(item.mFCData->mBits & FCDATA_IS_SVG_TEXT) &&
@ -6197,10 +6190,7 @@ nsIFrame* nsCSSFrameConstructor::GetInsertionPrevSibling(
*aIsAppend = false;
// Find the frame that precedes the insertion point. Walk backwards
// from the parent frame to get the parent content, because if an
// XBL insertion point is involved, we'll need to use _that_ to find
// the preceding frame.
// Find the frame that precedes the insertion point.
FlattenedChildIterator iter(aInsertion->mContainer);
if (iter.ShadowDOMInvolved() || !aChild->IsRootOfNativeAnonymousSubtree()) {
// The check for IsRootOfNativeAnonymousSubtree() is because editor is
@ -6705,12 +6695,12 @@ void nsCSSFrameConstructor::ContentAppended(nsIContent* aFirstNewContent,
LayoutFrameType frameType = parentFrame->Type();
FlattenedChildIterator iter(insertion.mContainer);
const bool haveNoXBLChildren =
const bool haveNoShadowDOM =
!iter.ShadowDOMInvolved() || !iter.GetNextChild();
AutoFrameConstructionItemList items(this);
if (aFirstNewContent->GetPreviousSibling() &&
GetParentType(frameType) == eTypeBlock && haveNoXBLChildren) {
GetParentType(frameType) == eTypeBlock && haveNoShadowDOM) {
// If there's a text node in the normal content list just before the new
// items, and it has no frame, make a frame construction item for it. If it
// doesn't need a frame, ConstructFramesFromItemList below won't give it
@ -6718,8 +6708,7 @@ void nsCSSFrameConstructor::ContentAppended(nsIContent* aFirstNewContent,
// since WipeContainingBlock already handles that situation.
//
// Because we're appending, we don't need to worry about any text
// after the appended content; there can only be XBL anonymous content
// (text in an XBL binding is not suppressed) or generated content
// after the appended content; there can only be generated content
// (and bare text nodes are not generated). Native anonymous content
// generated by frames never participates in inline layout.
AddTextItemIfNeeded(state, insertion,
@ -6760,7 +6749,7 @@ void nsCSSFrameConstructor::ContentAppended(nsIContent* aFirstNewContent,
}
// To suppress whitespace-only text frames, we have to verify that
// our container's DOM child list matches its flattened tree child list.
items.SetParentHasNoXBLChildren(haveNoXBLChildren);
items.SetParentHasNoShadowDOM(haveNoShadowDOM);
nsFrameList frameList;
ConstructFramesFromItemList(state, items, parentFrame,
@ -6952,9 +6941,9 @@ void nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild,
InsertionPoint insertion;
if (isSingleInsert) {
// See if we have an XBL insertion point. If so, then that's our
// real parent frame; if not, then the frame hasn't been built yet
// and we just bail.
// See if we have a Shadow DOM insertion point. If so, then that's our real
// parent frame; if not, then the frame hasn't been built yet and we just
// bail.
insertion = GetInsertionPoint(aStartChild);
} else {
// Get our insertion point. If we need to issue single ContentInserteds
@ -7115,9 +7104,10 @@ void nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild,
AutoFrameConstructionItemList items(this);
ParentType parentType = GetParentType(frameType);
FlattenedChildIterator iter(insertion.mContainer);
bool haveNoXBLChildren = !iter.ShadowDOMInvolved() || !iter.GetNextChild();
const bool haveNoShadowDOM =
!iter.ShadowDOMInvolved() || !iter.GetNextChild();
if (aStartChild->GetPreviousSibling() && parentType == eTypeBlock &&
haveNoXBLChildren) {
haveNoShadowDOM) {
// If there's a text node in the normal content list just before the
// new nodes, and it has no frame, make a frame construction item for
// it, because it might need a frame now. No need to do this if our
@ -7138,7 +7128,7 @@ void nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild,
}
}
if (aEndChild && parentType == eTypeBlock && haveNoXBLChildren) {
if (aEndChild && parentType == eTypeBlock && haveNoShadowDOM) {
// If there's a text node in the normal content list just after the
// new nodes, and it has no frame, make a frame construction item for
// it, because it might need a frame now. No need to do this if our
@ -7365,9 +7355,10 @@ bool nsCSSFrameConstructor::ContentRemoved(nsIContent* aChild,
// If we're removing the root, then make sure to remove things starting at
// the viewport's child instead of the primary frame (which might even be
// null if the root had an XBL binding or display:none, even though the
// frames above it got created). Detecting removal of a root is a little
// exciting; in particular, having no parent is necessary but NOT sufficient.
// null if the root was display:none, even though the frames above it got
// created). Detecting removal of a root is a little exciting; in particular,
// having no parent is necessary but NOT sufficient.
//
// Due to how we process reframes, the content node might not even be in our
// document by now. So explicitly check whether the viewport's first kid's
// content node is aChild.
@ -8793,8 +8784,7 @@ void nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems(
newItem->mChildItems.SetLineBoundaryAtEnd(true);
// The parent of the items in aItems is also the parent of the items
// in mChildItems
newItem->mChildItems.SetParentHasNoXBLChildren(
aItems.ParentHasNoXBLChildren());
newItem->mChildItems.SetParentHasNoShadowDOM(aItems.ParentHasNoShadowDOM());
// Eat up all items between |iter| and |endIter| and put them in our
// wrapper. This advances |iter| to point to |endIter|.
@ -9279,8 +9269,8 @@ void nsCSSFrameConstructor::WrapItemsInPseudoParent(
}
// The parent of the items in aItems is also the parent of the items
// in mChildItems
newItem->mChildItems.SetParentHasNoXBLChildren(
aIter.List()->ParentHasNoXBLChildren());
newItem->mChildItems.SetParentHasNoShadowDOM(
aIter.List()->ParentHasNoShadowDOM());
// Eat up all items between |aIter| and |aEndIter| and put them in our
// wrapper Advances |aIter| to point to |aEndIter|.
@ -9315,7 +9305,7 @@ void nsCSSFrameConstructor::CreateNeededPseudoSiblings(
// Use the content of the parent frame
aParentFrame->GetContent(), pseudoStyle.forget(), true);
newItem->mIsAllInline = true;
newItem->mChildItems.SetParentHasNoXBLChildren(true);
newItem->mChildItems.SetParentHasNoShadowDOM(true);
iter.InsertItem(newItem);
}
@ -9557,7 +9547,7 @@ void nsCSSFrameConstructor::ProcessChildren(
ClearLazyBits(child, child->GetNextSibling());
}
}
itemsToConstruct.SetParentHasNoXBLChildren(!iter.ShadowDOMInvolved());
itemsToConstruct.SetParentHasNoShadowDOM(!iter.ShadowDOMInvolved());
if (aCanHaveGeneratedContent) {
// Probe for generated content after

View File

@ -403,8 +403,8 @@ class nsCSSFrameConstructor final : public nsFrameManager {
ItemFlags = {});
// Construct the frames for the document element. This can return null if the
// document element is display:none, or if the document element has a
// not-yet-loaded XBL binding, or if it's an SVG element that's not <svg>.
// document element is display:none, or if it's an SVG element that's not
// <svg>, etc.
nsIFrame* ConstructDocElementFrame(Element* aDocElement);
// Set up our mDocElementContainingBlock correctly for the given root
@ -815,12 +815,12 @@ class nsCSSFrameConstructor final : public nsFrameManager {
void SetLineBoundaryAtEnd(bool aBoundary) {
mLineBoundaryAtEnd = aBoundary;
}
void SetParentHasNoXBLChildren(bool aHasNoXBLChildren) {
mParentHasNoXBLChildren = aHasNoXBLChildren;
void SetParentHasNoShadowDOM(bool aValue) {
mParentHasNoShadowDOM = aValue;
}
bool HasLineBoundaryAtStart() { return mLineBoundaryAtStart; }
bool HasLineBoundaryAtEnd() { return mLineBoundaryAtEnd; }
bool ParentHasNoXBLChildren() { return mParentHasNoXBLChildren; }
bool ParentHasNoShadowDOM() { return mParentHasNoShadowDOM; }
bool IsEmpty() const { return mItems.isEmpty(); }
bool AnyItemsNeedBlockParent() const { return mLineParticipantCount != 0; }
bool AreAllItemsInline() const { return mInlineCount == mItemCount; }
@ -982,7 +982,7 @@ class nsCSSFrameConstructor final : public nsFrameManager {
mItemCount(0),
mLineBoundaryAtStart(false),
mLineBoundaryAtEnd(false),
mParentHasNoXBLChildren(false) {
mParentHasNoShadowDOM(false) {
MOZ_COUNT_CTOR(FrameConstructionItemList);
memset(mDesiredParentCounts, 0, sizeof(mDesiredParentCounts));
}
@ -1037,8 +1037,8 @@ class nsCSSFrameConstructor final : public nsFrameManager {
// True if there is guaranteed to be a line boundary after the
// frames created by these items
bool mLineBoundaryAtEnd;
// True if the parent is guaranteed to have no XBL anonymous children
bool mParentHasNoXBLChildren;
// True if the parent is guaranteed to have no shadow tree.
bool mParentHasNoShadowDOM;
};
/* A struct representing a list of FrameConstructionItems on the stack. */
@ -1432,9 +1432,6 @@ class nsCSSFrameConstructor final : public nsFrameManager {
// Function to find FrameConstructionData for an element. Will return
// null if the element is not XUL.
//
// NOTE(emilio): This gets the overloaded tag and namespace id since they can
// be overriden by extends="" in XBL.
static const FrameConstructionData* FindXULTagData(const Element&,
ComputedStyle&);
// XUL data-finding helper functions and structures
@ -1546,8 +1543,11 @@ class nsCSSFrameConstructor final : public nsFrameManager {
/**
* Construct the frames for the children of aContent. "children" is defined
* as "whatever FlattenedChildIterator returns for aContent". This means
* we're basically operating on children in the "flattened tree" per
* sXBL/XBL2. This method will also handle constructing ::before, ::after,
* we're basically operating on children in the "flattened tree":
*
* https://drafts.csswg.org/css-scoping/#flat-tree
*
* This method will also handle constructing ::before, ::after,
* ::first-letter, and ::first-line frames, as needed and if allowed.
*
* If the parent is a float containing block, this method will handle pushing
@ -2026,8 +2026,8 @@ class nsCSSFrameConstructor final : public nsFrameManager {
// The skip parameters are used to ignore a range of children when looking
// for a sibling. All nodes starting from aStartSkipChild and up to but not
// including aEndSkipChild will be skipped over when looking for sibling
// frames. Skipping a range can deal with XBL but not when there are multiple
// insertion points.
// frames. Skipping a range can deal with shadow DOM, but not when there are
// multiple insertion points.
nsIFrame* GetInsertionPrevSibling(InsertionPoint* aInsertion, // inout
nsIContent* aChild, bool* aIsAppend,
bool* aIsRangeInsertSafe,

View File

@ -2395,10 +2395,8 @@ nsView* nsDocumentViewer::FindContainerView() {
return nullptr;
}
// subdocFrame might not be a subdocument frame; the frame
// constructor can treat a <frame> as an inline in some XBL
// cases. Treat that as display:none, the document is not
// displayed.
// Check subdocFrame just to be safe. If this somehow fails we treat that as
// display:none, the document is not displayed.
if (!subdocFrame->IsSubDocumentFrame()) {
NS_WARNING_ASSERTION(subdocFrame->Type() == LayoutFrameType::None,
"Subdocument container has non-subdocument frame");

View File

@ -96,8 +96,8 @@ nsresult nsGfxButtonControlFrame::GetDefaultLabel(nsAString& aString) const {
nsresult nsGfxButtonControlFrame::GetLabel(nsString& aLabel) {
// Get the text from the "value" property on our content if there is
// one; otherwise set it to a default value (localized).
dom::HTMLInputElement* elt = dom::HTMLInputElement::FromNode(mContent);
if (elt && elt->HasAttr(kNameSpaceID_None, nsGkAtoms::value)) {
auto* elt = dom::HTMLInputElement::FromNode(mContent);
if (elt && elt->HasAttr(nsGkAtoms::value)) {
elt->GetValue(aLabel, dom::CallerType::System);
} else {
// Generate localized label.
@ -127,8 +127,8 @@ nsresult nsGfxButtonControlFrame::GetLabel(nsString& aLabel) {
// this, even if the whitespace is significant, single leading and trailing
// _spaces_ (and not other whitespace) are removed. The proper solution,
// of course, is to not have the focus rect painting taking up 6px of
// horizontal space. We should do that instead (via XBL form controls or
// changing the renderer) and remove this.
// horizontal space. We should do that instead (changing the renderer) and
// remove this.
aLabel.Cut(0, 1);
aLabel.Truncate(aLabel.Length() - 1);
}

View File

@ -173,8 +173,8 @@ nsresult nsCanvasFrame::CreateAnonymousContent(
mTooltipContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_default,
NS_LITERAL_STRING("true"), false);
// Set the page attribute so the XBL binding will find the text for the
// tooltip from the currently hovered element.
// Set the page attribute so XULTooltipElement::PostHandleEvent will find
// the text for the tooltip from the currently hovered element.
mTooltipContent->SetAttr(kNameSpaceID_None, nsGkAtoms::page,
NS_LITERAL_STRING("true"), false);

View File

@ -3189,8 +3189,8 @@ class nsIFrame : public nsQueryFrame {
* true. Note that returning true here does not mean that the frame _can't_
* have kids. It could still have kids created via
* nsIAnonymousContentCreator. Returning true indicates that "normal"
* (non-anonymous, XBL-bound, CSS generated content, etc) children should not
* be constructed.
* (non-anonymous, CSS generated content, etc) children should not be
* constructed.
*/
bool IsLeaf() const {
MOZ_ASSERT(uint8_t(mClass) < mozilla::ArrayLength(sFrameClassBits));

View File

@ -70,16 +70,14 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
}
}
AutoTArray<StyleSheet*, 32> xblSheetArray;
styleSet->AppendAllNonDocumentAuthorSheets(xblSheetArray);
AutoTArray<StyleSheet*, 32> nonDocumentSheets;
styleSet->AppendAllNonDocumentAuthorSheets(nonDocumentSheets);
// The XBL stylesheet array will quite often be full of duplicates. Cope:
//
// FIXME(emilio, bug 1454467): I think this is not true since bug 1452525.
// The non-document stylesheet array can't have duplicates right now, but it
// could once we include adopted stylesheets.
nsTHashtable<nsPtrHashKey<StyleSheet>> sheetSet;
for (StyleSheet* sheet : xblSheetArray) {
if (!sheetSet.Contains(sheet)) {
sheetSet.PutEntry(sheet);
for (StyleSheet* sheet : nonDocumentSheets) {
if (sheetSet.EnsureInserted(sheet)) {
aResult.AppendElement(sheet);
}
}
@ -91,7 +89,8 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
}
// FIXME(emilio, bug 1617948): This doesn't deal with adopted stylesheets, and
// it should. It should also handle duplicates correctly when it does.
// it should. It should also handle duplicates correctly when it does, see
// above.
}
bool InspectorUtils::IsIgnorableWhitespace(CharacterData& aDataNode) {

View File

@ -218,7 +218,7 @@ nsresult inDeepTreeWalker::SetCurrentNode(nsINode* aCurrentNode,
if (index < 0) {
// If someone tries to set current node to some value that is not
// reachable otherwise, let's throw. (For example mShowAnonymousContent is
// false and some XBL anon content was passed in)
// false and some NAC was passed in)
// Restore state first.
mCurrentNode = tmpCurrent;