--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -180,21 +180,17 @@ nsCoreUtils::GetAccessKeyFor(nsIContent*
{
// Accesskeys are registered by @accesskey attribute only. At first check
// whether it is presented on the given element to avoid the slow
// EventStateManager::GetRegisteredAccessKey() method.
if (!aContent->IsElement() ||
!aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::accesskey))
return 0;
- nsIPresShell* presShell = aContent->OwnerDoc()->GetShell();
- if (!presShell)
- return 0;
-
- nsPresContext *presContext = presShell->GetPresContext();
+ nsPresContext* presContext = aContent->OwnerDoc()->GetPresContext();
if (!presContext)
return 0;
EventStateManager *esm = presContext->EventStateManager();
if (!esm)
return 0;
return esm->GetRegisteredAccessKey(aContent->AsElement());
--- a/dom/animation/DocumentTimeline.cpp
+++ b/dom/animation/DocumentTimeline.cpp
@@ -257,22 +257,17 @@ DocumentTimeline::ToTimeStamp(const Time
result =
timing->GetNavigationStartTimeStamp() + (aTimeDuration + mOriginTime);
return result;
}
nsRefreshDriver*
DocumentTimeline::GetRefreshDriver() const
{
- nsIPresShell* presShell = mDocument->GetShell();
- if (MOZ_UNLIKELY(!presShell)) {
- return nullptr;
- }
-
- nsPresContext* presContext = presShell->GetPresContext();
+ nsPresContext* presContext = mDocument->GetPresContext();
if (MOZ_UNLIKELY(!presContext)) {
return nullptr;
}
return presContext->RefreshDriver();
}
void
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1946,25 +1946,22 @@ Element::UnbindFromTree(bool aDeep, bool
SetParentIsContent(false);
}
#ifdef DEBUG
// If we can get access to the PresContext, then we sanity-check that
// we're not leaving behind a pointer to ourselves as the PresContext's
// cached provider of the viewport's scrollbar styles.
if (document) {
- nsIPresShell* presShell = document->GetShell();
- if (presShell) {
- nsPresContext* presContext = presShell->GetPresContext();
- if (presContext) {
- MOZ_ASSERT(this !=
- presContext->GetViewportScrollbarStylesOverrideElement(),
- "Leaving behind a raw pointer to this element (as having "
- "propagated scrollbar styles) - that's dangerous...");
- }
+ nsPresContext* presContext = document->GetPresContext();
+ if (presContext) {
+ MOZ_ASSERT(this !=
+ presContext->GetViewportScrollbarStylesOverrideElement(),
+ "Leaving behind a raw pointer to this element (as having "
+ "propagated scrollbar styles) - that's dangerous...");
}
}
#endif
ClearInDocument();
// Ensure that CSS transitions don't continue on an element at a
// different place in the tree (even if reinserted before next
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -231,21 +231,17 @@ nsIContent::GetDesiredIMEState()
// This is in another editable content, use the result of it.
if (editableAncestor && editableAncestor != this) {
return editableAncestor->GetDesiredIMEState();
}
nsIDocument* doc = GetComposedDoc();
if (!doc) {
return IMEState(IMEState::DISABLED);
}
- nsIPresShell* ps = doc->GetShell();
- if (!ps) {
- return IMEState(IMEState::DISABLED);
- }
- nsPresContext* pc = ps->GetPresContext();
+ nsPresContext* pc = doc->GetPresContext();
if (!pc) {
return IMEState(IMEState::DISABLED);
}
HTMLEditor* htmlEditor = nsContentUtils::GetHTMLEditor(pc);
if (!htmlEditor) {
return IMEState(IMEState::DISABLED);
}
IMEState state;
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -843,19 +843,18 @@ Location::Reload(bool aForceget)
// resize event. Sites do this since Netscape 4.x needed it, but
// we don't, and it's a horrible experience for nothing. In stead
// of reloading the page, just clear style data and reflow the
// page since some sites may use this trick to work around gecko
// reflow bugs, and this should have the same effect.
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
- nsIPresShell *shell;
- nsPresContext *pcx;
- if (doc && (shell = doc->GetShell()) && (pcx = shell->GetPresContext())) {
+ nsPresContext* pcx;
+ if (doc && (pcx = doc->GetPresContext())) {
pcx->RebuildAllStyleData(NS_STYLE_HINT_REFLOW, eRestyle_Subtree);
}
return NS_OK;
}
if (!webNav) {
return NS_ERROR_FAILURE;
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -190,21 +190,18 @@ PostMessageEvent::DispatchError(JSContex
void
PostMessageEvent::Dispatch(nsGlobalWindowInner* aTargetWindow, Event* aEvent)
{
// We can't simply call dispatchEvent on the window because doing so ends
// up flipping the trusted bit on the event, and we don't want that to
// happen because then untrusted content can call postMessage on a chrome
// window if it can get a reference to it.
- nsIPresShell *shell = aTargetWindow->GetExtantDoc()->GetShell();
- RefPtr<nsPresContext> presContext;
- if (shell) {
- presContext = shell->GetPresContext();
- }
+ RefPtr<nsPresContext> presContext =
+ aTargetWindow->GetExtantDoc()->GetPresContext();
aEvent->SetTrusted(mTrustedCaller);
WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
nsEventStatus status = nsEventStatus_eIgnore;
EventDispatcher::Dispatch(aTargetWindow->AsInner(),
presContext,
internalEvent,
--- a/dom/base/ResponsiveImageSelector.cpp
+++ b/dom/base/ResponsiveImageSelector.cpp
@@ -373,18 +373,17 @@ ResponsiveImageSelector::SelectImage(boo
ClearSelectedCandidate();
int numCandidates = mCandidates.Length();
if (!numCandidates) {
return oldBest != -1;
}
nsIDocument* doc = Document();
- nsIPresShell* shell = doc->GetShell();
- nsPresContext* pctx = shell ? shell->GetPresContext() : nullptr;
+ nsPresContext* pctx = doc->GetPresContext();
nsCOMPtr<nsIURI> baseURI = mOwnerNode->GetBaseURI();
if (!pctx || !baseURI) {
return oldBest != -1;
}
double displayDensity = pctx->CSSPixelsToDevPixels(1.0f);
double overrideDPPX = pctx->GetOverrideDPPX();
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6717,21 +6717,18 @@ nsContentUtils::DispatchXULCommand(nsICo
bool aCtrl,
bool aAlt,
bool aShift,
bool aMeta,
uint16_t aInputSource)
{
NS_ENSURE_STATE(aTarget);
nsIDocument* doc = aTarget->OwnerDoc();
- nsIPresShell* shell = doc->GetShell();
- nsPresContext* presContext = nullptr;
- if (shell) {
- presContext = shell->GetPresContext();
- }
+ nsPresContext* presContext = doc->GetPresContext();
+
RefPtr<XULCommandEvent> xulCommand = new XULCommandEvent(doc, presContext,
nullptr);
xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"), true, true,
doc->GetInnerWindow(), 0, aCtrl, aAlt, aShift,
aMeta, aSourceEvent, aInputSource);
if (aShell) {
nsEventStatus status = nsEventStatus_eIgnore;
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -927,29 +927,21 @@ nsExternalResourceMap::ShowViewers()
void
TransferZoomLevels(nsIDocument* aFromDoc,
nsIDocument* aToDoc)
{
MOZ_ASSERT(aFromDoc && aToDoc,
"transferring zoom levels from/to null doc");
- nsIPresShell* fromShell = aFromDoc->GetShell();
- if (!fromShell)
- return;
-
- nsPresContext* fromCtxt = fromShell->GetPresContext();
+ nsPresContext* fromCtxt = aFromDoc->GetPresContext();
if (!fromCtxt)
return;
- nsIPresShell* toShell = aToDoc->GetShell();
- if (!toShell)
- return;
-
- nsPresContext* toCtxt = toShell->GetPresContext();
+ nsPresContext* toCtxt = aToDoc->GetPresContext();
if (!toCtxt)
return;
toCtxt->SetFullZoom(fromCtxt->GetFullZoom());
toCtxt->SetBaseMinFontSize(fromCtxt->BaseMinFontSize());
toCtxt->SetTextZoom(fromCtxt->TextZoom());
toCtxt->SetOverrideDPPX(fromCtxt->GetOverrideDPPX());
}
@@ -3692,20 +3684,18 @@ nsDocument::GetBaseTarget(nsAString &aBa
}
void
nsDocument::SetDocumentCharacterSet(NotNull<const Encoding*> aEncoding)
{
if (mCharacterSet != aEncoding) {
mCharacterSet = aEncoding;
- if (nsIPresShell* shell = GetShell()) {
- if (nsPresContext* context = shell->GetPresContext()) {
- context->DispatchCharSetChange(aEncoding);
- }
+ if (nsPresContext* context = GetPresContext()) {
+ context->DispatchCharSetChange(aEncoding);
}
}
}
void
nsIDocument::GetSandboxFlagsAsString(nsAString& aFlags)
{
nsContentUtils::SandboxFlagsToString(mSandboxFlags, aFlags);
@@ -5326,24 +5316,21 @@ nsDocument::DispatchContentLoadedEvents(
// target is not in the same document, so the event would never reach
// the ancestor document if we used the normal event
// dispatching code.
WidgetEvent* innerEvent = event->WidgetEventPtr();
if (innerEvent) {
nsEventStatus status = nsEventStatus_eIgnore;
- nsIPresShell *shell = parent->GetShell();
- if (shell) {
- RefPtr<nsPresContext> context = shell->GetPresContext();
-
- if (context) {
- EventDispatcher::Dispatch(parent, context, innerEvent, event,
- &status);
- }
+ RefPtr<nsPresContext> context = parent->GetPresContext();
+
+ if (context) {
+ EventDispatcher::Dispatch(parent, context, innerEvent, event,
+ &status);
}
}
}
parent = parent->GetParentDocument();
} while (parent);
}
@@ -6740,23 +6727,20 @@ nsDocument::GetAnimationController()
// Refuse to create an Animation Controller for data documents.
if (mLoadedAsData || mLoadedAsInteractiveData)
return nullptr;
mAnimationController = new nsSMILAnimationController(this);
// If there's a presContext then check the animation mode and pause if
// necessary.
- nsIPresShell *shell = GetShell();
- if (mAnimationController && shell) {
- nsPresContext *context = shell->GetPresContext();
- if (context &&
- context->ImageAnimationMode() == imgIContainer::kDontAnimMode) {
- mAnimationController->Pause(nsSMILTimeContainer::PAUSE_USERPREF);
- }
+ nsPresContext* context = GetPresContext();
+ if (mAnimationController && context &&
+ context->ImageAnimationMode() == imgIContainer::kDontAnimMode) {
+ mAnimationController->Pause(nsSMILTimeContainer::PAUSE_USERPREF);
}
// If we're hidden (or being hidden), notify the newly-created animation
// controller. (Skip this check for SVG-as-an-image documents, though,
// because they don't get OnPageShow / OnPageHide calls).
if (!mIsShowing && !mIsBeingUsedAsImage) {
mAnimationController->OnPageHide();
}
@@ -7514,24 +7498,17 @@ nsDocument::GetEventTargetParent(EventCh
}
return NS_OK;
}
already_AddRefed<Event>
nsIDocument::CreateEvent(const nsAString& aEventType, CallerType aCallerType,
ErrorResult& rv) const
{
- nsIPresShell *shell = GetShell();
-
- nsPresContext *presContext = nullptr;
-
- if (shell) {
- // Retrieve the context
- presContext = shell->GetPresContext();
- }
+ nsPresContext* presContext = GetPresContext();
// Create event even without presContext.
RefPtr<Event> ev =
EventDispatcher::CreateEvent(const_cast<nsIDocument*>(this), presContext,
nullptr, aEventType, aCallerType);
if (!ev) {
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
@@ -8563,19 +8540,18 @@ DispatchCustomEventWithFlush(nsINode* aT
bool aBubbles, bool aOnlyChromeDispatch)
{
RefPtr<Event> event = NS_NewDOMEvent(aTarget, nullptr, nullptr);
event->InitEvent(aEventType, aBubbles, false);
event->SetTrusted(true);
if (aOnlyChromeDispatch) {
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
}
- if (nsIPresShell* shell = aTarget->OwnerDoc()->GetShell()) {
- shell->GetPresContext()->
- RefreshDriver()->ScheduleEventDispatch(aTarget, event);
+ if (nsPresContext* presContext = aTarget->OwnerDoc()->GetPresContext()) {
+ presContext->RefreshDriver()->ScheduleEventDispatch(aTarget, event);
}
}
static void
DispatchFullScreenChange(nsIDocument* aTarget)
{
DispatchCustomEventWithFlush(
aTarget, NS_LITERAL_STRING("fullscreenchange"),
@@ -10857,20 +10833,18 @@ nsIDocument::DispatchFullscreenError(con
NS_LITERAL_CSTRING("DOM"), this,
nsContentUtils::eDOM_PROPERTIES,
aMessage);
}
static void
UpdateViewportScrollbarOverrideForFullscreen(nsIDocument* aDoc)
{
- if (nsIPresShell* presShell = aDoc->GetShell()) {
- if (nsPresContext* presContext = presShell->GetPresContext()) {
- presContext->UpdateViewportScrollbarStylesOverride();
- }
+ if (nsPresContext* presContext = aDoc->GetPresContext()) {
+ presContext->UpdateViewportScrollbarStylesOverride();
}
}
static void
ClearFullscreenStateOnElement(Element* aElement)
{
// Remove styles from existing top element.
EventStateManager::SetFullScreenState(aElement, false);
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -4393,22 +4393,17 @@ nsGlobalWindowInner::DispatchEvent(nsIDO
return NS_ERROR_FAILURE;
}
if (!mDoc) {
return NS_ERROR_FAILURE;
}
// Obtain a presentation shell
- nsIPresShell *shell = mDoc->GetShell();
- RefPtr<nsPresContext> presContext;
- if (shell) {
- // Retrieve the context
- presContext = shell->GetPresContext();
- }
+ RefPtr<nsPresContext> presContext = mDoc->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
nsresult rv = EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr,
aEvent, presContext, &status);
*aRetVal = (status != nsEventStatus_eConsumeNoDefault);
return rv;
}
--- a/dom/base/nsHistory.cpp
+++ b/dom/base/nsHistory.cpp
@@ -184,19 +184,18 @@ nsHistory::Go(int32_t aDelta, ErrorResul
// 4.x needed it, but we don't, and it's a horrible experience
// for nothing. In stead of reloading the page, just clear
// style data and reflow the page since some sites may use this
// trick to work around gecko reflow bugs, and this should have
// the same effect.
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
- nsIPresShell *shell;
nsPresContext *pcx;
- if (doc && (shell = doc->GetShell()) && (pcx = shell->GetPresContext())) {
+ if (doc && (pcx = doc->GetPresContext())) {
pcx->RebuildAllStyleData(NS_STYLE_HINT_REFLOW, eRestyle_Subtree);
}
return;
}
}
nsCOMPtr<nsISHistory> session_history = GetSessionHistory();
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -908,16 +908,22 @@ public:
}
nsIPresShell* GetObservingShell() const
{
return mPresShell && mPresShell->IsObservingDocument()
? mPresShell : nullptr;
}
+ nsPresContext* GetPresContext() const
+ {
+ nsIPresShell* shell = GetShell();
+ return shell ? shell->GetPresContext() : nullptr;
+ }
+
bool HasShellOrBFCacheEntry() const
{
return mPresShell || mBFCacheEntry;
}
// Instead using this method, what you probably want is
// RemoveFromBFCacheSync() as we do in MessagePort and BroadcastChannel.
void DisallowBFCaching()
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1258,21 +1258,17 @@ nsINode::DispatchEvent(nsIDOMEvent *aEve
// Do nothing if the element does not belong to a document
if (!document) {
*aRetVal = true;
return NS_OK;
}
// Obtain a presentation shell
- nsIPresShell *shell = document->GetShell();
- RefPtr<nsPresContext> context;
- if (shell) {
- context = shell->GetPresContext();
- }
+ RefPtr<nsPresContext> context = document->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
nsresult rv =
EventDispatcher::DispatchDOMEvent(this, nullptr, aEvent, context, &status);
*aRetVal = (status != nsEventStatus_eConsumeNoDefault);
return rv;
}
--- a/dom/base/nsStyleLinkElement.cpp
+++ b/dom/base/nsStyleLinkElement.cpp
@@ -222,22 +222,17 @@ nsStyleLinkElement::CheckPreloadAttrs(co
if (policyType == nsIContentPolicy::TYPE_INVALID) {
return false;
}
// Check if media attribute is valid.
if (!aMedia.IsEmpty()) {
RefPtr<MediaList> mediaList = MediaList::Create(aDocument->GetStyleBackendType(),
aMedia);
- nsIPresShell* shell = aDocument->GetShell();
- if (!shell) {
- return false;
- }
-
- nsPresContext* presContext = shell->GetPresContext();
+ nsPresContext* presContext = aDocument->GetPresContext();
if (!presContext) {
return false;
}
if (!mediaList->Matches(presContext)) {
return false;
}
}
--- a/dom/browser-element/BrowserElementParent.cpp
+++ b/dom/browser-element/BrowserElementParent.cpp
@@ -76,21 +76,18 @@ CreateIframe(Element* aOpenerFrameElemen
}
bool
DispatchCustomDOMEvent(Element* aFrameElement, const nsAString& aEventName,
JSContext* cx, JS::Handle<JS::Value> aDetailValue,
nsEventStatus *aStatus)
{
NS_ENSURE_TRUE(aFrameElement, false);
- nsIPresShell *shell = aFrameElement->OwnerDoc()->GetShell();
- RefPtr<nsPresContext> presContext;
- if (shell) {
- presContext = shell->GetPresContext();
- }
+ RefPtr<nsPresContext> presContext =
+ aFrameElement->OwnerDoc()->GetPresContext();
RefPtr<CustomEvent> event =
NS_NewDOMCustomEvent(aFrameElement, presContext, nullptr);
ErrorResult res;
event->InitCustomEvent(cx,
aEventName,
/* aCanBubble = */ true,
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -339,19 +339,19 @@ Event::Init(mozilla::dom::EventTarget* a
return IsCurrentThreadRunningChromeWorker();
}
bool trusted = false;
nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(aGlobal);
if (w) {
nsCOMPtr<nsIDocument> d = w->GetExtantDoc();
if (d) {
trusted = nsContentUtils::IsChromeDoc(d);
- nsIPresShell* s = d->GetShell();
- if (s) {
- InitPresContextData(s->GetPresContext());
+ nsPresContext* presContext = d->GetPresContext();
+ if (presContext) {
+ InitPresContextData(presContext);
}
}
}
return trusted;
}
// static
already_AddRefed<Event>
--- a/dom/html/HTMLAnchorElement.cpp
+++ b/dom/html/HTMLAnchorElement.cpp
@@ -170,23 +170,20 @@ HTMLAnchorElement::IsHTMLFocusable(bool
{
if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex)) {
return true;
}
// cannot focus links if there is no link handler
nsIDocument* doc = GetComposedDoc();
if (doc) {
- nsIPresShell* presShell = doc->GetShell();
- if (presShell) {
- nsPresContext* presContext = presShell->GetPresContext();
- if (presContext && !presContext->GetLinkHandler()) {
- *aIsFocusable = false;
- return false;
- }
+ nsPresContext* presContext = doc->GetPresContext();
+ if (presContext && !presContext->GetLinkHandler()) {
+ *aIsFocusable = false;
+ return false;
}
}
// Links that are in an editable region should never be focusable, even if
// they are in a contenteditable="false" region.
if (IsNodeInEditableRegion(this)) {
if (aTabIndex) {
*aTabIndex = -1;
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -1333,22 +1333,17 @@ HTMLCanvasElement::RegisterFrameCaptureL
if (!doc) {
return NS_ERROR_FAILURE;
}
while (doc->GetParentDocument()) {
doc = doc->GetParentDocument();
}
- nsIPresShell* shell = doc->GetShell();
- if (!shell) {
- return NS_ERROR_FAILURE;
- }
-
- nsPresContext* context = shell->GetPresContext();
+ nsPresContext* context = doc->GetPresContext();
if (!context) {
return NS_ERROR_FAILURE;
}
context = context->GetRootPresContext();
if (!context) {
return NS_ERROR_FAILURE;
}
--- a/dom/html/HTMLMenuElement.cpp
+++ b/dom/html/HTMLMenuElement.cpp
@@ -65,22 +65,21 @@ HTMLMenuElement::SendShowEvent()
if (!document) {
return;
}
WidgetEvent event(true, eShow);
event.mFlags.mBubbles = false;
event.mFlags.mCancelable = false;
- nsCOMPtr<nsIPresShell> shell = document->GetShell();
- if (!shell) {
+ RefPtr<nsPresContext> presContext = document->GetPresContext();
+ if (!presContext) {
return;
}
- RefPtr<nsPresContext> presContext = shell->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event, nullptr, &status);
}
already_AddRefed<nsIMenuBuilder>
HTMLMenuElement::CreateBuilder()
{
--- a/dom/html/HTMLSourceElement.cpp
+++ b/dom/html/HTMLSourceElement.cpp
@@ -38,35 +38,33 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLS
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLSourceElement, nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLSourceElement)
bool
HTMLSourceElement::MatchesCurrentMedia()
{
if (mMediaList) {
- nsIPresShell* presShell = OwnerDoc()->GetShell();
- nsPresContext* pctx = presShell ? presShell->GetPresContext() : nullptr;
+ nsPresContext* pctx = OwnerDoc()->GetPresContext();
return pctx && mMediaList->Matches(pctx);
}
// No media specified
return true;
}
/* static */ bool
HTMLSourceElement::WouldMatchMediaForDocument(const nsAString& aMedia,
const nsIDocument *aDocument)
{
if (aMedia.IsEmpty()) {
return true;
}
- nsIPresShell* presShell = aDocument->GetShell();
- nsPresContext* pctx = presShell ? presShell->GetPresContext() : nullptr;
+ nsPresContext* pctx = aDocument->GetPresContext();
RefPtr<MediaList> mediaList =
MediaList::Create(aDocument->GetStyleBackendType(), aMedia);
return pctx && mediaList->Matches(pctx);
}
void
HTMLSourceElement::UpdateMediaList(const nsAttrValue* aValue)
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -725,22 +725,21 @@ ImageDocument::CreateSyntheticDocument()
nsresult
ImageDocument::CheckOverflowing(bool changeState)
{
/* Create a scope so that the style context gets destroyed before we might
* call RebuildStyleData. Also, holding onto pointers to the
* presentation through style resolution is potentially dangerous.
*/
{
- nsIPresShell *shell = GetShell();
- if (!shell) {
+ nsPresContext* context = GetPresContext();
+ if (!context) {
return NS_OK;
}
- nsPresContext *context = shell->GetPresContext();
nsRect visibleArea = context->GetVisibleArea();
mVisibleWidth = nsPresContext::AppUnitsToFloatCSSPixels(visibleArea.width);
mVisibleHeight = nsPresContext::AppUnitsToFloatCSSPixels(visibleArea.height);
}
bool imageWasOverflowing = ImageIsOverflowing();
bool imageWasOverflowingVertically = mImageIsOverflowingVertically;
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -984,21 +984,17 @@ nsGenericHTMLElement::GetFormControlFram
nsPresContext*
nsGenericHTMLElement::GetPresContext(PresContextFor aFor)
{
// Get the document
nsIDocument* doc = (aFor == eForComposedDoc) ?
GetComposedDoc() : GetUncomposedDoc();
if (doc) {
- // Get presentation shell.
- nsIPresShell *presShell = doc->GetShell();
- if (presShell) {
- return presShell->GetPresContext();
- }
+ return doc->GetPresContext();
}
return nullptr;
}
static const nsAttrValue::EnumTable kDivAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_MOZ_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT },
@@ -2455,23 +2451,19 @@ void
nsGenericHTMLElement::Click(CallerType aCallerType)
{
if (HandlingClick())
return;
// Strong in case the event kills it
nsCOMPtr<nsIDocument> doc = GetComposedDoc();
- nsCOMPtr<nsIPresShell> shell;
RefPtr<nsPresContext> context;
if (doc) {
- shell = doc->GetShell();
- if (shell) {
- context = shell->GetPresContext();
- }
+ context = doc->GetPresContext();
}
SetHandlingClick();
// Mark this event trusted if Click() is called from system code.
WidgetMouseEvent event(aCallerType == CallerType::System,
eMouseClick, nullptr, WidgetMouseEvent::eReal);
event.mFlags.mIsPositionless = true;
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -856,22 +856,19 @@ nsHTMLDocument::EndLoad()
void
nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
{
NS_ASSERTION(IsHTMLDocument() || aMode == eCompatibility_FullStandards,
"Bad compat mode for XHTML document!");
mCompatMode = aMode;
CSSLoader()->SetCompatibilityMode(mCompatMode);
- nsCOMPtr<nsIPresShell> shell = GetShell();
- if (shell) {
- nsPresContext *pc = shell->GetPresContext();
- if (pc) {
- pc->CompatibilityModeChanged();
- }
+ RefPtr<nsPresContext> pc = GetPresContext();
+ if (pc) {
+ pc->CompatibilityModeChanged();
}
}
nsIContent*
nsHTMLDocument::GetUnfocusedKeyEventTarget()
{
if (nsGenericHTMLElement* body = GetBody()) {
return body;
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1325,22 +1325,19 @@ TabChild::RecvUpdateDimensions(const Dim
mozilla::ipc::IPCResult
TabChild::RecvSizeModeChanged(const nsSizeMode& aSizeMode)
{
mPuppetWidget->SetSizeMode(aSizeMode);
if (!mPuppetWidget->IsVisible()) {
return IPC_OK();
}
nsCOMPtr<nsIDocument> document(GetDocument());
- nsCOMPtr<nsIPresShell> presShell = document->GetShell();
- if (presShell) {
- nsPresContext* presContext = presShell->GetPresContext();
- if (presContext) {
- presContext->SizeModeChanged(aSizeMode);
- }
+ nsPresContext* presContext = document->GetPresContext();
+ if (presContext) {
+ presContext->SizeModeChanged(aSizeMode);
}
return IPC_OK();
}
bool
TabChild::UpdateFrame(const FrameMetrics& aFrameMetrics)
{
return TabChildBase::UpdateFrameHandler(aFrameMetrics);
@@ -2375,29 +2372,26 @@ TabChild::RecvSwappedWithOtherRemoteLoad
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent,
nsTArray<uint32_t>&& aCharCodes)
{
nsCOMPtr<nsIDocument> document(GetDocument());
- nsCOMPtr<nsIPresShell> presShell = document->GetShell();
- if (presShell) {
- nsPresContext* pc = presShell->GetPresContext();
- if (pc) {
- if (!pc->EventStateManager()->
- HandleAccessKey(&(const_cast<WidgetKeyboardEvent&>(aEvent)),
- pc, aCharCodes)) {
- // If no accesskey was found, inform the parent so that accesskeys on
- // menus can be handled.
- WidgetKeyboardEvent localEvent(aEvent);
- localEvent.mWidget = mPuppetWidget;
- SendAccessKeyNotHandled(localEvent);
- }
+ RefPtr<nsPresContext> pc = document->GetPresContext();
+ if (pc) {
+ if (!pc->EventStateManager()->
+ HandleAccessKey(&(const_cast<WidgetKeyboardEvent&>(aEvent)),
+ pc, aCharCodes)) {
+ // If no accesskey was found, inform the parent so that accesskeys on
+ // menus can be handled.
+ WidgetKeyboardEvent localEvent(aEvent);
+ localEvent.mWidget = mPuppetWidget;
+ SendAccessKeyNotHandled(localEvent);
}
}
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvSetUseGlobalHistory(const bool& aUse)
@@ -3271,22 +3265,19 @@ TabChild::RecvUIResolutionChanged(const
const int32_t& aRounding,
const double& aScale)
{
ScreenIntSize oldScreenSize = GetInnerSize();
if (aDpi > 0) {
mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale);
}
nsCOMPtr<nsIDocument> document(GetDocument());
- nsCOMPtr<nsIPresShell> presShell = document->GetShell();
- if (presShell) {
- RefPtr<nsPresContext> presContext = presShell->GetPresContext();
- if (presContext) {
- presContext->UIResolutionChangedSync();
- }
+ RefPtr<nsPresContext> presContext = document->GetPresContext();
+ if (presContext) {
+ presContext->UIResolutionChangedSync();
}
ScreenIntSize screenSize = GetInnerSize();
if (mHasValidInnerSize && oldScreenSize != screenSize) {
ScreenIntRect screenRect = GetOuterRect();
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
screenRect.y + mClientOffset.y + mChromeOffset.y,
screenSize.width, screenSize.height, true);
@@ -3299,22 +3290,19 @@ TabChild::RecvUIResolutionChanged(const
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvThemeChanged(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
{
LookAndFeel::SetIntCache(aLookAndFeelIntCache);
nsCOMPtr<nsIDocument> document(GetDocument());
- nsCOMPtr<nsIPresShell> presShell = document->GetShell();
- if (presShell) {
- RefPtr<nsPresContext> presContext = presShell->GetPresContext();
- if (presContext) {
- presContext->ThemeChanged();
- }
+ RefPtr<nsPresContext> presContext = document->GetPresContext();
+ if (presContext) {
+ presContext->ThemeChanged();
}
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvAwaitLargeAlloc()
{
mAwaitingLA = true;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1157,18 +1157,17 @@ TabParent::SendRealMouseEvent(WidgetMous
MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
}
LayoutDeviceToCSSScale
TabParent::GetLayoutDeviceToCSSScale()
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
nsIDocument* doc = (content ? content->OwnerDoc() : nullptr);
- nsIPresShell* shell = (doc ? doc->GetShell() : nullptr);
- nsPresContext* ctx = (shell ? shell->GetPresContext() : nullptr);
+ nsPresContext* ctx = (doc ? doc->GetPresContext() : nullptr);
return LayoutDeviceToCSSScale(ctx
? (float)ctx->AppUnitsPerDevPixel() / nsPresContext::AppUnitsPerCSSPixel()
: 0.0f);
}
bool
TabParent::QueryDropLinksForVerification()
{
@@ -2153,19 +2152,17 @@ TabParent::RecvReplyKeyEvent(const Widge
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
WidgetKeyboardEvent localEvent(aEvent);
localEvent.MarkAsHandledInRemoteProcess();
// Here we convert the WidgetEvent that we received to an nsIDOMEvent
// to be able to dispatch it to the <browser> element as the target element.
nsIDocument* doc = mFrameElement->OwnerDoc();
- nsIPresShell* presShell = doc->GetShell();
- NS_ENSURE_TRUE(presShell, IPC_OK());
- nsPresContext* presContext = presShell->GetPresContext();
+ nsPresContext* presContext = doc->GetPresContext();
NS_ENSURE_TRUE(presContext, IPC_OK());
AutoHandlingUserInputStatePusher userInpStatePusher(localEvent.IsTrusted(),
&localEvent, doc);
nsEventStatus status = nsEventStatus_eIgnore;
// Handle access key in this process before dispatching reply event because
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -117,19 +117,19 @@ nsMathMLElement::BindToTree(nsIDocument*
// that created it to another document.
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
doc->SetMathMLEnabled();
doc->EnsureOnDemandBuiltInUASheet(cache->MathMLSheet());
// Rebuild style data for the presshell, because style system
// optimizations may have taken place assuming MathML was disabled.
// (See nsRuleNode::CheckSpecifiedProperties.)
- nsCOMPtr<nsIPresShell> shell = doc->GetShell();
- if (shell) {
- shell->GetPresContext()->
+ RefPtr<nsPresContext> presContext = doc->GetPresContext();
+ if (presContext) {
+ presContext->
PostRebuildAllStyleDataEvent(nsChangeHint(0), eRestyle_Subtree);
}
}
}
return rv;
}
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -416,22 +416,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
return NS_OK;
}
nsIDocument *doc = content->GetUncomposedDoc();
if (!doc) {
return NS_ERROR_FAILURE;
}
- nsIPresShell *presShell = doc->GetShell();
- if (!presShell) {
- return NS_ERROR_FAILURE;
- }
-
- nsPresContext *presContext = presShell->GetPresContext();
+ nsPresContext* presContext = doc->GetPresContext();
if (!presContext) {
return NS_ERROR_FAILURE;
}
// the container of the pres context will give us the link handler
nsCOMPtr<nsISupports> container = presContext->GetContainerWeak();
NS_ENSURE_TRUE(container,NS_ERROR_FAILURE);
nsCOMPtr<nsILinkHandler> lh = do_QueryInterface(container);
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -730,22 +730,17 @@ bool
nsSMILAnimationController::PreTraverseInSubtree(Element* aRoot)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mMightHavePendingStyleUpdates) {
return false;
}
- nsIPresShell* shell = mDocument->GetShell();
- if (!shell) {
- return false;
- }
-
- nsPresContext* context = shell->GetPresContext();
+ nsPresContext* context = mDocument->GetPresContext();
if (!context) {
return false;
}
MOZ_ASSERT(context->RestyleManager()->IsServo(),
"PreTraverse should only be called for the servo style system");
bool foundElementsNeedingRestyle = false;
for (auto iter = mAnimationElementTable.Iter(); !iter.Done(); iter.Next()) {
@@ -813,22 +808,17 @@ nsSMILAnimationController::RemoveChild(n
nsRefreshDriver*
nsSMILAnimationController::GetRefreshDriver()
{
if (!mDocument) {
NS_ERROR("Requesting refresh driver after document has disconnected!");
return nullptr;
}
- nsIPresShell* shell = mDocument->GetShell();
- if (!shell) {
- return nullptr;
- }
-
- nsPresContext* context = shell->GetPresContext();
+ nsPresContext* context = mDocument->GetPresContext();
return context ? context->RefreshDriver() : nullptr;
}
void
nsSMILAnimationController::FlagDocumentNeedsFlush()
{
if (nsIPresShell* shell = mDocument->GetShell()) {
shell->SetNeedStyleFlush();
--- a/dom/smil/nsSMILCSSValueType.cpp
+++ b/dom/smil/nsSMILCSSValueType.cpp
@@ -660,18 +660,17 @@ GetPresContextForElement(Element* aElem)
{
nsIDocument* doc = aElem->GetUncomposedDoc();
if (!doc) {
// This can happen if we process certain types of restyles mid-sample
// and remove anonymous animated content from the document as a result.
// See bug 534975.
return nullptr;
}
- nsIPresShell* shell = doc->GetShell();
- return shell ? shell->GetPresContext() : nullptr;
+ return doc->GetPresContext();
}
#ifdef MOZ_OLD_STYLE
static const nsDependentSubstring
GetNonNegativePropValue(const nsAString& aString, nsCSSPropertyID aPropID,
bool& aIsNegative)
{
// If value is negative, we'll strip off the "-" so the CSS parser won't
--- a/dom/smil/nsSMILTimedElement.cpp
+++ b/dom/smil/nsSMILTimedElement.cpp
@@ -101,20 +101,17 @@ namespace
NS_IMETHOD Run() override
{
InternalSMILTimeEvent event(true, mMsg);
event.mDetail = mDetail;
nsPresContext* context = nullptr;
nsIDocument* doc = mTarget->GetUncomposedDoc();
if (doc) {
- nsCOMPtr<nsIPresShell> shell = doc->GetShell();
- if (shell) {
- context = shell->GetPresContext();
- }
+ context = doc->GetPresContext();
}
return EventDispatcher::Dispatch(mTarget, context, &event);
}
};
} // namespace
//----------------------------------------------------------------------
--- a/dom/svg/SVGAElement.cpp
+++ b/dom/svg/SVGAElement.cpp
@@ -201,23 +201,20 @@ SVGAElement::IsSVGFocusable(bool* aIsFoc
{
if (nsSVGElement::IsSVGFocusable(aIsFocusable, aTabIndex)) {
return true;
}
// cannot focus links if there is no link handler
nsIDocument* doc = GetComposedDoc();
if (doc) {
- nsIPresShell* presShell = doc->GetShell();
- if (presShell) {
- nsPresContext* presContext = presShell->GetPresContext();
- if (presContext && !presContext->GetLinkHandler()) {
- *aIsFocusable = false;
- return false;
- }
+ nsPresContext* presContext = doc->GetPresContext();
+ if (presContext && !presContext->GetLinkHandler()) {
+ *aIsFocusable = false;
+ return false;
}
}
// Links that are in an editable region should never be focusable, even if
// they are in a contenteditable="false" region.
if (IsNodeInEditableRegion(this)) {
if (aTabIndex) {
*aTabIndex = -1;
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -815,24 +815,22 @@ XULDocument::ExecuteOnBroadcastHandlerFo
!listeningToAttribute.EqualsLiteral("*")) {
continue;
}
// This is the right <observes> element. Execute the
// |onbroadcast| event handler
WidgetEvent event(true, eXULBroadcast);
- nsCOMPtr<nsIPresShell> shell = GetShell();
- if (shell) {
- RefPtr<nsPresContext> aPresContext = shell->GetPresContext();
-
- // Handle the DOM event
- nsEventStatus status = nsEventStatus_eIgnore;
- EventDispatcher::Dispatch(child, aPresContext, &event, nullptr,
- &status);
+ RefPtr<nsPresContext> presContext = GetPresContext();
+ if (presContext) {
+ // Handle the DOM event
+ nsEventStatus status = nsEventStatus_eIgnore;
+ EventDispatcher::Dispatch(child, presContext, &event, nullptr,
+ &status);
}
}
return NS_OK;
}
static bool
ShouldPersistAttribute(Element* aElement, nsAtom* aAttribute)
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -1616,20 +1616,19 @@ nsXULElement::Click(CallerType aCallerTy
void
nsXULElement::ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent)
{
if (BoolAttrIsTrue(nsGkAtoms::disabled))
return;
nsCOMPtr<nsIDocument> doc = GetComposedDoc(); // Strong just in case
if (doc) {
- nsCOMPtr<nsIPresShell> shell = doc->GetShell();
- if (shell) {
+ RefPtr<nsPresContext> context = doc->GetPresContext();
+ if (context) {
// strong ref to PresContext so events don't destroy it
- RefPtr<nsPresContext> context = shell->GetPresContext();
WidgetMouseEvent eventDown(aIsTrustedEvent, eMouseDown,
nullptr, WidgetMouseEvent::eReal);
WidgetMouseEvent eventUp(aIsTrustedEvent, eMouseUp,
nullptr, WidgetMouseEvent::eReal);
WidgetMouseEvent eventClick(aIsTrustedEvent, eMouseClick, nullptr,
WidgetMouseEvent::eReal);
eventDown.inputSource = eventUp.inputSource = eventClick.inputSource
@@ -1771,24 +1770,22 @@ nsXULElement::HideWindowChrome(bool aSho
nsIDocument* doc = GetUncomposedDoc();
if (!doc || doc->GetRootElement() != this)
return NS_ERROR_UNEXPECTED;
// only top level chrome documents can hide the window chrome
if (!doc->IsRootDisplayDocument())
return NS_OK;
- nsIPresShell *shell = doc->GetShell();
-
- if (shell) {
+ nsPresContext* presContext = doc->GetPresContext();
+
+ if (presContext && presContext->IsChrome()) {
nsIFrame* frame = GetPrimaryFrame();
- nsPresContext *presContext = shell->GetPresContext();
-
- if (frame && presContext && presContext->IsChrome()) {
+ if (frame) {
nsView* view = frame->GetClosestView();
if (view) {
nsIWidget* w = view->GetWidget();
NS_ENSURE_STATE(w);
w->HideWindowChrome(aShouldHide);
}
}
--- a/dom/xul/nsXULPopupListener.cpp
+++ b/dom/xul/nsXULPopupListener.cpp
@@ -218,23 +218,22 @@ nsXULPopupListener::HandleEvent(nsIDOMEv
#ifndef NS_CONTEXT_MENU_IS_MOUSEUP
nsresult
nsXULPopupListener::FireFocusOnTargetContent(nsIDOMNode* aTargetNode, bool aIsTouch)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aTargetNode);
nsCOMPtr<nsIDocument> doc = content->OwnerDoc();
// Get nsIDOMElement for targetNode
- nsIPresShell *shell = doc->GetShell();
- if (!shell)
- return NS_ERROR_FAILURE;
-
// strong reference to keep this from going away between events
// XXXbz between what events? We don't use this local at all!
- RefPtr<nsPresContext> context = shell->GetPresContext();
+ RefPtr<nsPresContext> context = doc->GetPresContext();
+ if (!context) {
+ return NS_ERROR_FAILURE;
+ }
nsIFrame* targetFrame = content->GetPrimaryFrame();
if (!targetFrame) return NS_ERROR_FAILURE;
const nsStyleUserInterface* ui = targetFrame->StyleUserInterface();
bool suppressBlur = (ui->mUserFocus == StyleUserFocus::Ignore);
nsCOMPtr<nsIDOMElement> element;
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -8043,23 +8043,21 @@ PresShell::DispatchTouchEventToDOM(Widge
if (contentPresShell) {
//XXXsmaug huge hack. Pushing possibly capturing content,
// even though event target is something else.
contentPresShell->PushCurrentEventInfo(
content->GetPrimaryFrame(), content);
}
}
- nsIPresShell *presShell = doc->GetShell();
- if (!presShell) {
+ nsPresContext *context = doc->GetPresContext();
+ if (!context) {
continue;
}
- nsPresContext *context = presShell->GetPresContext();
-
tmpStatus = nsEventStatus_eIgnore;
EventDispatcher::Dispatch(targetPtr, context,
&newEvent, nullptr, &tmpStatus, aEventCB);
if (nsEventStatus_eConsumeNoDefault == tmpStatus ||
newEvent.mFlags.mMultipleActionsPrevented) {
preventDefault = true;
}
@@ -10498,19 +10496,19 @@ void PresShell::QueryIsActive()
nsIDocument* displayDoc = mDocument->GetDisplayDocument();
if (displayDoc) {
// Ok, we're an external resource document -- we need to use our display
// document's docshell to determine "IsActive" status, since we lack
// a container.
MOZ_ASSERT(!container,
"external resource doc shouldn't have its own container");
- nsIPresShell* displayPresShell = displayDoc->GetShell();
- if (displayPresShell) {
- container = displayPresShell->GetPresContext()->GetContainerWeak();
+ nsPresContext* displayPresContext = displayDoc->GetPresContext();
+ if (displayPresContext) {
+ container = displayPresContext->GetContainerWeak();
}
}
}
nsCOMPtr<nsIDocShell> docshell(do_QueryInterface(container));
if (docshell) {
bool isActive;
nsresult rv = docshell->GetIsActive(&isActive);
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1199,21 +1199,17 @@ nsDocumentViewer::PermitUnloadInternal(u
// Create an RAII object on mDocument that will increment the
// should-ignore-opens-during-unload counter on initialization
// and decrement it again when it goes out of score (regardless
// of how we exit this function).
IgnoreOpensDuringUnload ignoreOpens(mDocument);
// Now, fire an BeforeUnload event to the document and see if it's ok
// to unload...
- nsIPresShell* shell = mDocument->GetShell();
- nsPresContext* presContext = nullptr;
- if (shell) {
- presContext = shell->GetPresContext();
- }
+ nsPresContext* presContext = mDocument->GetPresContext();
RefPtr<BeforeUnloadEvent> event =
new BeforeUnloadEvent(mDocument, presContext, nullptr);
event->InitEvent(NS_LITERAL_STRING("beforeunload"), false, true);
// Dispatching to |window|, but using |document| as the target.
event->SetTarget(mDocument);
event->SetTrusted(true);
@@ -2659,23 +2655,20 @@ nsDocumentViewer::CreateDeviceContext(ns
NS_PRECONDITION(!mPresShell && !mWindow,
"This will screw up our existing presentation");
NS_PRECONDITION(mDocument, "Gotta have a document here");
nsIDocument* doc = mDocument->GetDisplayDocument();
if (doc) {
NS_ASSERTION(!aContainerView, "External resource document embedded somewhere?");
// We want to use our display document's device context if possible
- nsIPresShell* shell = doc->GetShell();
- if (shell) {
- nsPresContext* ctx = shell->GetPresContext();
- if (ctx) {
- mDeviceContext = ctx->DeviceContext();
- return NS_OK;
- }
+ nsPresContext* ctx = doc->GetPresContext();
+ if (ctx) {
+ mDeviceContext = ctx->DeviceContext();
+ return NS_OK;
}
}
// Create a device context even if we already have one, since our widget
// might have changed.
nsIWidget* widget = nullptr;
if (aContainerView) {
widget = aContainerView->GetNearestWidget(nullptr);
@@ -2948,68 +2941,56 @@ SetChildOverrideDPPX(nsIContentViewer* a
struct ZoomInfo* ZoomInfo = (struct ZoomInfo*) aClosure;
aChild->SetOverrideDPPX(ZoomInfo->mZoom);
}
static bool
SetExtResourceTextZoom(nsIDocument* aDocument, void* aClosure)
{
// Would it be better to enumerate external resource viewers instead?
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* ctxt = shell->GetPresContext();
- if (ctxt) {
- struct ZoomInfo* ZoomInfo = static_cast<struct ZoomInfo*>(aClosure);
- ctxt->SetTextZoom(ZoomInfo->mZoom);
- }
+ nsPresContext* ctxt = aDocument->GetPresContext();
+ if (ctxt) {
+ struct ZoomInfo* ZoomInfo = static_cast<struct ZoomInfo*>(aClosure);
+ ctxt->SetTextZoom(ZoomInfo->mZoom);
}
return true;
}
static bool
SetExtResourceMinFontSize(nsIDocument* aDocument, void* aClosure)
{
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* ctxt = shell->GetPresContext();
- if (ctxt) {
- ctxt->SetBaseMinFontSize(NS_PTR_TO_INT32(aClosure));
- }
+ nsPresContext* ctxt = aDocument->GetPresContext();
+ if (ctxt) {
+ ctxt->SetBaseMinFontSize(NS_PTR_TO_INT32(aClosure));
}
return true;
}
static bool
SetExtResourceFullZoom(nsIDocument* aDocument, void* aClosure)
{
// Would it be better to enumerate external resource viewers instead?
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* ctxt = shell->GetPresContext();
- if (ctxt) {
- struct ZoomInfo* ZoomInfo = static_cast<struct ZoomInfo*>(aClosure);
- ctxt->SetFullZoom(ZoomInfo->mZoom);
- }
+ nsPresContext* ctxt = aDocument->GetPresContext();
+ if (ctxt) {
+ struct ZoomInfo* ZoomInfo = static_cast<struct ZoomInfo*>(aClosure);
+ ctxt->SetFullZoom(ZoomInfo->mZoom);
}
return true;
}
static bool
SetExtResourceOverrideDPPX(nsIDocument* aDocument, void* aClosure)
{
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* ctxt = shell->GetPresContext();
- if (ctxt) {
- struct ZoomInfo* ZoomInfo = static_cast<struct ZoomInfo*>(aClosure);
- ctxt->SetOverrideDPPX(ZoomInfo->mZoom);
- }
+ nsPresContext* ctxt = aDocument->GetPresContext();
+ if (ctxt) {
+ struct ZoomInfo* ZoomInfo = static_cast<struct ZoomInfo*>(aClosure);
+ ctxt->SetOverrideDPPX(ZoomInfo->mZoom);
}
return true;
}
NS_IMETHODIMP
nsDocumentViewer::SetTextZoom(float aTextZoom)
{
@@ -3268,23 +3249,20 @@ nsDocumentViewer::GetAuthorStyleDisabled
*aStyleDisabled = false;
}
return NS_OK;
}
static bool
ExtResourceEmulateMedium(nsIDocument* aDocument, void* aClosure)
{
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* ctxt = shell->GetPresContext();
- if (ctxt) {
- const nsAString* mediaType = static_cast<nsAString*>(aClosure);
- ctxt->EmulateMedium(*mediaType);
- }
+ nsPresContext* ctxt = aDocument->GetPresContext();
+ if (ctxt) {
+ const nsAString* mediaType = static_cast<nsAString*>(aClosure);
+ ctxt->EmulateMedium(*mediaType);
}
return true;
}
static void
ChildEmulateMedium(nsIContentViewer* aChild, void* aClosure)
{
@@ -3306,22 +3284,19 @@ nsDocumentViewer::EmulateMedium(const ns
}
return NS_OK;
}
static bool
ExtResourceStopEmulatingMedium(nsIDocument* aDocument, void* aClosure)
{
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* ctxt = shell->GetPresContext();
- if (ctxt) {
- ctxt->StopEmulatingMedium();
- }
+ nsPresContext* ctxt = aDocument->GetPresContext();
+ if (ctxt) {
+ ctxt->StopEmulatingMedium();
}
return true;
}
static void
ChildStopEmulatingMedium(nsIContentViewer* aChild, void* aClosure)
{
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8442,19 +8442,19 @@ nsLayoutUtils::DeregisterImageRequest(ns
/* static */
void
nsLayoutUtils::PostRestyleEvent(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
nsIDocument* doc = aElement->GetComposedDoc();
if (doc) {
- nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
- if (presShell) {
- presShell->GetPresContext()->RestyleManager()->PostRestyleEvent(
+ RefPtr<nsPresContext> presContext = doc->GetPresContext();
+ if (presContext) {
+ presContext->RestyleManager()->PostRestyleEvent(
aElement, aRestyleHint, aMinChangeHint);
}
}
}
nsSetAttrRunnable::nsSetAttrRunnable(Element* aElement,
nsAtom* aAttrName,
const nsAString& aValue)
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -902,47 +902,43 @@ nsPresContext::Init(nsDeviceContext* aDe
mEventManager = new mozilla::EventStateManager();
mAnimationEventDispatcher = new mozilla::AnimationEventDispatcher(this);
mEffectCompositor = new mozilla::EffectCompositor(this);
mTransitionManager = new nsTransitionManager(this);
mAnimationManager = new nsAnimationManager(this);
if (mDocument->GetDisplayDocument()) {
- NS_ASSERTION(mDocument->GetDisplayDocument()->GetShell() &&
- mDocument->GetDisplayDocument()->GetShell()->GetPresContext(),
+ NS_ASSERTION(mDocument->GetDisplayDocument()->GetPresContext(),
"Why are we being initialized?");
- mRefreshDriver = mDocument->GetDisplayDocument()->GetShell()->
+ mRefreshDriver = mDocument->GetDisplayDocument()->
GetPresContext()->RefreshDriver();
} else {
nsIDocument* parent = mDocument->GetParentDocument();
// Unfortunately, sometimes |parent| here has no presshell because
// printing screws up things. Assert that in other cases it does,
// but whenever the shell is null just fall back on using our own
// refresh driver.
NS_ASSERTION(!parent || mDocument->IsStaticDocument() || parent->GetShell(),
"How did we end up with a presshell if our parent doesn't "
"have one?");
- if (parent && parent->GetShell()) {
- NS_ASSERTION(parent->GetShell()->GetPresContext(),
- "How did we get a presshell?");
-
+ if (parent && parent->GetPresContext()) {
// We don't have our container set yet at this point
nsCOMPtr<nsIDocShellTreeItem> ourItem = mDocument->GetDocShell();
if (ourItem) {
nsCOMPtr<nsIDocShellTreeItem> parentItem;
ourItem->GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {
Element* containingElement =
parent->FindContentForSubDocument(mDocument);
if (!containingElement->IsXULElement() ||
!containingElement->
HasAttr(kNameSpaceID_None,
nsGkAtoms::forceOwnRefreshDriver)) {
- mRefreshDriver = parent->GetShell()->GetPresContext()->RefreshDriver();
+ mRefreshDriver = parent->GetPresContext()->RefreshDriver();
}
}
}
}
if (!mRefreshDriver) {
mRefreshDriver = new nsRefreshDriver(this);
}
@@ -1956,27 +1952,24 @@ nsPresContext::UIResolutionChangedSync()
UIResolutionChangedInternalScale(0.0);
}
}
/*static*/ bool
nsPresContext::UIResolutionChangedSubdocumentCallback(nsIDocument* aDocument,
void* aData)
{
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* pc = shell->GetPresContext();
- if (pc) {
- // For subdocuments, we want to apply the parent's scale, because there
- // are cases where the subdoc's device context is connected to a widget
- // that has an out-of-date resolution (it's on a different screen, but
- // currently hidden, and will not be updated until shown): bug 1249279.
- double scale = *static_cast<double*>(aData);
- pc->UIResolutionChangedInternalScale(scale);
- }
+ nsPresContext* pc = aDocument->GetPresContext();
+ if (pc) {
+ // For subdocuments, we want to apply the parent's scale, because there
+ // are cases where the subdoc's device context is connected to a widget
+ // that has an out-of-date resolution (it's on a different screen, but
+ // currently hidden, and will not be updated until shown): bug 1249279.
+ double scale = *static_cast<double*>(aData);
+ pc->UIResolutionChangedInternalScale(scale);
}
return true;
}
static void
NotifyTabUIResolutionChanged(TabParent* aTab, void *aArg)
{
aTab->UIResolutionChanged();
@@ -2117,20 +2110,18 @@ struct MediaFeatureHints
nsRestyleHint restyleHint;
nsChangeHint changeHint;
};
static bool
MediaFeatureValuesChangedAllDocumentsCallback(nsIDocument* aDocument, void* aChange)
{
auto* change = static_cast<const MediaFeatureChange*>(aChange);
- if (nsIPresShell* shell = aDocument->GetShell()) {
- if (nsPresContext* pc = shell->GetPresContext()) {
- pc->MediaFeatureValuesChangedAllDocuments(*change);
- }
+ if (nsPresContext* pc = aDocument->GetPresContext()) {
+ pc->MediaFeatureValuesChangedAllDocuments(*change);
}
return true;
}
void
nsPresContext::MediaFeatureValuesChangedAllDocuments(
const MediaFeatureChange& aChange)
{
@@ -2489,26 +2480,23 @@ nsPresContext::FireDOMPaintEvent(nsTArra
EventDispatcher::DispatchDOMEvent(dispatchTarget, nullptr,
static_cast<Event*>(event), this, nullptr);
}
static bool
MayHavePaintEventListenerSubdocumentCallback(nsIDocument* aDocument, void* aData)
{
bool *result = static_cast<bool*>(aData);
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* pc = shell->GetPresContext();
- if (pc) {
- *result = pc->MayHavePaintEventListenerInSubDocument();
-
- // If we found a paint event listener, then we can stop enumerating
- // sub documents.
- return !*result;
- }
+ nsPresContext* pc = aDocument->GetPresContext();
+ if (pc) {
+ *result = pc->MayHavePaintEventListenerInSubDocument();
+
+ // If we found a paint event listener, then we can stop enumerating
+ // sub documents.
+ return !*result;
}
return true;
}
static bool
MayHavePaintEventListener(nsPIDOMWindowInner* aInnerWindow)
{
if (!aInnerWindow)
@@ -2685,23 +2673,20 @@ struct NotifyDidPaintSubdocumentCallback
uint64_t mTransactionId;
const mozilla::TimeStamp& mTimeStamp;
};
/* static */ bool
nsPresContext::NotifyDidPaintSubdocumentCallback(nsIDocument* aDocument, void* aData)
{
NotifyDidPaintSubdocumentCallbackClosure* closure =
static_cast<NotifyDidPaintSubdocumentCallbackClosure*>(aData);
- nsIPresShell* shell = aDocument->GetShell();
- if (shell) {
- nsPresContext* pc = shell->GetPresContext();
- if (pc) {
- pc->NotifyDidPaintForSubtree(closure->mTransactionId,
- closure->mTimeStamp);
- }
+ nsPresContext* pc = aDocument->GetPresContext();
+ if (pc) {
+ pc->NotifyDidPaintForSubtree(closure->mTransactionId,
+ closure->mTimeStamp);
}
return true;
}
class DelayedFireDOMPaintEvent : public Runnable {
public:
DelayedFireDOMPaintEvent(
nsPresContext* aPresContext,
--- a/layout/inspector/inLayoutUtils.cpp
+++ b/layout/inspector/inLayoutUtils.cpp
@@ -20,21 +20,21 @@
using namespace mozilla;
///////////////////////////////////////////////////////////////////////////////
EventStateManager*
inLayoutUtils::GetEventStateManagerFor(Element& aElement)
{
nsIDocument* doc = aElement.OwnerDoc();
- nsIPresShell* shell = doc->GetShell();
- if (!shell)
+ nsPresContext* presContext = doc->GetPresContext();
+ if (!presContext)
return nullptr;
- return shell->GetPresContext()->EventStateManager();
+ return presContext->EventStateManager();
}
nsIDOMDocument*
inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content) {
nsCOMPtr<nsIDocument> doc = content->GetComposedDoc();
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -1884,18 +1884,17 @@ FontFaceSet::MarkUserFontSetDirty()
nsPresContext*
FontFaceSet::GetPresContext()
{
if (!mDocument) {
return nullptr;
}
- nsIPresShell* shell = mDocument->GetShell();
- return shell ? shell->GetPresContext() : nullptr;
+ return mDocument->GetPresContext();
}
void
FontFaceSet::UpdateStandardFontLoadPrincipal()
{
MOZ_ASSERT(NS_IsMainThread());
nsIPrincipal* documentPrincipal = mDocument->NodePrincipal();
--- a/layout/style/ImageLoader.cpp
+++ b/layout/style/ImageLoader.cpp
@@ -301,22 +301,17 @@ ImageLoader::RemoveImage(ImageLoader::Im
nsPresContext*
ImageLoader::GetPresContext()
{
if (!mDocument) {
return nullptr;
}
- nsIPresShell* shell = mDocument->GetShell();
- if (!shell) {
- return nullptr;
- }
-
- return shell->GetPresContext();
+ return mDocument->GetPresContext();
}
static bool
IsRenderNoImages(uint32_t aDisplayItemKey)
{
DisplayItemType type = GetDisplayItemTypeFromKey(aDisplayItemKey);
uint8_t flags = GetDisplayItemFlagsForType(type);
return flags & TYPE_RENDERS_NO_IMAGES;
--- a/layout/style/MediaQueryList.cpp
+++ b/layout/style/MediaQueryList.cpp
@@ -150,23 +150,17 @@ MediaQueryList::RecomputeMatches()
// recreated as needed.
mDocument->GetParentDocument()->FlushPendingNotifications(FlushType::Frames);
// That might have killed our document, so recheck that.
if (!mDocument) {
return;
}
}
- nsIPresShell* shell = mDocument->GetShell();
- if (!shell) {
- // XXXbz What's the right behavior here? Spec doesn't say.
- return;
- }
-
- nsPresContext* presContext = shell->GetPresContext();
+ nsPresContext* presContext = mDocument->GetPresContext();
if (!presContext) {
// XXXbz What's the right behavior here? Spec doesn't say.
return;
}
mMatches = mMediaList->Matches(presContext);
mMatchesValid = true;
}
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -566,20 +566,20 @@ GetPseudoTypeFromElementForAnimation(con
bool
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
EffectCompositor::CascadeLevel aCascadeLevel,
RawServoAnimationValueMapBorrowedMut aAnimationValues)
{
MOZ_ASSERT(aElement);
nsIDocument* doc = aElement->GetComposedDoc();
- if (!doc || !doc->GetShell()) {
+ if (!doc) {
return false;
}
- nsPresContext* presContext = doc->GetShell()->GetPresContext();
+ nsPresContext* presContext = doc->GetPresContext();
if (!presContext || !presContext->IsDynamic()) {
// For print or print preview, ignore animations.
return false;
}
CSSPseudoElementType pseudoType =
GetPseudoTypeFromElementForAnimation(aElement);
--- a/layout/style/ServoSpecifiedValues.cpp
+++ b/layout/style/ServoSpecifiedValues.cpp
@@ -29,20 +29,18 @@ ServoSpecifiedValues::SetIdentAtomValue(
Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, aValue);
if (aId == eCSSProperty__x_lang) {
// This forces the lang prefs result to be cached so that we can access them
// off main thread during traversal.
//
// FIXME(emilio): Can we move mapped attribute declarations across
// documents? Isn't this wrong in that case? This is pretty out of place
// anyway.
- if (nsIPresShell* shell = mDocument->GetShell()) {
- if (nsPresContext* pc = shell->GetPresContext()) {
- pc->ForceCacheLang(aValue);
- }
+ if (nsPresContext* pc = mDocument->GetPresContext()) {
+ pc->ForceCacheLang(aValue);
}
}
}
void
ServoSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
{
Servo_DeclarationBlock_SetKeywordValue(mDecl, aId, aValue);
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -119,22 +119,17 @@ ServoStyleSet::~ServoStyleSet()
nsPresContext*
ServoStyleSet::GetPresContext()
{
if (!mDocument) {
return nullptr;
}
- auto* shell = mDocument->GetShell();
- if (!shell) {
- return nullptr;
- }
-
- return shell->GetPresContext();
+ return mDocument->GetPresContext();
}
void
ServoStyleSet::Init(nsPresContext* aPresContext)
{
mDocument = aPresContext->Document();
MOZ_ASSERT(GetPresContext() == aPresContext);
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -505,18 +505,17 @@ nsHTMLStyleSheet::ImplLinkColorSetter(
#endif
RefPtr<RawServoDeclarationBlock>& aDecl,
nscolor aColor)
{
if (!mDocument || !mDocument->GetShell()) {
return NS_OK;
}
- RestyleManager* restyle =
- mDocument->GetShell()->GetPresContext()->RestyleManager();
+ RestyleManager* restyle = mDocument->GetPresContext()->RestyleManager();
if (restyle->IsServo()) {
MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal());
aDecl = Servo_DeclarationBlock_CreateEmpty().Consume();
Servo_DeclarationBlock_SetColorValue(aDecl.get(), eCSSProperty_color,
aColor);
} else {
#ifdef MOZ_OLD_STYLE
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -82,32 +82,21 @@ struct OperatingSystemVersionInfo {
// Os version identities used in the -moz-os-version media query.
const OperatingSystemVersionInfo kOsVersionStrings[] = {
{ LookAndFeel::eOperatingSystemVersion_Windows7, &nsGkAtoms::windows_win7 },
{ LookAndFeel::eOperatingSystemVersion_Windows8, &nsGkAtoms::windows_win8 },
{ LookAndFeel::eOperatingSystemVersion_Windows10, &nsGkAtoms::windows_win10 }
};
#endif
-static nsPresContext*
-GetPresContext(nsIDocument* aDocument)
-{
- nsIPresShell* presShell = aDocument->GetShell();
- if (!presShell) {
- return nullptr;
- }
-
- return presShell->GetPresContext();
-}
-
// A helper for four features below
static nsSize
GetSize(nsIDocument* aDocument)
{
- nsPresContext* pc = GetPresContext(aDocument);
+ nsPresContext* pc = aDocument->GetPresContext();
// Per spec, return a 0x0 viewport if we're not being rendered. See:
//
// * https://github.com/w3c/csswg-drafts/issues/571
// * https://github.com/whatwg/html/issues/1813
//
if (!pc) {
return { };
@@ -153,17 +142,17 @@ IsDeviceSizePageSize(nsIDocument* aDocum
static nsSize
GetDeviceSize(nsIDocument* aDocument)
{
if (nsContentUtils::ShouldResistFingerprinting(aDocument) ||
IsDeviceSizePageSize(aDocument)) {
return GetSize(aDocument);
}
- nsPresContext* pc = GetPresContext(aDocument);
+ nsPresContext* pc = aDocument->GetPresContext();
// NOTE(emilio): We should probably figure out how to return an appropriate
// device size here, though in a multi-screen world that makes no sense
// really.
if (!pc) {
return { };
}
if (pc->IsRootPaginatedDocument()) {
@@ -247,17 +236,17 @@ GetDeviceAspectRatio(nsIDocument* aDocum
nsCSSValue& aResult)
{
MakeArray(GetDeviceSize(aDocument), aResult);
}
static nsDeviceContext*
GetDeviceContextFor(nsIDocument* aDocument)
{
- nsPresContext* pc = GetPresContext(aDocument);
+ nsPresContext* pc = aDocument->GetPresContext();
if (!pc) {
return nullptr;
}
// It would be nice to call nsLayoutUtils::GetDeviceContextForScreenInfo here,
// except for two things: (1) it can flush, and flushing is bad here, and (2)
// it doesn't really get us consistency in multi-monitor situations *anyway*.
return pc->DeviceContext();
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -81,22 +81,17 @@ public:
private:
nsCOMPtr<nsIContent> mContent;
EventMessage mMessage;
};
NS_IMETHODIMP
nsImageBoxFrameEvent::Run()
{
- nsIPresShell *pres_shell = mContent->OwnerDoc()->GetShell();
- if (!pres_shell) {
- return NS_OK;
- }
-
- RefPtr<nsPresContext> pres_context = pres_shell->GetPresContext();
+ RefPtr<nsPresContext> pres_context = mContent->OwnerDoc()->GetPresContext();
if (!pres_context) {
return NS_OK;
}
nsEventStatus status = nsEventStatus_eIgnore;
WidgetEvent event(true, mMessage);
event.mFlags.mBubbles = false;
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -2786,23 +2786,20 @@ nsXULPopupShowingEvent::Run()
NS_IMETHODIMP
nsXULPopupHidingEvent::Run()
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
nsIDocument *document = mPopup->GetUncomposedDoc();
if (pm && document) {
- nsIPresShell* presShell = document->GetShell();
- if (presShell) {
- nsPresContext* context = presShell->GetPresContext();
- if (context) {
- pm->FirePopupHidingEvent(mPopup, mNextPopup, mLastPopup,
- context, mPopupType, mDeselectMenu, mIsRollup);
- }
+ nsPresContext* context = document->GetPresContext();
+ if (context) {
+ pm->FirePopupHidingEvent(mPopup, mNextPopup, mLastPopup,
+ context, mPopupType, mDeselectMenu, mIsRollup);
}
}
return NS_OK;
}
bool
nsXULPopupPositionedEvent::DispatchIfNeeded(nsIContent *aPopup,
--- a/parser/html/nsHtml5SVGLoadDispatcher.cpp
+++ b/parser/html/nsHtml5SVGLoadDispatcher.cpp
@@ -23,19 +23,15 @@ NS_IMETHODIMP
nsHtml5SVGLoadDispatcher::Run()
{
WidgetEvent event(true, eSVGLoad);
event.mFlags.mBubbles = false;
// Do we care about forcing presshell creation if it hasn't happened yet?
// That is, should this code flush or something? Does it really matter?
// For that matter, do we really want to try getting the prescontext?
// Does this event ever want one?
- RefPtr<nsPresContext> ctx;
- nsCOMPtr<nsIPresShell> shell = mElement->OwnerDoc()->GetShell();
- if (shell) {
- ctx = shell->GetPresContext();
- }
+ RefPtr<nsPresContext> ctx = mElement->OwnerDoc()->GetPresContext();
EventDispatcher::Dispatch(mElement, ctx, &event);
// Unblocking onload on the same document that it was blocked even if
// the element has moved between docs since blocking.
mDocument->UnblockOnload(false);
return NS_OK;
}
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -2261,20 +2261,18 @@ nsWindowWatcher::SizeOpenedWindow(nsIDoc
if (!treeOwnerAsWin) { // we'll need this to actually size the docshell
return;
}
double openerZoom = aOpenerFullZoom.valueOr(1.0);
if (aParent && aOpenerFullZoom.isNothing()) {
nsCOMPtr<nsPIDOMWindowOuter> piWindow = nsPIDOMWindowOuter::From(aParent);
if (nsIDocument* doc = piWindow->GetDoc()) {
- if (nsIPresShell* shell = doc->GetShell()) {
- if (nsPresContext* presContext = shell->GetPresContext()) {
- openerZoom = presContext->GetFullZoom();
- }
+ if (nsPresContext* presContext = doc->GetPresContext()) {
+ openerZoom = presContext->GetFullZoom();
}
}
}
double scale = 1.0;
treeOwnerAsWin->GetUnscaledDevicePixelsPerCSSPixel(&scale);
/* The current position and size will be unchanged if not specified
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -686,23 +686,20 @@ void nsDocLoader::DocLoaderIsEmpty(bool
if (aFlushLayout && !mDontFlushLayout) {
nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (doc) {
// We start loads from style resolution, so we need to flush out style
// no matter what. If we have user fonts, we also need to flush layout,
// since the reflow is what starts font loads.
mozilla::FlushType flushType = mozilla::FlushType::Style;
- nsIPresShell* shell = doc->GetShell();
- if (shell) {
- // Be safe in case this presshell is in teardown now
- nsPresContext* presContext = shell->GetPresContext();
- if (presContext && presContext->GetUserFontSet()) {
- flushType = mozilla::FlushType::Layout;
- }
+ // Be safe in case this presshell is in teardown now
+ nsPresContext* presContext = doc->GetPresContext();
+ if (presContext && presContext->GetUserFontSet()) {
+ flushType = mozilla::FlushType::Layout;
}
mDontFlushLayout = mIsFlushingLayout = true;
doc->FlushPendingNotifications(flushType);
mDontFlushLayout = mIsFlushingLayout = false;
}
}
// And now check whether we're really busy; that might have changed with