Issue #2112 - Part 10: Remove remaining Stylo/Servo includes and code

Some classes have been marked for removal/merging, macros used for forwarding/casting were moved to DeprecatedUtils.h.
This commit is contained in:
FranklinDM 2024-03-25 20:00:34 +08:00 • committed by roytam1
commit d6852b3170
54 changed files with 35 additions and 2957 deletions

View file

@ -18,15 +18,13 @@ namespace mozilla {
class EventStates;
class RestyleManager;
class ServoRestyleManager;
namespace dom {
class Element;
}
/**
* Class for sharing data and logic common to both RestyleManager and
* ServoRestyleManager.
* Class for sharing data and logic common to RestyleManager.
*/
class RestyleManagerBase
{

View file

@ -14,7 +14,6 @@
namespace mozilla {
class RestyleManager;
class ServoRestyleManager;
namespace dom {
class Element;
} // namespace dom
@ -27,11 +26,8 @@ class nsStyleChangeList;
namespace mozilla {
#define SERVO_BIT 0x1
/**
* Smart pointer class that can hold a pointer to either a RestyleManager
* or a ServoRestyleManager.
* Smart pointer class that can hold a pointer to a RestyleManager.
*/
class RestyleManagerHandle
{
@ -67,7 +63,7 @@ public:
// Restyle manager interface. These inline methods are defined in
// RestyleManagerHandleInlines.h and just forward to the underlying
// RestyleManager or ServoRestyleManager. See corresponding comments in
// RestyleManager. See corresponding comments in
// RestyleManager.h for descriptions of these methods.
inline void Disconnect();
@ -113,10 +109,7 @@ public:
inline void NotifyDestroyingFrame(nsIFrame* aFrame);
private:
// Stores a pointer to an RestyleManager or a ServoRestyleManager. The least
// significant bit is 0 for the former, 1 for the latter. This is
// valid as the least significant bit will never be used for a pointer
// value on platforms we care about.
// Stores a pointer to an RestyleManager.
uintptr_t mValue;
};
@ -132,10 +125,6 @@ public:
{
*this = aManager;
}
MOZ_IMPLICIT RestyleManagerHandle(ServoRestyleManager* aManager)
{
*this = aManager;
}
RestyleManagerHandle& operator=(decltype(nullptr))
{
@ -145,18 +134,10 @@ public:
RestyleManagerHandle& operator=(RestyleManager* aManager)
{
MOZ_ASSERT(!(reinterpret_cast<uintptr_t>(aManager) & SERVO_BIT),
"least significant bit shouldn't be set; we use it for state");
mPtr.mValue = reinterpret_cast<uintptr_t>(aManager);
return *this;
}
RestyleManagerHandle& operator=(ServoRestyleManager* aManager)
{
MOZ_CRASH("should not have a ServoRestyleManager object when MOZ_STYLO is "
"disabled");
}
// Make RestyleManagerHandle usable in boolean contexts.
explicit operator bool() const { return !!mPtr.mValue; }
bool operator!() const { return !mPtr.mValue; }
@ -169,8 +150,6 @@ private:
Ptr mPtr;
};
#undef SERVO_BIT
} // namespace mozilla
#endif // mozilla_RestyleManagerHandle_h

View file

@ -1,146 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ServoRestyleManager.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/dom/ChildIterator.h"
#include "nsContentUtils.h"
#include "nsCSSFrameConstructor.h"
#include "nsPrintfCString.h"
#include "nsStyleChangeList.h"
using namespace mozilla::dom;
namespace mozilla {
ServoRestyleManager::ServoRestyleManager(nsPresContext* aPresContext)
: RestyleManagerBase(aPresContext)
{
}
void
ServoRestyleManager::PostRestyleEvent(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
}
void
ServoRestyleManager::PostRestyleEventForLazyConstruction()
{
}
void
ServoRestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
}
void
ServoRestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
}
static void
MarkSelfAndDescendantsAsNotDirtyForServo(nsIContent* aContent)
{
}
void
ServoRestyleManager::RecreateStyleContexts(nsIContent* aContent,
nsStyleContext* aParentContext,
ServoStyleSet* aStyleSet,
nsStyleChangeList& aChangeListToProcess)
{
}
static void
MarkChildrenAsDirtyForServo(nsIContent* aContent)
{
}
/* static */ nsIFrame*
ServoRestyleManager::FrameForPseudoElement(const nsIContent* aContent,
nsIAtom* aPseudoTagOrNull)
{
return nullptr;
}
/* static */ void
ServoRestyleManager::NoteRestyleHint(Element* aElement, nsRestyleHint aHint)
{
}
void
ServoRestyleManager::ProcessPendingRestyles()
{
}
void
ServoRestyleManager::RestyleForInsertOrChange(nsINode* aContainer,
nsIContent* aChild)
{
}
void
ServoRestyleManager::ContentInserted(nsINode* aContainer, nsIContent* aChild)
{
}
void
ServoRestyleManager::RestyleForAppend(nsIContent* aContainer,
nsIContent* aFirstNewContent)
{
}
void
ServoRestyleManager::ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent)
{
}
void
ServoRestyleManager::ContentRemoved(nsINode* aContainer,
nsIContent* aOldChild,
nsIContent* aFollowingSibling)
{
}
void
ServoRestyleManager::ContentStateChanged(nsIContent* aContent,
EventStates aChangedBits)
{
}
void
ServoRestyleManager::AttributeWillChange(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute, int32_t aModType,
const nsAttrValue* aNewValue)
{
}
void
ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
nsIAtom* aAttribute, int32_t aModType,
const nsAttrValue* aOldValue)
{
}
nsresult
ServoRestyleManager::ReparentStyleContext(nsIFrame* aFrame)
{
return NS_OK;
}
ServoElementSnapshot*
ServoRestyleManager::SnapshotForElement(Element* aElement)
{
return nullptr;
}
} // namespace mozilla

