зеркало из https://github.com/mozilla/gecko-dev.git
Bug 697978 - make display:none svg images load. r=dholbert,bzbarsky
This commit is contained in:
Родитель
19437ca0c9
Коммит
4778a050df
|
@ -235,6 +235,8 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool IsCallerTrustedForCapability(const char* aCapability);
|
static bool IsCallerTrustedForCapability(const char* aCapability);
|
||||||
|
|
||||||
|
static bool IsImageSrcSetDisabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent node of aChild crossing document boundaries.
|
* Returns the parent node of aChild crossing document boundaries.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1453,6 +1453,13 @@ nsContentUtils::IsCallerTrustedForWrite()
|
||||||
return IsCallerTrustedForCapability("UniversalBrowserWrite");
|
return IsCallerTrustedForCapability("UniversalBrowserWrite");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsContentUtils::IsImageSrcSetDisabled()
|
||||||
|
{
|
||||||
|
return Preferences::GetBool("dom.disable_image_src_set") &&
|
||||||
|
!IsCallerChrome();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
nsINode*
|
nsINode*
|
||||||
nsContentUtils::GetCrossDocParentNode(nsINode* aChild)
|
nsContentUtils::GetCrossDocParentNode(nsINode* aChild)
|
||||||
|
|
|
@ -76,7 +76,6 @@
|
||||||
#include "nsEventDispatcher.h"
|
#include "nsEventDispatcher.h"
|
||||||
|
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "mozilla/Preferences.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
@ -487,10 +486,8 @@ nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||||
if (aNotify &&
|
if (aNotify &&
|
||||||
aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src) {
|
aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src) {
|
||||||
|
|
||||||
// If caller is not chrome and dom.disable_image_src_set is true,
|
// Prevent setting image.src by exiting early
|
||||||
// prevent setting image.src by exiting early
|
if (nsContentUtils::IsImageSrcSetDisabled()) {
|
||||||
if (Preferences::GetBool("dom.disable_image_src_set") &&
|
|
||||||
!nsContentUtils::IsCallerChrome()) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,31 @@ nsSVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// nsIContent methods:
|
// nsIContent methods:
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsSVGImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||||
|
const nsAString* aValue, bool aNotify)
|
||||||
|
{
|
||||||
|
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
|
||||||
|
|
||||||
|
// If there's a frame it will deal
|
||||||
|
if (!GetPrimaryFrame()) {
|
||||||
|
|
||||||
|
// Prevent setting image.src by exiting early
|
||||||
|
if (nsContentUtils::IsImageSrcSetDisabled()) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aValue) {
|
||||||
|
LoadSVGImage(true, aNotify);
|
||||||
|
} else {
|
||||||
|
CancelImageRequests(aNotify);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nsSVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
|
||||||
|
aValue, aNotify);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsSVGImageElement::MaybeLoadSVGImage()
|
nsSVGImageElement::MaybeLoadSVGImage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGImageElementBase::)
|
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGImageElementBase::)
|
||||||
|
|
||||||
// nsIContent interface
|
// nsIContent interface
|
||||||
|
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||||
|
const nsAString* aValue, bool aNotify);
|
||||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||||
nsIContent* aBindingParent,
|
nsIContent* aBindingParent,
|
||||||
bool aCompileEventHandlers);
|
bool aCompileEventHandlers);
|
||||||
|
@ -94,6 +96,8 @@ public:
|
||||||
|
|
||||||
void MaybeLoadSVGImage();
|
void MaybeLoadSVGImage();
|
||||||
|
|
||||||
|
bool IsImageSrcSetDisabled() const;
|
||||||
|
|
||||||
virtual nsXPCClassInfo* GetClassInfo();
|
virtual nsXPCClassInfo* GetClassInfo();
|
||||||
protected:
|
protected:
|
||||||
nsresult LoadSVGImage(bool aForce, bool aNotify);
|
nsresult LoadSVGImage(bool aForce, bool aNotify);
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<!--
|
||||||
|
Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
-->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
|
||||||
|
<title>Testcase to ensure that images load when they don't have frames</title>
|
||||||
|
|
||||||
|
<rect width="100%" height="100%" fill="lime"/>
|
||||||
|
<rect width="64" height="64" fill="red"/>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var img = document.createElementNS("http://www.w3.org/2000/svg", "image");
|
||||||
|
img.setAttribute("width", "64");
|
||||||
|
img.setAttribute("height", "64");
|
||||||
|
document.querySelector("svg").appendChild(img);
|
||||||
|
img.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAJFJREFUaEPt1UEOg0AMBEHz/0ez8IY5zFqqKFdLkGrHz7yz/PO9wOrv7qf/81n983uBCwAl1EYgQCD8H5eQhCTUboAAgbCBcNwdaBdIgIAlbjdAgEDYQDjuDrQLJEDAErcbIEAgbCAcdwfaBRIgYInbDRAgEDYQjrsD7QIJELDE7QYIEAgbCMfdgXaBBAhkS3wAXsqyIo0zj4gAAAAASUVORK5CYII=");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</svg>
|
После Ширина: | Высота: | Размер: 1.1 KiB |
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
== image-fill-01.svg ../pass.svg
|
== image-fill-01.svg ../pass.svg
|
||||||
== image-filter-01.svg image-filter-01-ref.svg
|
== image-filter-01.svg image-filter-01-ref.svg
|
||||||
|
== image-load-01.svg ../pass.svg
|
||||||
== image-opacity-01.svg image-opacity-01-ref.svg
|
== image-opacity-01.svg image-opacity-01-ref.svg
|
||||||
== image-opacity-02.svg image-opacity-02-ref.svg
|
== image-opacity-02.svg image-opacity-02-ref.svg
|
||||||
== image-rotate-01.svg image-rotate-01-ref.svg
|
== image-rotate-01.svg image-rotate-01-ref.svg
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "nsSVGSVGElement.h"
|
#include "nsSVGSVGElement.h"
|
||||||
#include "mozilla/Preferences.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
|
@ -210,10 +209,9 @@ nsSVGImageFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
||||||
}
|
}
|
||||||
if (aNameSpaceID == kNameSpaceID_XLink &&
|
if (aNameSpaceID == kNameSpaceID_XLink &&
|
||||||
aAttribute == nsGkAtoms::href) {
|
aAttribute == nsGkAtoms::href) {
|
||||||
// If caller is not chrome and dom.disable_image_src_set is true,
|
|
||||||
// prevent setting image.src by exiting early
|
// Prevent setting image.src by exiting early
|
||||||
if (Preferences::GetBool("dom.disable_image_src_set") &&
|
if (nsContentUtils::IsImageSrcSetDisabled()) {
|
||||||
!nsContentUtils::IsCallerChrome()) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче