From da4399a912624ef61267833a345fe78d30c56f15 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Mar 25 2024 17:25:59 +0000 Subject: 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. --- diff --git a/dom/animation/KeyframeEffectReadOnly.cpp b/dom/animation/KeyframeEffectReadOnly.cpp index 62dddd2..3882735 100644 --- a/dom/animation/KeyframeEffectReadOnly.cpp +++ b/dom/animation/KeyframeEffectReadOnly.cpp @@ -15,7 +15,6 @@ #include "mozilla/FloatingPoint.h" // For IsFinite #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt #include "mozilla/KeyframeUtils.h" -#include "mozilla/ServoBindings.h" #include "mozilla/StyleAnimationValue.h" #include "Layers.h" // For Layer #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetStyleContextForElement @@ -32,17 +31,7 @@ namespace mozilla { bool PropertyValuePair::operator==(const PropertyValuePair& aOther) const { - if (mProperty != aOther.mProperty || mValue != aOther.mValue) { - return false; - } - if (mServoDeclarationBlock == aOther.mServoDeclarationBlock) { - return true; - } - if (!mServoDeclarationBlock || !aOther.mServoDeclarationBlock) { - return false; - } - return Servo_DeclarationBlock_Equals(mServoDeclarationBlock, - aOther.mServoDeclarationBlock); + return mProperty == aOther.mProperty && mValue == aOther.mValue; } namespace dom { @@ -933,13 +922,8 @@ KeyframeEffectReadOnly::GetKeyframes(JSContext*& aCx, : propertyValue.mProperty; nsAutoString stringValue; - if (propertyValue.mServoDeclarationBlock) { - Servo_DeclarationBlock_SerializeOneValue( - propertyValue.mServoDeclarationBlock, &stringValue); - } else { - propertyValue.mValue.AppendToString( - propertyForSerializing, stringValue, nsCSSValue::eNormalized); - } + propertyValue.mValue.AppendToString( + propertyForSerializing, stringValue, nsCSSValue::eNormalized); JS::Rooted value(aCx); if (!ToJSValue(aCx, stringValue, &value) || diff --git a/dom/animation/KeyframeEffectReadOnly.h b/dom/animation/KeyframeEffectReadOnly.h index 5d8d12d..77e3074 100644 --- a/dom/animation/KeyframeEffectReadOnly.h +++ b/dom/animation/KeyframeEffectReadOnly.h @@ -19,8 +19,6 @@ #include "mozilla/EffectCompositor.h" #include "mozilla/KeyframeEffectParams.h" #include "mozilla/LayerAnimationInfo.h" // LayerAnimations::kRecords -#include "mozilla/ServoBindingTypes.h" // RawServoDeclarationBlock and - // associated RefPtrTraits #include "mozilla/StyleAnimationValue.h" #include "mozilla/dom/AnimationEffectReadOnly.h" #include "mozilla/dom/Element.h" @@ -63,11 +61,6 @@ struct PropertyValuePair // (string). nsCSSValue mValue; - // The specified value when using the Servo backend. However, even when - // using the Servo backend, we still fill in |mValue| in the case where we - // fail to parse the value since we use it to store the original string. - RefPtr mServoDeclarationBlock; - bool operator==(const PropertyValuePair&) const; }; diff --git a/dom/base/ChildIterator.cpp b/dom/base/ChildIterator.cpp index 3d24da3..3507d47 100644 --- a/dom/base/ChildIterator.cpp +++ b/dom/base/ChildIterator.cpp @@ -474,10 +474,7 @@ IsNativeAnonymousImplementationOfPseudoElement(nsIContent* aContent) // Unlike regular nodes, native anonymous content (NAC) gets created during // frame construction, which happens after the main style traversal. This // means that we have to manually resolve style for those nodes shortly after - // they're created, either by (a) invoking ResolvePseudoElementStyle (for PE - // NAC), or (b) handing the subtree off to Servo for a mini-traversal (for - // non-PE NAC). We have assertions in nsCSSFrameConstructor that we don't do - // both. + // they're created by invoking ResolvePseudoElementStyle (for PE NAC). // // Once that happens, the NAC has a frame. So if we have no frame here, // we're either not NAC, or in the process of doing (b). Either way, this diff --git a/dom/base/WindowNamedPropertiesHandler.cpp b/dom/base/WindowNamedPropertiesHandler.cpp index 97ea3f8..67da208 100644 --- a/dom/base/WindowNamedPropertiesHandler.cpp +++ b/dom/base/WindowNamedPropertiesHandler.cpp @@ -43,9 +43,7 @@ ShouldExposeChildWindow(nsString& aNameBeingResolved, nsPIDOMWindowOuter* aChild // // This is problematic because it allows possibly-malicious and unrelated // cross-origin subframes to pollute the global namespace of their parent in - // unpredictable ways (see bug 860494). This is also problematic for browser - // engines like Servo that want to run cross-origin script on different - // threads. + // unpredictable ways (see bug 860494). // // The naive solution here would be to filter out any cross-origin subframes // obtained when doing named lookup in global scope. But that is unlikely to diff --git a/dom/base/nsAttrValue.cpp b/dom/base/nsAttrValue.cpp index c2dec15..cdc95a5 100644 --- a/dom/base/nsAttrValue.cpp +++ b/dom/base/nsAttrValue.cpp @@ -16,7 +16,6 @@ #include "nsIAtom.h" #include "nsUnicharUtils.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/ServoBindingTypes.h" #include "mozilla/DeclarationBlockInlines.h" #include "nsContentUtils.h" #include "nsReadableUtils.h" @@ -1984,8 +1983,6 @@ nsAttrValue::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const if (Type() == eCSSDeclaration && container->mValue.mCSSDeclaration) { // TODO: mCSSDeclaration might be owned by another object which // would make us count them twice, bug 677493. - // Bug 1281964: For ServoDeclarationBlock if we do measure we'll - // need a way to call the Servo heap_size_of function. //n += container->mCSSDeclaration->SizeOfIncludingThis(aMallocSizeOf); } else if (Type() == eAtomArray && container->mValue.mAtomArray) { // Don't measure each nsIAtom, they are measured separatly. diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index a4c2b48..573cf63 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -1152,7 +1152,6 @@ nsDOMStyleSheetSetList::EnsureFresh() for (size_t index = 0; index < count; index++) { StyleSheet* sheet = mDocument->SheetAt(index); NS_ASSERTION(sheet, "Null sheet in sheet list!"); - // XXXheycam ServoStyleSheets don't expose their title yet. sheet->AsGecko()->GetTitle(title); if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) { return; diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 03ea679..04e299d 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -19,7 +19,6 @@ #include "mozilla/InternalMutationEvent.h" #include "mozilla/Likely.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/ServoBindings.h" #include "mozilla/TimeStamp.h" #include "mozilla/css/StyleRule.h" #include "mozilla/dom/Element.h" @@ -1440,11 +1439,6 @@ nsINode::UnoptimizableCCNode() const AsElement()->IsInNamespace(kNameSpaceID_XBL)); } -void -nsINode::ClearServoData() { - MOZ_CRASH("Accessing servo node data in non-stylo build"); -} - /* static */ bool nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb) diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index acba58f..c80797b 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -7,7 +7,6 @@ #define nsINode_h___ #include "mozilla/Likely.h" -#include "mozilla/ServoTypes.h" #include "mozilla/UniquePtr.h" #include "nsCOMPtr.h" // for member, local #include "nsGkAtoms.h" // for nsGkAtoms::baseURIProperty @@ -2086,12 +2085,6 @@ public: #undef TOUCH_EVENT #undef EVENT - bool HasServoData() { - MOZ_CRASH("Accessing servo node data in non-stylo build"); - } - - void ClearServoData(); - protected: static bool Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb); static void Unlink(nsINode *tmp); diff --git a/dom/base/nsNameSpaceManager.h b/dom/base/nsNameSpaceManager.h index 8c7eb4d..ecaaae4 100644 --- a/dom/base/nsNameSpaceManager.h +++ b/dom/base/nsNameSpaceManager.h @@ -41,21 +41,6 @@ public: virtual nsresult GetNameSpaceURI(int32_t aNameSpaceID, nsAString& aURI); - // Returns the atom for the namespace URI associated with the given ID. The - // ID must be within range and not be kNameSpaceID_None (i.e. zero); - nsIAtom* NameSpaceURIAtom(int32_t aNameSpaceID) { - MOZ_ASSERT(aNameSpaceID > 0); - return NameSpaceURIAtomForServo(aNameSpaceID); - } - - // NB: This function should only be called by Servo code (and the above - // accessor), which uses the empty atom to represent kNameSpaceID_None. - nsIAtom* NameSpaceURIAtomForServo(int32_t aNameSpaceID) { - MOZ_ASSERT(aNameSpaceID >= 0); - MOZ_ASSERT((int64_t) aNameSpaceID < (int64_t) mURIArray.Length()); - return mURIArray.ElementAt(aNameSpaceID); - } - int32_t GetNameSpaceID(const nsAString& aURI, bool aInChromeDoc); int32_t GetNameSpaceID(nsIAtom* aURI, diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index d1a6187..e7a7eea 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -2671,9 +2671,6 @@ GetFontParentStyleContext(Element* aElement, nsIPresShell* aPresShell, nsStyleSet* styleSet = aPresShell->StyleSet()->GetAsGecko(); if (!styleSet) { - // XXXheycam ServoStyleSets do not support resolving style from a list of - // rules yet. - NS_ERROR("stylo: cannot resolve style for canvas from a ServoStyleSet yet"); aError.Throw(NS_ERROR_FAILURE); return nullptr; } @@ -2715,9 +2712,6 @@ GetFontStyleContext(Element* aElement, const nsAString& aFont, { nsStyleSet* styleSet = aPresShell->StyleSet()->GetAsGecko(); if (!styleSet) { - // XXXheycam ServoStyleSets do not support resolving style from a list of - // rules yet. - NS_ERROR("stylo: cannot resolve style for canvas from a ServoStyleSet yet"); aError.Throw(NS_ERROR_FAILURE); return nullptr; } @@ -2792,9 +2786,6 @@ ResolveStyleForFilter(const nsAString& aFilterString, { nsStyleSet* styleSet = aPresShell->StyleSet()->GetAsGecko(); if (!styleSet) { - // XXXheycam ServoStyleSets do not support resolving style from a list of - // rules yet. - NS_ERROR("stylo: cannot resolve style for canvas from a ServoStyleSet yet"); aError.Throw(NS_ERROR_FAILURE); return nullptr; } diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp index 9845c61..b0b3c6a 100644 --- a/dom/xbl/nsXBLBinding.cpp +++ b/dom/xbl/nsXBLBinding.cpp @@ -55,7 +55,6 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ShadowRoot.h" -#include "mozilla/ServoStyleSet.h" using namespace mozilla; using namespace mozilla::dom; diff --git a/layout/base/RestyleManagerBase.h b/layout/base/RestyleManagerBase.h index b5f99d0..99e41d4 100644 --- a/layout/base/RestyleManagerBase.h +++ b/layout/base/RestyleManagerBase.h @@ -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 { diff --git a/layout/base/RestyleManagerHandle.h b/layout/base/RestyleManagerHandle.h index 9087347..9cebd03 100644 --- a/layout/base/RestyleManagerHandle.h +++ b/layout/base/RestyleManagerHandle.h @@ -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(aManager) & SERVO_BIT), - "least significant bit shouldn't be set; we use it for state"); mPtr.mValue = reinterpret_cast(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 diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp deleted file mode 100644 index c715242..0000000 --- a/layout/base/ServoRestyleManager.cpp +++ /dev/null @@ -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 diff --git a/layout/base/ServoRestyleManager.h b/layout/base/ServoRestyleManager.h deleted file mode 100644 index 8e52e19..0000000 --- a/layout/base/ServoRestyleManager.h +++ /dev/null @@ -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, 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 diff --git a/layout/base/moz.build b/layout/base/moz.build index bdc6655..1b3532a 100644 --- a/layout/base/moz.build +++ b/layout/base/moz.build @@ -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', diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 668dbca..b06ebd3 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1863,9 +1863,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(); @@ -5022,9 +5019,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(); diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index c01d6ad..af29cdc 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -56,7 +56,6 @@ public: friend class mozilla::RestyleManager; friend class mozilla::RestyleManagerBase; - friend class mozilla::ServoRestyleManager; nsCSSFrameConstructor(nsIDocument* aDocument, nsIPresShell* aPresShell); ~nsCSSFrameConstructor(void) { diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 92fab43..c7206ac 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2139,8 +2139,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; } @@ -2481,9 +2479,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(); } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index cd40bd2..2b3f9c7 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1446,10 +1446,8 @@ PresShell::AddAgentSheet(nsISupports* aSheet) { // Make sure this does what nsDocumentViewer::CreateStyleSet does // wrt ordering. - // XXXheycam This needs to work with ServoStyleSheets too. RefPtr sheet = do_QueryObject(aSheet); if (!sheet) { - NS_ERROR("stylo: AddAgentSheet needs to support ServoStyleSheets"); return; } @@ -1460,10 +1458,8 @@ PresShell::AddAgentSheet(nsISupports* aSheet) void PresShell::AddAuthorSheet(nsISupports* aSheet) { - // XXXheycam This needs to work with ServoStyleSheets too. RefPtr sheet = do_QueryObject(aSheet); if (!sheet) { - NS_ERROR("stylo: AddAuthorSheet needs to support ServoStyleSheets"); return; } @@ -1485,7 +1481,6 @@ PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet) { RefPtr sheet = do_QueryObject(aSheet); if (!sheet) { - NS_ERROR("stylo: RemoveSheet needs to support ServoStyleSheets"); return; } @@ -2825,8 +2820,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); @@ -4170,11 +4164,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; } @@ -10810,8 +10799,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); @@ -11019,7 +11006,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; diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index e9095ce..fe2581c 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -118,7 +118,6 @@ #include "MediaDecoder.h" #include "MediaManager.h" #include "MediaPrefs.h" -#include "mozilla/ServoBindings.h" #include "mozilla/StaticPresData.h" #include "mozilla/dom/WebIDLGlobalNameHash.h" @@ -302,10 +301,6 @@ nsLayoutStatics::Initialize() mozilla::dom::WebCryptoThreadPool::Initialize(); - // NB: We initialize servo in nsAppRunner.cpp, because we need to do it after - // creating the hidden DOM window to support some current stylo hacks. We - // should move initialization back here once those go away. - MediaPrefs::GetSingleton(); return NS_OK; diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index ca55cf6..fd89ad0 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -407,8 +407,6 @@ void nsTextControlFrame::AppendAnonymousContentTo(nsTArray& aElements, uint32_t aFilter) { - // This can be called off-main-thread during Servo traversal, so we take care - // to avoid QI-ing the DOM node. nsITextControlElement* txtCtrl = nullptr; nsIContent* content = GetContent(); if (content->IsHTMLElement(nsGkAtoms::input)) { diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index fb6ee6d..f76e67d 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -8975,8 +8975,6 @@ GetCorrectedParent(const nsIFrame* aFrame) // It would be nice to put it in CorrectStyleParentFrame and therefore share // it, but that would lose the information of whether the _child_ is NAC, // since CorrectStyleParentFrame only knows about the prospective _parent_. - // This duplication and complexity will go away when we fully switch to the - // Servo style system, where all this can be handled much more naturally. // // We need to take special care not to disrupt the style inheritance of frames // whose content is NAC but who implement a pseudo (like an anonymous diff --git a/layout/style/CSS.cpp b/layout/style/CSS.cpp index 49ea6ee..4600495 100644 --- a/layout/style/CSS.cpp +++ b/layout/style/CSS.cpp @@ -8,7 +8,6 @@ #include "CSS.h" #include "mozilla/dom/BindingDeclarations.h" -#include "mozilla/ServoBindings.h" #include "nsCSSParser.h" #include "nsGlobalWindow.h" #include "nsIDocument.h" diff --git a/layout/style/CounterStyleManager.cpp b/layout/style/CounterStyleManager.cpp index 8dba9b0..46bd866 100644 --- a/layout/style/CounterStyleManager.cpp +++ b/layout/style/CounterStyleManager.cpp @@ -2028,7 +2028,6 @@ CounterStyleManager::BuildCounterStyle(const nsSubstring& aName) // It is intentional that the predefined names are case-insensitive // but the user-defined names case-sensitive. - // XXXheycam ServoStyleSets do not support custom counter styles yet. StyleSetHandle styleSet = mPresContext->StyleSet(); nsCSSCounterStyleRule* rule = styleSet->AsGecko()->CounterStyleRuleForName(aName); @@ -2071,7 +2070,6 @@ CounterStyleManager::NotifyRuleChanged() RefPtr& style = iter.Data(); bool toBeUpdated = false; bool toBeRemoved = false; - // XXXheycam ServoStyleSets do not support custom counter styles yet. StyleSetHandle styleSet = mPresContext->StyleSet(); nsCSSCounterStyleRule* newRule = styleSet->AsGecko()->CounterStyleRuleForName(iter.Key()); diff --git a/layout/style/DeclarationBlock.h b/layout/style/DeclarationBlock.h index 9a0c9db..272cdcc 100644 --- a/layout/style/DeclarationBlock.h +++ b/layout/style/DeclarationBlock.h @@ -11,7 +11,7 @@ #ifndef mozilla_DeclarationBlock_h #define mozilla_DeclarationBlock_h -#include "mozilla/ServoUtils.h" +#include "mozilla/DeprecatedUtils.h" #include "nsCSSPropertyID.h" @@ -19,8 +19,6 @@ class nsHTMLCSSStyleSheet; namespace mozilla { -class ServoDeclarationBlock; - namespace css { class Declaration; class Rule; @@ -36,7 +34,7 @@ protected: : DeclarationBlock() {} public: - MOZ_DECL_STYLO_METHODS(css::Declaration) + MOZ_DECL_DEPRECATED_METHODS(css::Declaration) inline MozExternalRefCountType AddRef(); inline MozExternalRefCountType Release(); diff --git a/layout/style/DeclarationBlockInlines.h b/layout/style/DeclarationBlockInlines.h index 40bbdc2..17f7ddb 100644 --- a/layout/style/DeclarationBlockInlines.h +++ b/layout/style/DeclarationBlockInlines.h @@ -10,7 +10,7 @@ namespace mozilla { -MOZ_DEFINE_STYLO_METHODS(DeclarationBlock, css::Declaration) +MOZ_DEFINE_DEPRECATED_METHODS(DeclarationBlock, css::Declaration) MozExternalRefCountType DeclarationBlock::AddRef() diff --git a/layout/style/DeprecatedUtils.h b/layout/style/DeprecatedUtils.h new file mode 100644 index 0000000..0484b6d --- /dev/null +++ b/layout/style/DeprecatedUtils.h @@ -0,0 +1,33 @@ +/* -*- 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/. */ + +/* some deprecated utilities */ + +#ifndef mozilla_DeprecatedUtils_h +#define mozilla_DeprecatedUtils_h + +#include "mozilla/TypeTraits.h" + +/** + * Macro used in a base class of |geckotype_|. + */ +#define MOZ_DECL_DEPRECATED_METHODS(geckotype_) \ + inline geckotype_* AsGecko(); \ + inline const geckotype_* AsGecko() const; + +/** + * Macro used in inline header of class |type_| with its Gecko + * subclass named |geckotype_| for implementing the inline methods + * defined by MOZ_DECL_DEPRECATED_METHODS. + */ +#define MOZ_DEFINE_DEPRECATED_METHODS(type_, geckotype_) \ + geckotype_* type_::AsGecko() { \ + return static_cast(this); \ + } \ + const geckotype_* type_::AsGecko() const { \ + return static_cast(this); \ + } + +#endif // mozilla_DeprecatedUtils_h diff --git a/layout/style/DocumentStyleRootIterator.cpp b/layout/style/DocumentStyleRootIterator.cpp deleted file mode 100644 index d99454e..0000000 --- a/layout/style/DocumentStyleRootIterator.cpp +++ /dev/null @@ -1,40 +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 "DocumentStyleRootIterator.h" - -#include "nsContentUtils.h" - -namespace mozilla { - -DocumentStyleRootIterator::DocumentStyleRootIterator(nsIDocument* aDocument) - : mPosition(0) -{ - MOZ_COUNT_CTOR(DocumentStyleRootIterator); - if (Element* root = aDocument->GetRootElement()) { - mStyleRoots.AppendElement(root); - } - nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo( - aDocument, mStyleRoots); -} - -Element* -DocumentStyleRootIterator::GetNextStyleRoot() -{ - for (;;) { - if (mPosition >= mStyleRoots.Length()) { - return nullptr; - } - - nsIContent* next = mStyleRoots[mPosition]; - ++mPosition; - - if (next->IsElement()) { - return next->AsElement(); - } - } -} - -} // namespace mozilla diff --git a/layout/style/DocumentStyleRootIterator.h b/layout/style/DocumentStyleRootIterator.h deleted file mode 100644 index 7c07d5c..0000000 --- a/layout/style/DocumentStyleRootIterator.h +++ /dev/null @@ -1,37 +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 DocumentStyleRootIterator_h -#define DocumentStyleRootIterator_h - -#include "nsTArray.h" -#include "mozilla/dom/Element.h" - -class nsIContent; -class nsIDocument; - -namespace mozilla { - -/** - * DocumentStyleRootIterator traverses the roots of the document from the - * perspective of the Servo-backed style system. This will first traverse - * the document root, followed by any document level native anonymous content. - */ -class DocumentStyleRootIterator -{ -public: - explicit DocumentStyleRootIterator(nsIDocument* aDocument); - ~DocumentStyleRootIterator() { MOZ_COUNT_DTOR(DocumentStyleRootIterator); } - - Element* GetNextStyleRoot(); - -private: - AutoTArray mStyleRoots; - uint32_t mPosition; -}; - -} // namespace mozilla - -#endif // DocumentStyleRootIterator_h diff --git a/layout/style/ServoBindingList.h b/layout/style/ServoBindingList.h deleted file mode 100644 index ff0fba4..0000000 --- a/layout/style/ServoBindingList.h +++ /dev/null @@ -1,145 +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/. */ - -/* a list of all Servo binding functions */ - -/* This file contains the list of all Servo binding functions. Each - * entry is defined as a SERVO_BINDING_FUNC macro with the following - * parameters: - * - 'name_' the name of the binding function - * - 'return_' the return type of the binding function - * and the parameter list of the function. - * - * Users of this list should define a macro - * SERVO_BINDING_FUNC(name_, return_, ...) - * before including this file. - */ - -// Node data -SERVO_BINDING_FUNC(Servo_Node_ClearNodeData, void, RawGeckoNodeBorrowed node) - -// Styleset and Stylesheet management -SERVO_BINDING_FUNC(Servo_StyleSheet_Empty, RawServoStyleSheetStrong, - mozilla::css::SheetParsingMode parsing_mode) -SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong, - const nsACString* data, - mozilla::css::SheetParsingMode parsing_mode, - const nsACString* base_url, - ThreadSafeURIHolder* base, - ThreadSafeURIHolder* referrer, - ThreadSafePrincipalHolder* principal) -SERVO_BINDING_FUNC(Servo_StyleSheet_AddRef, void, - RawServoStyleSheetBorrowed sheet) -SERVO_BINDING_FUNC(Servo_StyleSheet_Release, void, - RawServoStyleSheetBorrowed sheet) -SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool, - RawServoStyleSheetBorrowed sheet) -SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned) -SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set) -SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet) -SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet) -SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet) -SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void, - RawServoStyleSetBorrowed set, RawServoStyleSheetBorrowed sheet, - RawServoStyleSheetBorrowed reference) - -// Animations API -SERVO_BINDING_FUNC(Servo_ParseProperty, - RawServoDeclarationBlockStrong, - const nsACString* property, const nsACString* value, - const nsACString* base_url, ThreadSafeURIHolder* base, - ThreadSafeURIHolder* referrer, - ThreadSafePrincipalHolder* principal) -SERVO_BINDING_FUNC(Servo_RestyleWithAddedDeclaration, - ServoComputedValuesStrong, - RawServoDeclarationBlockBorrowed declarations, - ServoComputedValuesBorrowed previous_style) - -// Style attribute -SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong, - const nsACString* data) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty, - RawServoDeclarationBlockStrong) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_Clone, RawServoDeclarationBlockStrong, - RawServoDeclarationBlockBorrowed declarations) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_AddRef, void, - RawServoDeclarationBlockBorrowed declarations) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_Release, void, - RawServoDeclarationBlockBorrowed declarations) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_Equals, bool, - RawServoDeclarationBlockBorrowed a, - RawServoDeclarationBlockBorrowed b) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetCssText, void, - RawServoDeclarationBlockBorrowed declarations, - nsAString* result) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_SerializeOneValue, void, - RawServoDeclarationBlockBorrowed declarations, - nsString* buffer) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_Count, uint32_t, - RawServoDeclarationBlockBorrowed declarations) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetNthProperty, bool, - RawServoDeclarationBlockBorrowed declarations, - uint32_t index, nsAString* result) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyValue, void, - RawServoDeclarationBlockBorrowed declarations, - nsIAtom* property, bool is_custom, nsAString* value) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyIsImportant, bool, - RawServoDeclarationBlockBorrowed declarations, - nsIAtom* property, bool is_custom) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetProperty, bool, - RawServoDeclarationBlockBorrowed declarations, - nsIAtom* property, bool is_custom, - nsACString* value, bool is_important) -SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, void, - RawServoDeclarationBlockBorrowed declarations, - nsIAtom* property, bool is_custom) - -// CSS supports() -SERVO_BINDING_FUNC(Servo_CSSSupports, bool, - const nsACString* name, const nsACString* value) - -// Computed style data -SERVO_BINDING_FUNC(Servo_ComputedValues_Get, ServoComputedValuesStrong, - RawGeckoNodeBorrowed node) -SERVO_BINDING_FUNC(Servo_ComputedValues_GetForAnonymousBox, - ServoComputedValuesStrong, - ServoComputedValuesBorrowedOrNull parent_style_or_null, - nsIAtom* pseudoTag, RawServoStyleSetBorrowed set) -SERVO_BINDING_FUNC(Servo_ComputedValues_GetForPseudoElement, - ServoComputedValuesStrong, - ServoComputedValuesBorrowed parent_style, - RawGeckoElementBorrowed match_element, nsIAtom* pseudo_tag, - RawServoStyleSetBorrowed set, bool is_probe) -SERVO_BINDING_FUNC(Servo_ComputedValues_Inherit, ServoComputedValuesStrong, - ServoComputedValuesBorrowedOrNull parent_style) -SERVO_BINDING_FUNC(Servo_ComputedValues_AddRef, void, - ServoComputedValuesBorrowed computed_values) -SERVO_BINDING_FUNC(Servo_ComputedValues_Release, void, - ServoComputedValuesBorrowed computed_values) - -// Initialize Servo components. Should be called exactly once at startup. -SERVO_BINDING_FUNC(Servo_Initialize, void) -// Shut down Servo components. Should be called exactly once at shutdown. -SERVO_BINDING_FUNC(Servo_Shutdown, void) - -// Restyle hints -SERVO_BINDING_FUNC(Servo_ComputeRestyleHint, nsRestyleHint, - RawGeckoElementBorrowed element, ServoElementSnapshot* snapshot, - RawServoStyleSetBorrowed set) - -// Restyle the given subtree. -SERVO_BINDING_FUNC(Servo_RestyleSubtree, void, - RawGeckoNodeBorrowed node, RawServoStyleSetBorrowed set) - -// Style-struct management. -#define STYLE_STRUCT(name, checkdata_cb) \ - struct nsStyle##name; \ - SERVO_BINDING_FUNC(Servo_GetStyle##name, const nsStyle##name*, \ - ServoComputedValuesBorrowedOrNull computed_values) -#include "nsStyleStructList.h" -#undef STYLE_STRUCT diff --git a/layout/style/ServoBindingTypes.h b/layout/style/ServoBindingTypes.h deleted file mode 100644 index c1e25aa..0000000 --- a/layout/style/ServoBindingTypes.h +++ /dev/null @@ -1,143 +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_ServoBindingTypes_h -#define mozilla_ServoBindingTypes_h - -#include "mozilla/RefPtr.h" -#include "mozilla/UniquePtr.h" - -struct ServoComputedValues; -struct RawServoStyleSheet; -struct RawServoStyleSet; -struct RawServoDeclarationBlock; - -namespace mozilla { -namespace dom { -class Element; -class StyleChildrenIterator; -} // namespace dom -} // namespace mozilla - -class nsCSSValue; -class nsIDocument; -class nsINode; - -using mozilla::dom::StyleChildrenIterator; - -typedef nsINode RawGeckoNode; -typedef mozilla::dom::Element RawGeckoElement; -typedef nsIDocument RawGeckoDocument; - -// We have these helper types so that we can directly generate -// things like &T or Borrowed on the Rust side in the function, providing -// additional safety benefits. -// -// FFI has a problem with templated types, so we just use raw pointers here. -// -// The "Borrowed" types generate &T or Borrowed in the nullable case. -// -// The "Owned" types generate Owned or OwnedOrNull. Some of these -// are Servo-managed and can be converted to Box on the -// Servo side. -// -// The "Arc" types are Servo-managed Arcs, which are passed -// over FFI as Strong (which is nullable). -// Note that T != ServoType, rather T is ArcInner -#define DECL_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##Borrowed; -#define DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##BorrowedOrNull; -#define DECL_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMut; -#define DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMutOrNull; - -#define DECL_ARC_REF_TYPE_FOR(type_) \ - DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \ - DECL_BORROWED_REF_TYPE_FOR(type_) \ - struct MOZ_MUST_USE_TYPE type_##Strong \ - { \ - type_* mPtr; \ - already_AddRefed Consume(); \ - }; - -#define DECL_OWNED_REF_TYPE_FOR(type_) \ - typedef type_* type_##Owned; \ - DECL_BORROWED_REF_TYPE_FOR(type_) \ - DECL_BORROWED_MUT_REF_TYPE_FOR(type_) - -#define DECL_NULLABLE_OWNED_REF_TYPE_FOR(type_) \ - typedef type_* type_##OwnedOrNull; \ - DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \ - DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_) - -DECL_ARC_REF_TYPE_FOR(ServoComputedValues) -DECL_ARC_REF_TYPE_FOR(RawServoStyleSheet) -DECL_ARC_REF_TYPE_FOR(RawServoDeclarationBlock) -// This is a reference to a reference of RawServoDeclarationBlock, which -// corresponds to Option<&Arc> in Servo side. -DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoDeclarationBlockStrong) - -DECL_OWNED_REF_TYPE_FOR(RawServoStyleSet) -DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleChildrenIterator) -DECL_OWNED_REF_TYPE_FOR(StyleChildrenIterator) - -// We don't use BorrowedMut because the nodes may alias -// Servo itself doesn't directly read or mutate these; -// it only asks Gecko to do so. In case we wish to in -// the future, we should ensure that things being mutated -// are protected from noalias violations by a cell type -DECL_BORROWED_REF_TYPE_FOR(RawGeckoNode) -DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoNode) -DECL_BORROWED_REF_TYPE_FOR(RawGeckoElement) -DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoElement) -DECL_BORROWED_REF_TYPE_FOR(RawGeckoDocument) -DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoDocument) -DECL_BORROWED_MUT_REF_TYPE_FOR(StyleChildrenIterator) -DECL_BORROWED_REF_TYPE_FOR(nsCSSValue) -DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSValue) - -#undef DECL_ARC_REF_TYPE_FOR -#undef DECL_OWNED_REF_TYPE_FOR -#undef DECL_NULLABLE_OWNED_REF_TYPE_FOR -#undef DECL_BORROWED_REF_TYPE_FOR -#undef DECL_NULLABLE_BORROWED_REF_TYPE_FOR -#undef DECL_BORROWED_MUT_REF_TYPE_FOR -#undef DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR - -#define DEFINE_REFPTR_TRAITS(name_, type_) \ - extern "C" { \ - void Servo_##name_##_AddRef(type_##Borrowed ptr); \ - void Servo_##name_##_Release(type_##Borrowed ptr); \ - } \ - namespace mozilla { \ - template<> struct RefPtrTraits { \ - static void AddRef(type_* aPtr) { \ - Servo_##name_##_AddRef(aPtr); \ - } \ - static void Release(type_* aPtr) { \ - Servo_##name_##_Release(aPtr); \ - } \ - }; \ - } - -DEFINE_REFPTR_TRAITS(StyleSheet, RawServoStyleSheet) -DEFINE_REFPTR_TRAITS(ComputedValues, ServoComputedValues) -DEFINE_REFPTR_TRAITS(DeclarationBlock, RawServoDeclarationBlock) - -#undef DEFINE_REFPTR_TRAITS - -extern "C" void Servo_StyleSet_Drop(RawServoStyleSetOwned ptr); - -namespace mozilla { -template<> -class DefaultDelete -{ -public: - void operator()(RawServoStyleSet* aPtr) const - { - Servo_StyleSet_Drop(aPtr); - } -}; -} - -#endif // mozilla_ServoBindingTypes_h diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp deleted file mode 100644 index e0aeba4..0000000 --- a/layout/style/ServoBindings.cpp +++ /dev/null @@ -1,693 +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/ServoBindings.h" - -#include "ChildIterator.h" -#include "StyleStructContext.h" -#include "gfxFontFamilyList.h" -#include "nsAttrValueInlines.h" -#include "nsCSSRuleProcessor.h" -#include "nsContentUtils.h" -#include "nsDOMTokenList.h" -#include "nsIContentInlines.h" -#include "nsIDOMNode.h" -#include "nsIDocument.h" -#include "nsIFrame.h" -#include "nsINode.h" -#include "nsIPrincipal.h" -#include "nsNameSpaceManager.h" -#include "nsRuleNode.h" -#include "nsString.h" -#include "nsStyleStruct.h" -#include "nsStyleUtil.h" -#include "nsTArray.h" - -#include "mozilla/EventStates.h" -#include "mozilla/ServoElementSnapshot.h" -#include "mozilla/ServoRestyleManager.h" -#include "mozilla/StyleAnimationValue.h" -#include "mozilla/DeclarationBlockInlines.h" -#include "mozilla/dom/Element.h" - -using namespace mozilla; -using namespace mozilla::dom; - -#define IMPL_STRONG_REF_TYPE_FOR(type_) \ - already_AddRefed \ - type_##Strong::Consume() { \ - RefPtr result; \ - result.swap(mPtr); \ - return result.forget(); \ - } - -IMPL_STRONG_REF_TYPE_FOR(ServoComputedValues) -IMPL_STRONG_REF_TYPE_FOR(RawServoStyleSheet) -IMPL_STRONG_REF_TYPE_FOR(RawServoDeclarationBlock) - -#undef IMPL_STRONG_REF_TYPE_FOR - -uint32_t -Gecko_ChildrenCount(RawGeckoNodeBorrowed aNode) -{ - return 0; -} - -bool -Gecko_NodeIsElement(RawGeckoNodeBorrowed aNode) -{ - return false; -} - -RawGeckoNodeBorrowedOrNull -Gecko_GetParentNode(RawGeckoNodeBorrowed aNode) -{ - return nullptr; -} - -RawGeckoNodeBorrowedOrNull -Gecko_GetFirstChild(RawGeckoNodeBorrowed aNode) -{ - return nullptr; -} - -RawGeckoNodeBorrowedOrNull -Gecko_GetLastChild(RawGeckoNodeBorrowed aNode) -{ - return nullptr; -} - -RawGeckoNodeBorrowedOrNull -Gecko_GetPrevSibling(RawGeckoNodeBorrowed aNode) -{ - return nullptr; -} - -RawGeckoNodeBorrowedOrNull -Gecko_GetNextSibling(RawGeckoNodeBorrowed aNode) -{ - return nullptr; -} - -RawGeckoElementBorrowedOrNull -Gecko_GetParentElement(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -RawGeckoElementBorrowedOrNull -Gecko_GetFirstChildElement(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -RawGeckoElementBorrowedOrNull Gecko_GetLastChildElement(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -RawGeckoElementBorrowedOrNull -Gecko_GetPrevSiblingElement(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -RawGeckoElementBorrowedOrNull -Gecko_GetNextSiblingElement(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -RawGeckoElementBorrowedOrNull -Gecko_GetDocumentElement(RawGeckoDocumentBorrowed aDoc) -{ - return nullptr; -} - -StyleChildrenIteratorOwnedOrNull -Gecko_MaybeCreateStyleChildrenIterator(RawGeckoNodeBorrowed aNode) -{ - return nullptr; -} - -void -Gecko_DropStyleChildrenIterator(StyleChildrenIteratorOwned aIterator) -{ -} - -RawGeckoNodeBorrowed -Gecko_GetNextStyleChild(StyleChildrenIteratorBorrowedMut aIterator) -{ - return nullptr; -} - -EventStates::ServoType -Gecko_ElementState(RawGeckoElementBorrowed aElement) -{ - return 0; -} - -bool -Gecko_IsHTMLElementInHTMLDocument(RawGeckoElementBorrowed aElement) -{ - return false; -} - -bool -Gecko_IsLink(RawGeckoElementBorrowed aElement) -{ - return false; -} - -bool -Gecko_IsTextNode(RawGeckoNodeBorrowed aNode) -{ - return false; -} - -bool -Gecko_IsVisitedLink(RawGeckoElementBorrowed aElement) -{ - return false; -} - -bool -Gecko_IsUnvisitedLink(RawGeckoElementBorrowed aElement) -{ - return false; -} - -bool -Gecko_IsRootElement(RawGeckoElementBorrowed aElement) -{ - return false; -} - -nsIAtom* -Gecko_LocalName(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -nsIAtom* -Gecko_Namespace(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -nsIAtom* -Gecko_GetElementId(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -// Dirtiness tracking. -uint32_t -Gecko_GetNodeFlags(RawGeckoNodeBorrowed aNode) -{ - return 0; -} - -void -Gecko_SetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags) -{ -} - -void -Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags) -{ -} - -nsStyleContext* -Gecko_GetStyleContext(RawGeckoNodeBorrowed aNode, nsIAtom* aPseudoTagOrNull) -{ - return nullptr; -} - -nsChangeHint -Gecko_CalcStyleDifference(nsStyleContext* aOldStyleContext, - ServoComputedValuesBorrowed aComputedValues) -{ - return nsChangeHint(0); -} - -void -Gecko_StoreStyleDifference(RawGeckoNodeBorrowed aNode, nsChangeHint aChangeHintToStore) -{ -} - -RawServoDeclarationBlockStrongBorrowedOrNull -Gecko_GetServoDeclarationBlock(RawGeckoElementBorrowed aElement) -{ - return nullptr; -} - -template -static nsIAtom* -AtomAttrValue(Implementor* aElement, nsIAtom* aName) -{ - return nullptr; -} - -template -static bool -DoMatch(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, MatchFn aMatch) -{ - return false; -} - -template -static bool -HasAttr(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName) -{ - return false; -} - -template -static bool -AttrEquals(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, nsIAtom* aStr, - bool aIgnoreCase) -{ - return false; -} - -template -static bool -AttrDashEquals(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, - nsIAtom* aStr) -{ - return false; -} - -template -static bool -AttrIncludes(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, - nsIAtom* aStr) -{ - return false; -} - -template -static bool -AttrHasSubstring(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, - nsIAtom* aStr) -{ - return false; -} - -template -static bool -AttrHasPrefix(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, - nsIAtom* aStr) -{ - return false; -} - -template -static bool -AttrHasSuffix(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, - nsIAtom* aStr) -{ - return false; -} - -/** - * Gets the class or class list (if any) of the implementor. The calling - * convention here is rather hairy, and is optimized for getting Servo the - * information it needs for hot calls. - * - * The return value indicates the number of classes. If zero, neither outparam - * is valid. If one, the class_ outparam is filled with the atom of the class. - * If two or more, the classList outparam is set to point to an array of atoms - * representing the class list. - * - * The array is borrowed and the atoms are not addrefed. These values can be - * invalidated by any DOM mutation. Use them in a tight scope. - */ -template -static uint32_t -ClassOrClassList(Implementor* aElement, nsIAtom** aClass, nsIAtom*** aClassList) -{ - return 0; -} - -#define SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \ - nsIAtom* prefix_##AtomAttrValue(implementor_ aElement, nsIAtom* aName) \ - { \ - return AtomAttrValue(aElement, aName); \ - } \ - bool prefix_##HasAttr(implementor_ aElement, nsIAtom* aNS, nsIAtom* aName) \ - { \ - return HasAttr(aElement, aNS, aName); \ - } \ - bool prefix_##AttrEquals(implementor_ aElement, nsIAtom* aNS, \ - nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \ - { \ - return AttrEquals(aElement, aNS, aName, aStr, aIgnoreCase); \ - } \ - bool prefix_##AttrDashEquals(implementor_ aElement, nsIAtom* aNS, \ - nsIAtom* aName, nsIAtom* aStr) \ - { \ - return AttrDashEquals(aElement, aNS, aName, aStr); \ - } \ - bool prefix_##AttrIncludes(implementor_ aElement, nsIAtom* aNS, \ - nsIAtom* aName, nsIAtom* aStr) \ - { \ - return AttrIncludes(aElement, aNS, aName, aStr); \ - } \ - bool prefix_##AttrHasSubstring(implementor_ aElement, nsIAtom* aNS, \ - nsIAtom* aName, nsIAtom* aStr) \ - { \ - return AttrHasSubstring(aElement, aNS, aName, aStr); \ - } \ - bool prefix_##AttrHasPrefix(implementor_ aElement, nsIAtom* aNS, \ - nsIAtom* aName, nsIAtom* aStr) \ - { \ - return AttrHasPrefix(aElement, aNS, aName, aStr); \ - } \ - bool prefix_##AttrHasSuffix(implementor_ aElement, nsIAtom* aNS, \ - nsIAtom* aName, nsIAtom* aStr) \ - { \ - return AttrHasSuffix(aElement, aNS, aName, aStr); \ - } \ - uint32_t prefix_##ClassOrClassList(implementor_ aElement, nsIAtom** aClass, \ - nsIAtom*** aClassList) \ - { \ - return ClassOrClassList(aElement, aClass, aClassList); \ - } - -SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed) -SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot, ServoElementSnapshot*) - -#undef SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS - -nsIAtom* -Gecko_Atomize(const char* aString, uint32_t aLength) -{ - return nullptr; -} - -void -Gecko_AddRefAtom(nsIAtom* aAtom) -{ -} - -void -Gecko_ReleaseAtom(nsIAtom* aAtom) -{ -} - -const uint16_t* -Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength) -{ - return nullptr; -} - -bool -Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength) -{ - return false; -} - -bool -Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength) -{ - return false; -} - -void -Gecko_Utf8SliceToString(nsString* aString, - const uint8_t* aBuffer, - size_t aBufferLen) -{ -} - -void -Gecko_FontFamilyList_Clear(FontFamilyList* aList) { -} - -void -Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName) -{ -} - -void -Gecko_FontFamilyList_AppendGeneric(FontFamilyList* aList, FontFamilyType aType) -{ -} - -void -Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src) -{ -} - -void -Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type) -{ -} - -void -Gecko_CopyListStyleTypeFrom(nsStyleList* dst, const nsStyleList* src) -{ -} - -NS_IMPL_HOLDER_FFI_REFCOUNTING(nsIPrincipal, Principal) -NS_IMPL_HOLDER_FFI_REFCOUNTING(nsIURI, URI) - -void -Gecko_SetMozBinding(nsStyleDisplay* aDisplay, - const uint8_t* aURLString, uint32_t aURLStringLength, - ThreadSafeURIHolder* aBaseURI, - ThreadSafeURIHolder* aReferrer, - ThreadSafePrincipalHolder* aPrincipal) -{ -} - -void -Gecko_CopyMozBindingFrom(nsStyleDisplay* aDest, const nsStyleDisplay* aSrc) -{ -} - - -void -Gecko_SetNullImageValue(nsStyleImage* aImage) -{ -} - -void -Gecko_SetGradientImageValue(nsStyleImage* aImage, nsStyleGradient* aGradient) -{ -} - -static already_AddRefed -CreateStyleImageRequest(nsStyleImageRequest::Mode aModeFlags, - const uint8_t* aURLString, uint32_t aURLStringLength, - ThreadSafeURIHolder* aBaseURI, - ThreadSafeURIHolder* aReferrer, - ThreadSafePrincipalHolder* aPrincipal) -{ - return nullptr; -} - -void -Gecko_SetUrlImageValue(nsStyleImage* aImage, - const uint8_t* aURLString, uint32_t aURLStringLength, - ThreadSafeURIHolder* aBaseURI, - ThreadSafeURIHolder* aReferrer, - ThreadSafePrincipalHolder* aPrincipal) -{ -} - -void -Gecko_CopyImageValueFrom(nsStyleImage* aImage, const nsStyleImage* aOther) -{ -} - -nsStyleGradient* -Gecko_CreateGradient(uint8_t aShape, - uint8_t aSize, - bool aRepeating, - bool aLegacySyntax, - uint32_t aStopCount) -{ - return nullptr; -} - -void -Gecko_SetListStyleImageNone(nsStyleList* aList) -{ -} - -void -Gecko_SetListStyleImage(nsStyleList* aList, - const uint8_t* aURLString, uint32_t aURLStringLength, - ThreadSafeURIHolder* aBaseURI, - ThreadSafeURIHolder* aReferrer, - ThreadSafePrincipalHolder* aPrincipal) -{ -} - -void -Gecko_CopyListStyleImageFrom(nsStyleList* aList, const nsStyleList* aSource) -{ -} - -void -Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, size_t aElemSize) -{ -} - -void -Gecko_ClearPODTArray(void* aArray, size_t aElementSize, size_t aElementAlign) -{ -} - -void -Gecko_ClearStyleContents(nsStyleContent* aContent) -{ -} - -void -Gecko_CopyStyleContentsFrom(nsStyleContent* aContent, const nsStyleContent* aOther) -{ -} - -void -Gecko_EnsureImageLayersLength(nsStyleImageLayers* aLayers, size_t aLen, - nsStyleImageLayers::LayerType aLayerType) -{ -} - -void -Gecko_ResetStyleCoord(nsStyleUnit* aUnit, nsStyleUnion* aValue) -{ -} - -void -Gecko_SetStyleCoordCalcValue(nsStyleUnit* aUnit, nsStyleUnion* aValue, nsStyleCoord::CalcValue aCalc) -{ -} - -void -Gecko_CopyClipPathValueFrom(mozilla::StyleClipPath* aDst, const mozilla::StyleClipPath* aSrc) -{ -} - -void -Gecko_DestroyClipPath(mozilla::StyleClipPath* aClip) -{ -} - -mozilla::StyleBasicShape* -Gecko_NewBasicShape(mozilla::StyleBasicShapeType aType) -{ - return nullptr; -} - -void -Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len) -{ -} - -void -Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest) -{ -} - -NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc); - -nsCSSShadowArray* -Gecko_NewCSSShadowArray(uint32_t aLen) -{ - return nullptr; -} - -NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray); - -nsStyleQuoteValues* -Gecko_NewStyleQuoteValues(uint32_t aLen) -{ - return nullptr; -} - -NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues); - -nsCSSValueSharedList* -Gecko_NewCSSValueSharedList(uint32_t aLen) -{ - return nullptr; -} - -void -Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut aCSSValue, nscoord aLen) -{ -} - -void -Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut aCSSValue, float aNumber) -{ -} - -void -Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut aCSSValue, nsCSSKeyword aKeyword) -{ -} - -void -Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut aCSSValue, float aPercent) -{ -} - -void -Gecko_CSSValue_SetAngle(nsCSSValueBorrowedMut aCSSValue, float aRadians) -{ -} - -void -Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut aCSSValue, nsStyleCoord::CalcValue aCalc) -{ -} - -void -Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut aCSSValue, int32_t aLen) -{ -} - -nsCSSValueBorrowedMut -Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut aCSSValue, int32_t aIndex) -{ - return nullptr; -} - -NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList); - -#define STYLE_STRUCT(name, checkdata_cb) \ - \ -void \ -Gecko_Construct_nsStyle##name(nsStyle##name* ptr) \ -{ \ -} \ - \ -void \ -Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \ - const nsStyle##name* other) \ -{ \ -} \ - \ -void \ -Gecko_Destroy_nsStyle##name(nsStyle##name* ptr) \ -{ \ -} - -#include "nsStyleStructList.h" - -#undef STYLE_STRUCT - -#define SERVO_BINDING_FUNC(name_, return_, ...) \ - return_ name_(__VA_ARGS__) { \ - MOZ_CRASH("stylo: shouldn't be calling " #name_ "in a non-stylo build"); \ - } -#include "ServoBindingList.h" -#undef SERVO_BINDING_FUNC diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h deleted file mode 100644 index a8a6214..0000000 --- a/layout/style/ServoBindings.h +++ /dev/null @@ -1,284 +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_ServoBindings_h -#define mozilla_ServoBindings_h - -#include - -#include "mozilla/ServoTypes.h" -#include "mozilla/ServoBindingTypes.h" -#include "mozilla/ServoElementSnapshot.h" -#include "mozilla/css/SheetParsingMode.h" -#include "nsChangeHint.h" -#include "nsStyleStruct.h" - -/* - * API for Servo to access Gecko data structures. This file must compile as valid - * C code in order for the binding generator to parse it. - * - * Functions beginning with Gecko_ are implemented in Gecko and invoked from Servo. - * Functions beginning with Servo_ are implemented in Servo and invoked from Gecko. - */ - -class nsIAtom; -class nsIPrincipal; -class nsIURI; -struct nsFont; -namespace mozilla { - class FontFamilyList; - enum FontFamilyType : uint32_t; -} -using mozilla::FontFamilyList; -using mozilla::FontFamilyType; -using mozilla::ServoElementSnapshot; -struct nsStyleList; -struct nsStyleImage; -struct nsStyleGradientStop; -class nsStyleGradient; -class nsStyleCoord; -struct nsStyleDisplay; - -#define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \ - void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \ - void Gecko_Release##name_##ArbitraryThread(class_* aPtr); -#define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \ - static_assert(class_::HasThreadSafeRefCnt::value, \ - "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \ - "classes that have thread-safe refcounting"); \ - void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) \ - { NS_ADDREF(aPtr); } \ - void Gecko_Release##name_##ArbitraryThread(class_* aPtr) \ - { NS_RELEASE(aPtr); } - -#define NS_DECL_HOLDER_FFI_REFCOUNTING(class_, name_) \ - typedef nsMainThreadPtrHolder ThreadSafe##name_##Holder; \ - void Gecko_AddRef##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr); \ - void Gecko_Release##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr); -#define NS_IMPL_HOLDER_FFI_REFCOUNTING(class_, name_) \ - void Gecko_AddRef##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr) \ - { NS_ADDREF(aPtr); } \ - void Gecko_Release##name_##ArbitraryThread(ThreadSafe##name_##Holder* aPtr) \ - { NS_RELEASE(aPtr); } \ - -extern "C" { - -// Object refcounting. -NS_DECL_HOLDER_FFI_REFCOUNTING(nsIPrincipal, Principal) -NS_DECL_HOLDER_FFI_REFCOUNTING(nsIURI, URI) - -// DOM Traversal. -uint32_t Gecko_ChildrenCount(RawGeckoNodeBorrowed node); -bool Gecko_NodeIsElement(RawGeckoNodeBorrowed node); -RawGeckoNodeBorrowedOrNull Gecko_GetParentNode(RawGeckoNodeBorrowed node); -RawGeckoNodeBorrowedOrNull Gecko_GetFirstChild(RawGeckoNodeBorrowed node); -RawGeckoNodeBorrowedOrNull Gecko_GetLastChild(RawGeckoNodeBorrowed node); -RawGeckoNodeBorrowedOrNull Gecko_GetPrevSibling(RawGeckoNodeBorrowed node); -RawGeckoNodeBorrowedOrNull Gecko_GetNextSibling(RawGeckoNodeBorrowed node); -RawGeckoElementBorrowedOrNull Gecko_GetParentElement(RawGeckoElementBorrowed element); -RawGeckoElementBorrowedOrNull Gecko_GetFirstChildElement(RawGeckoElementBorrowed element); -RawGeckoElementBorrowedOrNull Gecko_GetLastChildElement(RawGeckoElementBorrowed element); -RawGeckoElementBorrowedOrNull Gecko_GetPrevSiblingElement(RawGeckoElementBorrowed element); -RawGeckoElementBorrowedOrNull Gecko_GetNextSiblingElement(RawGeckoElementBorrowed element); -RawGeckoElementBorrowedOrNull Gecko_GetDocumentElement(RawGeckoDocumentBorrowed document); - -// By default, Servo walks the DOM by traversing the siblings of the DOM-view -// first child. This generally works, but misses anonymous children, which we -// want to traverse during styling. To support these cases, we create an -// optional heap-allocated iterator for nodes that need it. If the creation -// method returns null, Servo falls back to the aforementioned simpler (and -// faster) sibling traversal. -StyleChildrenIteratorOwnedOrNull Gecko_MaybeCreateStyleChildrenIterator(RawGeckoNodeBorrowed node); -void Gecko_DropStyleChildrenIterator(StyleChildrenIteratorOwned it); -RawGeckoNodeBorrowedOrNull Gecko_GetNextStyleChild(StyleChildrenIteratorBorrowedMut it); - -// Selector Matching. -uint8_t Gecko_ElementState(RawGeckoElementBorrowed element); -bool Gecko_IsHTMLElementInHTMLDocument(RawGeckoElementBorrowed element); -bool Gecko_IsLink(RawGeckoElementBorrowed element); -bool Gecko_IsTextNode(RawGeckoNodeBorrowed node); -bool Gecko_IsVisitedLink(RawGeckoElementBorrowed element); -bool Gecko_IsUnvisitedLink(RawGeckoElementBorrowed element); -bool Gecko_IsRootElement(RawGeckoElementBorrowed element); -nsIAtom* Gecko_LocalName(RawGeckoElementBorrowed element); -nsIAtom* Gecko_Namespace(RawGeckoElementBorrowed element); -nsIAtom* Gecko_GetElementId(RawGeckoElementBorrowed element); - -// Attributes. -#define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \ - nsIAtom* prefix_##AtomAttrValue(implementor_ element, nsIAtom* attribute); \ - bool prefix_##HasAttr(implementor_ element, nsIAtom* ns, nsIAtom* name); \ - bool prefix_##AttrEquals(implementor_ element, nsIAtom* ns, nsIAtom* name, \ - nsIAtom* str, bool ignoreCase); \ - bool prefix_##AttrDashEquals(implementor_ element, nsIAtom* ns, \ - nsIAtom* name, nsIAtom* str); \ - bool prefix_##AttrIncludes(implementor_ element, nsIAtom* ns, \ - nsIAtom* name, nsIAtom* str); \ - bool prefix_##AttrHasSubstring(implementor_ element, nsIAtom* ns, \ - nsIAtom* name, nsIAtom* str); \ - bool prefix_##AttrHasPrefix(implementor_ element, nsIAtom* ns, \ - nsIAtom* name, nsIAtom* str); \ - bool prefix_##AttrHasSuffix(implementor_ element, nsIAtom* ns, \ - nsIAtom* name, nsIAtom* str); \ - uint32_t prefix_##ClassOrClassList(implementor_ element, nsIAtom** class_, \ - nsIAtom*** classList); - -SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed) -SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot, - ServoElementSnapshot*) - -#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS - -// Style attributes. -RawServoDeclarationBlockStrongBorrowedOrNull -Gecko_GetServoDeclarationBlock(RawGeckoElementBorrowed element); - -// Atoms. -nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength); -void Gecko_AddRefAtom(nsIAtom* aAtom); -void Gecko_ReleaseAtom(nsIAtom* aAtom); -const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength); -bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength); -bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength); - -// Strings (temporary until bug 1294742) -void Gecko_Utf8SliceToString(nsString* aString, - const uint8_t* aBuffer, - size_t aBufferLen); - -// Font style -void Gecko_FontFamilyList_Clear(FontFamilyList* aList); -void Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName); -void Gecko_FontFamilyList_AppendGeneric(FontFamilyList* list, FontFamilyType familyType); -void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src); - -// Counter style. -void Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type); -void Gecko_CopyListStyleTypeFrom(nsStyleList* dst, const nsStyleList* src); - -// background-image style. -// TODO: support element() and -moz-image() -void Gecko_SetNullImageValue(nsStyleImage* image); -void Gecko_SetGradientImageValue(nsStyleImage* image, nsStyleGradient* gradient); -void Gecko_SetUrlImageValue(nsStyleImage* image, - const uint8_t* url_bytes, - uint32_t url_length, - ThreadSafeURIHolder* base_uri, - ThreadSafeURIHolder* referrer, - ThreadSafePrincipalHolder* principal); -void Gecko_CopyImageValueFrom(nsStyleImage* image, const nsStyleImage* other); - -nsStyleGradient* Gecko_CreateGradient(uint8_t shape, - uint8_t size, - bool repeating, - bool legacy_syntax, - uint32_t stops); - -// list-style-image style. -void Gecko_SetListStyleImageNone(nsStyleList* style_struct); -void Gecko_SetListStyleImage(nsStyleList* style_struct, - const uint8_t* string_bytes, uint32_t string_length, - ThreadSafeURIHolder* base_uri, - ThreadSafeURIHolder* referrer, - ThreadSafePrincipalHolder* principal); -void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src); - -// Display style. -void Gecko_SetMozBinding(nsStyleDisplay* style_struct, - const uint8_t* string_bytes, uint32_t string_length, - ThreadSafeURIHolder* base_uri, - ThreadSafeURIHolder* referrer, - ThreadSafePrincipalHolder* principal); -void Gecko_CopyMozBindingFrom(nsStyleDisplay* des, const nsStyleDisplay* src); - -// Dirtiness tracking. -uint32_t Gecko_GetNodeFlags(RawGeckoNodeBorrowed node); -void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags); -void Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags); - -// Incremental restyle. -// TODO: We would avoid a few ffi calls if we decide to make an API like the -// former CalcAndStoreStyleDifference, but that would effectively mean breaking -// some safety guarantees in the servo side. -// -// Also, we might want a ComputedValues to ComputedValues API for animations? -// Not if we do them in Gecko... -nsStyleContext* Gecko_GetStyleContext(RawGeckoNodeBorrowed node, - nsIAtom* aPseudoTagOrNull); -nsChangeHint Gecko_CalcStyleDifference(nsStyleContext* oldstyle, - ServoComputedValuesBorrowed newstyle); -void Gecko_StoreStyleDifference(RawGeckoNodeBorrowed node, nsChangeHint change); - -// `array` must be an nsTArray -// If changing this signature, please update the -// friend function declaration in nsTArray.h -void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size); - -// Same here, `array` must be an nsTArray, for some T. -// -// Important note: Only valid for POD types, since destructors won't be run -// otherwise. This is ensured with rust traits for the relevant structs. -void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align); - -// Clear the mContents field in nsStyleContent. This is needed to run the -// destructors, otherwise we'd leak the images (though we still don't support -// those), strings, and whatnot. -void Gecko_ClearStyleContents(nsStyleContent* content); -void Gecko_CopyStyleContentsFrom(nsStyleContent* content, const nsStyleContent* other); - -void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len, - nsStyleImageLayers::LayerType layer_type); - -// Clean up pointer-based coordinates -void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value); - -// Set an nsStyleCoord to a computed `calc()` value -void Gecko_SetStyleCoordCalcValue(nsStyleUnit* unit, nsStyleUnion* value, nsStyleCoord::CalcValue calc); - -void Gecko_CopyClipPathValueFrom(mozilla::StyleClipPath* dst, const mozilla::StyleClipPath* src); - -void Gecko_DestroyClipPath(mozilla::StyleClipPath* clip); -mozilla::StyleBasicShape* Gecko_NewBasicShape(mozilla::StyleBasicShapeType type); - -void Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len); -void Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest); - -void Gecko_FillAllBackgroundLists(nsStyleImageLayers* layers, uint32_t max_len); -void Gecko_FillAllMaskLists(nsStyleImageLayers* layers, uint32_t max_len); -NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc); - -nsCSSShadowArray* Gecko_NewCSSShadowArray(uint32_t len); -NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray); - -nsStyleQuoteValues* Gecko_NewStyleQuoteValues(uint32_t len); -NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues); - -nsCSSValueSharedList* Gecko_NewCSSValueSharedList(uint32_t len); -void Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut css_value, nscoord len); -void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number); -void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword); -void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent); -void Gecko_CSSValue_SetAngle(nsCSSValueBorrowedMut css_value, float radians); -void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc); -void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len); -nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index); -NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList); - -// Style-struct management. -#define STYLE_STRUCT(name, checkdata_cb) \ - void Gecko_Construct_nsStyle##name(nsStyle##name* ptr); \ - void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \ - const nsStyle##name* other); \ - void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr); -#include "nsStyleStructList.h" -#undef STYLE_STRUCT - -#define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__); -#include "mozilla/ServoBindingList.h" -#undef SERVO_BINDING_FUNC - -} // extern "C" - -#endif // mozilla_ServoBindings_h diff --git a/layout/style/ServoDeclarationBlock.cpp b/layout/style/ServoDeclarationBlock.cpp deleted file mode 100644 index 219050e..0000000 --- a/layout/style/ServoDeclarationBlock.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; 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/ServoDeclarationBlock.h" - -#include "mozilla/ServoBindings.h" - -#include "nsCSSProps.h" - -namespace mozilla { - -/* static */ already_AddRefed -ServoDeclarationBlock::FromCssText(const nsAString& aCssText) -{ - return nullptr; -} - -/** - * An RAII class holding an atom for the given property. - */ -class MOZ_STACK_CLASS PropertyAtomHolder -{ -public: - explicit PropertyAtomHolder(const nsAString& aProperty) - { - } - - ~PropertyAtomHolder() - { - } - - explicit operator bool() const { return !!mAtom; } - nsIAtom* Atom() const { MOZ_ASSERT(mAtom); return mAtom; } - bool IsCustomProperty() const { return mIsCustomProperty; } - -private: - nsIAtom* mAtom; - bool mIsCustomProperty; -}; - -void -ServoDeclarationBlock::GetPropertyValue(const nsAString& aProperty, - nsAString& aValue) const -{ -} - -void -ServoDeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID, - nsAString& aValue) const -{ -} - -bool -ServoDeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const -{ - return false; -} - -void -ServoDeclarationBlock::RemoveProperty(const nsAString& aProperty) -{ -} - -void -ServoDeclarationBlock::RemovePropertyByID(nsCSSPropertyID aPropID) -{ -} - -} // namespace mozilla diff --git a/layout/style/ServoDeclarationBlock.h b/layout/style/ServoDeclarationBlock.h deleted file mode 100644 index ccc05d6..0000000 --- a/layout/style/ServoDeclarationBlock.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; 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_ServoDeclarationBlock_h -#define mozilla_ServoDeclarationBlock_h - -#include "mozilla/ServoBindings.h" -#include "mozilla/DeclarationBlock.h" - -namespace mozilla { - -class ServoDeclarationBlock final : public DeclarationBlock -{ -public: - ServoDeclarationBlock() - : ServoDeclarationBlock(Servo_DeclarationBlock_CreateEmpty().Consume()) {} - - ServoDeclarationBlock(const ServoDeclarationBlock& aCopy) - : DeclarationBlock(aCopy) - , mRaw(Servo_DeclarationBlock_Clone(aCopy.mRaw).Consume()) {} - - NS_INLINE_DECL_REFCOUNTING(ServoDeclarationBlock) - - static already_AddRefed - FromCssText(const nsAString& aCssText); - - RawServoDeclarationBlock* Raw() const { return mRaw; } - RawServoDeclarationBlock* const* RefRaw() const { - static_assert(sizeof(RefPtr) == - sizeof(RawServoDeclarationBlock*), - "RefPtr should just be a pointer"); - return reinterpret_cast(&mRaw); - } - - void ToString(nsAString& aResult) const { - Servo_DeclarationBlock_GetCssText(mRaw, &aResult); - } - - uint32_t Count() const { - return Servo_DeclarationBlock_Count(mRaw); - } - bool GetNthProperty(uint32_t aIndex, nsAString& aReturn) const { - aReturn.Truncate(); - return Servo_DeclarationBlock_GetNthProperty(mRaw, aIndex, &aReturn); - } - - void GetPropertyValue(const nsAString& aProperty, nsAString& aValue) const; - void GetPropertyValueByID(nsCSSPropertyID aPropID, nsAString& aValue) const; - void GetAuthoredPropertyValue(const nsAString& aProperty, - nsAString& aValue) const { - GetPropertyValue(aProperty, aValue); - } - bool GetPropertyIsImportant(const nsAString& aProperty) const; - void RemoveProperty(const nsAString& aProperty); - void RemovePropertyByID(nsCSSPropertyID aPropID); - -protected: - explicit ServoDeclarationBlock( - already_AddRefed aRaw) - : DeclarationBlock(), mRaw(aRaw) {} - -private: - ~ServoDeclarationBlock() {} - - RefPtr mRaw; -}; - -} // namespace mozilla - -#endif // mozilla_ServoDeclarationBlock_h diff --git a/layout/style/ServoElementSnapshot.cpp b/layout/style/ServoElementSnapshot.cpp deleted file mode 100644 index 83a462c..0000000 --- a/layout/style/ServoElementSnapshot.cpp +++ /dev/null @@ -1,26 +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/ServoElementSnapshot.h" -#include "mozilla/dom/Element.h" -#include "nsIContentInlines.h" -#include "nsContentUtils.h" - -namespace mozilla { - -ServoElementSnapshot::ServoElementSnapshot(Element* aElement) - : mContains(Flags(0)) - , mState(0) - , mExplicitRestyleHint(nsRestyleHint(0)) - , mExplicitChangeHint(nsChangeHint(0)) -{ -} - -void -ServoElementSnapshot::AddAttrs(Element* aElement) -{ -} - -} // namespace mozilla diff --git a/layout/style/ServoElementSnapshot.h b/layout/style/ServoElementSnapshot.h deleted file mode 100644 index 15b6b9c..0000000 --- a/layout/style/ServoElementSnapshot.h +++ /dev/null @@ -1,144 +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_ServoElementSnapshot_h -#define mozilla_ServoElementSnapshot_h - -#include "mozilla/EventStates.h" -#include "mozilla/TypedEnumBits.h" -#include "mozilla/dom/BorrowedAttrInfo.h" -#include "nsAttrName.h" -#include "nsAttrValue.h" -#include "nsChangeHint.h" -#include "nsIAtom.h" - -namespace mozilla { - -namespace dom { -class Element; -} // namespace dom - -/** - * A structure representing a single attribute name and value. - * - * This is pretty similar to the private nsAttrAndChildArray::InternalAttr. - */ -struct ServoAttrSnapshot -{ - nsAttrName mName; - nsAttrValue mValue; - - ServoAttrSnapshot(const nsAttrName& aName, const nsAttrValue& aValue) - : mName(aName) - , mValue(aValue) - { - } -}; - -/** - * A bitflags enum class used to determine what data does a ServoElementSnapshot - * contains. - */ -enum class ServoElementSnapshotFlags : uint8_t -{ - State = 1 << 0, - Attributes = 1 << 1, - All = State | Attributes -}; - -MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ServoElementSnapshotFlags) - -/** - * This class holds all non-tree-structural state of an element that might be - * used for selector matching eventually. - * - * This means the attributes, and the element state, such as :hover, :active, - * etc... - */ -class ServoElementSnapshot -{ - typedef dom::BorrowedAttrInfo BorrowedAttrInfo; - typedef dom::Element Element; - typedef EventStates::ServoType ServoStateType; - -public: - typedef ServoElementSnapshotFlags Flags; - - explicit ServoElementSnapshot(Element* aElement); - - bool HasAttrs() { return HasAny(Flags::Attributes); } - - bool HasState() { return HasAny(Flags::State); } - - /** - * Captures the given state (if not previously captured). - */ - void AddState(EventStates aState) - { - } - - /** - * Captures the given element attributes (if not previously captured). - */ - void AddAttrs(Element* aElement); - - void AddExplicitChangeHint(nsChangeHint aMinChangeHint) - { - } - - void AddExplicitRestyleHint(nsRestyleHint aRestyleHint) - { - } - - nsRestyleHint ExplicitRestyleHint() { return mExplicitRestyleHint; } - - nsChangeHint ExplicitChangeHint() { return mExplicitChangeHint; } - - /** - * Needed methods for attribute matching. - */ - BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const - { - return BorrowedAttrInfo(nullptr, nullptr); - } - - const nsAttrValue* GetParsedAttr(nsIAtom* aLocalName) const - { - return GetParsedAttr(aLocalName, kNameSpaceID_None); - } - - const nsAttrValue* GetParsedAttr(nsIAtom* aLocalName, - int32_t aNamespaceID) const - { - return nullptr; - } - - bool IsInChromeDocument() const - { - return false; - } - - bool HasAny(Flags aFlags) - { - return false; - } - -private: - // TODO: Profile, a 1 or 2 element AutoTArray could be worth it, given we know - // we're dealing with attribute changes when we take snapshots of attributes, - // though it can be wasted space if we deal with a lot of state-only - // snapshots. - Flags mContains; - nsTArray mAttrs; - ServoStateType mState; - nsRestyleHint mExplicitRestyleHint; - nsChangeHint mExplicitChangeHint; - bool mIsHTMLElementInHTMLDocument; - bool mIsInChromeDocument; -}; - -} // namespace mozilla - -#endif diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp deleted file mode 100644 index 6b40e3f..0000000 --- a/layout/style/ServoStyleSet.cpp +++ /dev/null @@ -1,254 +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/ServoStyleSet.h" - -#include "ServoBindings.h" -#include "mozilla/ServoRestyleManager.h" -#include "mozilla/dom/ChildIterator.h" -#include "nsCSSAnonBoxes.h" -#include "nsCSSPseudoElements.h" -#include "nsIDocumentInlines.h" -#include "nsPrintfCString.h" -#include "nsStyleContext.h" -#include "nsStyleSet.h" - -using namespace mozilla; -using namespace mozilla::dom; - -ServoStyleSet::ServoStyleSet() - : mPresContext(nullptr) - , mRawSet(Servo_StyleSet_Init()) - , mBatching(0) -{ -} - -void -ServoStyleSet::Init(nsPresContext* aPresContext) -{ - mPresContext = aPresContext; -} - -void -ServoStyleSet::BeginShutdown() -{ -} - -void -ServoStyleSet::Shutdown() -{ - mRawSet = nullptr; -} - -bool -ServoStyleSet::GetAuthorStyleDisabled() const -{ - return false; -} - -nsresult -ServoStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled) -{ - return NS_OK; -} - -void -ServoStyleSet::BeginUpdate() -{ -} - -nsresult -ServoStyleSet::EndUpdate() -{ - return NS_OK; -} - -already_AddRefed -ServoStyleSet::ResolveStyleFor(Element* aElement, - nsStyleContext* aParentContext) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::GetContext(nsIContent* aContent, - nsStyleContext* aParentContext, - nsIAtom* aPseudoTag, - CSSPseudoElementType aPseudoType) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::GetContext(already_AddRefed aComputedValues, - nsStyleContext* aParentContext, - nsIAtom* aPseudoTag, - CSSPseudoElementType aPseudoType) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::ResolveStyleFor(Element* aElement, - nsStyleContext* aParentContext, - TreeMatchContext& aTreeMatchContext) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::ResolveStyleForText(nsIContent* aTextNode, - nsStyleContext* aParentContext) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::ResolveStyleForOtherNonElement(nsStyleContext* aParentContext) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::ResolvePseudoElementStyle(Element* aParentElement, - CSSPseudoElementType aType, - nsStyleContext* aParentContext, - Element* aPseudoElement) -{ - return nullptr; -} - -// aFlags is an nsStyleSet flags bitfield -already_AddRefed -ServoStyleSet::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, - nsStyleContext* aParentContext, - uint32_t aFlags) -{ - return nullptr; -} - -// manage the set of style sheets in the style set -nsresult -ServoStyleSet::AppendStyleSheet(SheetType aType, - ServoStyleSheet* aSheet) -{ - return NS_OK; -} - -nsresult -ServoStyleSet::PrependStyleSheet(SheetType aType, - ServoStyleSheet* aSheet) -{ - return NS_OK; -} - -nsresult -ServoStyleSet::RemoveStyleSheet(SheetType aType, - ServoStyleSheet* aSheet) -{ - return NS_OK; -} - -nsresult -ServoStyleSet::ReplaceSheets(SheetType aType, - const nsTArray>& aNewSheets) -{ - return NS_OK; -} - -nsresult -ServoStyleSet::InsertStyleSheetBefore(SheetType aType, - ServoStyleSheet* aNewSheet, - ServoStyleSheet* aReferenceSheet) -{ - return NS_OK; -} - -int32_t -ServoStyleSet::SheetCount(SheetType aType) const -{ - return 0; -} - -ServoStyleSheet* -ServoStyleSet::StyleSheetAt(SheetType aType, - int32_t aIndex) const -{ - return nullptr; -} - -nsresult -ServoStyleSet::RemoveDocStyleSheet(ServoStyleSheet* aSheet) -{ - return NS_OK; -} - -nsresult -ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet, - nsIDocument* aDocument) -{ - return NS_OK; -} - -already_AddRefed -ServoStyleSet::ProbePseudoElementStyle(Element* aParentElement, - CSSPseudoElementType aType, - nsStyleContext* aParentContext) -{ - return nullptr; -} - -already_AddRefed -ServoStyleSet::ProbePseudoElementStyle(Element* aParentElement, - CSSPseudoElementType aType, - nsStyleContext* aParentContext, - TreeMatchContext& aTreeMatchContext, - Element* aPseudoElement) -{ - return nullptr; -} - -nsRestyleHint -ServoStyleSet::HasStateDependentStyle(dom::Element* aElement, - EventStates aStateMask) -{ - return nsRestyleHint(0); -} - -nsRestyleHint -ServoStyleSet::HasStateDependentStyle(dom::Element* aElement, - CSSPseudoElementType aPseudoType, - dom::Element* aPseudoElement, - EventStates aStateMask) -{ - return nsRestyleHint(0); -} - -nsRestyleHint -ServoStyleSet::ComputeRestyleHint(dom::Element* aElement, - ServoElementSnapshot* aSnapshot) -{ - return nsRestyleHint(0); -} - -static void -ClearDirtyBits(nsIContent* aContent) -{ -} - -void -ServoStyleSet::StyleDocument(bool aLeaveDirtyBits) -{ -} - -void -ServoStyleSet::StyleNewSubtree(nsIContent* aContent) -{ -} - -void -ServoStyleSet::StyleNewChildren(nsIContent* aParent) -{ -} diff --git a/layout/style/ServoStyleSet.h b/layout/style/ServoStyleSet.h deleted file mode 100644 index eacb837..0000000 --- a/layout/style/ServoStyleSet.h +++ /dev/null @@ -1,174 +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_ServoStyleSet_h -#define mozilla_ServoStyleSet_h - -#include "mozilla/EnumeratedArray.h" -#include "mozilla/EventStates.h" -#include "mozilla/ServoBindingTypes.h" -#include "mozilla/ServoElementSnapshot.h" -#include "mozilla/StyleSheetInlines.h" -#include "mozilla/SheetType.h" -#include "mozilla/UniquePtr.h" -#include "nsCSSPseudoElements.h" -#include "nsChangeHint.h" -#include "nsIAtom.h" -#include "nsTArray.h" - -namespace mozilla { -namespace dom { -class Element; -} // namespace dom -class CSSStyleSheet; -class ServoRestyleManager; -class ServoStyleSheet; -} // namespace mozilla -class nsIDocument; -class nsStyleContext; -class nsPresContext; -struct TreeMatchContext; - -namespace mozilla { - -/** - * The set of style sheets that apply to a document, backed by a Servo - * Stylist. A ServoStyleSet contains ServoStyleSheets. - */ -class ServoStyleSet -{ - friend class ServoRestyleManager; -public: - ServoStyleSet(); - - void Init(nsPresContext* aPresContext); - void BeginShutdown(); - void Shutdown(); - - bool GetAuthorStyleDisabled() const; - nsresult SetAuthorStyleDisabled(bool aStyleDisabled); - - void BeginUpdate(); - nsresult EndUpdate(); - - already_AddRefed - ResolveStyleFor(dom::Element* aElement, - nsStyleContext* aParentContext); - - already_AddRefed - ResolveStyleFor(dom::Element* aElement, - nsStyleContext* aParentContext, - TreeMatchContext& aTreeMatchContext); - - already_AddRefed - ResolveStyleForText(nsIContent* aTextNode, - nsStyleContext* aParentContext); - - already_AddRefed - ResolveStyleForOtherNonElement(nsStyleContext* aParentContext); - - already_AddRefed - ResolvePseudoElementStyle(dom::Element* aParentElement, - mozilla::CSSPseudoElementType aType, - nsStyleContext* aParentContext, - dom::Element* aPseudoElement); - - // aFlags is an nsStyleSet flags bitfield - already_AddRefed - ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext, - uint32_t aFlags = 0); - - // manage the set of style sheets in the style set - nsresult AppendStyleSheet(SheetType aType, ServoStyleSheet* aSheet); - nsresult PrependStyleSheet(SheetType aType, ServoStyleSheet* aSheet); - nsresult RemoveStyleSheet(SheetType aType, ServoStyleSheet* aSheet); - nsresult ReplaceSheets(SheetType aType, - const nsTArray>& aNewSheets); - nsresult InsertStyleSheetBefore(SheetType aType, - ServoStyleSheet* aNewSheet, - ServoStyleSheet* aReferenceSheet); - - int32_t SheetCount(SheetType aType) const; - ServoStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const; - - nsresult RemoveDocStyleSheet(ServoStyleSheet* aSheet); - nsresult AddDocStyleSheet(ServoStyleSheet* aSheet, nsIDocument* aDocument); - - // check whether there is ::before/::after style for an element - already_AddRefed - ProbePseudoElementStyle(dom::Element* aParentElement, - mozilla::CSSPseudoElementType aType, - nsStyleContext* aParentContext); - - already_AddRefed - ProbePseudoElementStyle(dom::Element* aParentElement, - mozilla::CSSPseudoElementType aType, - nsStyleContext* aParentContext, - TreeMatchContext& aTreeMatchContext, - dom::Element* aPseudoElement = nullptr); - - // Test if style is dependent on content state - nsRestyleHint HasStateDependentStyle(dom::Element* aElement, - EventStates aStateMask); - nsRestyleHint HasStateDependentStyle( - dom::Element* aElement, mozilla::CSSPseudoElementType aPseudoType, - dom::Element* aPseudoElement, EventStates aStateMask); - - /** - * Computes a restyle hint given a element and a previous element snapshot. - */ - nsRestyleHint ComputeRestyleHint(dom::Element* aElement, - ServoElementSnapshot* aSnapshot); - - /** - * Performs a Servo traversal to compute style for all dirty nodes in the - * document. The root element must be non-null. - * - * If aLeaveDirtyBits is true, the dirty/dirty-descendant bits are not - * cleared. - */ - void StyleDocument(bool aLeaveDirtyBits); - - /** - * Eagerly styles a subtree of dirty nodes that were just appended to the - * tree. This is used in situations where we need the style immediately and - * cannot wait for a future batch restyle. - * - * The subtree must have the root dirty bit set, which currently gets - * propagated to all descendants. The dirty bits are cleared before - * returning. - */ - void StyleNewSubtree(nsIContent* aContent); - - /** - * Like the above, but does not assume that the root node is dirty. When - * appending multiple children to a potentially-non-dirty node, it's - * preferable to call StyleNewChildren on the node rather than making multiple - * calls to StyleNewSubtree on each child, since it allows for more - * parallelism. - */ - void StyleNewChildren(nsIContent* aParent); - -private: - already_AddRefed GetContext(already_AddRefed, - nsStyleContext* aParentContext, - nsIAtom* aPseudoTag, - CSSPseudoElementType aPseudoType); - - already_AddRefed GetContext(nsIContent* aContent, - nsStyleContext* aParentContext, - nsIAtom* aPseudoTag, - CSSPseudoElementType aPseudoType); - - nsPresContext* mPresContext; - UniquePtr mRawSet; - EnumeratedArray>> mSheets; - int32_t mBatching; -}; - -} // namespace mozilla - -#endif // mozilla_ServoStyleSet_h diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp deleted file mode 100644 index daec2f8..0000000 --- a/layout/style/ServoStyleSheet.cpp +++ /dev/null @@ -1,114 +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 "ServoBindings.h" -#include "mozilla/ServoStyleSheet.h" -#include "CSSRuleList.h" - -using namespace mozilla::dom; - -namespace mozilla { - -ServoStyleSheet::ServoStyleSheet(css::SheetParsingMode aParsingMode, - CORSMode aCORSMode, - net::ReferrerPolicy aReferrerPolicy, - const dom::SRIMetadata& aIntegrity) - : StyleSheet(aParsingMode) - , mSheetInfo(aCORSMode, aReferrerPolicy, aIntegrity) -{ -} - -ServoStyleSheet::~ServoStyleSheet() -{ -} - -bool -ServoStyleSheet::HasRules() const -{ - return false; -} - -void -ServoStyleSheet::SetAssociatedDocument(nsIDocument* aDocument, - DocumentAssociationMode aAssociationMode) -{ -} - -ServoStyleSheet* -ServoStyleSheet::GetParentSheet() const -{ - return nullptr; -} - -void -ServoStyleSheet::AppendStyleSheet(ServoStyleSheet* aSheet) -{ -} - -nsresult -ServoStyleSheet::ParseSheet(const nsAString& aInput, - nsIURI* aSheetURI, - nsIURI* aBaseURI, - nsIPrincipal* aSheetPrincipal, - uint32_t aLineNumber) -{ - return NS_OK; -} - -void -ServoStyleSheet::LoadFailed() -{ -} - -void -ServoStyleSheet::DropSheet() -{ -} - -size_t -ServoStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const -{ - return 0; -} - -#ifdef DEBUG -void -ServoStyleSheet::List(FILE* aOut, int32_t aIndex) const -{ - MOZ_CRASH("stylo: not implemented"); -} -#endif - -nsMediaList* -ServoStyleSheet::Media() -{ - return nullptr; -} - -nsIDOMCSSRule* -ServoStyleSheet::GetDOMOwnerRule() const -{ - return nullptr; -} - -CSSRuleList* -ServoStyleSheet::GetCssRulesInternal(ErrorResult& aRv) -{ - return nullptr; -} - -uint32_t -ServoStyleSheet::InsertRuleInternal(const nsAString& aRule, - uint32_t aIndex, ErrorResult& aRv) -{ - return 0; -} - -void -ServoStyleSheet::DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv) -{ -} - -} // namespace mozilla diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h deleted file mode 100644 index 8c3b888..0000000 --- a/layout/style/ServoStyleSheet.h +++ /dev/null @@ -1,90 +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_ServoStyleSheet_h -#define mozilla_ServoStyleSheet_h - -#include "mozilla/dom/SRIMetadata.h" -#include "mozilla/RefPtr.h" -#include "mozilla/ServoBindingTypes.h" -#include "mozilla/StyleSheet.h" -#include "mozilla/StyleSheetInfo.h" -#include "nsStringFwd.h" - -namespace mozilla { - -/** - * CSS style sheet object that is a wrapper for a Servo Stylesheet. - */ -class ServoStyleSheet : public StyleSheet -{ -public: - ServoStyleSheet(css::SheetParsingMode aParsingMode, - CORSMode aCORSMode, - net::ReferrerPolicy aReferrerPolicy, - const dom::SRIMetadata& aIntegrity); - - bool HasRules() const; - - void SetAssociatedDocument(nsIDocument* aDocument, - DocumentAssociationMode aAssociationMode); - - ServoStyleSheet* GetParentSheet() const; - void AppendStyleSheet(ServoStyleSheet* aSheet); - - [[nodiscard]] nsresult ParseSheet(const nsAString& aInput, - nsIURI* aSheetURI, - nsIURI* aBaseURI, - nsIPrincipal* aSheetPrincipal, - uint32_t aLineNumber); - - /** - * Called instead of ParseSheet to initialize the Servo stylesheet object - * for a failed load. Either ParseSheet or LoadFailed must be called before - * adding a ServoStyleSheet to a ServoStyleSet. - */ - void LoadFailed(); - - size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; - -#ifdef DEBUG - void List(FILE* aOut = stdout, int32_t aIndex = 0) const; -#endif - - RawServoStyleSheet* RawSheet() const { return mSheet; } - - // WebIDL StyleSheet API - nsMediaList* Media() final; - - // WebIDL CSSStyleSheet API - // Can't be inline because we can't include ImportRule here. And can't be - // called GetOwnerRule because that would be ambiguous with the ImportRule - // version. - nsIDOMCSSRule* GetDOMOwnerRule() const final; - - void WillDirty() {} - void DidDirty() {} - -protected: - virtual ~ServoStyleSheet(); - - // Internal methods which do not have security check and completeness check. - dom::CSSRuleList* GetCssRulesInternal(ErrorResult& aRv); - uint32_t InsertRuleInternal(const nsAString& aRule, - uint32_t aIndex, ErrorResult& aRv); - void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv); - -private: - void DropSheet(); - - RefPtr mSheet; - StyleSheetInfo mSheetInfo; - - friend class StyleSheet; -}; - -} // namespace mozilla - -#endif // mozilla_ServoStyleSheet_h diff --git a/layout/style/ServoTypes.h b/layout/style/ServoTypes.h deleted file mode 100644 index 8bfed9b..0000000 --- a/layout/style/ServoTypes.h +++ /dev/null @@ -1,39 +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_ServoTypes_h -#define mozilla_ServoTypes_h - -/* - * Type definitions used to interact with Servo. This gets included by nsINode, - * so don't add significant include dependencies to this file. - */ - -struct ServoNodeData; -namespace mozilla { - -/* - * Replaced types. These get mapped to associated Servo types in bindgen. - */ - -template -struct ServoUnsafeCell { - T value; - - // Ensure that primitive types (i.e. pointers) get zero-initialized. - ServoUnsafeCell() : value() {}; -}; - -template -struct ServoCell { - ServoUnsafeCell value; - T Get() const { return value.value; } - void Set(T arg) { value.value = arg; } - ServoCell() : value() {}; -}; - -} // namespace mozilla - -#endif // mozilla_ServoTypes_h diff --git a/layout/style/ServoUtils.h b/layout/style/ServoUtils.h deleted file mode 100644 index 7be775c..0000000 --- a/layout/style/ServoUtils.h +++ /dev/null @@ -1,34 +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/. */ - -/* some utilities for stylo */ - -#ifndef mozilla_ServoUtils_h -#define mozilla_ServoUtils_h - -#include "mozilla/TypeTraits.h" - -/** - * Macro used in a base class of |geckotype_| and |servotype_|. - * The class should define |StyleBackendType mType;| itself. - */ -#define MOZ_DECL_STYLO_METHODS(geckotype_) \ - inline geckotype_* AsGecko(); \ - inline const geckotype_* AsGecko() const; - -/** - * Macro used in inline header of class |type_| with its Gecko and Servo - * subclasses named |geckotype_| and |servotype_| correspondingly for - * implementing the inline methods defined by MOZ_DECL_STYLO_METHODS. - */ -#define MOZ_DEFINE_STYLO_METHODS(type_, geckotype_) \ - geckotype_* type_::AsGecko() { \ - return static_cast(this); \ - } \ - const geckotype_* type_::AsGecko() const { \ - return static_cast(this); \ - } - -#endif // mozilla_ServoUtils_h diff --git a/layout/style/StyleContextSource.h b/layout/style/StyleContextSource.h index c9046f9..9af2ebe 100644 --- a/layout/style/StyleContextSource.h +++ b/layout/style/StyleContextSource.h @@ -6,12 +6,12 @@ #ifndef mozilla_StyleContextSource_h #define mozilla_StyleContextSource_h -#include "mozilla/ServoBindingTypes.h" #include "nsRuleNode.h" namespace mozilla { -// Tagged union between Gecko Rule Nodes and Servo Computed Values. +// Temporary holder of Gecko Rule Nodes. +// TODO: This struct is marked for removal. // // The rule node is the node in the lexicographic tree of rule nodes // (the "rule tree") that indicates which style rules are used to @@ -19,21 +19,14 @@ namespace mozilla { // specific rule matched is the one whose rule node is a child of the // root of the rule tree, and the most specific rule matched is the // |mRule| member of the rule node. -// -// In the Servo case, we hold an atomically-refcounted handle to a -// Servo ComputedValues struct, which is more or less the Servo equivalent -// of an nsStyleContext. // Underlying pointer without any strong ownership semantics. struct NonOwningStyleContextSource { MOZ_IMPLICIT NonOwningStyleContextSource(nsRuleNode* aRuleNode) : mBits(reinterpret_cast(aRuleNode)) {} - explicit NonOwningStyleContextSource(const ServoComputedValues* aComputedValues) - : mBits(reinterpret_cast(aComputedValues) | 1) {} bool operator==(const NonOwningStyleContextSource& aOther) const { - // TODO: remove this servo-specific function. return mBits == aOther.mBits; } bool operator!=(const NonOwningStyleContextSource& aOther) const { @@ -65,13 +58,6 @@ struct OwningStyleContextSource MOZ_ASSERT(!mRaw.IsNull()); }; - explicit OwningStyleContextSource(already_AddRefed aComputedValues) - : mRaw(aComputedValues.take()) - { - MOZ_COUNT_CTOR(OwningStyleContextSource); - MOZ_ASSERT(!mRaw.IsNull()); - } - OwningStyleContextSource(OwningStyleContextSource&& aOther) : mRaw(aOther.mRaw) { diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 9af37c4..fcf23b8 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -8,7 +8,6 @@ #include "mozilla/dom/BindingDeclarations.h" // for Optional<> #include "mozilla/dom/CSSRuleList.h" #include "mozilla/dom/ShadowRoot.h" -#include "mozilla/ServoStyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/CSSStyleSheet.h" diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index 94ff05c..cf03b51 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -10,7 +10,7 @@ #include "mozilla/dom/CSSStyleSheetBinding.h" #include "mozilla/net/ReferrerPolicy.h" #include "mozilla/CORSMode.h" -#include "mozilla/ServoUtils.h" +#include "mozilla/DeprecatedUtils.h" #include "nsIDOMCSSStyleSheet.h" #include "nsWrapperCache.h" @@ -23,7 +23,6 @@ class nsMediaList; namespace mozilla { class CSSStyleSheet; -class ServoStyleSheet; struct StyleSheetInfo; namespace dom { @@ -32,7 +31,7 @@ class SRIMetadata; } // namespace dom /** - * Superclass for data common to CSSStyleSheet and ServoStyleSheet. + * Superclass for CSSStyleSheet. */ class StyleSheet : public nsIDOMCSSStyleSheet , public nsWrapperCache @@ -65,7 +64,7 @@ public: bool IsComplete() const; void SetComplete(); - MOZ_DECL_STYLO_METHODS(CSSStyleSheet) + MOZ_DECL_DEPRECATED_METHODS(CSSStyleSheet) // Whether the sheet is for an inline