1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #2112 - Part 6: Remove IsStyledByServo function and callers

This commit is contained in:
FranklinDM
2024-03-25 02:09:12 +08:00
committed by roytam1
parent a93a7bed47
commit 10bf8705d0
13 changed files with 16 additions and 181 deletions
+2 -20
View File
@@ -1615,7 +1615,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// And clear the lazy frame construction bits.
NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
// And the restyle bits
UnsetRestyleFlagsIfGecko();
UnsetRestyleFlags();
} else if (IsInShadowTree()) {
// We're not in a document, but we did get inserted into a shadow tree.
// Since we won't have any restyle data in the document's restyle trackers,
@@ -1625,7 +1625,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// inserted into a document.
UnsetFlags(NODE_FORCE_XBL_BINDINGS |
NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
UnsetRestyleFlagsIfGecko();
UnsetRestyleFlags();
} else {
// If we're not in the doc and not in a shadow tree,
// update our subtree pointer.
@@ -1766,18 +1766,6 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
}
}
// It would be cleanest to mark nodes as dirty when (a) they're created and
// (b) they're unbound from a tree. However, we can't easily do (a) right now,
// because IsStyledByServo() is not always easy to check at node creation time,
// and the bits have different meaning in the non-IsStyledByServo case.
//
// So for now, we just mark nodes as dirty when they're inserted into a
// document or shadow tree.
if (IsStyledByServo() && IsInComposedDoc()) {
MOZ_ASSERT(!HasServoData());
SetIsDirtyForServo();
}
// XXXbz script execution during binding can trigger some of these
// postcondition asserts.... But we do want that, since things will
// generally be quite broken when that happens.
@@ -1904,12 +1892,6 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
ClearInDocument();
// Computed styled data isn't useful for detached nodes, and we'll need to
// recomputed it anyway if we ever insert the nodes back into a document.
if (IsStyledByServo()) {
ClearServoData();
}
// Editable descendant count only counts descendants that
// are in the uncomposed document.
ResetEditableDescendantCount();
+2 -2
View File
@@ -1662,9 +1662,9 @@ inline const mozilla::dom::Element* nsINode::AsElement() const
return static_cast<const mozilla::dom::Element*>(this);
}
inline void nsINode::UnsetRestyleFlagsIfGecko()
inline void nsINode::UnsetRestyleFlags()
{
if (IsElement() && !IsStyledByServo()) {
if (IsElement()) {
UnsetFlags(ELEMENT_ALL_RESTYLE_FLAGS);
}
}
-48
View File
@@ -2531,51 +2531,3 @@ FragmentOrElement::SetIsElementInStyleScopeFlagOnShadowTree(bool aInStyleScope)
shadowRoot->SetIsElementInStyleScopeFlagOnSubtree(aInStyleScope);
}
}
#ifdef DEBUG
static void
AssertDirtyDescendantsBitPropagated(nsINode* aNode)
{
MOZ_ASSERT(aNode->HasDirtyDescendantsForServo());
nsINode* parent = aNode->GetFlattenedTreeParentNode();
if (!parent->IsContent()) {
MOZ_ASSERT(parent == aNode->OwnerDoc());
MOZ_ASSERT(parent->HasDirtyDescendantsForServo());
} else {
AssertDirtyDescendantsBitPropagated(parent);
}
}
#else
static void AssertDirtyDescendantsBitPropagated(nsINode* aNode) {}
#endif
void
nsIContent::MarkAncestorsAsHavingDirtyDescendantsForServo()
{
MOZ_ASSERT(IsInComposedDoc());
// Get the parent in the flattened tree.
nsINode* parent = GetFlattenedTreeParentNode();
// Loop until we hit a base case.
while (true) {
// Base case: the document.
if (!parent->IsContent()) {
MOZ_ASSERT(parent == OwnerDoc());
parent->SetHasDirtyDescendantsForServo();
return;
}
// Base case: the parent is already marked, and therefore
// so are all its ancestors.
if (parent->HasDirtyDescendantsForServo()) {
AssertDirtyDescendantsBitPropagated(parent);
return;
}
// Mark the parent and iterate.
parent->SetHasDirtyDescendantsForServo();
parent = parent->GetFlattenedTreeParentNode();
}
}
-5
View File
@@ -2277,11 +2277,6 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
if (doc && doc->IsStyledByServo()) {
NS_WARNING("stylo: Web Components not supported yet");
return false;
}
return true;
}
-18
View File
@@ -555,18 +555,6 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
UpdateEditableState(false);
// It would be cleanest to mark nodes as dirty when (a) they're created and
// (b) they're unbound from a tree. However, we can't easily do (a) right now,
// because IsStyledByServo() is not always easy to check at node creation time,
// and the bits have different meaning in the non-IsStyledByServo case.
//
// So for now, we just mark nodes as dirty when they're inserted into a
// document or shadow tree.
if (IsStyledByServo() && IsInComposedDoc()) {
MOZ_ASSERT(!HasServoData());
SetIsDirtyForServo();
}
NS_POSTCONDITION(aDocument == GetUncomposedDoc(), "Bound to wrong document");
NS_POSTCONDITION(aParent == GetParent(), "Bound to wrong parent");
NS_POSTCONDITION(aBindingParent == GetBindingParent(),
@@ -598,12 +586,6 @@ nsGenericDOMDataNode::UnbindFromTree(bool aDeep, bool aNullParent)
}
ClearInDocument();
// Computed styled data isn't useful for detached nodes, and we'll need to
// recomputed it anyway if we ever insert the nodes back into a document.
if (IsStyledByServo()) {
ClearServoData();
}
if (aNullParent || !mParent->IsInShadowTree()) {
UnsetFlags(NODE_IS_IN_SHADOW_TREE);
-7
View File
@@ -933,13 +933,6 @@ public:
mozilla::dom::Element* GetEditingHost();
/**
* Set NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO all the way up the flattened
* parent chain to the document. If an ancestor is found with the bit already
* set, this method asserts that all of its ancestors also have the bit set.
*/
void MarkAncestorsAsHavingDirtyDescendantsForServo();
/**
* Determining language. Look at the nearest ancestor element that has a lang
* attribute in the XML namespace or is an HTML/SVG element and has a lang in
-4
View File
@@ -1158,10 +1158,6 @@ public:
void UpdateStyleBackendType();
bool IsStyledByServo() const {
return GetStyleBackendType() == mozilla::StyleBackendType::Servo;
}
/**
* Get this document's StyleImageLoader. This is guaranteed to not return null.
*/
+1 -49
View File
@@ -1018,55 +1018,7 @@ public:
virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override;
virtual nsIGlobalObject* GetOwnerGlobal() const override;
/**
* Returns true if this is a node belonging to a document that uses the Servo
* style system.
*/
bool IsStyledByServo() const { return false; }
bool IsDirtyForServo() const
{
MOZ_ASSERT(IsStyledByServo());
return HasFlag(NODE_IS_DIRTY_FOR_SERVO);
}
bool HasDirtyDescendantsForServo() const
{
MOZ_ASSERT(IsStyledByServo());
return HasFlag(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void SetIsDirtyForServo() {
MOZ_ASSERT(IsStyledByServo());
SetFlags(NODE_IS_DIRTY_FOR_SERVO);
}
void SetHasDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
SetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void SetIsDirtyAndHasDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
SetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO | NODE_IS_DIRTY_FOR_SERVO);
}
void UnsetIsDirtyForServo() {
MOZ_ASSERT(IsStyledByServo());
UnsetFlags(NODE_IS_DIRTY_FOR_SERVO);
}
void UnsetHasDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
UnsetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void UnsetIsDirtyAndHasDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
UnsetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO | NODE_IS_DIRTY_FOR_SERVO);
}
inline void UnsetRestyleFlagsIfGecko();
inline void UnsetRestyleFlags();
/**
* Adds a mutation observer to be notified when this node, or any of its
-8
View File
@@ -1417,7 +1417,6 @@ ElementRestyler::ElementRestyler(nsPresContext* aPresContext,
, mLoggingDepth(aRestyleTracker.LoggingDepth() + 1)
#endif
{
MOZ_ASSERT_IF(mContent, !mContent->IsStyledByServo());
}
ElementRestyler::ElementRestyler(const ElementRestyler& aParentRestyler,
@@ -1452,7 +1451,6 @@ ElementRestyler::ElementRestyler(const ElementRestyler& aParentRestyler,
, mLoggingDepth(aParentRestyler.mLoggingDepth + 1)
#endif
{
MOZ_ASSERT_IF(mContent, !mContent->IsStyledByServo());
if (aConstructorFlags & FOR_OUT_OF_FLOW_CHILD) {
// Note that the out-of-flow may not be a geometric descendant of
// the frame where we started the reresolve. Therefore, even if
@@ -1501,7 +1499,6 @@ ElementRestyler::ElementRestyler(ParentContextFromChildFrame,
, mLoggingDepth(aParentRestyler.mLoggingDepth + 1)
#endif
{
MOZ_ASSERT_IF(mContent, !mContent->IsStyledByServo());
}
ElementRestyler::ElementRestyler(nsPresContext* aPresContext,
@@ -1715,7 +1712,6 @@ ElementRestyler::ConditionallyRestyleChildren(nsIFrame* aFrame,
{
MOZ_ASSERT(aFrame->GetContent());
MOZ_ASSERT(aFrame->GetContent()->IsElement());
MOZ_ASSERT(!aFrame->GetContent()->IsStyledByServo());
ConditionallyRestyleUndisplayedDescendants(aFrame, aRestyleRoot);
ConditionallyRestyleContentChildren(aFrame, aRestyleRoot);
@@ -1729,7 +1725,6 @@ ElementRestyler::ConditionallyRestyleContentChildren(nsIFrame* aFrame,
{
MOZ_ASSERT(aFrame->GetContent());
MOZ_ASSERT(aFrame->GetContent()->IsElement());
MOZ_ASSERT(!aFrame->GetContent()->IsStyledByServo());
if (aFrame->GetContent()->HasFlag(mRestyleTracker.RootBit())) {
aRestyleRoot = aFrame->GetContent()->AsElement();
@@ -1821,7 +1816,6 @@ ElementRestyler::ConditionallyRestyleUndisplayedNodes(
if (aUndisplayedParent &&
aUndisplayedParent->IsElement() &&
aUndisplayedParent->HasFlag(mRestyleTracker.RootBit())) {
MOZ_ASSERT(!aUndisplayedParent->IsStyledByServo());
aRestyleRoot = aUndisplayedParent->AsElement();
}
@@ -1848,7 +1842,6 @@ void
ElementRestyler::ConditionallyRestyleContentDescendants(Element* aElement,
Element* aRestyleRoot)
{
MOZ_ASSERT(!aElement->IsStyledByServo());
if (aElement->HasFlag(mRestyleTracker.RootBit())) {
aRestyleRoot = aElement;
}
@@ -1879,7 +1872,6 @@ ElementRestyler::ConditionallyRestyle(nsIFrame* aFrame, Element* aRestyleRoot)
bool
ElementRestyler::ConditionallyRestyle(Element* aElement, Element* aRestyleRoot)
{
MOZ_ASSERT(!aElement->IsStyledByServo());
LOG_RESTYLE("considering element %s for eRestyle_SomeDescendants",
ElementTagToString(aElement).get());
LOG_RESTYLE_INDENT();
-3
View File
@@ -166,8 +166,6 @@ RestyleTracker::DoProcessRestyles()
AutoTArray<RefPtr<Element>, RESTYLE_ARRAY_STACKSIZE> laterSiblingArr;
for (auto iter = mPendingRestyles.Iter(); !iter.Done(); iter.Next()) {
auto element = static_cast<dom::Element*>(iter.Key());
MOZ_ASSERT(!element->IsStyledByServo(),
"Should not have Servo-styled elements here");
// Only collect the entries that actually need restyling by us (and
// haven't, for example, already been restyled).
// It's important to not mess with the flags on entries not in our
@@ -180,7 +178,6 @@ RestyleTracker::DoProcessRestyles()
}
for (uint32_t i = 0; i < laterSiblingArr.Length(); ++i) {
Element* element = laterSiblingArr[i];
MOZ_ASSERT(!element->IsStyledByServo());
for (nsIContent* sibling = element->GetNextSibling();
sibling;
sibling = sibling->GetNextSibling()) {
+7 -8
View File
@@ -2442,7 +2442,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
// this document. Unlike in AddFrameConstructionItems, it's safe to
// unset all element restyle flags, since we don't have any
// siblings.
aDocElement->UnsetRestyleFlagsIfGecko();
aDocElement->UnsetRestyleFlags();
// --------- CREATE AREA OR BOX FRAME -------
// FIXME: Should this use ResolveStyleContext? (The calls in this
@@ -5585,7 +5585,7 @@ nsCSSFrameConstructor::ShouldCreateItemsForChild(nsFrameConstructorState& aState
nsContainerFrame* aParentFrame)
{
aContent->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
if (aContent->IsElement() && !aContent->IsStyledByServo()) {
if (aContent->IsElement()) {
// We can't just remove our pending restyle flags, since we may
// have restyle-later-siblings set on us. But we _can_ remove the
// "is possible restyle root" flags, and need to. Otherwise we can
@@ -10504,14 +10504,13 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent(
{
for (uint32_t i = 0; i < aAnonymousItems.Length(); ++i) {
nsIContent* content = aAnonymousItems[i].mContent;
// Gecko-styled nodes should have no pending restyle flags.
MOZ_ASSERT_IF(!content->IsStyledByServo(),
!content->IsElement() ||
!(content->GetFlags() & ELEMENT_ALL_RESTYLE_FLAGS));
// Assert some things about this content
MOZ_ASSERT(!(content->GetFlags() &
(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME)),
"Should not be marked as needing frames");
MOZ_ASSERT(!content->IsElement() ||
!(content->GetFlags() & ELEMENT_ALL_RESTYLE_FLAGS),
"Should have no pending restyle flags");
MOZ_ASSERT(!content->GetPrimaryFrame(),
"Should have no existing frame");
MOZ_ASSERT(!content->IsNodeOfType(nsINode::eCOMMENT) &&
@@ -10753,7 +10752,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
// Frame construction item construction should not post
// restyles, so removing restyle flags here is safe.
child->UnsetRestyleFlagsIfGecko();
child->UnsetRestyleFlags();
if (addChildItems) {
AddFrameConstructionItems(aState, child, iter.XBLInvolved(), insertion,
itemsToConstruct);
@@ -11917,7 +11916,7 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState,
// restyle root" flags in AddFrameConstructionItems. But note
// that we can remove all restyle flags, just like in
// ProcessChildren and for the same reason.
content->UnsetRestyleFlagsIfGecko();
content->UnsetRestyleFlags();
RefPtr<nsStyleContext> childContext =
ResolveStyleContext(parentStyleContext, content, &aState);
+2 -2
View File
@@ -281,7 +281,7 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent,
for (uint32_t i = childX; i < numChildren; i++) {
nsIContent *child = mContent->GetChildAt(i);
child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
child->UnsetRestyleFlagsIfGecko();
child->UnsetRestyleFlags();
}
break;
}
@@ -289,7 +289,7 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent,
child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
// Also clear the restyle flags in the child like
// nsCSSFrameConstructor::ProcessChildren does.
child->UnsetRestyleFlagsIfGecko();
child->UnsetRestyleFlags();
// IMPORTANT: This must match the conditions in
// nsCSSFrameConstructor::ContentAppended/Inserted/Removed
+2 -7
View File
@@ -18,7 +18,6 @@
#include "nsWrapperCacheInlines.h"
#include "nsIFrame.h"
#include "ActiveLayerTracker.h"
#include "ServoDeclarationBlock.h"
#include "StyleSetHandle.h"
#include "DeclarationBlockInlines.h"
@@ -134,12 +133,8 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation)
// cannot fail
RefPtr<DeclarationBlock> decl;
if (mElement->IsStyledByServo()) {
decl = new ServoDeclarationBlock();
} else {
decl = new css::Declaration();
decl->AsGecko()->InitializeEmpty();
}
decl = new css::Declaration();
decl->AsGecko()->InitializeEmpty();
// this *can* fail (inside SetAttrAndNotify, at least).
nsresult rv;