2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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"
|
2017-04-25 04:17:38 +03:00
|
|
|
#include "mozilla/EventStateManager.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*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
SVGImageElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-06 13:32:01 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return SVGImageElementBinding::Wrap(aCx, this, aGivenProto);
|
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
|
|
|
|
2016-07-05 12:35:24 +03:00
|
|
|
nsSVGElement::StringInfo SVGImageElement::sStringInfo[2] =
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
2016-07-05 12:35:24 +03:00
|
|
|
{ &nsGkAtoms::href, kNameSpaceID_None, true },
|
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
|
|
|
{
|
2016-07-05 12:35:24 +03:00
|
|
|
return mStringAttributes[HREF].IsExplicitlySet()
|
|
|
|
? mStringAttributes[HREF].ToDOMAnimatedString(this)
|
|
|
|
: mStringAttributes[XLINK_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;
|
2016-07-05 12:35:24 +03:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
|
|
|
mStringAttributes[HREF].GetAnimValue(href, this);
|
|
|
|
} else {
|
|
|
|
mStringAttributes[XLINK_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
|
|
|
|
2017-04-25 04:17:38 +03:00
|
|
|
// Mark channel as urgent-start before load image if the image load is
|
|
|
|
// initaiated by a user interaction.
|
|
|
|
mUseUrgentStartForChannel = EventStateManager::IsHandlingUserInput();
|
|
|
|
|
2014-08-20 01:49:38 +04:00
|
|
|
return LoadImage(href, aForce, aNotify, eImageLoadType_Normal);
|
2004-12-18 02:45:30 +03:00
|
|
|
}
|
|
|
|
|
2016-10-06 07:30:35 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// EventTarget methods:
|
|
|
|
|
|
|
|
void
|
|
|
|
SVGImageElement::AsyncEventRunning(AsyncEventDispatcher* aEvent)
|
|
|
|
{
|
|
|
|
nsImageLoadingContent::AsyncEventRunning(aEvent);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2016-07-05 12:35:24 +03:00
|
|
|
if (aName == nsGkAtoms::href &&
|
|
|
|
(aNamespaceID == kNameSpaceID_None ||
|
|
|
|
aNamespaceID == kNameSpaceID_XLink)) {
|
2011-10-29 12:18:25 +04:00
|
|
|
|
2017-05-06 22:51:59 +03:00
|
|
|
if (aValue) {
|
|
|
|
LoadSVGImage(true, aNotify);
|
|
|
|
} else {
|
|
|
|
CancelImageRequests(aNotify);
|
2011-10-29 12:18:25 +04:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2016-07-05 12:35:24 +03:00
|
|
|
if ((mStringAttributes[HREF].IsExplicitlySet() ||
|
|
|
|
mStringAttributes[XLINK_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);
|
|
|
|
|
2016-07-05 12:35:24 +03:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet() ||
|
|
|
|
mStringAttributes[XLINK_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(
|
2016-05-05 11:45:00 +03:00
|
|
|
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
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-12-18 14:11:47 +03:00
|
|
|
// SVGGeometryElement methods
|
2006-06-21 19:42:28 +04:00
|
|
|
|
|
|
|
/* For the purposes of the update/invalidation logic pretend to
|
|
|
|
be a rectangle. */
|
2015-01-21 16:09:45 +03:00
|
|
|
bool
|
2015-09-01 07:17:00 +03:00
|
|
|
SVGImageElement::GetGeometryBounds(Rect* aBounds,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const Matrix& aToBoundsSpace,
|
|
|
|
const Matrix* aToNonScalingStrokeSpace)
|
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
|
|
|
|
}
|
|
|
|
|
2015-09-01 07:17:00 +03:00
|
|
|
*aBounds = aToBoundsSpace.TransformBounds(rect);
|
2015-01-21 16:09:45 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<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
|
2017-04-20 22:57:48 +03:00
|
|
|
SVGImageElement::CopyInnerTo(Element* aDest, bool aPreallocateChildren)
|
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
|
|
|
}
|
2017-04-20 22:57:48 +03:00
|
|
|
return SVGImageElementBase::CopyInnerTo(aDest, aPreallocateChildren);
|
2009-12-11 07:02:13 +03:00
|
|
|
}
|
2013-01-06 13:32:01 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|