View file

@ -1,127 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ServoRestyleManager_h
#define mozilla_ServoRestyleManager_h
#include "mozilla/EventStates.h"
#include "mozilla/RestyleManagerBase.h"
#include "mozilla/ServoElementSnapshot.h"
#include "nsChangeHint.h"
#include "nsHashKeys.h"
#include "nsINode.h"
#include "nsISupportsImpl.h"
#include "nsPresContext.h"
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class nsAttrValue;
class nsIAtom;
class nsIContent;
class nsIFrame;
class nsStyleChangeList;
namespace mozilla {
/**
* Restyle manager for a Servo-backed style system.
*/
class ServoRestyleManager : public RestyleManagerBase
{
friend class ServoStyleSet;
public:
typedef RestyleManagerBase base_type;
NS_INLINE_DECL_REFCOUNTING(ServoRestyleManager)
explicit ServoRestyleManager(nsPresContext* aPresContext);
void PostRestyleEvent(dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint);
void PostRestyleEventForLazyConstruction();
void RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
void ProcessPendingRestyles();
void ContentInserted(nsINode* aContainer, nsIContent* aChild);
void ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent);
void ContentRemoved(nsINode* aContainer,
nsIContent* aOldChild,
nsIContent* aFollowingSibling);
void RestyleForInsertOrChange(nsINode* aContainer,
nsIContent* aChild);
void RestyleForAppend(nsIContent* aContainer,
nsIContent* aFirstNewContent);
void ContentStateChanged(nsIContent* aContent, EventStates aStateMask);
void AttributeWillChange(dom::Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType,
const nsAttrValue* aNewValue);
void AttributeChanged(dom::Element* aElement, int32_t aNameSpaceID,
nsIAtom* aAttribute, int32_t aModType,
const nsAttrValue* aOldValue);
nsresult ReparentStyleContext(nsIFrame* aFrame);
bool HasPendingRestyles()
{
return false;
}
/**
* Gets the appropriate frame given a content and a pseudo-element tag.
*
* Right now only supports a null tag, before or after. If the pseudo-element
* is not null, the content needs to be an element.
*/
static nsIFrame* FrameForPseudoElement(const nsIContent* aContent,
nsIAtom* aPseudoTagOrNull);
protected:
~ServoRestyleManager() {}
private:
ServoElementSnapshot* SnapshotForElement(Element* aElement);
/**
* The element-to-element snapshot table to compute restyle hints.
*/
nsClassHashtable<nsRefPtrHashKey<Element>, ServoElementSnapshot>
mModifiedElements;
/**
* Traverses a tree of content that Servo has just restyled, recreating style
* contexts for their frames with the new style data.
*/
void RecreateStyleContexts(nsIContent* aContent,
nsStyleContext* aParentContext,
ServoStyleSet* aStyleSet,
nsStyleChangeList& aChangeList);
/**
* Marks the tree with the appropriate dirty flags for the given restyle hint.
*/
static void NoteRestyleHint(Element* aElement, nsRestyleHint aRestyleHint);
inline ServoStyleSet* StyleSet() const
{
return nullptr;
}
};
} // namespace mozilla
#endif // mozilla_ServoRestyleManager_h

View file

