[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

jschuh at chromium.org jschuh at chromium.org
Wed Dec 22 18:31:37 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit c7ed98b67c274729258ff6c790fdca6039cda9ba
Author: jschuh at chromium.org <jschuh at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 13 18:21:38 2010 +0000

    2010-12-13  Justin Schuh  <jschuh at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            HTMLCanvasElement should handle multiple observers.
            https://bugs.webkit.org/show_bug.cgi?id=50899
    
            Test: fast/canvas/canvas-bg-multiple-removal.html
    
            * css/CSSCanvasValue.cpp:
            (WebCore::CSSCanvasValue::~CSSCanvasValue):
            (WebCore::CSSCanvasValue::canvasDestroyed):
            (WebCore::CSSCanvasValue::element):
            * html/HTMLCanvasElement.cpp:
            (WebCore::HTMLCanvasElement::HTMLCanvasElement):
            (WebCore::HTMLCanvasElement::~HTMLCanvasElement):
            (WebCore::HTMLCanvasElement::addObserver):
            (WebCore::HTMLCanvasElement::removeObserver):
            (WebCore::HTMLCanvasElement::didDraw):
            (WebCore::HTMLCanvasElement::reset):
            * html/HTMLCanvasElement.h:
    2010-12-13  Justin Schuh  <jschuh at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            HTMLCanvasElement should handle multiple observers.
            https://bugs.webkit.org/show_bug.cgi?id=50899
    
            * fast/canvas/canvas-bg-multiple-removal-expected.txt: Added.
            * fast/canvas/canvas-bg-multiple-removal.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73927 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8c30722..e045f40 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-12-13  Justin Schuh  <jschuh at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        HTMLCanvasElement should handle multiple observers.
+        https://bugs.webkit.org/show_bug.cgi?id=50899
+
+        * fast/canvas/canvas-bg-multiple-removal-expected.txt: Added.
+        * fast/canvas/canvas-bg-multiple-removal.html: Added.
+
 2010-12-13  Mihai Parparita  <mihaip at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/fast/canvas/canvas-bg-multiple-removal-expected.txt b/LayoutTests/fast/canvas/canvas-bg-multiple-removal-expected.txt
new file mode 100644
index 0000000..d65d530
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-bg-multiple-removal-expected.txt
@@ -0,0 +1 @@
+PASSED: Duplicate webkit-canvas styles removed without crash.
diff --git a/LayoutTests/fast/canvas/canvas-bg-multiple-removal.html b/LayoutTests/fast/canvas/canvas-bg-multiple-removal.html
new file mode 100644
index 0000000..898cf87
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-bg-multiple-removal.html
@@ -0,0 +1,62 @@
+<html>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+window.onload = function()
+{
+    if (location.hash == "#2") {
+        document.body.innerHTML = "PASSED: Duplicate webkit-canvas styles removed without crash.";
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    } else {
+        if (location.hash)
+            location.hash = "#" + (parseInt(location.hash.slice(1)) + 1).toString();
+        else
+            location.hash = "#1";
+
+        iframe = document.body.appendChild(document.createElement('iframe'));
+        element1 = document.createElement('a');
+        iframe.contentDocument.body.appendChild(element1);
+        element1.style.setProperty('background', '-webkit-canvas(canvas)');
+
+        element2 = document.createElement('a');
+        iframe.contentDocument.body.appendChild(element2);  
+        element2.style.setProperty('background', '-webkit-canvas(canvas)');  
+
+        element1.textContent = element2.textContent = 1;
+        setTimeout(removeElements, 0);
+    }
+}
+
+function removeElements()
+{ 
+    iframe.contentDocument.body.removeChild(element1);
+    document.adoptNode(element1);
+
+    iframe.contentDocument.body.removeChild(element2);
+    document.adoptNode(element2);  
+
+    document.body.removeChild(iframe);
+    delete iframe;
+
+    var timeout = 50;
+    if (window.GCController)
+        window.GCController.collect();
+    else if (window.gc)
+        gc();
+    else
+        timeout = 400;
+    setTimeout(finishTest, timeout);
+}
+
+function finishTest()
+{
+    document.body.appendChild(element1);
+    setTimeout(function () { location.reload() }, 0);
+}
+
+</script>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5b3ad7b..63818ce 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-12-13  Justin Schuh  <jschuh at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        HTMLCanvasElement should handle multiple observers.
+        https://bugs.webkit.org/show_bug.cgi?id=50899
+
+        Test: fast/canvas/canvas-bg-multiple-removal.html
+
+        * css/CSSCanvasValue.cpp:
+        (WebCore::CSSCanvasValue::~CSSCanvasValue):
+        (WebCore::CSSCanvasValue::canvasDestroyed):
+        (WebCore::CSSCanvasValue::element):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::HTMLCanvasElement):
+        (WebCore::HTMLCanvasElement::~HTMLCanvasElement):
+        (WebCore::HTMLCanvasElement::addObserver):
+        (WebCore::HTMLCanvasElement::removeObserver):
+        (WebCore::HTMLCanvasElement::didDraw):
+        (WebCore::HTMLCanvasElement::reset):
+        * html/HTMLCanvasElement.h:
+
 2010-12-13  Mihai Parparita  <mihaip at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/css/CSSCanvasValue.cpp b/WebCore/css/CSSCanvasValue.cpp
