зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1285474: Decide style system backend type for documents earlier. r=bholley
MozReview-Commit-ID: 7A4t3957CWe
This commit is contained in:
Родитель
474ff66ca4
Коммит
acd21d26c0
|
@ -13653,14 +13653,27 @@ nsIDocument::ReportHasScrollLinkedEffect()
|
|||
"ScrollLinkedEffectFound2");
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType
|
||||
nsIDocument::GetStyleBackendType() const
|
||||
void
|
||||
nsIDocument::UpdateStyleBackendType()
|
||||
{
|
||||
if (!mPresShell) {
|
||||
MOZ_ASSERT(mStyleBackendType == StyleBackendType(0),
|
||||
"no need to call UpdateStyleBackendType now");
|
||||
#ifdef MOZ_STYLO
|
||||
NS_WARNING("GetStyleBackendType() called on document without a pres shell");
|
||||
// XXX For now we use a Servo-backed style set only for (X)HTML documents
|
||||
// in content docshells. This should let us avoid implementing XUL-specific
|
||||
// CSS features. And apart from not supporting SVG properties in Servo
|
||||
// yet, the root SVG element likes to create a style sheet for an SVG
|
||||
// document before we have a pres shell (i.e. before we make the decision
|
||||
// here about whether to use a Gecko- or Servo-backed style system), so
|
||||
// we avoid Servo-backed style sets for SVG documents.
|
||||
NS_ASSERTION(mDocumentContainer, "stylo: calling UpdateStyleBackendType "
|
||||
"before we have a docshell");
|
||||
mStyleBackendType =
|
||||
nsLayoutUtils::SupportsServoStyleBackend(this) &&
|
||||
mDocumentContainer ?
|
||||
StyleBackendType::Servo :
|
||||
StyleBackendType::Gecko;
|
||||
#else
|
||||
mStyleBackendType = StyleBackendType::Gecko;
|
||||
#endif
|
||||
return StyleBackendType::Gecko;
|
||||
}
|
||||
return mPresShell->StyleSet()->BackendType();
|
||||
}
|
||||
|
|
|
@ -1080,7 +1080,15 @@ public:
|
|||
return mCSSLoader;
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType GetStyleBackendType() const;
|
||||
mozilla::StyleBackendType GetStyleBackendType() const {
|
||||
if (mStyleBackendType == mozilla::StyleBackendType(0)) {
|
||||
const_cast<nsIDocument*>(this)->UpdateStyleBackendType();
|
||||
}
|
||||
MOZ_ASSERT(mStyleBackendType != mozilla::StyleBackendType(0));
|
||||
return mStyleBackendType;
|
||||
}
|
||||
|
||||
void UpdateStyleBackendType();
|
||||
|
||||
bool IsStyledByServo() const {
|
||||
return GetStyleBackendType() == mozilla::StyleBackendType::Servo;
|
||||
|
@ -2916,6 +2924,10 @@ protected:
|
|||
// Our visibility state
|
||||
mozilla::dom::VisibilityState mVisibilityState;
|
||||
|
||||
// Whether this document has (or will have, once we have a pres shell) a
|
||||
// Gecko- or Servo-backed style system.
|
||||
mozilla::StyleBackendType mStyleBackendType;
|
||||
|
||||
// True if BIDI is enabled.
|
||||
bool mBidiEnabled : 1;
|
||||
// True if a MathML element has ever been owned by this document.
|
||||
|
|
|
@ -2165,27 +2165,6 @@ nsDocumentViewer::RequestWindowClose(bool* aCanClose)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static StyleBackendType
|
||||
StyleBackendTypeForDocument(nsIDocument* aDocument, nsIDocShell* aContainer)
|
||||
{
|
||||
MOZ_ASSERT(aDocument);
|
||||
|
||||
// XXX For now we use a Servo-backed style set only for (X)HTML documents
|
||||
// in content docshells. This should let us avoid implementing XUL-specific
|
||||
// CSS features. And apart from not supporting SVG properties in Servo
|
||||
// yet, the root SVG element likes to create a style sheet for an SVG
|
||||
// document before we have a pres shell (i.e. before we make the decision
|
||||
// here about whether to use a Gecko- or Servo-backed style system), so
|
||||
// we avoid Servo-backed style sets for SVG documents.
|
||||
|
||||
return nsPresContext::StyloEnabled() &&
|
||||
aDocument->IsHTMLOrXHTML() &&
|
||||
aContainer &&
|
||||
aContainer->ItemType() == nsIDocShell::typeContent ?
|
||||
StyleBackendType::Servo :
|
||||
StyleBackendType::Gecko;
|
||||
}
|
||||
|
||||
StyleSetHandle
|
||||
nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
|
||||
{
|
||||
|
@ -2194,8 +2173,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
|
|||
// this should eventually get expanded to allow for creating
|
||||
// different sets for different media
|
||||
|
||||
StyleBackendType backendType =
|
||||
StyleBackendTypeForDocument(aDocument, mContainer);
|
||||
StyleBackendType backendType = aDocument->GetStyleBackendType();
|
||||
|
||||
StyleSetHandle styleSet;
|
||||
if (backendType == StyleBackendType::Gecko) {
|
||||
|
|
|
@ -9365,3 +9365,11 @@ nsLayoutUtils::GetCumulativeApzCallbackTransform(nsIFrame* aFrame)
|
|||
}
|
||||
return delta;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsLayoutUtils::SupportsServoStyleBackend(nsIDocument* aDocument)
|
||||
{
|
||||
return nsPresContext::StyloEnabled() &&
|
||||
aDocument->IsHTMLOrXHTML() &&
|
||||
static_cast<nsDocument*>(aDocument)->IsContentDocument();
|
||||
}
|
||||
|
|
|
@ -2854,6 +2854,14 @@ public:
|
|||
*/
|
||||
static CSSPoint GetCumulativeApzCallbackTransform(nsIFrame* aFrame);
|
||||
|
||||
/*
|
||||
* Returns whether the given document supports being rendered with a
|
||||
* Servo-backed style system. This checks whether Stylo is enabled
|
||||
* globally, that the document is an HTML document, and that it is
|
||||
* being presented in a content docshell.
|
||||
*/
|
||||
static bool SupportsServoStyleBackend(nsIDocument* aDocument);
|
||||
|
||||
private:
|
||||
static uint32_t sFontSizeInflationEmPerLine;
|
||||
static uint32_t sFontSizeInflationMinTwips;
|
||||
|
|
|
@ -201,19 +201,6 @@ public:
|
|||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Loader)
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(Loader)
|
||||
|
||||
/**
|
||||
* Returns the StyleBackendType that will be used for style sheets created
|
||||
* by this Loader. If SetStyleBackendType has been called, that value
|
||||
* will be returned by GetStyleBackendType. For Loaders created with the
|
||||
* nsIDocument* constructor and which haven't had SetStyleBackendType
|
||||
* called on them, the document's StyleBackendType will be returned.
|
||||
*/
|
||||
StyleBackendType GetStyleBackendType() const;
|
||||
|
||||
void SetStyleBackendType(StyleBackendType aType) {
|
||||
mStyleBackendType = Some(aType);
|
||||
}
|
||||
|
||||
void DropDocumentReference(); // notification that doc is going away
|
||||
|
||||
void SetCompatibilityMode(nsCompatibility aCompatMode)
|
||||
|
@ -552,6 +539,8 @@ private:
|
|||
void DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
|
||||
LoadDataArray& aDatasToNotify);
|
||||
|
||||
StyleBackendType GetStyleBackendType() const;
|
||||
|
||||
struct Sheets {
|
||||
nsBaseHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey,
|
||||
StyleSheetHandle::RefPtr,
|
||||
|
@ -588,6 +577,8 @@ private:
|
|||
nsCompatibility mCompatMode;
|
||||
nsString mPreferredSheet; // title of preferred sheet
|
||||
|
||||
// Set explicitly when the Loader(StyleBackendType) constructor is used, or
|
||||
// taken from the document when the Loader(nsIDocument*) constructor is used.
|
||||
mozilla::Maybe<StyleBackendType> mStyleBackendType;
|
||||
|
||||
bool mEnabled; // is enabled to load new styles
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace mozilla {
|
|||
*/
|
||||
enum class StyleBackendType : int
|
||||
{
|
||||
Gecko,
|
||||
Gecko = 1,
|
||||
Servo
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче