Bug 587585 - Allow SVG effects on anonymous XBL elements to refer to elements in the bound document if the binding lives in different document, and don't attempt to start an external resource load in that case. r=bz, a=beta8

This commit is contained in:
Markus Stange 2010-11-05 17:01:17 +01:00
Родитель 195c10cec1
Коммит b84c3ab43f
15 изменённых файлов: 223 добавлений и 36 удалений

Просмотреть файл

@ -105,34 +105,45 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
if (!doc)
return;
// This will be the URI of the document the content belongs to
// (the URI of the XBL document if the content is anonymous
// XBL content)
nsCOMPtr<nsIURL> documentURL = do_QueryInterface(doc->GetDocumentURI());
nsIContent* bindingParent = aFromContent->GetBindingParent();
PRBool isXBL = PR_FALSE;
if (bindingParent) {
nsXBLBinding* binding = doc->BindingManager()->GetBinding(bindingParent);
if (binding) {
// XXX sXBL/XBL2 issue
// If this is an anonymous XBL element then the URI is
// relative to the binding document. A full fix requires a
// proper XBL2 implementation but for now URIs that are
// relative to the binding document should be resolve to the
// copy of the target element that has been inserted into the
// bound document.
documentURL = do_QueryInterface(binding->PrototypeBinding()->DocURI());
isXBL = PR_TRUE;
nsCOMPtr<nsIURL> bindingDocumentURL =
do_QueryInterface(binding->PrototypeBinding()->DocURI());
if (EqualExceptRef(url, bindingDocumentURL)) {
// XXX sXBL/XBL2 issue
// Our content is an anonymous XBL element from a binding inside the
// same document that the referenced URI points to. In order to avoid
// the risk of ID collisions we restrict ourselves to anonymous
// elements from this binding; specifically, URIs that are relative to
// the binding document should resolve to the copy of the target
// element that has been inserted into the bound document.
// If the URI points to a different document we don't need this
// restriction.
nsINodeList* anonymousChildren =
doc->BindingManager()->GetAnonymousNodesFor(bindingParent);
if (anonymousChildren) {
PRUint32 length;
anonymousChildren->GetLength(&length);
for (PRUint32 i = 0; i < length && !mElement; ++i) {
mElement =
nsContentUtils::MatchElementId(anonymousChildren->GetNodeAt(i), ref);
}
}
// We don't have watching working yet for XBL, so bail out here.
return;
}
}
}
nsCOMPtr<nsIURL> documentURL = do_QueryInterface(doc->GetDocumentURI());
if (!documentURL)
return;
if (!EqualExceptRef(url, documentURL)) {
// Don't take the XBL codepath here, since we'll want to just
// normally set up our external resource document and then watch
// it as needed.
isXBL = PR_FALSE;
nsRefPtr<nsIDocument::ExternalResourceLoad> load;
doc = doc->RequestExternalResource(url, aFromContent, getter_AddRefs(load));
if (!doc) {
@ -151,24 +162,6 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
}
}
// Get the element
if (isXBL) {
nsINodeList* anonymousChildren =
doc->BindingManager()-> GetAnonymousNodesFor(bindingParent);
if (anonymousChildren) {
PRUint32 length;
anonymousChildren->GetLength(&length);
for (PRUint32 i = 0; i < length && !mElement; ++i) {
mElement =
nsContentUtils::MatchElementId(anonymousChildren->GetNodeAt(i), ref);
}
}
// We don't have watching working yet for XBL, so bail out here.
return;
}
if (aWatch) {
nsCOMPtr<nsIAtom> atom = do_GetAtom(ref);
if (!atom)

Просмотреть файл

@ -0,0 +1,11 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<!DOCTYPE html>
<title>Test -moz-element reference with external binding</title>
<body style="margin:0">
<div style="width: 100px; height: 100px; background: lime;"></div>
</body>

Просмотреть файл

@ -0,0 +1,22 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<!DOCTYPE html>
<title>Test -moz-element reference with external binding</title>
<style>
.paintClient {
background: -moz-element(#image-element);
width: 100px;
height: 100px;
}
</style>
<body style="margin:0">
<div style="-moz-binding: url(referenced-from-binding-01.xbl#insertPaintClient);"></div>
<div style="height: 0; overflow: hidden;">
<div id="image-element"
style="width: 20px; height: 20px; background: lime;"></div>
</div>
</body>

Просмотреть файл

@ -0,0 +1,11 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="insertPaintClient">
<content>
<div xmlns="http://www.w3.org/1999/xhtml" class="paintClient"></div>
</content>
</binding>
</bindings>

Просмотреть файл

@ -42,3 +42,4 @@ random-if(!cocoaWidget) == gradient-html-07a.html gradient-html-07b.html
== gradient-html-07b.html gradient-html-07c.html
== pattern-html-01.html pattern-html-01-ref.svg
== pattern-html-02.html pattern-html-02-ref.svg
== referenced-from-binding-01.html referenced-from-binding-01-ref.html

Просмотреть файл

@ -8,6 +8,10 @@
fails == xbl-grad-ref--grad-in-bound-02.svg pass-black.svg
fails == xbl-grad-ref--grad-in-resources-01.svg pass.svg
fails == xbl-grad-ref--grad-in-resources-02.svg pass.svg
== xbl-grad-ref--grad-in-binding-03.svg pass.svg
== xbl-grad-ref--grad-in-bound-03.svg pass.svg
== xbl-grad-ref--grad-in-binding-04.svg pass.svg
== xbl-grad-ref--grad-in-bound-04.svg pass.svg
# Tests for zooming with the full page zoom UI
== feImage-zoom-01a.svg feImage-zoom-01-ref.svg

Просмотреть файл

@ -0,0 +1,26 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<title>Test gradient reference in binding for gradient inside &lt;bindings&gt;</title>
<g style="-moz-binding: url(#lime);"/>
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="lime">
<content>
<rect xmlns="http://www.w3.org/2000/svg"
width="100%" height="100%" fill="url(#grad) red"/>
<linearGradient xmlns="http://www.w3.org/2000/svg"
id="grad" gradientUnits="userSpaceOnUse">
<stop stop-color="lime"/>
</linearGradient>
</content>
</binding>
</bindings>
</svg>

После

Ширина:  |  Высота:  |  Размер: 804 B

Просмотреть файл

@ -0,0 +1,13 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<title>Test gradient reference in binding for gradient inside &lt;bindings&gt; with external binding</title>
<g style="-moz-binding: url(xbl-grad-ref--grad-in-binding-04.xbl#lime);"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 426 B

Просмотреть файл

@ -0,0 +1,16 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="lime">
<content>
<rect xmlns="http://www.w3.org/2000/svg"
width="100%" height="100%" fill="url(#grad) red"/>
<linearGradient xmlns="http://www.w3.org/2000/svg"
id="grad" gradientUnits="userSpaceOnUse">
<stop stop-color="lime"/>
</linearGradient>
</content>
</binding>
</bindings>

Просмотреть файл

@ -0,0 +1,25 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<title>Test gradient reference in binding for gradient outside &lt;bindings&gt;</title>
<g style="-moz-binding: url(#lime);"/>
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="lime">
<content>
<rect xmlns="http://www.w3.org/2000/svg"
width="100%" height="100%" fill="url(#grad) lime"/>
</content>
</binding>
</bindings>
<linearGradient id="grad" gradientUnits="userSpaceOnUse">
<stop stop-color="red"/>
</linearGradient>
</svg>

После

Ширина:  |  Высота:  |  Размер: 728 B

Просмотреть файл

@ -0,0 +1,17 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<title>Test gradient reference in binding for gradient in bound document with external binding</title>
<g style="-moz-binding: url(xbl-grad-ref--grad-in-bound-04.xbl#lime);"/>
<linearGradient id="grad" gradientUnits="userSpaceOnUse">
<stop stop-color="lime"/>
</linearGradient>
</svg>

После

Ширина:  |  Высота:  |  Размер: 529 B

Просмотреть файл

@ -0,0 +1,12 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="lime">
<content>
<rect xmlns="http://www.w3.org/2000/svg"
width="100%" height="100%" fill="url(xbl-grad-ref--grad-in-bound-04.svg#grad) red"/>
</content>
</binding>
</bindings>

Просмотреть файл

@ -0,0 +1,22 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=587585 -->
<!DOCTYPE html>
<title>Test mask reference in binding for mask in bound document with external binding</title>
<body style="margin:0">
<div style="-moz-binding: url(mask-html-xbl-bound-01.xbl#lime);"></div>
<svg height="0">
<mask id="m1" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">
<linearGradient id="g" gradientUnits="objectBoundingBox" x2="0" y2="1">
<stop stop-color="white" offset="0"/>
<stop stop-color="white" stop-opacity="0" offset="1"/>
</linearGradient>
<circle cx="0.25" cy="0.25" r="0.25" id="circle" fill="white"/>
<rect x="0.5" y="0" width="0.5" height="1" fill="url(#g)"/>
</mask>
</svg>
</body>

Просмотреть файл

@ -0,0 +1,13 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="lime">
<content>
<div xmlns="http://www.w3.org/1999/xhtml"
style="mask: url(mask-html-xbl-bound-01.html#m1);
width:500px; height:500px; background:lime;"></div>
</content>
</binding>
</bindings>

Просмотреть файл

@ -18,3 +18,4 @@
== mask-html-01-extref-01.xhtml mask-html-01-ref.svg
== mask-html-01-extref-02.xhtml mask-html-01-ref.svg
== mask-html-zoomed-01.xhtml mask-html-01-ref.svg
== mask-html-xbl-bound-01.html mask-html-01-ref.svg