index 767c11e..e9e83c5 100644
--- a/WebCore/css/CSSCanvasValue.cpp
+++ b/WebCore/css/CSSCanvasValue.cpp
@@ -34,7 +34,7 @@ namespace WebCore {
 CSSCanvasValue::~CSSCanvasValue()
 {
     if (m_element)
-        m_element->setObserver(0);
+        m_element->removeObserver(this);
 }
 
 String CSSCanvasValue::cssText() const
@@ -62,8 +62,7 @@ void CSSCanvasValue::canvasResized(HTMLCanvasElement*)
 void CSSCanvasValue::canvasDestroyed(HTMLCanvasElement* element)
 {
     ASSERT(element == m_element);
-    if (element == m_element)
-        m_element = 0;
+    m_element = 0;
 }
 
 IntSize CSSCanvasValue::fixedSize(const RenderObject* renderer)
@@ -79,7 +78,7 @@ HTMLCanvasElement* CSSCanvasValue::element(Document* document)
         m_element = document->getCSSCanvasElement(m_name);
         if (!m_element)
             return 0;
-        m_element->setObserver(this);
+        m_element->addObserver(this);
     }
     return m_element;
 }
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index 8bc88d4..6e8e708 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -71,7 +71,6 @@ static const float MaxSkiaDim = 32767.0F; // Maximum width/height in CSS pixels.
 
 HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document)
-    , m_observer(0)
     , m_size(DefaultWidth, DefaultHeight)
     , m_ignoreReset(false)
     , m_pageScaleFactor(document->frame() ? document->frame()->page()->chrome()->scaleFactor() : 1)
@@ -93,8 +92,9 @@ PassRefPtr<HTMLCanvasElement> HTMLCanvasElement::create(const QualifiedName& tag
 
 HTMLCanvasElement::~HTMLCanvasElement()
 {
-    if (m_observer)
-        m_observer->canvasDestroyed(this);
+    HashSet<CanvasObserver*>::iterator end = m_observers.end();
+    for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
+        (*it)->canvasDestroyed(this);
 }
 
 void HTMLCanvasElement::parseMappedAttribute(Attribute* attr)
@@ -117,6 +117,16 @@ RenderObject* HTMLCanvasElement::createRenderer(RenderArena* arena, RenderStyle*
     return HTMLElement::createRenderer(arena, style);
 }
 
+void HTMLCanvasElement::addObserver(CanvasObserver* observer)
+{
+    m_observers.add(observer);
+}
+
+void HTMLCanvasElement::removeObserver(CanvasObserver* observer)
+{
+    m_observers.remove(observer);
+}
+
 void HTMLCanvasElement::setHeight(int value)
 {
     setAttribute(heightAttr, String::number(value));
@@ -200,8 +210,9 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect)
         ro->repaintRectangle(enclosingIntRect(m_dirtyRect));
     }
 
-    if (m_observer)
-        m_observer->canvasChanged(this, rect);
+    HashSet<CanvasObserver*>::iterator end = m_observers.end();
+    for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
+        (*it)->canvasChanged(this, rect);
 }
 
 void HTMLCanvasElement::reset()
@@ -238,8 +249,9 @@ void HTMLCanvasElement::reset()
         }
     }
 
-    if (m_observer)
-        m_observer->canvasResized(this);
+    HashSet<CanvasObserver*>::iterator end = m_observers.end();
+    for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
+        (*it)->canvasResized(this);
 }
 
 void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
diff --git a/WebCore/html/HTMLCanvasElement.h b/WebCore/html/HTMLCanvasElement.h
index 1081c33..ba2b99d 100644
--- a/WebCore/html/HTMLCanvasElement.h
+++ b/WebCore/html/HTMLCanvasElement.h
@@ -65,7 +65,8 @@ public:
     static PassRefPtr<HTMLCanvasElement> create(const QualifiedName&, Document*);
     virtual ~HTMLCanvasElement();
 
-    void setObserver(CanvasObserver* observer) { m_observer = observer; }
+    void addObserver(CanvasObserver* observer);
+    void removeObserver(CanvasObserver* observer);
 
     // Attributes and functions exposed to script
     int width() const { return size().width(); }
@@ -138,7 +139,7 @@ private:
     void setSurfaceSize(const IntSize&);
     bool hasCreatedImageBuffer() const { return m_hasCreatedImageBuffer; }
 
-    CanvasObserver* m_observer;
+    HashSet<CanvasObserver*> m_observers;
 
     IntSize m_size;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list