[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

pkasting at chromium.org pkasting at chromium.org
Thu Apr 8 01:02:31 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 74df843124e570aed4a00e93ab48501710fadf81
Author: pkasting at chromium.org <pkasting at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 12 19:52:37 2010 +0000

    Remove XBM support from the open-source image decoders.
    https://bugs.webkit.org/show_bug.cgi?id=27823
    
    Reviewed by Dimitri Glazkov.
    
    * GNUmakefile.am:
    * WebCore.gypi:
    * WebCore.vcproj/WebCore.vcproj:
    * WebCoreSources.bkl:
    * platform/image-decoders/ImageDecoder.cpp:
    (WebCore::ImageDecoder::create):
    * platform/image-decoders/xbm: Removed.
    * platform/image-decoders/xbm/XBMImageDecoder.cpp: Removed.
    * platform/image-decoders/xbm/XBMImageDecoder.h: Removed.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53152 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ed40e3f..b42f426 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-01-12  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        Remove XBM support from the open-source image decoders.
+        https://bugs.webkit.org/show_bug.cgi?id=27823
+
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCoreSources.bkl:
+        * platform/image-decoders/ImageDecoder.cpp:
+        (WebCore::ImageDecoder::create):
+        * platform/image-decoders/xbm: Removed.
+        * platform/image-decoders/xbm/XBMImageDecoder.cpp: Removed.
+        * platform/image-decoders/xbm/XBMImageDecoder.h: Removed.
+
 2010-01-12  Alexey Proskuryakov  <ap at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 9745fb7..970e648 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -41,7 +41,6 @@ webcore_cppflags += \
 	-I$(srcdir)/WebCore/platform/image-decoders/ico \
 	-I$(srcdir)/WebCore/platform/image-decoders/jpeg \
 	-I$(srcdir)/WebCore/platform/image-decoders/png \
-	-I$(srcdir)/WebCore/platform/image-decoders/xbm \
 	-I$(srcdir)/WebCore/platform/mock \
 	-I$(srcdir)/WebCore/platform/network \
 	-I$(srcdir)/WebCore/platform/sql \
@@ -2034,8 +2033,6 @@ webcoregtk_sources += \
 	WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h \
 	WebCore/platform/image-decoders/png/PNGImageDecoder.cpp \
 	WebCore/platform/image-decoders/png/PNGImageDecoder.h \
-	WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp \
-	WebCore/platform/image-decoders/xbm/XBMImageDecoder.h \
 	WebCore/platform/network/soup/AuthenticationChallenge.h \
 	WebCore/platform/network/soup/CookieJarSoup.cpp \
 	WebCore/platform/network/soup/CookieJarSoup.h \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index e763b4c..0cab6be 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2335,8 +2335,6 @@
             'platform/image-decoders/png/PNGImageDecoder.h',
             'platform/image-decoders/skia/ImageDecoderSkia.cpp',
             'platform/image-decoders/wx/ImageDecoderWx.cpp',
-            'platform/image-decoders/xbm/XBMImageDecoder.cpp',
-            'platform/image-decoders/xbm/XBMImageDecoder.h',
             'platform/image-decoders/zlib/crc32.h',
             'platform/image-decoders/zlib/deflate.h',
             'platform/image-decoders/zlib/inffast.h',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 52b9a2a..c640854 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -26155,83 +26155,6 @@
 						</FileConfiguration>
 					</File>
 				</Filter>
-				<Filter
-					Name="xbm"
-					>
-					<File
-						RelativePath="..\platform\image-decoders\xbm\XBMImageDecoder.cpp"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Debug_Internal|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Debug_All|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\platform\image-decoders\xbm\XBMImageDecoder.h"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCustomBuildTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCustomBuildTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Debug_Internal|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCustomBuildTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Debug_All|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCustomBuildTool"
-							/>
-						</FileConfiguration>
-					</File>
-				</Filter>
-			</Filter>
 			<Filter
 				Name="animation"
 				>
diff --git a/WebCore/WebCoreSources.bkl b/WebCore/WebCoreSources.bkl
index 57d407f..87ac07e 100644
--- a/WebCore/WebCoreSources.bkl
+++ b/WebCore/WebCoreSources.bkl
@@ -953,10 +953,6 @@ This file contains the list of files needed to build WebCore.
         platform/image-decoders/ico/ICOImageDecoder.cpp
     </set>
 
-    <set append="1" var="WEBCORE_SOURCES_XBM">
-        platform/image-decoders/xbm/XBMImageDecoder.cpp
-    </set>
-
     <set append="1" var="WEBCORE_SOURCES_RENDERING">
         rendering/AutoTableLayout.cpp
         rendering/break_lines.cpp
diff --git a/WebCore/platform/image-decoders/ImageDecoder.cpp b/WebCore/platform/image-decoders/ImageDecoder.cpp
index 9f665d9..e9a947e 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/ImageDecoder.cpp
@@ -33,7 +33,6 @@
 #include "JPEGImageDecoder.h"
 #include "PNGImageDecoder.h"
 #include "SharedBuffer.h"
-#include "XBMImageDecoder.h"
 
 using namespace std;
 
@@ -56,14 +55,11 @@ static unsigned copyFromSharedBuffer(char* buffer, unsigned bufferLength, const
 
 ImageDecoder* ImageDecoder::create(const SharedBuffer& data)
 {
-    // XBMs require 8 bytes of info.
-    static const unsigned maxMarkerLength = 8;
-
+    // We need at least 4 bytes to figure out what kind of image we're dealing with.
+    static const unsigned maxMarkerLength = 4;
     char contents[maxMarkerLength];
     unsigned length = copyFromSharedBuffer(contents, maxMarkerLength, data, 0);
-
-    // We need at least 4 bytes to figure out what kind of image we're dealing with.
-    if (length < 4)
+    if (length < maxMarkerLength)
         return 0;
 
     const unsigned char* uContents = reinterpret_cast<const unsigned char*>(contents);
@@ -95,10 +91,6 @@ ImageDecoder* ImageDecoder::create(const SharedBuffer& data)
         !memcmp(contents, "\000\000\002\000", 4))
         return new ICOImageDecoder();
 
-    // XBMs require 8 bytes of info.
-    if (length >= 8 && strncmp(contents, "#define ", 8) == 0)
-        return new XBMImageDecoder();
-
     // Give up. We don't know what the heck this is.
     return 0;
 }
diff --git a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp b/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp
deleted file mode 100644
index 332bc72..0000000
--- a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "XBMImageDecoder.h"
-
-#include "ASCIICType.h"
-
-#include <algorithm>
-#include <cstdio>
-
-namespace WebCore {
-
-XBMImageDecoder::XBMImageDecoder()
-    : m_decodeOffset(0)
-    , m_allDataReceived(false)
-    , m_decodedHeader(false)
-    , m_dataType(Unknown)
-    , m_bitsDecoded(0)
-{
-}
-
-void XBMImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
-{
-    ImageDecoder::setData(data, allDataReceived);
-    m_xbmString = data->buffer();
-    m_xbmString.append('\0');
-
-    m_allDataReceived = allDataReceived;
-}
-
-bool XBMImageDecoder::isSizeAvailable()
-{
-    if (!ImageDecoder::isSizeAvailable() && !m_failed)
-        decode(true);
-
-    return ImageDecoder::isSizeAvailable();
-}
-
-RGBA32Buffer* XBMImageDecoder::frameBufferAtIndex(size_t index)
-{
-    if (index)
-        return 0;
-
-    if (m_frameBufferCache.isEmpty())
-        m_frameBufferCache.resize(1);
-
-    // Attempt to get the size if we don't have it yet.
-    if (!ImageDecoder::isSizeAvailable())
-        decode(true);
-    
-    // Initialize the framebuffer if needed.
-    RGBA32Buffer& buffer = m_frameBufferCache[0];
-    if (!failed() && ImageDecoder::isSizeAvailable()
-        && (buffer.status() == RGBA32Buffer::FrameEmpty)) {
-        if (!buffer.setSize(size().width(), size().height())) {
-            m_failed = true;
-            return 0;
-        }
-        buffer.setStatus(RGBA32Buffer::FramePartial);
-
-        // For XBMs, the frame always fills the entire image.
-        buffer.setRect(IntRect(IntPoint(), size()));
-    }
-        
-    // Keep trying to decode until we've got the entire image.
-    if (buffer.status() == RGBA32Buffer::FramePartial)
-        decode(false);
-
-    return &buffer;
-}
-
-bool XBMImageDecoder::decodeHeader()
-{
-    ASSERT(m_decodeOffset <= m_xbmString.size());
-    ASSERT(!m_decodedHeader);
-
-    const char* input = m_xbmString.data();
-
-    // At least 2 "#define <string> <unsigned>" sequences are required. These
-    // specify the width and height of the image.
-    int width, height;
-    if (!ImageDecoder::isSizeAvailable()) {
-        int count;
-        if (sscanf(&input[m_decodeOffset], "#define %*s %i #define %*s %i%n",
-                   &width, &height, &count) != 2)
-            return false;
-
-        // The width and height need to follow some rules.
-        if (width < 0 || width > maxDimension || height < 0 || height > maxDimension) {
-            // If this happens, decoding should not continue.
-            setFailed();
-            return false;
-        }
-
-        if (!setSize(width, height)) {
-            setFailed();
-            return false;
-        }
-        m_decodeOffset += count;
-        ASSERT(m_decodeOffset <= m_xbmString.size());
-    }
-
-    ASSERT(ImageDecoder::isSizeAvailable());
-
-    // Now we're looking for something that tells us that we've seen all of the
-    // "#define <string> <unsigned>" sequences that we're going to. Mozilla
-    // just looks for " char " or " short ". We'll do the same.
-    if (m_dataType == Unknown) {
-        const char* x11hint = " char ";
-        const char* x11HintLocation = strstr(&input[m_decodeOffset], x11hint);
-        if (x11HintLocation) {
-            m_dataType = X11;
-            m_decodeOffset += ((x11HintLocation - &input[m_decodeOffset]) + strlen(x11hint));
-        } else {
-            const char* x10hint = " short ";
-            const char* x10HintLocation = strstr(&input[m_decodeOffset], x10hint);
-            if (x10HintLocation) {
-                m_dataType = X10;
-                m_decodeOffset += ((x10HintLocation - &input[m_decodeOffset]) + strlen(x10hint));
-            } else
-                return false;
-        }
-        ASSERT(m_decodeOffset <= m_xbmString.size());
-    }
-
-    // Find the start of the data. Again, we do what mozilla does and just
-    // look for a '{' in the input.
-    const char* found = strchr(&input[m_decodeOffset], '{');
-    if (!found)
-        return false;
-
-    // Advance to character after the '{'
-    m_decodeOffset += ((found - &input[m_decodeOffset]) + 1);
-    ASSERT(m_decodeOffset <= m_xbmString.size());
-    m_decodedHeader = true;
-
-    return true;
-}
-
-// The data in an XBM file is provided as an array of either "char" or "short"
-// values. These values are decoded one at a time using strtoul() and the bits
-// are used to set the alpha value for the image.
-//
-// The value for the color is always set to RGB(0,0,0), the alpha value takes
-// care of whether or not the pixel shows up.
-//
-// Since the data may arrive in chunks, and many prefixes of valid numbers are
-// themselves valid numbers, this code needs to check to make sure that the
-// value is not truncated. This is done by consuming space after the value
-// read until a ',' or a '}' occurs. In a valid XBM, one of these characters
-// will occur after each value.
-//
-// The checks after strtoul are based on Mozilla's nsXBMDecoder.cpp.
-bool XBMImageDecoder::decodeDatum(uint16_t* result)
-{
-    const char* input = m_xbmString.data();
-    char* endPtr;
-    const uint16_t value = strtoul(&input[m_decodeOffset], &endPtr, 0);
-
-    // End of input or couldn't decode anything, can't go any further.
-    if (endPtr == &input[m_decodeOffset] || !*endPtr)
-        return false;
-
-    // Possibly a hex value truncated at "0x". Need more data.
-    if (value == 0 && (*endPtr == 'x' || *endPtr == 'X'))
-        return false;
-
-    // Skip whitespace
-    while (*endPtr && isASCIISpace(*endPtr))
-        ++endPtr;
-
-    // Out of input, don't know what comes next.
-    if (!*endPtr)
-        return false;
-
-    // If the next non-whitespace character is not one of these, it's an error.
-    // Every valid entry in the data array needs to be followed by ',' or '}'.
-    if (*endPtr != ',' && *endPtr != '}') {
-        setFailed();
-        return false;
-    }
-
-    // At this point we have a value.
-    *result = value;
-
-    // Skip over the decoded value plus the delimiter (',' or '}').
-    m_decodeOffset += ((endPtr - &input[m_decodeOffset]) + 1);
-    ASSERT(m_decodeOffset <= m_xbmString.size());
-
-    return true;
-}
-
-bool XBMImageDecoder::decodeData()
-{
-    ASSERT(m_decodeOffset <= m_xbmString.size());
-    ASSERT(m_decodedHeader && !m_frameBufferCache.isEmpty());
-
-    RGBA32Buffer& frame = m_frameBufferCache[0];
-
-    ASSERT(frame.status() == RGBA32Buffer::FramePartial);
-
-    const int bitsPerRow = size().width();
-
-    ASSERT(m_dataType != Unknown);
-
-    while (m_bitsDecoded < (size().width() * size().height())) {
-        uint16_t value;
-        if (!decodeDatum(&value))
-            return false;
-
-        int x = m_bitsDecoded % bitsPerRow;
-        const int y = m_bitsDecoded / bitsPerRow;
-
-        // How many bits will be written?
-        const int bits = std::min(bitsPerRow - x, (m_dataType == X11) ? 8 : 16);
-
-        // Only the alpha channel matters here, so the color values are always
-        // set to 0.
-        for (int i = 0; i < bits; ++i)
-            frame.setRGBA(x++, y, 0, 0, 0, value & (1 << i) ? 255 : 0);
-
-        m_bitsDecoded += bits;
-    }
-
-    frame.setStatus(RGBA32Buffer::FrameComplete);
-
-    return true;
-}
-
-// Decode as much as we can of the XBM file.
-void XBMImageDecoder::decode(bool sizeOnly)
-{
-    if (failed())
-        return;
-
-    bool decodeResult = false;
-
-    if (!m_decodedHeader)
-        decodeResult = decodeHeader();
-
-    if (m_decodedHeader && !sizeOnly)
-        decodeResult = decodeData();
-
-    // The header or the data could not be decoded, but there is no more
-    // data: decoding has failed.
-    if (!decodeResult && m_allDataReceived)
-        setFailed();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h b/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h
deleted file mode 100644
index 00f62ce..0000000
--- a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef XBMImageDecoder_h
-#define XBMImageDecoder_h
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-    // This class decodes the XBM image format.
-    class XBMImageDecoder : public ImageDecoder {
-    public:
-        XBMImageDecoder();
-        virtual ~XBMImageDecoder() {}
-
-        virtual String filenameExtension() const { return "xbm"; }
-
-        virtual void setData(SharedBuffer* data, bool allDataReceived);
-        // Whether or not the size information has been decoded yet.
-        virtual bool isSizeAvailable();
-        virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-
-    private:
-        // Restricts image size to something "reasonable".
-        // This protects agains ridiculously large XBMs and prevents bad things
-        // like overflow of m_bitsDecoded.
-        static const int maxDimension = 65535;
-
-        // In X10, an array of type "short" is used to declare the image bits,
-        // but in X11, the type is "char".
-        enum DataType {
-            Unknown,
-            X10,
-            X11,
-        };
-
-        bool decodeHeader();
-        bool decodeDatum(uint16_t* result);
-        bool decodeData();
-        void decode(bool sizeOnly);
-
-        // FIXME: Copying all the XBM data just so we can NULL-terminate, just
-        // so we can use sscanf() and friends, is lame.  The decoder should be
-        // rewritten to operate on m_data directly.
-        Vector<char> m_xbmString;  // Null-terminated copy of the XBM data.
-        size_t m_decodeOffset;    // The current offset in m_xbmString for decoding.
-        bool m_allDataReceived;
-        bool m_decodedHeader;
-        enum DataType m_dataType;
-        int m_bitsDecoded;
-    };
-
-} // namespace WebCore
-
-#endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list