Commit 32370f5c authored by jschuh@chromium.org's avatar jschuh@chromium.org
Browse files

2010-09-06 Justin Schuh <jschuh@chromium.org>

        Reviewed by Nikolas Zimmermann.

        Make SVG PendingResources use RefPtr
        https://bugs.webkit.org/show_bug.cgi?id=43587

        Convert SVGDocumentExtensions::m_pendingResources to use a RefPtr for 
        pending elements instead of a raw pointer so that pending elements can't
        be freed prematurely.

        Test: svg/custom/use-invalid-pattern.svg

        * rendering/RenderSVGResourceContainer.cpp:
        (WebCore::RenderSVGResourceContainer::registerResource):
        * svg/SVGDocumentExtensions.cpp:
        (WebCore::SVGDocumentExtensions::addPendingResource):
        (WebCore::SVGDocumentExtensions::removePendingResource):
        * svg/SVGDocumentExtensions.h:
        * svg/SVGElement.cpp:
        (WebCore::SVGElement::insertedIntoDocument):
2010-09-06  Justin Schuh  <jschuh@chromium.org>

        Reviewed by Nikolas Zimmermann.

        Test that an invalid pending resource pattern doesn't crash
        https://bugs.webkit.org/show_bug.cgi?id=43587

        * platform/mac-snowleopard/svg: Added.
        * platform/mac-snowleopard/svg/custom: Added.
        * platform/mac-snowleopard/svg/custom/use-invalid-pattern-expected.txt: Added.
        * svg/custom/use-invalid-pattern.svg: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a10b3572
2010-09-06 Justin Schuh <jschuh@chromium.org>
Reviewed by Nikolas Zimmermann.
Test that an invalid pending resource pattern doesn't crash
https://bugs.webkit.org/show_bug.cgi?id=43587
* platform/mac-snowleopard/svg: Added.
* platform/mac-snowleopard/svg/custom: Added.
* platform/mac-snowleopard/svg/custom/use-invalid-pattern-expected.txt: Added.
* svg/custom/use-invalid-pattern.svg: Added.
2010-09-06 Robert Hogan <robert@webkit.org>
 
Reviewed by Andreas Kling.
This page contains the following errors:
error on line 11 at column 7: Opening and ending tag mismatch: use line 0 and svg
Below is a rendering of the page up to the first error.
This should not crash, but display an error document.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
</script>
<text y="20">This should not crash, but display an error document.</text>
<g id="crash">
<pattern xlink:href="#crash"></pattern>
</g>
<use xlink:href="#crash">
</svg>
2010-09-06 Justin Schuh <jschuh@chromium.org>
Reviewed by Nikolas Zimmermann.
Make SVG PendingResources use RefPtr
https://bugs.webkit.org/show_bug.cgi?id=43587
Convert SVGDocumentExtensions::m_pendingResources to use a RefPtr for
pending elements instead of a raw pointer so that pending elements can't
be freed prematurely.
Test: svg/custom/use-invalid-pattern.svg
* rendering/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::registerResource):
* svg/SVGDocumentExtensions.cpp:
(WebCore::SVGDocumentExtensions::addPendingResource):
(WebCore::SVGDocumentExtensions::removePendingResource):
* svg/SVGDocumentExtensions.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::insertedIntoDocument):
2010-09-06 Martin Robinson <mrobinson@igalia.com>
 
