Bug 1075125 - GetCurrentDoc fixes in content/svg, r=wchen

--HG--
extra : rebase_source : 72ca9c3f48b54ca7eaf4eefd061b06fad0f37385
This commit is contained in:
Olli Pettay 2014-10-03 15:32:26 +03:00
parent 6530938e0a
commit 266f1943a8
11 changed files with 28 additions and 24 deletions

View File

@ -134,8 +134,9 @@ SVGAElement::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
aDocument->RegisterPendingLinkUpdate(this);
nsIDocument* doc = GetComposedDoc();
if (doc) {
doc->RegisterPendingLinkUpdate(this);
}
return NS_OK;
@ -148,7 +149,9 @@ SVGAElement::UnbindFromTree(bool aDeep, bool aNullParent)
// be under a different xml:base, so forget the cached state now.
Link::ResetLinkState(false, Link::ElementHasHref());
nsIDocument* doc = GetCurrentDoc();
// Note, we need to use OwnerDoc() here since GetComposedDoc() may
// return null already at this point.
nsIDocument* doc = OwnerDoc();
if (doc) {
doc->UnregisterPendingLinkUpdate(this);
}

View File

@ -221,7 +221,7 @@ SVGAnimationElement::BindToTree(nsIDocument* aDocument,
href->ToString(hrefStr);
// Pass in |aParent| instead of |this| -- first argument is only used
// for a call to GetCurrentDoc(), and |this| might not have a current
// for a call to GetComposedDoc(), and |this| might not have a current
// document yet.
UpdateHrefTarget(aParent, hrefStr);
}

View File

