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
|
|
|
|
2018-12-28 05:47:10 +03:00
|
|
|
#include "mozilla/dom/SVGImageElement.h"
|
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.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"
|
2018-02-02 16:21:33 +03:00
|
|
|
#include "mozilla/dom/SVGLengthBinding.h"
|
2019-09-20 23:51:25 +03:00
|
|
|
#include "mozilla/dom/UserActivation.h"
|
2013-02-01 03:11:49 +04:00
|
|
|
#include "nsContentUtils.h"
|
2019-05-24 15:40:12 +03:00
|
|
|
#include "SVGGeometryProperty.h"
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2018-12-21 14:43:29 +03:00
|
|
|
NS_IMPL_NS_NEW_SVG_ELEMENT(Image)
|
2013-01-06 13:32:01 +04:00
|
|
|
|
2013-11-02 15:10:38 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
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
|
|
|
JSObject* SVGImageElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGImageElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-06 13:32:01 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthInfo SVGImageElement::sLengthInfo[4] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::x, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::y, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER,
|
|
|
|
SVGContentUtils::Y},
|
|
|
|
{nsGkAtoms::width, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER,
|
|
|
|
SVGContentUtils::X},
|
|
|
|
{nsGkAtoms::height, 0, SVGLength_Binding::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
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringInfo SVGImageElement::sStringInfo[2] = {
|
2018-03-29 12:45:24 +03:00
|
|
|
{nsGkAtoms::href, kNameSpaceID_None, true},
|
|
|
|
{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,
|
|
|
|
imgINotificationObserver, nsIImageLoadingContent)
|
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
|
|
|
|
|
2019-05-24 15:40:12 +03:00
|
|
|
namespace SVGT = SVGGeometryProperty::Tags;
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
SVGImageElement::SVGImageElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: SVGImageElementBase(std::move(aNodeInfo)) {
|
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() { DestroyImageLoadingContent(); }
|
2006-06-01 22:35:21 +04:00
|
|
|
|
2019-05-24 15:40:12 +03:00
|
|
|
nsCSSPropertyID SVGImageElement::GetCSSPropertyIdForAttrEnum(
|
|
|
|
uint8_t aAttrEnum) {
|
|
|
|
switch (aAttrEnum) {
|
|
|
|
case ATTR_X:
|
|
|
|
return eCSSProperty_x;
|
|
|
|
case ATTR_Y:
|
|
|
|
return eCSSProperty_y;
|
|
|
|
case ATTR_WIDTH:
|
|
|
|
return eCSSProperty_width;
|
|
|
|
case ATTR_HEIGHT:
|
|
|
|
return eCSSProperty_height;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unknown attr enum");
|
|
|
|
return eCSSProperty_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
//----------------------------------------------------------------------
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode methods
|
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
|
|
|
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
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> 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
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> 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
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> SVGImageElement::Width() {
|
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
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> 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() {
|
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
|
|
|
}
|
|
|
|
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> SVGImageElement::Href() {
|
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
|
|
|
}
|
|
|
|
|
2018-08-08 14:56:01 +03:00
|
|
|
void SVGImageElement::GetDecoding(nsAString& aValue) {
|
|
|
|
GetEnumAttr(nsGkAtoms::decoding, kDecodingTableDefault->tag, aValue);
|
|
|
|
}
|
|
|
|
|
2018-11-08 20:45:50 +03:00
|
|
|
already_AddRefed<Promise> SVGImageElement::Decode(ErrorResult& aRv) {
|
|
|
|
return nsImageLoadingContent::QueueDecodeAsync(aRv);
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
nsresult SVGImageElement::LoadSVGImage(bool aForce, bool aNotify) {
|
2008-06-14 13:01:02 +04:00
|
|
|
// resolve href attribute
|
2019-07-15 21:29:05 +03:00
|
|
|
nsIURI* baseURI = GetBaseURI();
|
2008-06-14 13:01:02 +04:00
|
|
|
|
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.
|
2019-09-20 23:51:25 +03:00
|
|
|
mUseUrgentStartForChannel = UserActivation::IsHandlingUserInput();
|
2017-04-25 04:17:38 +03:00
|
|
|
|
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:
|
|
|
|
|
2018-08-08 14:56:01 +03:00
|
|
|
bool SVGImageElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
nsAttrValue& aResult) {
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::decoding) {
|
|
|
|
return aResult.ParseEnumValue(aValue, kDecodingTable, false,
|
|
|
|
kDecodingTableDefault);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SVGImageElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aMaybeScriptedPrincipal, aResult);
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
bool aNotify) {
|
2016-07-05 12:35:24 +03:00
|
|
|
if (aName == nsGkAtoms::href && (aNamespaceID == kNameSpaceID_None ||
|
|
|
|
aNamespaceID == kNameSpaceID_XLink)) {
|
2017-05-06 22:51:59 +03:00
|
|
|
if (aValue) {
|
|
|
|
LoadSVGImage(true, aNotify);
|
|
|
|
} else {
|
|
|
|
CancelImageRequests(aNotify);
|
2011-10-29 12:18:25 +04:00
|
|
|
}
|
2018-08-08 14:56:01 +03:00
|
|
|
} else if (aName == nsGkAtoms::decoding &&
|
|
|
|
aNamespaceID == kNameSpaceID_None) {
|
|
|
|
// Request sync or async image decoding.
|
|
|
|
SetSyncDecodingHint(
|
|
|
|
aValue && static_cast<ImageDecodingType>(aValue->GetEnumValue()) ==
|
|
|
|
ImageDecodingType::Sync);
|
2011-10-29 12:18:25 +04:00
|
|
|
}
|
2013-01-06 13:32:01 +04:00
|
|
|
return SVGImageElementBase::AfterSetAttr(
|
2017-10-10 00:33:38 +03:00
|
|
|
aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
|
2011-10-29 12:18:25 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
void SVGImageElement::MaybeLoadSVGImage() {
|
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)) || !LoadingEnabled())) {
|
|
|
|
CancelImageRequests(true);
|
2009-05-20 12:00:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult SVGImageElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|
|
|
nsresult rv = SVGImageElementBase::BindToTree(aContext, aParent);
|
2006-08-17 12:45:07 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsImageLoadingContent::BindToTree(aContext, aParent);
|
2012-08-14 02:11:50 +04:00
|
|
|
|
2016-07-05 12:35:24 +03:00
|
|
|
if (mStringAttributes[HREF].IsExplicitlySet() ||
|
|
|
|
mStringAttributes[XLINK_HREF].IsExplicitlySet()) {
|
2009-05-20 12:00:04 +04:00
|
|
|
nsContentUtils::AddScriptRunner(
|
2017-06-12 22:34:10 +03:00
|
|
|
NewRunnableMethod("dom::SVGImageElement::MaybeLoadSVGImage", this,
|
|
|
|
&SVGImageElement::MaybeLoadSVGImage));
|
2008-09-20 19:07:54 +04:00
|
|
|
}
|
2006-08-17 12:45:07 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
void SVGImageElement::UnbindFromTree(bool aNullParent) {
|
|
|
|
nsImageLoadingContent::UnbindFromTree(aNullParent);
|
|
|
|
SVGImageElementBase::UnbindFromTree(aNullParent);
|
2012-08-14 02:11:50 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
EventStates SVGImageElement::IntrinsicState() const {
|
|
|
|
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)
|
2017-10-03 01:05:19 +03:00
|
|
|
SVGImageElement::IsAttributeMapped(const nsAtom* name) const {
|
2006-01-12 20:39:46 +03:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sViewportsMap,
|
|
|
|
};
|
2013-01-06 13:32:01 +04:00
|
|
|
|
2019-05-16 16:21:19 +03:00
|
|
|
return IsInLengthInfo(name, sLengthInfo) ||
|
|
|
|
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-09-01 07:17:00 +03:00
|
|
|
bool SVGImageElement::GetGeometryBounds(
|
|
|
|
Rect* aBounds, const StrokeOptions& aStrokeOptions,
|
|
|
|
const Matrix& aToBoundsSpace, const Matrix* aToNonScalingStrokeSpace) {
|
2018-02-19 23:15:23 +03:00
|
|
|
Rect rect;
|
2019-05-24 15:40:12 +03:00
|
|
|
|
|
|
|
MOZ_ASSERT(GetPrimaryFrame());
|
|
|
|
SVGGeometryProperty::ResolveAll<SVGT::X, SVGT::Y, SVGT::Width, SVGT::Height>(
|
|
|
|
this, &rect.x, &rect.y, &rect.width, &rect.height);
|
2015-01-21 16:09:45 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-07-06 00:53:04 +04:00
|
|
|
already_AddRefed<Path> SVGImageElement::BuildPath(PathBuilder* aBuilder) {
|
2019-06-01 19:06:33 +03:00
|
|
|
// To get bound, the faster method GetGeometryBounds() should already return
|
|
|
|
// success. For render and hittest, nsSVGImageFrame should have its own
|
|
|
|
// implementation that doesn't need to build path for an image.
|
2019-06-20 16:14:08 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE(
|
|
|
|
"There is no reason to call BuildPath for SVGImageElement");
|
2019-06-01 19:06:33 +03:00
|
|
|
return nullptr;
|
2013-11-02 15:10:38 +04:00
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-21 11:58:14 +03:00
|
|
|
// SVGElement methods
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* virtual */
|
|
|
|
bool SVGImageElement::HasValidDimensions() const {
|
2019-05-24 15:40:12 +03:00
|
|
|
float width, height;
|
|
|
|
|
|
|
|
MOZ_ASSERT(GetPrimaryFrame());
|
|
|
|
SVGGeometryProperty::ResolveAll<SVGT::Width, SVGT::Height>(this, &width,
|
|
|
|
&height);
|
|
|
|
|
|
|
|
return width > 0 && height > 0;
|
2012-03-03 13:21:09 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::LengthAttributesInfo 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
|
|
|
}
|
|
|
|
|
2019-04-10 07:08:14 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio*
|
|
|
|
SVGImageElement::GetAnimatedPreserveAspectRatio() {
|
2009-01-05 04:19:38 +03:00
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
|
|
|
|
2018-12-21 11:58:14 +03:00
|
|
|
SVGElement::StringAttributesInfo 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
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult SVGImageElement::CopyInnerTo(Element* aDest) {
|
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
|
|
|
}
|
2018-08-09 02:58:44 +03: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
|