Loading layout/base/nsDocumentViewer.cpp +18 −35 Original line number Diff line number Diff line Loading @@ -318,6 +318,8 @@ class nsDocumentViewer final : public nsIContentViewer, // nsIDocumentViewerPrint Printing Methods NS_DECL_NSIDOCUMENTVIEWERPRINT void EmulateMediumInternal(nsAtom*); protected: virtual ~nsDocumentViewer(); Loading Loading @@ -2957,61 +2959,42 @@ nsDocumentViewer::GetAuthorStyleDisabled(bool* aStyleDisabled) { } static bool ExtResourceEmulateMedium(Document* aDocument, void* aClosure) { nsPresContext* ctxt = aDocument->GetPresContext(); if (ctxt) { const nsAString* mediaType = static_cast<nsAString*>(aClosure); ctxt->EmulateMedium(*mediaType); if (nsPresContext* pc = aDocument->GetPresContext()) { pc->EmulateMedium(static_cast<nsAtom*>(aClosure)); } return true; } static void ChildEmulateMedium(nsDocumentViewer* aChild, void* aClosure) { const nsAString* mediaType = static_cast<nsAString*>(aClosure); aChild->EmulateMedium(*mediaType); aChild->EmulateMediumInternal(static_cast<nsAtom*>(aClosure)); } NS_IMETHODIMP nsDocumentViewer::EmulateMedium(const nsAString& aMediaType) { void nsDocumentViewer::EmulateMediumInternal(nsAtom* aMedia) { if (mPresContext) { mPresContext->EmulateMedium(aMediaType); mPresContext->EmulateMedium(aMedia); } CallChildren(ChildEmulateMedium, const_cast<nsAString*>(&aMediaType)); if (mDocument) { mDocument->EnumerateExternalResources(ExtResourceEmulateMedium, const_cast<nsAString*>(&aMediaType)); } CallChildren(ChildEmulateMedium, aMedia); return NS_OK; if (mDocument) { mDocument->EnumerateExternalResources(ExtResourceEmulateMedium, aMedia); } static bool ExtResourceStopEmulatingMedium(Document* aDocument, void* aClosure) { nsPresContext* ctxt = aDocument->GetPresContext(); if (ctxt) { ctxt->StopEmulatingMedium(); } return true; } NS_IMETHODIMP nsDocumentViewer::EmulateMedium(const nsAString& aMediaType) { nsAutoString mediaType; nsContentUtils::ASCIIToLower(aMediaType, mediaType); RefPtr<nsAtom> media = NS_Atomize(mediaType); static void ChildStopEmulatingMedium(nsIContentViewer* aChild, void* aClosure) { aChild->StopEmulatingMedium(); EmulateMediumInternal(media); return NS_OK; } NS_IMETHODIMP nsDocumentViewer::StopEmulatingMedium() { if (mPresContext) { mPresContext->StopEmulatingMedium(); } CallChildren(ChildStopEmulatingMedium, nullptr); if (mDocument) { mDocument->EnumerateExternalResources(ExtResourceStopEmulatingMedium, nullptr); } EmulateMediumInternal(nullptr); return NS_OK; } Loading layout/base/nsPresContext.cpp +4 −18 Original line number Diff line number Diff line Loading @@ -144,7 +144,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType) mPresShell(nullptr), mDocument(aDocument), mMedium(aType == eContext_Galley ? nsGkAtoms::screen : nsGkAtoms::print), mMediaEmulated(mMedium), mInflationDisabledForShrinkWrap(false), mSystemFontScale(1.0), mTextZoom(1.0), Loading Loading @@ -186,7 +185,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType) mPendingUIResolutionChanged(false), mPrefChangePendingNeedsReflow(false), mPostedPrefChangedRunnable(false), mIsEmulatingMedia(false), mIsGlyph(false), mUsesRootEMUnits(false), mUsesExChUnits(false), Loading Loading @@ -1423,27 +1421,15 @@ void nsPresContext::UIResolutionChangedInternalScale(double aScale) { &aScale); } void nsPresContext::EmulateMedium(const nsAString& aMediaType) { nsAtom* previousMedium = Medium(); mIsEmulatingMedia = true; nsAutoString mediaType; nsContentUtils::ASCIIToLower(aMediaType, mediaType); mMediaEmulated = NS_Atomize(mediaType); void nsPresContext::EmulateMedium(nsAtom* aMediaType) { MOZ_ASSERT(!aMediaType || aMediaType->IsAsciiLowercase()); RefPtr<const nsAtom> previousMedium = Medium(); mMediaEmulated = aMediaType; if (mMediaEmulated != previousMedium && mPresShell) { MediaFeatureValuesChanged({MediaFeatureChangeReason::MediumChange}); } } void nsPresContext::StopEmulatingMedium() { nsAtom* previousMedium = Medium(); mIsEmulatingMedia = false; if (Medium() != previousMedium) { MediaFeatureValuesChanged({MediaFeatureChangeReason::MediumChange}); } } void nsPresContext::ContentLanguageChanged() { PostRebuildAllStyleDataEvent(nsChangeHint(0), RestyleHint::RecascadeSubtree()); Loading layout/base/nsPresContext.h +7 −12 Original line number Diff line number Diff line Loading @@ -303,21 +303,18 @@ class nsPresContext : public nsISupports, /** * Get medium of presentation */ nsAtom* Medium() { if (!mIsEmulatingMedia) return mMedium; return mMediaEmulated; const nsAtom* Medium() { MOZ_ASSERT(mMedium); return mMediaEmulated ? mMediaEmulated.get() : mMedium; } /* * Render the document as if being viewed on a device with the specified * media type. * * If passed null, it stops emulating. */ void EmulateMedium(const nsAString& aMediaType); /* * Restore the viewer's natural medium */ void StopEmulatingMedium(); void EmulateMedium(nsAtom* aMediaType); /** Get a cached integer pref, by its type */ // * - initially created for bugs 30910, 61883, 74186, 84398 Loading Loading @@ -1119,8 +1116,7 @@ class nsPresContext : public nsISupports, mozilla::UniquePtr<nsAnimationManager> mAnimationManager; mozilla::UniquePtr<mozilla::RestyleManager> mRestyleManager; RefPtr<mozilla::CounterStyleManager> mCounterStyleManager; nsAtom* MOZ_UNSAFE_REF( "always a static atom") mMedium; // initialized by subclass ctors const nsStaticAtom* mMedium; RefPtr<nsAtom> mMediaEmulated; RefPtr<gfxFontFeatureValueSet> mFontFeatureValuesLookup; Loading Loading @@ -1221,7 +1217,6 @@ class nsPresContext : public nsISupports, unsigned mPendingUIResolutionChanged : 1; unsigned mPrefChangePendingNeedsReflow : 1; unsigned mPostedPrefChangedRunnable : 1; unsigned mIsEmulatingMedia : 1; // Are we currently drawing an SVG glyph? unsigned mIsGlyph : 1; Loading servo/components/style/gecko/media_queries.rs +3 −4 Original line number Diff line number Diff line Loading @@ -213,12 +213,11 @@ impl Device { None => return MediaType::screen(), }; // Gecko allows emulating random media with mIsEmulatingMedia and // mMediaEmulated. let medium_to_use = if pc.mIsEmulatingMedia() != 0 { // Gecko allows emulating random media with mMediaEmulated. let medium_to_use = if !pc.mMediaEmulated.mRawPtr.is_null() { pc.mMediaEmulated.mRawPtr } else { pc.mMedium pc.mMedium as *const bindings::nsAtom as *mut _ }; MediaType(CustomIdent(unsafe { Atom::from_raw(medium_to_use) })) Loading Loading
layout/base/nsDocumentViewer.cpp +18 −35 Original line number Diff line number Diff line Loading @@ -318,6 +318,8 @@ class nsDocumentViewer final : public nsIContentViewer, // nsIDocumentViewerPrint Printing Methods NS_DECL_NSIDOCUMENTVIEWERPRINT void EmulateMediumInternal(nsAtom*); protected: virtual ~nsDocumentViewer(); Loading Loading @@ -2957,61 +2959,42 @@ nsDocumentViewer::GetAuthorStyleDisabled(bool* aStyleDisabled) { } static bool ExtResourceEmulateMedium(Document* aDocument, void* aClosure) { nsPresContext* ctxt = aDocument->GetPresContext(); if (ctxt) { const nsAString* mediaType = static_cast<nsAString*>(aClosure); ctxt->EmulateMedium(*mediaType); if (nsPresContext* pc = aDocument->GetPresContext()) { pc->EmulateMedium(static_cast<nsAtom*>(aClosure)); } return true; } static void ChildEmulateMedium(nsDocumentViewer* aChild, void* aClosure) { const nsAString* mediaType = static_cast<nsAString*>(aClosure); aChild->EmulateMedium(*mediaType); aChild->EmulateMediumInternal(static_cast<nsAtom*>(aClosure)); } NS_IMETHODIMP nsDocumentViewer::EmulateMedium(const nsAString& aMediaType) { void nsDocumentViewer::EmulateMediumInternal(nsAtom* aMedia) { if (mPresContext) { mPresContext->EmulateMedium(aMediaType); mPresContext->EmulateMedium(aMedia); } CallChildren(ChildEmulateMedium, const_cast<nsAString*>(&aMediaType)); if (mDocument) { mDocument->EnumerateExternalResources(ExtResourceEmulateMedium, const_cast<nsAString*>(&aMediaType)); } CallChildren(ChildEmulateMedium, aMedia); return NS_OK; if (mDocument) { mDocument->EnumerateExternalResources(ExtResourceEmulateMedium, aMedia); } static bool ExtResourceStopEmulatingMedium(Document* aDocument, void* aClosure) { nsPresContext* ctxt = aDocument->GetPresContext(); if (ctxt) { ctxt->StopEmulatingMedium(); } return true; } NS_IMETHODIMP nsDocumentViewer::EmulateMedium(const nsAString& aMediaType) { nsAutoString mediaType; nsContentUtils::ASCIIToLower(aMediaType, mediaType); RefPtr<nsAtom> media = NS_Atomize(mediaType); static void ChildStopEmulatingMedium(nsIContentViewer* aChild, void* aClosure) { aChild->StopEmulatingMedium(); EmulateMediumInternal(media); return NS_OK; } NS_IMETHODIMP nsDocumentViewer::StopEmulatingMedium() { if (mPresContext) { mPresContext->StopEmulatingMedium(); } CallChildren(ChildStopEmulatingMedium, nullptr); if (mDocument) { mDocument->EnumerateExternalResources(ExtResourceStopEmulatingMedium, nullptr); } EmulateMediumInternal(nullptr); return NS_OK; } Loading
layout/base/nsPresContext.cpp +4 −18 Original line number Diff line number Diff line Loading @@ -144,7 +144,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType) mPresShell(nullptr), mDocument(aDocument), mMedium(aType == eContext_Galley ? nsGkAtoms::screen : nsGkAtoms::print), mMediaEmulated(mMedium), mInflationDisabledForShrinkWrap(false), mSystemFontScale(1.0), mTextZoom(1.0), Loading Loading @@ -186,7 +185,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType) mPendingUIResolutionChanged(false), mPrefChangePendingNeedsReflow(false), mPostedPrefChangedRunnable(false), mIsEmulatingMedia(false), mIsGlyph(false), mUsesRootEMUnits(false), mUsesExChUnits(false), Loading Loading @@ -1423,27 +1421,15 @@ void nsPresContext::UIResolutionChangedInternalScale(double aScale) { &aScale); } void nsPresContext::EmulateMedium(const nsAString& aMediaType) { nsAtom* previousMedium = Medium(); mIsEmulatingMedia = true; nsAutoString mediaType; nsContentUtils::ASCIIToLower(aMediaType, mediaType); mMediaEmulated = NS_Atomize(mediaType); void nsPresContext::EmulateMedium(nsAtom* aMediaType) { MOZ_ASSERT(!aMediaType || aMediaType->IsAsciiLowercase()); RefPtr<const nsAtom> previousMedium = Medium(); mMediaEmulated = aMediaType; if (mMediaEmulated != previousMedium && mPresShell) { MediaFeatureValuesChanged({MediaFeatureChangeReason::MediumChange}); } } void nsPresContext::StopEmulatingMedium() { nsAtom* previousMedium = Medium(); mIsEmulatingMedia = false; if (Medium() != previousMedium) { MediaFeatureValuesChanged({MediaFeatureChangeReason::MediumChange}); } } void nsPresContext::ContentLanguageChanged() { PostRebuildAllStyleDataEvent(nsChangeHint(0), RestyleHint::RecascadeSubtree()); Loading
layout/base/nsPresContext.h +7 −12 Original line number Diff line number Diff line Loading @@ -303,21 +303,18 @@ class nsPresContext : public nsISupports, /** * Get medium of presentation */ nsAtom* Medium() { if (!mIsEmulatingMedia) return mMedium; return mMediaEmulated; const nsAtom* Medium() { MOZ_ASSERT(mMedium); return mMediaEmulated ? mMediaEmulated.get() : mMedium; } /* * Render the document as if being viewed on a device with the specified * media type. * * If passed null, it stops emulating. */ void EmulateMedium(const nsAString& aMediaType); /* * Restore the viewer's natural medium */ void StopEmulatingMedium(); void EmulateMedium(nsAtom* aMediaType); /** Get a cached integer pref, by its type */ // * - initially created for bugs 30910, 61883, 74186, 84398 Loading Loading @@ -1119,8 +1116,7 @@ class nsPresContext : public nsISupports, mozilla::UniquePtr<nsAnimationManager> mAnimationManager; mozilla::UniquePtr<mozilla::RestyleManager> mRestyleManager; RefPtr<mozilla::CounterStyleManager> mCounterStyleManager; nsAtom* MOZ_UNSAFE_REF( "always a static atom") mMedium; // initialized by subclass ctors const nsStaticAtom* mMedium; RefPtr<nsAtom> mMediaEmulated; RefPtr<gfxFontFeatureValueSet> mFontFeatureValuesLookup; Loading Loading @@ -1221,7 +1217,6 @@ class nsPresContext : public nsISupports, unsigned mPendingUIResolutionChanged : 1; unsigned mPrefChangePendingNeedsReflow : 1; unsigned mPostedPrefChangedRunnable : 1; unsigned mIsEmulatingMedia : 1; // Are we currently drawing an SVG glyph? unsigned mIsGlyph : 1; Loading
servo/components/style/gecko/media_queries.rs +3 −4 Original line number Diff line number Diff line Loading @@ -213,12 +213,11 @@ impl Device { None => return MediaType::screen(), }; // Gecko allows emulating random media with mIsEmulatingMedia and // mMediaEmulated. let medium_to_use = if pc.mIsEmulatingMedia() != 0 { // Gecko allows emulating random media with mMediaEmulated. let medium_to_use = if !pc.mMediaEmulated.mRawPtr.is_null() { pc.mMediaEmulated.mRawPtr } else { pc.mMedium pc.mMedium as *const bindings::nsAtom as *mut _ }; MediaType(CustomIdent(unsafe { Atom::from_raw(medium_to_use) })) Loading