@ -426,7 +426,7 @@ GetCTMInternal(nsSVGElement *aElement, bool aScreenCTM, bool aHaveRecursed)
// XXX this does not take into account CSS transform, or that the non-SVG
// content that we've hit may itself be inside an SVG foreignObject higher up
nsIDocument* currentDoc = aElement->GetCurrentDoc();
nsIDocument* currentDoc = aElement->GetComposedDoc();
float x = 0.0f, y = 0.0f;
if (currentDoc && element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) {
nsIPresShell *presShell = currentDoc->GetShell();

View File

@ -213,7 +213,7 @@ SVGMPathElement::UpdateHrefTarget(nsIContent* aParent,
if (aParent) {
// Pass in |aParent| instead of |this| -- first argument is only used
// for a call to GetCurrentDoc(), and |this| might not have a current
// for a call to GetComposedDoc(), and |this| might not have a current
// document yet (if our caller is BindToTree).
mHrefTarget.Reset(aParent, targetURI);
} else {

View File

@ -307,7 +307,7 @@ SVGSVGElement::UnsuspendRedrawAll()
void
SVGSVGElement::ForceRedraw(ErrorResult& rv)
{
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetComposedDoc();
if (!doc) {
rv.Throw(NS_ERROR_FAILURE);
return;
@ -514,7 +514,7 @@ SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y)
mCurrentTranslate = SVGPoint(x, y);
// now dispatch the appropriate event if we are the root element
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetUncomposedDoc();
if (doc) {
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
if (presShell && IsRoot()) {
@ -831,7 +831,8 @@ SVGViewElement*
SVGSVGElement::GetCurrentViewElement() const
{
if (mCurrentViewID) {
nsIDocument* doc = GetCurrentDoc();
//XXXsmaug It is unclear how this should work in case we're in Shadow DOM.
nsIDocument* doc = GetUncomposedDoc();
if (doc) {
Element *element = doc->GetElementById(*mCurrentViewID);
if (element && element->IsSVG(nsGkAtoms::view)) {
@ -874,7 +875,7 @@ SVGSVGElement::GetViewBoxWithSynthesis(
SVGPreserveAspectRatio
SVGSVGElement::GetPreserveAspectRatioWithOverride() const
{
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetUncomposedDoc();
if (doc && doc->IsBeingUsedAsImage()) {
const SVGPreserveAspectRatio *pAROverridePtr = GetPreserveAspectRatioProperty();
if (pAROverridePtr) {
@ -1037,7 +1038,7 @@ SVGSVGElement::ShouldSynthesizeViewBox() const
NS_ABORT_IF_FALSE(!HasViewBoxRect(),
"Should only be called if we lack a viewBox");
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetUncomposedDoc();
return doc &&
doc->IsBeingUsedAsImage() &&
!mIsPaintingSVGImageElement &&
@ -1086,7 +1087,7 @@ SVGSVGElement::
SetImageOverridePreserveAspectRatio(const SVGPreserveAspectRatio& aPAR)
{
#ifdef DEBUG
NS_ABORT_IF_FALSE(GetCurrentDoc()->IsBeingUsedAsImage(),
NS_ABORT_IF_FALSE(OwnerDoc()->IsBeingUsedAsImage(),
"should only override preserveAspectRatio in images");
#endif
@ -1116,7 +1117,7 @@ void
SVGSVGElement::ClearImageOverridePreserveAspectRatio()
{
#ifdef DEBUG
NS_ABORT_IF_FALSE(GetCurrentDoc()->IsBeingUsedAsImage(),
NS_ABORT_IF_FALSE(OwnerDoc()->IsBeingUsedAsImage(),
"should only override image preserveAspectRatio in images");
#endif
@ -1137,7 +1138,7 @@ void
SVGSVGElement::FlushImageTransformInvalidation()
{
NS_ABORT_IF_FALSE(!GetParent(), "Should only be called on root node");
NS_ABORT_IF_FALSE(GetCurrentDoc()->IsBeingUsedAsImage(),
NS_ABORT_IF_FALSE(OwnerDoc()->IsBeingUsedAsImage(),
"Should only be called on image documents");
if (mImageNeedsTransformInvalidation) {

View File

@ -85,7 +85,7 @@ SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
void
SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
ShadowRoot* oldShadow = GetContainingShadow();
SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
UpdateStyleSheetInternal(oldDoc, oldShadow);

View File

@ -111,7 +111,7 @@ SVGTitleElement::DoneAddingChildren(bool aHaveNotified)
void
SVGTitleElement::SendTitleChangeEvent(bool aBound)
{
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetUncomposedDoc();
if (doc) {
doc->NotifyPossibleTitleChange(aBound);
}

View File

@ -225,7 +225,7 @@ SVGTransformableElement::GetBBox(const SVGBoundingBoxOptions& aOptions,
already_AddRefed<SVGMatrix>
SVGTransformableElement::GetCTM()
{
nsIDocument* currentDoc = GetCurrentDoc();
nsIDocument* currentDoc = GetComposedDoc();
if (currentDoc) {
// Flush all pending notifications so that our frames are up to date
currentDoc->FlushPendingNotifications(Flush_Layout);
@ -238,7 +238,7 @@ SVGTransformableElement::GetCTM()
already_AddRefed<SVGMatrix>
SVGTransformableElement::GetScreenCTM()
{
nsIDocument* currentDoc = GetCurrentDoc();
nsIDocument* currentDoc = GetComposedDoc();
if (currentDoc) {
// Flush all pending notifications so that our frames are up to date
currentDoc->FlushPendingNotifications(Flush_Layout);

View File

@ -269,7 +269,7 @@ SVGUseElement::CreateAnonymousContent()
return nullptr;
if (newcontent->IsSVG(nsGkAtoms::symbol)) {
nsIDocument *document = GetCurrentDoc();
nsIDocument *document = GetComposedDoc();
if (!document)
return nullptr;
@ -392,7 +392,7 @@ SVGUseElement::LookupHref()
nsCOMPtr<nsIURI> targetURI;
nsCOMPtr<nsIURI> baseURI = mOriginal ? mOriginal->GetBaseURI() : GetBaseURI();
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), href,
GetCurrentDoc(), baseURI);
GetComposedDoc(), baseURI);
mSource.Reset(this, targetURI);
}
@ -400,7 +400,7 @@ SVGUseElement::LookupHref()
void
SVGUseElement::TriggerReclone()
{
nsIDocument *doc = GetCurrentDoc();
nsIDocument *doc = GetComposedDoc();
if (!doc)
return;
nsIPresShell *presShell = doc->GetShell();

View File

@ -2705,7 +2705,7 @@ nsSVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName)
void
nsSVGElement::AnimationNeedsResample()
{
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetComposedDoc();
if (doc && doc->HasAnimationController()) {
doc->GetAnimationController()->SetResampleNeeded();
}
@ -2714,7 +2714,7 @@ nsSVGElement::AnimationNeedsResample()
void
nsSVGElement::FlushAnimations()
{
nsIDocument* doc = GetCurrentDoc();
nsIDocument* doc = GetComposedDoc();
if (doc && doc->HasAnimationController()) {
doc->GetAnimationController()->FlushResampleRequests();
}

View File

@ -25,7 +25,7 @@ nsSVGFeatures::HasFeature(nsISupports* aObject, const nsAString& aFeature)
if (aFeature.EqualsLiteral("http://www.w3.org/TR/SVG11/feature#Script")) {
nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
if (content) {
nsIDocument *doc = content->GetCurrentDoc();
nsIDocument* doc = content->GetUncomposedDoc();
if (doc && doc->IsResourceDoc()) {
// no scripting in SVG images or external resource documents
return false;