@ -114,7 +114,6 @@ EXPORTS.mozilla += [
'RestyleManagerBase.h',
'RestyleManagerHandle.h',
'RestyleManagerHandleInlines.h',
'ServoRestyleManager.h',
'StaticPresData.h',
]
@ -161,7 +160,6 @@ UNIFIED_SOURCES += [
'RestyleManagerBase.cpp',
'RestyleTracker.cpp',
'ScrollStyles.cpp',
'ServoRestyleManager.cpp',
'StackArena.cpp',
'StaticPresData.cpp',
'TouchManager.cpp',

View file

@ -1884,9 +1884,6 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat
return;
}
// stylo: ServoRestyleManager does not handle transitions yet, and when it
// does it probably won't need to track reframed style contexts to start
// transitions correctly.
if (mozilla::RestyleManager* geckoRM = RestyleManager()->GetAsGecko()) {
RestyleManager::ReframingStyleContexts* rsc =
geckoRM->GetReframingStyleContexts();
@ -5060,9 +5057,6 @@ nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
result = styleSet->ResolveStyleForText(aContent, aParentStyleContext);
}
// ServoRestyleManager does not handle transitions yet, and when it does
// it probably won't need to track reframed style contexts to start
// transitions correctly.
if (mozilla::RestyleManager* geckoRM = RestyleManager()->GetAsGecko()) {
RestyleManager::ReframingStyleContexts* rsc =
geckoRM->GetReframingStyleContexts();

View file

@ -56,7 +56,6 @@ public:
friend class mozilla::RestyleManager;
friend class mozilla::RestyleManagerBase;
friend class mozilla::ServoRestyleManager;
nsCSSFrameConstructor(nsIDocument* aDocument, nsIPresShell* aPresShell);
~nsCSSFrameConstructor(void) {

View file

@ -2137,8 +2137,6 @@ nsPresContext::EnsureSafeToHandOutCSSRules()
{
nsStyleSet* styleSet = mShell->StyleSet()->GetAsGecko();
if (!styleSet) {
// ServoStyleSets do not need to handle copy-on-write style sheet
// innards like with CSSStyleSheets.
return;
}
@ -2479,9 +2477,6 @@ nsPresContext::HasCachedStyleData()
nsStyleSet* styleSet = mShell->StyleSet()->GetAsGecko();
if (!styleSet) {
// XXXheycam ServoStyleSets do not use the rule tree, so just assume for now
// that we need to restyle when e.g. dppx changes assuming we're sufficiently
// bootstrapped.
return mShell->DidInitialize();
}

View file

@ -1452,10 +1452,8 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
{
// Make sure this does what nsDocumentViewer::CreateStyleSet does
// wrt ordering.
// XXXheycam This needs to work with ServoStyleSheets too.
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
if (!sheet) {
NS_ERROR("stylo: AddAgentSheet needs to support ServoStyleSheets");
return;
}
@ -1466,10 +1464,8 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
void
PresShell::AddAuthorSheet(nsISupports* aSheet)
{
// XXXheycam This needs to work with ServoStyleSheets too.
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
if (!sheet) {
NS_ERROR("stylo: AddAuthorSheet needs to support ServoStyleSheets");
return;
}
@ -1491,7 +1487,6 @@ PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet)
{
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
if (!sheet) {
NS_ERROR("stylo: RemoveSheet needs to support ServoStyleSheets");
return;
}
@ -2831,8 +2826,7 @@ PresShell::DestroyFramesForAndRestyle(Element* aElement)
: nsChangeHint_ReconstructFrame;
// NOTE(emilio): eRestyle_Subtree is needed to force also a full subtree
// restyle for the content (in Stylo, where the existence of frames != the
// existence of styles).
// restyle for the content.
mPresContext->RestyleManager()->PostRestyleEvent(
aElement, eRestyle_Subtree, changeHint);
@ -4176,11 +4170,6 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument,
nsStyleSet* styleSet = mStyleSet->GetAsGecko();
if (!styleSet) {
// XXXheycam ServoStyleSets don't support document state selectors,
// but these are only used in chrome documents, which we are not
// aiming to support yet.
NS_WARNING("stylo: ServoStyleSets cannot respond to document state "
"changes yet (only matters for chrome documents). See bug 1290285.");
return;
}
@ -10815,8 +10804,6 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
if (nsStyleSet* styleSet = StyleSet()->GetAsGecko()) {
*aStyleSetsSize += styleSet->SizeOfIncludingThis(aMallocSizeOf);
} else {
NS_WARNING("ServoStyleSets do not support memory measurements yet");
}
*aTextRunsSize += SizeOfTextRuns(aMallocSizeOf);
@ -11024,7 +11011,6 @@ nsIPresShell::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
*aRetVal = false;
if (nsStyleSet* styleSet = mStyleSet->GetAsGecko()) {
// ServoStyleSets do not have rule processors.
*aRetVal = styleSet->HasRuleProcessorUsedByMultipleStyleSets(type);
}
return NS_OK;