Skip to content

Commit

Permalink
Bug 1540015 - part 3: Rename Document::GetShell() to Document::GetPre…
Browse files Browse the repository at this point in the history
…sShell() and make it return PresShell* rather than nsIPresShell* r=smaug,emilio

This makes `Document::GetShell()` return `PresShell*` instead of `nsIPresShell`.

Additonally, "shell" is unclear ("docshell" vs. "presshell").  Therefore, this
also renames `Document::GetShell()` to `Document::GetPresShell()`.

Similarly, some other method names of `Document` are also renamed from
`*Shell*` to `*PresShell*`.

Differential Revision: https://phabricator.services.mozilla.com/D25338
  • Loading branch information
masayuki-nakano committed Mar 29, 2019
1 parent 135997d commit 5b20301
Show file tree
Hide file tree
Showing 98 changed files with 658 additions and 588 deletions.
7 changes: 5 additions & 2 deletions accessible/base/DocManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "mozilla/Components.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/Event.h" // for Event
#include "nsContentUtils.h"
#include "nsDocShellLoadTypes.h"
Expand Down Expand Up @@ -437,8 +438,10 @@ DocAccessible* DocManager::CreateDocOrRootAccessible(Document* aDocument) {
}

// Ignore documents without presshell and not having root frame.
nsIPresShell* presShell = aDocument->GetShell();
if (!presShell || presShell->IsDestroying()) return nullptr;
PresShell* presShell = aDocument->GetPresShell();
if (!presShell || presShell->IsDestroying()) {
return nullptr;
}

bool isRootDoc = nsCoreUtils::IsRootDocument(aDocument);

Expand Down
5 changes: 3 additions & 2 deletions accessible/base/DocManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define mozilla_a11_DocManager_h_

#include "mozilla/ClearOnShutdown.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/Document.h"
#include "nsIDOMEventListener.h"
#include "nsRefPtrHashtable.h"
Expand Down Expand Up @@ -183,8 +184,8 @@ class DocManager : public nsIWebProgressListener,
* more than one.
*/
inline DocAccessible* GetExistingDocAccessible(const dom::Document* aDocument) {
nsIPresShell* ps = aDocument->GetShell();
return ps ? ps->GetDocAccessible() : nullptr;
PresShell* presShell = aDocument->GetPresShell();
return presShell ? presShell->GetDocAccessible() : nullptr;
}

} // namespace a11y
Expand Down
11 changes: 6 additions & 5 deletions accessible/base/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "prenv.h"
#include "nsIDocShellTreeItem.h"
#include "nsIURI.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLBodyElement.h"
#include "mozilla/dom/Selection.h"
Expand Down Expand Up @@ -164,13 +165,13 @@ static void LogDocState(dom::Document* aDocumentNode) {
}

