[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

pkasting at chromium.org pkasting at chromium.org
Fri Feb 26 22:25:52 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 2159526bea9a8f48d8406452e3060cd7e74aa423
Author: pkasting at chromium.org <pkasting at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 19 21:44:32 2010 +0000

    WebCore: Make Pasteboard::writeImage() safe against NULL cachedImages, and clean
    up some code.
    https://bugs.webkit.org/show_bug.cgi?id=35136
    
    Reviewed by Darin Fisher.
    
    * loader/ImageLoader.cpp:
    (WebCore::ImageLoader::updateRenderer): Shorten some code.
    * page/DragController.cpp:
    (WebCore::getImage): Shorten some code.
    * platform/chromium/PasteboardChromium.cpp:
    (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
    * platform/gtk/PasteboardGtk.cpp:
    (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
    * platform/mac/PasteboardMac.mm:
    (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
    * platform/qt/PasteboardQt.cpp:
    (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
    * platform/win/PasteboardWin.cpp:
    (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
    
    WebKit/chromium: Add an isImageBlocked bool to the WebContextMenuData struct.
    https://bugs.webkit.org/show_bug.cgi?id=35136
    
    Reviewed by Darin Fisher.
    
    This lets us properly enable/disable the "Copy Image" context menu entry
    (and, in the future, maybe add a "Load Image" function).
    
    * public/WebContextMenuData.h:
    * src/ContextMenuClientImpl.cpp:
    (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55029 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ef43d75..70567bd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-02-18  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Darin Fisher.
+
+        Make Pasteboard::writeImage() safe against NULL cachedImages, and clean
+        up some code.
+        https://bugs.webkit.org/show_bug.cgi?id=35136
+
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::updateRenderer): Shorten some code.
+        * page/DragController.cpp:
+        (WebCore::getImage): Shorten some code.
+        * platform/chromium/PasteboardChromium.cpp:
+        (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
+        * platform/qt/PasteboardQt.cpp:
+        (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
+        * platform/win/PasteboardWin.cpp:
+        (WebCore::Pasteboard::writeImage): NULL-check cachedImage().
+
 2010-02-19  Kenneth Rohde Christiansen  <kenneth at webkit.org>
 
         Rubberstamped by Noam Rosenthal, who wrote the original code.
diff --git a/WebCore/loader/ImageLoader.cpp b/WebCore/loader/ImageLoader.cpp
index c61d133..929b28a 100644
--- a/WebCore/loader/ImageLoader.cpp
+++ b/WebCore/loader/ImageLoader.cpp
@@ -230,7 +230,7 @@ void ImageLoader::updateRenderer()
         // is a complete image.  This prevents flickering in the case where a dynamic
         // change is happening between two images.
         CachedImage* cachedImage = imageRenderer->cachedImage();
-        if (m_image != cachedImage && (m_imageComplete || !imageRenderer->cachedImage()))
+        if (m_image != cachedImage && (m_imageComplete || !cachedImage))
             imageRenderer->setCachedImage(m_image.get());
     }
 }
diff --git a/WebCore/page/DragController.cpp b/WebCore/page/DragController.cpp
index c9769df..18e3195 100644
--- a/WebCore/page/DragController.cpp
+++ b/WebCore/page/DragController.cpp
@@ -556,14 +556,9 @@ static CachedImage* getCachedImage(Element* element)
 static Image* getImage(Element* element)
 {
     ASSERT(element);
-    RenderObject* renderer = element->renderer();
-    if (!renderer || !renderer->isImage())
-        return 0;
-
-    RenderImage* image = toRenderImage(renderer);
-    if (image->cachedImage() && !image->cachedImage()->errorOccurred())
-        return image->cachedImage()->image();
-    return 0;
+    CachedImage* cachedImage = getCachedImage(element);
+    return (cachedImage && !cachedImage->errorOccurred()) ?
+        cachedImage->image() : 0;
 }
 
 static void prepareClipboardForImageDrag(Frame* src, Clipboard* clipboard, Element* node, const KURL& linkURL, const KURL& imageURL, const String& label)
diff --git a/WebCore/platform/chromium/PasteboardChromium.cpp b/WebCore/platform/chromium/PasteboardChromium.cpp
index d4f9a27..6904050 100644
--- a/WebCore/platform/chromium/PasteboardChromium.cpp
+++ b/WebCore/platform/chromium/PasteboardChromium.cpp
@@ -125,7 +125,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String& title)
     ASSERT(node->renderer()->isImage());
     RenderImage* renderer = toRenderImage(node->renderer());
     CachedImage* cachedImage = renderer->cachedImage();
-    ASSERT(cachedImage);
+    if (!cachedImage || cachedImage->errorOccurred())
+        return;
     Image* image = cachedImage->image();
     ASSERT(image);
 
diff --git a/WebCore/platform/gtk/PasteboardGtk.cpp b/WebCore/platform/gtk/PasteboardGtk.cpp
index 0b4d356..5c7d9a7 100644
--- a/WebCore/platform/gtk/PasteboardGtk.cpp
+++ b/WebCore/platform/gtk/PasteboardGtk.cpp
@@ -134,7 +134,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
     ASSERT(node && node->renderer() && node->renderer()->isImage());
     RenderImage* renderer = toRenderImage(node->renderer());
     CachedImage* cachedImage = renderer->cachedImage();
-    ASSERT(cachedImage);
+    if (!cachedImage || cachedImage->errorOccurred())
+        return;
     Image* image = cachedImage->image();
     ASSERT(image);
 
diff --git a/WebCore/platform/mac/PasteboardMac.mm b/WebCore/platform/mac/PasteboardMac.mm
index 690637a..086b272 100644
--- a/WebCore/platform/mac/PasteboardMac.mm
+++ b/WebCore/platform/mac/PasteboardMac.mm
@@ -300,9 +300,7 @@ void Pasteboard::writeImage(Node* node, const KURL& url, const String& title)
     ASSERT(node->renderer() && node->renderer()->isImage());
     RenderImage* renderer = toRenderImage(node->renderer());
     CachedImage* cachedImage = renderer->cachedImage();
-    ASSERT(cachedImage);
-    
-    if (cachedImage->errorOccurred())
+    if (!cachedImage || cachedImage->errorOccurred())
         return;
 
     NSArray* types = writableTypesForImage();
diff --git a/WebCore/platform/qt/PasteboardQt.cpp b/WebCore/platform/qt/PasteboardQt.cpp
index 44c9eec..70ec546 100644
--- a/WebCore/platform/qt/PasteboardQt.cpp
+++ b/WebCore/platform/qt/PasteboardQt.cpp
@@ -151,7 +151,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
 
 #ifndef QT_NO_CLIPBOARD
     CachedImage* cachedImage = toRenderImage(node->renderer())->cachedImage();
-    ASSERT(cachedImage);
+    if (!cachedImage || cachedImage->errorOccurred())
+        return;
 
     Image* image = cachedImage->image();
     ASSERT(image);
diff --git a/WebCore/platform/win/PasteboardWin.cpp b/WebCore/platform/win/PasteboardWin.cpp
index d09769a..ffafd02 100644
--- a/WebCore/platform/win/PasteboardWin.cpp
+++ b/WebCore/platform/win/PasteboardWin.cpp
@@ -205,7 +205,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
     ASSERT(node && node->renderer() && node->renderer()->isImage());
     RenderImage* renderer = toRenderImage(node->renderer());
     CachedImage* cachedImage = renderer->cachedImage();
-    ASSERT(cachedImage);
+    if (!cachedImage || cachedImage->errorOccurred())
+        return;
     Image* image = cachedImage->image();
     ASSERT(image);
 
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 9e35866..0869387 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,17 @@
+2010-02-18  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Darin Fisher.
+
+        Add an isImageBlocked bool to the WebContextMenuData struct.
+        https://bugs.webkit.org/show_bug.cgi?id=35136
+        
+        This lets us properly enable/disable the "Copy Image" context menu entry
+        (and, in the future, maybe add a "Load Image" function).
+
+        * public/WebContextMenuData.h:
+        * src/ContextMenuClientImpl.cpp:
+        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
+
 2010-02-19  Marcus Bulach  <bulach at chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/WebKit/chromium/public/WebContextMenuData.h b/WebKit/chromium/public/WebContextMenuData.h
index 5d67046..384240d 100644
--- a/WebKit/chromium/public/WebContextMenuData.h
+++ b/WebKit/chromium/public/WebContextMenuData.h
@@ -63,6 +63,9 @@ struct WebContextMenuData {
     // The absolute URL of the image/video/audio that is in context.
     WebURL srcURL;
 
+    // Whether the image in context has been blocked.
+    bool isImageBlocked;
+
     // The absolute URL of the page in context.
     WebURL pageURL;
 
diff --git a/WebKit/chromium/src/ContextMenuClientImpl.cpp b/WebKit/chromium/src/ContextMenuClientImpl.cpp
index 8472082..06a29ff 100644
--- a/WebKit/chromium/src/ContextMenuClientImpl.cpp
+++ b/WebKit/chromium/src/ContextMenuClientImpl.cpp
@@ -182,6 +182,10 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
         if (mediaElement->hasAudio())
             data.mediaFlags |= WebContextMenuData::MediaHasAudio;
     }
+
+    data.isImageBlocked =
+        (data.mediaType == WebContextMenuData::MediaTypeImage) && !r.image();
+
     // If it's not a link, an image, a media element, or an image/media link,
     // show a selection menu or a more generic page menu.
     data.frameEncoding = selectedFrame->loader()->encoding();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list