Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: third_party/WebKit/Source/core/svg/SVGUseElement.cpp

Issue 1706243002: Don't use SVG resource documents with an unrecognized MIME-type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use testharness; add unit test for extractMIMETypeFromMediaType Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGUseElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
index d07ffa3fede96384bc815b795aa20408853b84bd..155dc2002df7fabaf3931f9651a1a14db718c300 100644
--- a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
@@ -146,14 +146,11 @@ TreeScope* SVGUseElement::referencedScope() const
Document* SVGUseElement::externalDocument() const
{
- if (m_resource && m_resource->isLoaded()) {
- // Gracefully handle error condition.
- if (m_resource->errorOccurred())
- return nullptr;
- ASSERT(m_resource->document());
- return m_resource->document();
- }
- return nullptr;
+ // Gracefully handle error condition.
+ if (!resourceIsValid())
+ return nullptr;
+ ASSERT(m_resource->document());
+ return m_resource->document();
}
void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGElement* shadowElement, const SVGElement& originalElement)
@@ -789,11 +786,12 @@ void SVGUseElement::dispatchPendingEvent(SVGUseEventSender* eventSender)
void SVGUseElement::notifyFinished(Resource* resource)
{
+ ASSERT(m_resource == resource);
if (!inDocument())
return;
invalidateShadowTree();
- if (resource->errorOccurred()) {
+ if (!resourceIsValid()) {
dispatchEvent(Event::create(EventTypeNames::error));
} else if (!resource->wasCanceled()) {
if (m_haveFiredLoadEvent)
@@ -811,6 +809,14 @@ bool SVGUseElement::resourceIsStillLoading() const
return m_resource && m_resource->isLoading();
}
+bool SVGUseElement::resourceIsValid() const
+{
+ return m_resource
+ && m_resource->isLoaded()
+ && !m_resource->errorOccurred()
+ && m_resource->document();
+}
+
bool SVGUseElement::instanceTreeIsLoading(const SVGElement* targetInstance)
{
for (const SVGElement* element = targetInstance; element; element = Traversal<SVGElement>::next(*element, targetInstance)) {
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.h ('k') | third_party/WebKit/Source/platform/network/HTTPParsers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698