static void LogPresShell(dom::Document* aDocumentNode) {
nsIPresShell* ps = aDocumentNode->GetShell();
printf("presshell: %p", static_cast<void*>(ps));
PresShell* presShell = aDocumentNode->GetPresShell();
printf("presshell: %p", static_cast<void*>(presShell));

nsIScrollableFrame* sf = nullptr;
if (ps) {
printf(", is %s destroying", (ps->IsDestroying() ? "" : "not"));
sf = ps->GetRootScrollFrameAsScrollable();
if (presShell) {
printf(", is %s destroying", (presShell->IsDestroying() ? "" : "not"));
sf = presShell->GetRootScrollFrameAsScrollable();
}
printf(", root scroll frame: %p", static_cast<void*>(sf));
}
Expand Down
7 changes: 4 additions & 3 deletions accessible/base/nsAccessibilityService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/HTMLTableElement.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include "mozilla/Services.h"
#include "nsDeckFrame.h"

Expand Down Expand Up @@ -372,9 +373,9 @@ class PluginTimerCallBack final : public nsITimerCallback, public nsINamed {
NS_IMETHOD Notify(nsITimer* aTimer) final {
if (!mContent->IsInUncomposedDoc()) return NS_OK;

nsIPresShell* ps = mContent->OwnerDoc()->GetShell();
if (ps) {
DocAccessible* doc = ps->GetDocAccessible();
PresShell* presShell = mContent->OwnerDoc()->GetPresShell();
if (presShell) {
DocAccessible* doc = presShell->GetDocAccessible();
if (doc) {
// Make sure that if we created an accessible for the plugin that wasn't
// a plugin accessible we remove it before creating the right
Expand Down
8 changes: 5 additions & 3 deletions accessible/base/nsCoreUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "nsXULElement.h"
#include "nsIDocShell.h"
#include "nsIObserverService.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIScrollableFrame.h"
#include "nsISelectionController.h"
Expand All @@ -24,6 +23,7 @@
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/PresShell.h"
#include "mozilla/TouchEvents.h"
#include "nsView.h"
#include "nsGkAtoms.h"
Expand Down Expand Up @@ -70,8 +70,10 @@ void nsCoreUtils::DispatchClickEvent(XULTreeElement *aTree, int32_t aRowIndex,
Document *document = tcElm->GetUncomposedDoc();
if (!document) return;

nsCOMPtr<nsIPresShell> presShell = document->GetShell();
if (!presShell) return;
RefPtr<PresShell> presShell = document->GetPresShell();
if (!presShell) {
return;
}

// Ensure row is visible.
aTree->EnsureRowIsVisible(aRowIndex);
Expand Down
6 changes: 3 additions & 3 deletions accessible/base/nsCoreUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#define nsCoreUtils_h_

#include "mozilla/EventForwards.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/Element.h"
#include "nsIAccessibleEvent.h"
#include "nsIContent.h"
#include "mozilla/dom/Document.h" // for GetShell()
#include "nsIPresShell.h"
#include "mozilla/dom/Document.h" // for GetPresShell()

#include "nsPoint.h"
#include "nsTArray.h"
Expand Down Expand Up @@ -213,7 +213,7 @@ class nsCoreUtils {
* Return presShell for the document containing the given DOM node.
*/
static nsIPresShell *GetPresShellFor(nsINode *aNode) {
return aNode->OwnerDoc()->GetShell();
return aNode->OwnerDoc()->GetPresShell();
}

/**
Expand Down
8 changes: 5 additions & 3 deletions accessible/generic/DocAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsImageFrame.h"
#include "nsIPersistentProperties2.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsViewManager.h"
#include "nsIScrollableFrame.h"
Expand All @@ -43,6 +42,7 @@
#include "mozilla/EventStateManager.h"
#include "mozilla/EventStates.h"
#include "mozilla/HTMLEditor.h"
#include "mozilla/PresShell.h"
#include "mozilla/TextEditor.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/DocumentType.h"
Expand Down Expand Up @@ -466,8 +466,10 @@ nsRect DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const {

nsRect bounds;
while (document) {
nsIPresShell* presShell = document->GetShell();
if (!presShell) return nsRect();
mozilla::PresShell* presShell = document->GetPresShell();
if (!presShell) {
return nsRect();
}

nsRect scrollPort;
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
Expand Down
11 changes: 6 additions & 5 deletions chrome/nsChromeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include "mozilla/dom/Document.h"
#include "nsIDOMWindow.h"
#include "nsIObserverService.h"
#include "nsIPresShell.h"
#include "nsIScriptError.h"
#include "nsIWindowMediator.h"
#include "nsIPrefService.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include "mozilla/Printf.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInlines.h"
Expand All @@ -38,6 +38,7 @@ nsChromeRegistry* nsChromeRegistry::gChromeRegistry;

// DO NOT use namespace mozilla; it'll break due to a naming conflict between
// mozilla::TextRange and a TextRange in OSX headers.
using mozilla::PresShell;
using mozilla::StyleSheet;
using mozilla::dom::Document;
using mozilla::dom::IsChromeURI;
Expand Down Expand Up @@ -344,11 +345,11 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
if (!document) return NS_OK;

// Deal with the agent sheets first. Have to do all the style sets by hand.
nsCOMPtr<nsIPresShell> shell = document->GetShell();
if (shell) {
RefPtr<PresShell> presShell = document->GetPresShell();
if (presShell) {
// Reload only the chrome URL agent style sheets.
nsTArray<RefPtr<StyleSheet>> agentSheets;
rv = shell->GetAgentStyleSheets(agentSheets);
rv = presShell->GetAgentStyleSheets(agentSheets);
NS_ENSURE_SUCCESS(rv, rv);

nsTArray<RefPtr<StyleSheet>> newAgentSheets;
Expand All @@ -370,7 +371,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
}
}

rv = shell->SetAgentStyleSheets(newAgentSheets);
rv = presShell->SetAgentStyleSheets(newAgentSheets);
NS_ENSURE_SUCCESS(rv, rv);
}

Expand Down
6 changes: 4 additions & 2 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "mozilla/Logging.h"
#include "mozilla/MediaFeatureChange.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/Services.h"
Expand Down Expand Up @@ -7878,8 +7879,9 @@ nsresult nsDocShell::RestoreFromHistory() {
} else {
rootViewParent = nullptr;
}
if (sibling && sibling->GetShell() && sibling->GetShell()->GetViewManager()) {
rootViewSibling = sibling->GetShell()->GetViewManager()->GetRootView();
if (sibling && sibling->GetPresShell() &&
sibling->GetPresShell()->GetViewManager()) {
rootViewSibling = sibling->GetPresShell()->GetViewManager()->GetRootView();
} else {
rootViewSibling = nullptr;
}
Expand Down
8 changes: 4 additions & 4 deletions dom/animation/KeyframeEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "mozilla/LayerAnimationInfo.h"
#include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
#include "mozilla/KeyframeUtils.h"
#include "mozilla/PresShell.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/StaticPrefs.h"
#include "mozilla/TypeTraits.h"
Expand All @@ -31,7 +32,6 @@
#include "nsCSSPseudoElements.h" // For PseudoStyleType
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsIScriptError.h"
#include "nsPresContextInlines.h"
#include "nsRefreshDriver.h"
Expand Down Expand Up @@ -1207,7 +1207,7 @@ bool KeyframeEffect::CanThrottleIfNotVisible(nsIFrame& aFrame) const {
return false;
}

nsIPresShell* presShell = GetPresShell();
PresShell* presShell = GetPresShell();
if (presShell && !presShell->IsActive()) {
return true;
}
Expand Down Expand Up @@ -1409,12 +1409,12 @@ Document* KeyframeEffect::GetRenderedDocument() const {
return mTarget->mElement->GetComposedDoc();
}

nsIPresShell* KeyframeEffect::GetPresShell() const {
PresShell* KeyframeEffect::GetPresShell() const {
Document* doc = GetRenderedDocument();
if (!doc) {
return nullptr;
}
return doc->GetShell();
return doc->GetPresShell();
}

/* static */
Expand Down
4 changes: 2 additions & 2 deletions dom/animation/KeyframeEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct JSContext;
class JSObject;
class nsIContent;
class nsIFrame;
class nsIPresShell;

namespace mozilla {

Expand All @@ -45,6 +44,7 @@ struct AnimationRule;
struct TimingParams;
class EffectSet;
class ComputedStyle;
class PresShell;

namespace dom {
class ElementOrCSSPseudoElement;
Expand Down Expand Up @@ -283,7 +283,7 @@ class KeyframeEffect : public AnimationEffect {
}

Document* GetRenderedDocument() const;
nsIPresShell* GetPresShell() const;
PresShell* GetPresShell() const;

// Associates a warning with the animated property set on the specified frame
// indicating why, for example, the property could not be animated on the
Expand Down
4 changes: 2 additions & 2 deletions dom/animation/PendingAnimationTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#include "PendingAnimationTracker.h"

#include "mozilla/PresShell.h"
#include "mozilla/dom/AnimationTimeline.h"
#include "mozilla/dom/Nullable.h"
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsTransitionManager.h" // For CSSTransition

using mozilla::dom::Nullable;
Expand Down Expand Up @@ -173,7 +173,7 @@ void PendingAnimationTracker::EnsurePaintIsScheduled() {
return;
}

nsIPresShell* presShell = mDocument->GetShell();
PresShell* presShell = mDocument->GetPresShell();
if (!presShell) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions dom/base/AnonymousContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "AnonymousContent.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/AnonymousContentBinding.h"
#include "nsComputedDOMStyle.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/Document.h"
#include "nsIFrame.h"
#include "nsStyledElement.h"
#include "HTMLCanvasElement.h"
Expand Down Expand Up @@ -185,8 +186,7 @@ void AnonymousContent::GetComputedStylePropertyValue(
return;
}

nsIPresShell* shell = element->OwnerDoc()->GetShell();
if (!shell) {
if (!element->OwnerDoc()->GetPresShell()) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion dom/base/DOMIntersectionObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "nsIFrame.h"
#include "nsContentUtils.h"
#include "nsLayoutUtils.h"
#include "mozilla/PresShell.h"
#include "mozilla/ServoBindings.h"

namespace mozilla {
Expand Down Expand Up @@ -252,7 +253,7 @@ void DOMIntersectionObserver::Update(Document* aDocument,
rootFrame, rootRectRelativeToRootFrame, containingBlock);
}
} else {
nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell();
RefPtr<PresShell> presShell = aDocument->GetPresShell();
if (presShell) {
rootFrame = presShell->GetRootScrollFrame();
if (rootFrame) {
Expand Down
Loading

0 comments on commit 5b20301

Please sign in to comment.