Reviewed by Gustavo Noronha Silva.
......@@ -160,14 +160,14 @@ void RenderSVGResourceContainer::registerResource()
return;
}
OwnPtr<HashSet<SVGStyledElement*> > clients(extensions->removePendingResource(m_id));
OwnPtr<SVGDocumentExtensions::SVGPendingElements> clients(extensions->removePendingResource(m_id));
// Cache us with the new id.
extensions->addResource(m_id, this);
// Update cached resources of pending clients.
const HashSet<SVGStyledElement*>::const_iterator end = clients->end();
for (HashSet<SVGStyledElement*>::const_iterator it = clients->begin(); it != end; ++it) {
const SVGDocumentExtensions::SVGPendingElements::const_iterator end = clients->end();
for (SVGDocumentExtensions::SVGPendingElements::const_iterator it = clients->begin(); it != end; ++it) {
RenderObject* renderer = (*it)->renderer();
if (!renderer)
continue;
......
......@@ -156,7 +156,7 @@ void SVGDocumentExtensions::reportError(const String& message)
reportMessage(m_document, ErrorMessageLevel, "Error: " + message);
}
void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj)
void SVGDocumentExtensions::addPendingResource(const AtomicString& id, PassRefPtr<SVGStyledElement> obj)
{
ASSERT(obj);
......@@ -166,7 +166,7 @@ void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyled
if (m_pendingResources.contains(id))
m_pendingResources.get(id)->add(obj);
else {
HashSet<SVGStyledElement*>* set = new HashSet<SVGStyledElement*>;
SVGPendingElements* set = new SVGPendingElements;
set->add(obj);
m_pendingResources.add(id, set);
......@@ -181,11 +181,11 @@ bool SVGDocumentExtensions::isPendingResource(const AtomicString& id) const
return m_pendingResources.contains(id);
}
PassOwnPtr<HashSet<SVGStyledElement*> > SVGDocumentExtensions::removePendingResource(const AtomicString& id)
PassOwnPtr<HashSet<RefPtr<SVGStyledElement> > > SVGDocumentExtensions::removePendingResource(const AtomicString& id)
{
ASSERT(m_pendingResources.contains(id));
OwnPtr<HashSet<SVGStyledElement*> > set(m_pendingResources.get(id));
OwnPtr<SVGPendingElements> set(m_pendingResources.get(id));
m_pendingResources.remove(id);
return set.release();
}
......
......@@ -40,6 +40,7 @@ class SVGSVGElement;
class SVGDocumentExtensions : public Noncopyable {
public:
typedef HashSet<RefPtr<SVGStyledElement> > SVGPendingElements;
SVGDocumentExtensions(Document*);
~SVGDocumentExtensions();
......@@ -64,7 +65,7 @@ private:
Document* m_document; // weak reference
HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
HashMap<AtomicString, RenderSVGResourceContainer*> m_resources;
HashMap<AtomicString, HashSet<SVGStyledElement*>*> m_pendingResources;
HashMap<AtomicString, SVGPendingElements*> m_pendingResources;
OwnPtr<SVGResourcesCache> m_resourcesCache;
SVGDocumentExtensions(const SVGDocumentExtensions&);
......@@ -74,9 +75,9 @@ public:
// This HashMap contains a list of pending resources. Pending resources, are such
// which are referenced by any object in the SVG document, but do NOT exist yet.
// For instance, dynamically build gradients / patterns / clippers...
void addPendingResource(const AtomicString& id, SVGStyledElement*);
void addPendingResource(const AtomicString& id, PassRefPtr<SVGStyledElement>);
bool isPendingResource(const AtomicString& id) const;
PassOwnPtr<HashSet<SVGStyledElement*> > removePendingResource(const AtomicString& id);
PassOwnPtr<SVGPendingElements> removePendingResource(const AtomicString& id);
};
}
......
......@@ -287,12 +287,12 @@ void SVGElement::insertedIntoDocument()
if (!extensions->isPendingResource(resourceId))
return;
OwnPtr<HashSet<SVGStyledElement*> > clients(extensions->removePendingResource(resourceId));
OwnPtr<SVGDocumentExtensions::SVGPendingElements> clients(extensions->removePendingResource(resourceId));
if (clients->isEmpty())
return;
const HashSet<SVGStyledElement*>::const_iterator end = clients->end();
for (HashSet<SVGStyledElement*>::const_iterator it = clients->begin(); it != end; ++it)
const SVGDocumentExtensions::SVGPendingElements::const_iterator end = clients->end();
for (SVGDocumentExtensions::SVGPendingElements::const_iterator it = clients->begin(); it != end; ++it)
(*it)->buildPendingResource();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment