Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2014-04-03 04:18:36 +00:00
|
|
|
#include "mozilla/EventStates.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
#include "mozilla/dom/SVGImageElement.h"
|
2013-11-02 11:10:38 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsNetUtil.h"
|
2012-10-12 16:11:22 +00:00
|
|
|
#include "imgINotificationObserver.h"
|
2013-01-06 09:32:01 +00:00
|
|
|
#include "mozilla/dom/SVGImageElementBinding.h"
|
2013-01-31 23:11:49 +00:00
|
|
|
#include "nsContentUtils.h"
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image)
|
|
|
|
|
2013-11-02 11:10:38 +00:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 22:27:17 +00:00
|
|
|
SVGImageElement::WrapNode(JSContext *aCx)
|
2013-01-06 09:32:01 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return SVGImageElementBinding::Wrap(aCx, this);
|
2013-01-06 09:32:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::LengthInfo SVGImageElement::sLengthInfo[4] =
|
2006-04-14 15:09:39 +00:00
|
|
|
{
|
2012-09-22 19:26:05 +00:00
|
|
|
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
2006-04-14 15:09:39 +00:00
|
|
|
};
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
nsSVGElement::StringInfo SVGImageElement::sStringInfo[1] =
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
2008-06-14 09:01:02 +00:00
|
|
|
};
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(SVGImageElement, SVGImageElementBase,
|
|
|
|
nsIDOMNode, nsIDOMElement,
|
|
|
|
nsIDOMSVGElement,
|
|
|
|
imgINotificationObserver,
|
|
|
|
nsIImageLoadingContent, imgIOnloadBlocker)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
SVGImageElement::SVGImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-06 09:32:01 +00:00
|
|
|
: SVGImageElementBase(aNodeInfo)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
{
|
2011-06-01 01:46:57 +00:00
|
|
|
// We start out broken
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_BROKEN);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::~SVGImageElement()
|
2006-06-01 18:35:21 +00:00
|
|
|
{
|
|
|
|
DestroyImageLoadingContent();
|
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGImageElement)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-06 09:32:01 +00:00
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::X()
|
|
|
|
{
|
2013-01-06 09:32:02 +00:00
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::Y()
|
|
|
|
{
|
2013-01-06 09:32:02 +00:00
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::Width()
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
{
|
2013-01-06 09:32:02 +00:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 20:56:00 +00:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::Height()
|
|
|
|
{
|
2013-01-06 09:32:02 +00:00
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 09:32:01 +00:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGImageElement::PreserveAspectRatio()
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
{
|
2013-01-06 09:32:01 +00:00
|
|
|
nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
|
|
|
|
mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
|
|
|
|
return ratio.forget();
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::Href()
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
{
|
2013-02-07 08:08:56 +00:00
|
|
|
return mStringAttributes[HREF].ToDOMAnimatedString(this);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2008-08-07 14:03:58 +00:00
|
|
|
nsresult
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
|
|
|
// resolve href attribute
|
|
|
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
|
|
2009-01-22 00:56:51 +00:00
|
|
|
nsAutoString href;
|
|
|
|
mStringAttributes[HREF].GetAnimValue(href, this);
|
2008-08-07 14:03:58 +00:00
|
|
|
href.Trim(" \t\n\r");
|
|
|
|
|
|
|
|
if (baseURI && !href.IsEmpty())
|
|
|
|
NS_MakeAbsoluteURI(href, href, baseURI);
|
2008-06-14 09:01:02 +00:00
|
|
|
|
2014-08-19 21:49:38 +00:00
|
|
|
return LoadImage(href, aForce, aNotify, eImageLoadType_Normal);
|
2004-12-17 23:45:30 +00:00
|
|
|
}
|
|
|
|
|
2005-09-18 18:05:40 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods:
|
|
|
|
|
2011-10-29 08:18:25 +00:00
|
|
|
nsresult
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue, bool aNotify)
|
2011-10-29 08:18:25 +00:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
|
|
|
|
|
2011-11-19 17:53:52 +00:00
|
|
|
// If there isn't a frame we still need to load the image in case
|
|
|
|
// the frame is created later e.g. by attaching to a document.
|
|
|
|
// If there is a frame then it should deal with loading as the image
|
|
|
|
// url may be animated
|
2011-10-29 08:18:25 +00:00
|
|
|
if (!GetPrimaryFrame()) {
|
|
|
|
|
|
|
|
// Prevent setting image.src by exiting early
|
|
|
|
if (nsContentUtils::IsImageSrcSetDisabled()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aValue) {
|
|
|
|
LoadSVGImage(true, aNotify);
|
|
|
|
} else {
|
|
|
|
CancelImageRequests(aNotify);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-06 09:32:01 +00:00
|
|
|
return SVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
|
|
|
|
aValue, aNotify);
|
2011-10-29 08:18:25 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 08:00:04 +00:00
|
|
|
void
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::MaybeLoadSVGImage()
|
2009-05-20 08:00:04 +00:00
|
|
|
{
|
2011-07-01 07:19:52 +00:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet() &&
|
2011-10-17 14:59:28 +00:00
|
|
|
(NS_FAILED(LoadSVGImage(false, true)) ||
|
2009-05-20 08:00:04 +00:00
|
|
|
!LoadingEnabled())) {
|
2011-10-17 14:59:28 +00:00
|
|
|
CancelImageRequests(true);
|
2009-05-20 08:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-17 08:45:07 +00:00
|
|
|
nsresult
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2006-08-17 08:45:07 +00:00
|
|
|
{
|
2013-01-06 09:32:01 +00:00
|
|
|
nsresult rv = SVGImageElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2006-08-17 08:45:07 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-13 22:11:50 +00:00
|
|
|
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
2011-06-01 01:46:57 +00:00
|
|
|
// FIXME: Bug 660963 it would be nice if we could just have
|
|
|
|
// ClearBrokenState update our state and do it fast...
|
2009-05-20 08:00:04 +00:00
|
|
|
ClearBrokenState();
|
2011-06-01 01:46:57 +00:00
|
|
|
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
|
2009-05-20 08:00:04 +00:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2013-01-06 09:32:01 +00:00
|
|
|
NS_NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage));
|
2008-09-20 15:07:54 +00:00
|
|
|
}
|
2006-08-17 08:45:07 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-08-13 22:11:50 +00:00
|
|
|
void
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2012-08-13 22:11:50 +00:00
|
|
|
{
|
|
|
|
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElementBase::UnbindFromTree(aDeep, aNullParent);
|
2012-08-13 22:11:50 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 04:18:36 +00:00
|
|
|
EventStates
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::IntrinsicState() const
|
2005-09-18 18:05:40 +00:00
|
|
|
{
|
2013-01-06 09:32:01 +00:00
|
|
|
return SVGImageElementBase::IntrinsicState() |
|
2005-09-18 18:05:40 +00:00
|
|
|
nsImageLoadingContent::ImageState();
|
|
|
|
}
|
2006-01-12 17:39:46 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::IsAttributeMapped(const nsIAtom* name) const
|
2006-01-12 17:39:46 +00:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sViewportsMap,
|
|
|
|
};
|
2013-01-06 09:32:01 +00:00
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElementBase::IsAttributeMapped(name);
|
2006-01-12 17:39:46 +00:00
|
|
|
}
|
2006-06-21 15:42:28 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGPathGeometryElement methods
|
|
|
|
|
|
|
|
/* For the purposes of the update/invalidation logic pretend to
|
|
|
|
be a rectangle. */
|
2013-11-02 11:10:38 +00:00
|
|
|
TemporaryRef<Path>
|
2014-07-05 20:53:04 +00:00
|
|
|
SVGImageElement::BuildPath(PathBuilder* aBuilder)
|
2013-11-02 11:10:38 +00:00
|
|
|
{
|
|
|
|
// We get called in order to get bounds for this element, and for
|
|
|
|
// hit-testing against it. For that we just pretend to be a rectangle.
|
|
|
|
|
|
|
|
float x, y, width, height;
|
|
|
|
GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
|
|
|
|
|
|
|
|
if (width <= 0 || height <= 0) {
|
2013-11-06 10:05:18 +00:00
|
|
|
return nullptr;
|
2013-11-02 11:10:38 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 10:05:18 +00:00
|
|
|
Rect r(x, y, width, height);
|
2014-10-04 11:13:30 +00:00
|
|
|
aBuilder->MoveTo(r.TopLeft());
|
|
|
|
aBuilder->LineTo(r.TopRight());
|
|
|
|
aBuilder->LineTo(r.BottomRight());
|
|
|
|
aBuilder->LineTo(r.BottomLeft());
|
|
|
|
aBuilder->Close();
|
2013-11-06 10:05:18 +00:00
|
|
|
|
2014-10-04 11:13:30 +00:00
|
|
|
return aBuilder->Finish();
|
2013-11-02 11:10:38 +00:00
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2012-03-03 09:21:09 +00:00
|
|
|
/* virtual */ bool
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::HasValidDimensions() const
|
2012-03-03 09:21:09 +00:00
|
|
|
{
|
2013-01-06 09:32:01 +00:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
2012-03-03 09:21:09 +00:00
|
|
|
}
|
|
|
|
|
2009-01-05 01:19:38 +00:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::GetLengthInfo()
|
2009-01-05 01:19:38 +00:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sLengthInfo));
|
2009-01-05 01:19:38 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::GetPreserveAspectRatio()
|
2009-01-05 01:19:38 +00:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::GetStringInfo()
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 05:50:08 +00:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2009-12-11 04:02:13 +00:00
|
|
|
|
|
|
|
nsresult
|
2013-01-06 09:32:01 +00:00
|
|
|
SVGImageElement::CopyInnerTo(Element* aDest)
|
2009-12-11 04:02:13 +00:00
|
|
|
{
|
2011-10-18 10:53:36 +00:00
|
|
|
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
2013-01-06 09:32:01 +00:00
|
|
|
CreateStaticImageClone(static_cast<SVGImageElement*>(aDest));
|
2009-12-11 04:02:13 +00:00
|
|
|
}
|
2013-01-06 09:32:01 +00:00
|
|
|
return SVGImageElementBase::CopyInnerTo(aDest);
|
2009-12-11 04:02:13 +00:00
|
|
|
}
|
2013-01-06 09:32:01 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|