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 15:39:26 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 15:39:26 +03:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
#include "mozilla/dom/SVGImageElement.h"
|
2013-11-02 15:10:38 +04: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 15:39:26 +03:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsNetUtil.h"
|
2012-10-12 20:11:22 +04:00
|
|
|
#include "imgINotificationObserver.h"
|
2013-01-06 13:32:01 +04:00
|
|
|
#include "mozilla/dom/SVGImageElementBinding.h"
|
2013-02-01 03:11:49 +04:00
|
|
|
#include "nsContentUtils.h"
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image)
|
|
|
|
|
2013-11-02 15:10:38 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-09 02:27:17 +04:00
|
|
|
SVGImageElement::WrapNode(JSContext *aCx)
|
2013-01-06 13:32:01 +04: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-09 02:27:17 +04:00
|
|
|
return SVGImageElementBinding::Wrap(aCx, this);
|
2013-01-06 13:32:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::LengthInfo SVGImageElement::sLengthInfo[4] =
|
2006-04-14 19:09:39 +04:00
|
|
|
{
|
2012-09-22 23:26:05 +04: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 19:09:39 +04: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 15:39:26 +03:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
nsSVGElement::StringInfo SVGImageElement::sStringInfo[1] =
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
|
2008-06-14 13:01:02 +04: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 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2014-04-27 11:06:00 +04: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 15:39:26 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGImageElement::SVGImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-06 13:32:01 +04: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 15:39:26 +03:00
|
|
|
{
|
2011-06-01 05:46:57 +04: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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::~SVGImageElement()
|
2006-06-01 22:35:21 +04: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 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
|
|
|
|
2013-01-06 13:32:01 +04: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 15:39:26 +03:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-06 13:32:01 +04:00
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::X()
|
|
|
|
{
|
2013-01-06 13:32:02 +04: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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::Y()
|
|
|
|
{
|
2013-01-06 13:32:02 +04: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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 13:32:01 +04: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 15:39:26 +03:00
|
|
|
{
|
2013-01-06 13:32:02 +04: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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::Height()
|
|
|
|
{
|
2013-01-06 13:32:02 +04: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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2013-01-06 13:32:01 +04: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 15:39:26 +03:00
|
|
|
{
|
2015-01-27 12:51:34 +03:00
|
|
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2013-01-06 13:32:01 +04: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 15:39:26 +03:00
|
|
|
{
|
2013-02-07 12:08:56 +04: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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2008-08-07 18:03:58 +04:00
|
|
|
nsresult
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
|
|
|
// resolve href attribute
|
|
|
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
|
|
2009-01-22 03:56:51 +03:00
|
|
|
nsAutoString href;
|
|
|
|
mStringAttributes[HREF].GetAnimValue(href, this);
|
2008-08-07 18:03:58 +04:00
|
|
|
href.Trim(" \t\n\r");
|
|
|
|
|
|
|
|
if (baseURI && !href.IsEmpty())
|
|
|
|
NS_MakeAbsoluteURI(href, href, baseURI);
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2014-08-20 01:49:38 +04:00
|
|
|
return LoadImage(href, aForce, aNotify, eImageLoadType_Normal);
|
2004-12-18 02:45:30 +03:00
|
|
|
}
|
|
|
|
|
2005-09-18 22:05:40 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods:
|
|
|
|
|
2011-10-29 12:18:25 +04:00
|
|
|
nsresult
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue, bool aNotify)
|
2011-10-29 12:18:25 +04:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
|
|
|
|
|
2011-11-19 21:53:52 +04: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 12:18:25 +04: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 13:32:01 +04:00
|
|
|
return SVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
|
|
|
|
aValue, aNotify);
|
2011-10-29 12:18:25 +04:00
|
|
|
}
|
|
|
|
|
2009-05-20 12:00:04 +04:00
|
|
|
void
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::MaybeLoadSVGImage()
|
2009-05-20 12:00:04 +04:00
|
|
|
{
|
2011-07-01 11:19:52 +04:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet() &&
|
2011-10-17 18:59:28 +04:00
|
|
|
(NS_FAILED(LoadSVGImage(false, true)) ||
|
2009-05-20 12:00:04 +04:00
|
|
|
!LoadingEnabled())) {
|
2011-10-17 18:59:28 +04:00
|
|
|
CancelImageRequests(true);
|
2009-05-20 12:00:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-17 12:45:07 +04:00
|
|
|
nsresult
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2006-08-17 12:45:07 +04:00
|
|
|
{
|
2013-01-06 13:32:01 +04:00
|
|
|
nsresult rv = SVGImageElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2006-08-17 12:45:07 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-14 02:11:50 +04:00
|
|
|
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
2011-06-01 05:46:57 +04:00
|
|
|
// FIXME: Bug 660963 it would be nice if we could just have
|
|
|
|
// ClearBrokenState update our state and do it fast...
|
2009-05-20 12:00:04 +04:00
|
|
|
ClearBrokenState();
|
2011-06-01 05:46:57 +04:00
|
|
|
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
|
2009-05-20 12:00:04 +04:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2013-01-06 13:32:01 +04:00
|
|
|
NS_NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage));
|
2008-09-20 19:07:54 +04:00
|
|
|
}
|
2006-08-17 12:45:07 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-08-14 02:11:50 +04:00
|
|
|
void
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2012-08-14 02:11:50 +04:00
|
|
|
{
|
|
|
|
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElementBase::UnbindFromTree(aDeep, aNullParent);
|
2012-08-14 02:11:50 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::IntrinsicState() const
|
2005-09-18 22:05:40 +04:00
|
|
|
{
|
2013-01-06 13:32:01 +04:00
|
|
|
return SVGImageElementBase::IntrinsicState() |
|
2005-09-18 22:05:40 +04:00
|
|
|
nsImageLoadingContent::ImageState();
|
|
|
|
}
|
2006-01-12 20:39:46 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::IsAttributeMapped(const nsIAtom* name) const
|
2006-01-12 20:39:46 +03:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sViewportsMap,
|
|
|
|
};
|
2013-01-06 13:32:01 +04:00
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElementBase::IsAttributeMapped(name);
|
2006-01-12 20:39:46 +03:00
|
|
|
}
|
2006-06-21 19:42:28 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGPathGeometryElement methods
|
|
|
|
|
|
|
|
/* For the purposes of the update/invalidation logic pretend to
|
|
|
|
be a rectangle. */
|
2015-01-21 16:09:45 +03:00
|
|
|
bool
|
2015-02-03 21:36:32 +03:00
|
|
|
SVGImageElement::GetGeometryBounds(
|
|
|
|
Rect* aBounds, const StrokeOptions& aStrokeOptions, const Matrix& aTransform)
|
2015-01-21 16:09:45 +03:00
|
|
|
{
|
|
|
|
Rect rect;
|
|
|
|
GetAnimatedLengthValues(&rect.x, &rect.y, &rect.width,
|
|
|
|
&rect.height, nullptr);
|
|
|
|
|
|
|
|
if (rect.IsEmpty()) {
|
|
|
|
// Rendering of the element disabled
|
|
|
|
rect.SetEmpty(); // Make sure width/height are zero and not negative
|
|
|
|
}
|
|
|
|
|
|
|
|
*aBounds = aTransform.TransformBounds(rect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-02 15:10:38 +04:00
|
|
|
TemporaryRef<Path>
|
2014-07-06 00:53:04 +04:00
|
|
|
SVGImageElement::BuildPath(PathBuilder* aBuilder)
|
2013-11-02 15:10:38 +04: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 14:05:18 +04:00
|
|
|
return nullptr;
|
2013-11-02 15:10:38 +04:00
|
|
|
}
|
|
|
|
|
2013-11-06 14:05:18 +04:00
|
|
|
Rect r(x, y, width, height);
|
2014-10-04 15:13:30 +04:00
|
|
|
aBuilder->MoveTo(r.TopLeft());
|
|
|
|
aBuilder->LineTo(r.TopRight());
|
|
|
|
aBuilder->LineTo(r.BottomRight());
|
|
|
|
aBuilder->LineTo(r.BottomLeft());
|
|
|
|
aBuilder->Close();
|
2013-11-06 14:05:18 +04:00
|
|
|
|
2014-10-04 15:13:30 +04:00
|
|
|
return aBuilder->Finish();
|
2013-11-02 15:10:38 +04:00
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
/* virtual */ bool
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::HasValidDimensions() const
|
2012-03-03 13:21:09 +04:00
|
|
|
{
|
2013-01-06 13:32:01 +04:00
|
|
|
return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
|
2012-03-03 13:21:09 +04:00
|
|
|
}
|
|
|
|
|
2009-01-05 04:19:38 +03:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::GetLengthInfo()
|
2009-01-05 04:19:38 +03:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sLengthInfo));
|
2009-01-05 04:19:38 +03:00
|
|
|
}
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::GetPreserveAspectRatio()
|
2009-01-05 04:19:38 +03:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
nsSVGElement::StringAttributesInfo
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::GetStringInfo()
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
|
|
|
return StringAttributesInfo(mStringAttributes, sStringInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sStringInfo));
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2009-12-11 07:02:13 +03:00
|
|
|
|
|
|
|
nsresult
|
2013-01-06 13:32:01 +04:00
|
|
|
SVGImageElement::CopyInnerTo(Element* aDest)
|
2009-12-11 07:02:13 +03:00
|
|
|
{
|
2011-10-18 14:53:36 +04:00
|
|
|
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
2013-01-06 13:32:01 +04:00
|
|
|
CreateStaticImageClone(static_cast<SVGImageElement*>(aDest));
|
2009-12-11 07:02:13 +03:00
|
|
|
}
|
2013-01-06 13:32:01 +04:00
|
|
|
return SVGImageElementBase::CopyInnerTo(aDest);
|
2009-12-11 07:02:13 +03:00
|
|
|
}
|
2013-01-06 13:32:01 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|