diff options
author | japhet <japhet@chromium.org> | 2016-02-03 14:49:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-03 22:50:21 +0000 |
commit | 332761c7f4da3aa451028a6a3d16aafd607b69be (patch) | |
tree | fbeceb2c5665ba511fcf0e6700ae98eadb1a14f7 | |
parent | 9a215f69096b5517e51c7e6bd08c9fcf58815913 (diff) | |
download | chromium_src-332761c7f4da3aa451028a6a3d16aafd607b69be.zip chromium_src-332761c7f4da3aa451028a6a3d16aafd607b69be.tar.gz chromium_src-332761c7f4da3aa451028a6a3d16aafd607b69be.tar.bz2 |
Don't reload an svg <use> element's xlink:href if only the fragment changes
BUG=580809
TEST=http/tests/cache/svg-use-revalidate.html
Review URL: https://codereview.chromium.org/1661803003
Cr-Commit-Position: refs/heads/master@{#373371}
5 files changed, 31 insertions, 1 deletions
diff --git a/third_party/WebKit/LayoutTests/http/tests/cache/resources/.htaccess b/third_party/WebKit/LayoutTests/http/tests/cache/resources/.htaccess index 42b9ba9..4efd7ae 100644 --- a/third_party/WebKit/LayoutTests/http/tests/cache/resources/.htaccess +++ b/third_party/WebKit/LayoutTests/http/tests/cache/resources/.htaccess @@ -2,3 +2,7 @@ Header set Cache-Control "no-cache, must-revalidate" Header set Pragma no-cache </Files> +<Files "circles-no-cache.svg"> +Header set Cache-Control "no-cache, must-revalidate" +Header set Pragma no-cache +</Files> diff --git a/third_party/WebKit/LayoutTests/http/tests/cache/resources/circles-no-cache.svg b/third_party/WebKit/LayoutTests/http/tests/cache/resources/circles-no-cache.svg new file mode 100644 index 0000000..e6b322d --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/cache/resources/circles-no-cache.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="500"> + <circle id="red" cx="250" cy="250" r="200" fill="red"></circle> + <circle id="green" cx="250" cy="250" r="200" fill="green"></circle> +</svg>
\ No newline at end of file diff --git a/third_party/WebKit/LayoutTests/http/tests/cache/svg-use-revalidate-expected.html b/third_party/WebKit/LayoutTests/http/tests/cache/svg-use-revalidate-expected.html new file mode 100644 index 0000000..3c55d1f --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/cache/svg-use-revalidate-expected.html @@ -0,0 +1,4 @@ +<!DOCTYPE HTML> +<svg width="500" height="500" overflow="hidden" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <use xlink:href="resources/circles-no-cache.svg#green" /> +</svg> diff --git a/third_party/WebKit/LayoutTests/http/tests/cache/svg-use-revalidate.html b/third_party/WebKit/LayoutTests/http/tests/cache/svg-use-revalidate.html new file mode 100644 index 0000000..28fe237 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/cache/svg-use-revalidate.html @@ -0,0 +1,17 @@ +<!DOCTYPE HTML> +<svg width="500" height="500" overflow="hidden" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <use xlink:href="resources/circles-no-cache.svg#red" /> +</svg> +<script> +if (window.testRunner) + testRunner.waitUntilDone(); + +window.onload = function() { + setTimeout(function() { + var circle = document.getElementsByTagName("use")[0]; + circle.setAttributeNS("http://www.w3.org/1999/xlink", "href", "resources/circles-no-cache.svg#green"); + if (window.testRunner) + testRunner.notifyDone(); + }, 0); +} +</script> diff --git a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp index 453af10..01ac2ab 100644 --- a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp @@ -227,7 +227,8 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) SVGElement::InvalidationGuard invalidationGuard(this); if (isStructurallyExternal()) { KURL url = document().completeURL(hrefString()); - if (url.hasFragmentIdentifier()) { + const KURL& existingURL = m_resource ? m_resource->url() : KURL(); + if (url.hasFragmentIdentifier() && !equalIgnoringFragmentIdentifier(url, existingURL)) { FetchRequest request(ResourceRequest(url), localName()); setDocumentResource(DocumentResource::fetchSVGDocument(request, document().fetcher())); } |