Changeset 166665 in webkit


Ignore:
Timestamp:
Apr 2, 2014 2:06:33 PM (10 years ago)
Author:
dbates@webkit.org
Message:

Remove Settings::maximumDecodedImageSize()
https://bugs.webkit.org/show_bug.cgi?id=131057
<rdar://problem/15626368>

Source/WebCore:

Reviewed by Darin Adler.

The setting Settings::maximumDecodedImageSize() and its related logic have various
shortcomings, including the inability to cancel an image load when the estimated
decoded image size exceeds the maximum decoded image size. In the iOS port, this
setting is less useful given image subsampling support. For now, we remove this
setting and its related logic. Should it turn out that such a setting is useful
then we can implement it again taking care to address the shortcomings in the
original design.

  • html/HTMLCanvasElement.cpp: For the iOS port, define MaxCanvasArea to be 4580 * 1145

pixels such that the maximum size of the image buffer is 20 MB (assumes 4 bytes per pixel).
(WebCore::HTMLCanvasElement::HTMLCanvasElement):
(WebCore::HTMLCanvasElement::createImageBuffer):

  • html/HTMLCanvasElement.h:
  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::createImageData):
(WebCore::CanvasRenderingContext2D::getImageData):

  • loader/cache/CachedImage.cpp:

(WebCore::CachedImage::addIncrementalDataBuffer):
(WebCore::CachedImage::finishLoading):

  • loader/cache/CachedImage.h:
  • page/Settings.in:

Source/WebKit/mac:

Reviewed by Darin Adler.

Remove preferences key WebKitMaximumImageSize.

  • WebView/WebPreferenceKeysPrivate.h:
  • WebView/WebPreferences.mm:

(+[WebPreferences initialize]):
(-[WebPreferences _maximumImageSize:]): Deleted.

  • WebView/WebPreferencesPrivate.h:
  • WebView/WebView.mm:

(-[WebView _preferencesChanged:]):

LayoutTests:

Reviewed by Darin Adler.

Remove test LayoutTests/fast/images/decoded-size-exceeds-max-decoded-size.html as it
isn't applicable following the removal of the setting Settings::maximumDecodedImageSize().
Additionally update the test fast/images/bag-png.html to ensure that we dispatch
a DOM Error event when we fail to decode a malformed image.

  • fast/images/bad-png.html:
  • fast/images/decoded-size-exceeds-max-decoded-size-expected.txt: Removed.
  • fast/images/decoded-size-exceeds-max-decoded-size.html: Removed.
Location:
trunk
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r166657 r166665  
     12014-04-02  Daniel Bates  <dabates@apple.com>
     2
     3        Remove Settings::maximumDecodedImageSize()
     4        https://bugs.webkit.org/show_bug.cgi?id=131057
     5        <rdar://problem/15626368>
     6
     7        Reviewed by Darin Adler.
     8
     9        Remove test LayoutTests/fast/images/decoded-size-exceeds-max-decoded-size.html as it
     10        isn't applicable following the removal of the setting Settings::maximumDecodedImageSize().
     11        Additionally update the test fast/images/bag-png.html to ensure that we dispatch
     12        a DOM Error event when we fail to decode a malformed image.
     13
     14        * fast/images/bad-png.html:
     15        * fast/images/decoded-size-exceeds-max-decoded-size-expected.txt: Removed.
     16        * fast/images/decoded-size-exceeds-max-decoded-size.html: Removed.
     17
    1182014-04-02  Timothy Hatcher  <timothy@apple.com>
    219
  • trunk/LayoutTests/fast/images/bad-png.html

    r121012 r166665  
    22  <head>
    33    <script>
    4       if (window.testRunner)
     4      if (window.testRunner) {
     5        testRunner.waitUntilDone();
    56        testRunner.dumpAsText();
     7      }
     8
     9      function testPassed()
     10      {
     11        document.getElementById("result").innerText = "PASS";
     12        if (window.testRunner)
     13          testRunner.notifyDone();
     14      }
    615    </script>
    716
     
    1120          corruption when trying to unwind the stack through a member of a
    1221          destroyed object. -->
    13      <img src="resources/bad-png.png">
    14      <p>PASS</p>
     22     <img src="resources/bad-png.png" onerror="testPassed()">
     23     <p id="result">FAIL</p>
    1524   </body>
    1625 </html>
  • trunk/Source/WebCore/ChangeLog

    r166661 r166665  
     12014-04-02  Daniel Bates  <dabates@apple.com>
     2
     3        Remove Settings::maximumDecodedImageSize()
     4        https://bugs.webkit.org/show_bug.cgi?id=131057
     5        <rdar://problem/15626368>
     6
     7        Reviewed by Darin Adler.
     8
     9        The setting Settings::maximumDecodedImageSize() and its related logic have various
     10        shortcomings, including the inability to cancel an image load when the estimated
     11        decoded image size exceeds the maximum decoded image size. In the iOS port, this
     12        setting is less useful given image subsampling support. For now, we remove this
     13        setting and its related logic. Should it turn out that such a setting is useful
     14        then we can implement it again taking care to address the shortcomings in the
     15        original design.
     16
     17        * html/HTMLCanvasElement.cpp: For the iOS port, define MaxCanvasArea to be 4580 * 1145
     18        pixels such that the maximum size of the image buffer is 20 MB (assumes 4 bytes per pixel).
     19        (WebCore::HTMLCanvasElement::HTMLCanvasElement):
     20        (WebCore::HTMLCanvasElement::createImageBuffer):
     21        * html/HTMLCanvasElement.h:
     22        * html/canvas/CanvasRenderingContext2D.cpp:
     23        (WebCore::CanvasRenderingContext2D::createImageData):
     24        (WebCore::CanvasRenderingContext2D::getImageData):
     25        * loader/cache/CachedImage.cpp:
     26        (WebCore::CachedImage::addIncrementalDataBuffer):
     27        (WebCore::CachedImage::finishLoading):
     28        * loader/cache/CachedImage.h:
     29        * page/Settings.in:
     30
    1312014-04-02  Martin Hock  <mhock@apple.com>
    232
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r166491 r166665  
    6868// Firefox limits width/height to 32767 pixels, but slows down dramatically before it
    6969// reaches that limit. We limit by area instead, giving us larger maximum dimensions,
    70 // in exchange for a smaller maximum canvas size.
    71 #if !PLATFORM(IOS)
    72 static const float MaxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS pixels
     70// in exchange for a smaller maximum canvas size. The maximum canvas size is in CSS pixels.
     71#if PLATFORM(IOS)
     72static const float MaxCanvasArea = 4580 * 1145; // 20 MB assuming 4 bytes per pixel
     73#else
     74static const float MaxCanvasArea = 32768 * 8192;
    7375#endif
    7476
     
    8082    , m_deviceScaleFactor(targetDeviceScaleFactor())
    8183    , m_originClean(true)
    82 #if PLATFORM(IOS)
    83     // FIXME: We should look to reconcile usage of MaxCanvasArea and m_maximumDecodedImageSize.
    84     , m_maximumDecodedImageSize(document.settings() ? document.settings()->maximumDecodedImageSize() : 0)
    85 #endif
    8684    , m_hasCreatedImageBuffer(false)
    8785    , m_didClearImageBuffer(false)
     
    575573        return;
    576574
    577 #if PLATFORM(IOS)
    578     if (deviceSize.width() * deviceSize.height() * 4 > m_maximumDecodedImageSize)
    579         return;
    580 #else
    581575    if (deviceSize.width() * deviceSize.height() > MaxCanvasArea)
    582576        return;
    583 #endif
    584577
    585578    IntSize bufferSize(deviceSize.width(), deviceSize.height());
  • trunk/Source/WebCore/html/HTMLCanvasElement.h

    r166491 r166665  
    129129    bool originClean() const { return m_originClean; }
    130130
    131 #if PLATFORM(IOS)
    132     // FIXME: Can we use unsigned data types, unsigned or size_t?
    133     void setMaximumDecodedImageSize(float maximumDecodedImageSize) { m_maximumDecodedImageSize = maximumDecodedImageSize; }
    134     float maximumDecodedImageSize() { return m_maximumDecodedImageSize; }
    135 #endif
    136 
    137131    AffineTransform baseTransform() const;
    138132
     
    183177    bool m_originClean;
    184178
    185 #if PLATFORM(IOS)
    186     // FIXME: Can we use a unsigned data type, unsigned or size_t?
    187     float m_maximumDecodedImageSize;
    188 #endif
    189 
    190179    // m_createdImageBuffer means we tried to malloc the buffer.  We didn't necessarily get it.
    191180    mutable bool m_hasCreatedImageBuffer;
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r166300 r166665  
    18581858    }
    18591859
    1860 #if PLATFORM(IOS)
    1861     // If the canvas element was created before Document had a Frame,
    1862     // then no maximumDecodedImageSize was set.
    1863     if (!canvas()->maximumDecodedImageSize()) {
    1864         if (Settings* settings = canvas()->document().settings())
    1865             canvas()->setMaximumDecodedImageSize(settings->maximumDecodedImageSize());
    1866     }
    1867 #endif
    1868 
    18691860    FloatSize logicalSize(fabs(sw), fabs(sh));
    18701861    if (!logicalSize.isExpressibleAsIntSize())
     
    19161907        sh = -sh;
    19171908    }
    1918 
    1919 #if PLATFORM(IOS)
    1920     // If the canvas element was created before Document had a Frame,
    1921     // then no maximumDecodedImageSize was set.
    1922     if (!canvas()->maximumDecodedImageSize()) {
    1923         if (Settings* settings = canvas()->document().settings())
    1924             canvas()->setMaximumDecodedImageSize(settings->maximumDecodedImageSize());
    1925     }
    1926 #endif
    19271909
    19281910    FloatRect logicalRect(sx, sy, sw, sh);
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r166642 r166665  
    382382}
    383383
    384 bool CachedImage::canBeDrawn() const
    385 {
    386     if (!m_image || m_image->isNull())
    387         return false;
    388 
    389     if (!m_loader || m_loader->reachedTerminalState())
    390         return true;
    391 
    392     size_t estimatedDecodedImageSize = m_image->width() * m_image->height() * 4; // no overflow check
    393     return estimatedDecodedImageSize <= m_loader->frameLoader()->frame().settings().maximumDecodedImageSize();
    394 }
    395 
    396384void CachedImage::addIncrementalDataBuffer(ResourceBuffer* data)
    397385{
     
    409397        return;
    410398
    411     if (!canBeDrawn()) {
    412         // There's no image to draw or its decoded size is bigger than the maximum allowed.
     399    if (m_image->isNull()) {
     400        // Image decoding failed. Either we need more image data or the image data is malformed.
    413401        error(errorOccurred() ? status() : DecodeError);
    414402        if (inCache())
     
    448436        m_image->setData(m_data->sharedBuffer(), true);
    449437
    450     if (!canBeDrawn()) {
    451         // There's no image to draw or its decoded size is bigger than the maximum allowed.
     438    if (!m_image || m_image->isNull()) {
     439        // Image decoding failed; the image data is malformed.
    452440        error(errorOccurred() ? status() : DecodeError);
    453441        if (inCache())
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r166642 r166665  
    100100    void createImage();
    101101    void clearImage();
    102     bool canBeDrawn() const;
    103102    // If not null, changeRect is the changed part of the image.
    104103    void notifyObservers(const IntRect* changeRect = 0);
  • trunk/Source/WebCore/page/Settings.in

    r166516 r166665  
    2626
    2727layoutFallbackWidth type=int, initial=980
    28 maximumDecodedImageSize type=size_t, initial=std::numeric_limits<size_t>::max()
    2928deviceWidth type=int, initial=0
    3029deviceHeight type=int, initial=0
  • trunk/Source/WebKit/mac/ChangeLog

    r166661 r166665  
     12014-04-02  Daniel Bates  <dabates@apple.com>
     2
     3        Remove Settings::maximumDecodedImageSize()
     4        https://bugs.webkit.org/show_bug.cgi?id=131057
     5        <rdar://problem/15626368>
     6
     7        Reviewed by Darin Adler.
     8
     9        Remove preferences key WebKitMaximumImageSize.
     10
     11        * WebView/WebPreferenceKeysPrivate.h:
     12        * WebView/WebPreferences.mm:
     13        (+[WebPreferences initialize]):
     14        (-[WebPreferences _maximumImageSize:]): Deleted.
     15        * WebView/WebPreferencesPrivate.h:
     16        * WebView/WebView.mm:
     17        (-[WebView _preferencesChanged:]):
     18
    1192014-04-02  Martin Hock  <mhock@apple.com>
    220
  • trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h

    r165753 r166665  
    181181
    182182#if TARGET_OS_IPHONE
    183 #define WebKitMaximumImageSizePreferenceKey @"WebKitMaximumImageSize"
    184183#define WebKitStandalonePreferenceKey @"WebKitStandalonePreferenceKey"
    185184#define WebKitTelephoneParsingEnabledPreferenceKey @"WebKitTelephoneParsingEnabledPreferenceKey"
  • trunk/Source/WebKit/mac/WebView/WebPreferences.mm

    r166614 r166665  
    395395    RunLoop::initializeMainRunLoop();
    396396#endif
    397 #if PLATFORM(IOS)
    398     static unsigned defaultMaximumImageSize = 20 * 1024 * 1024;
    399 #endif
    400397
    401398    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
     
    558555
    559556#if PLATFORM(IOS)
    560         [NSNumber numberWithUnsignedInt:defaultMaximumImageSize], WebKitMaximumImageSizePreferenceKey,
    561557        [NSNumber numberWithBool:NO],   WebKitTelephoneParsingEnabledPreferenceKey,
    562558        [NSNumber numberWithInt:-1],      WebKitLayoutIntervalPreferenceKey,
     
    14061402
    14071403#if PLATFORM(IOS)
    1408 - (size_t)_maximumImageSize
    1409 {
    1410     return [[NSUserDefaults standardUserDefaults] integerForKey:WebKitMaximumImageSizePreferenceKey];
    1411 }
    1412 
    14131404- (BOOL)_standalone
    14141405{
  • trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h

    r165979 r166665  
    293293// Other private methods
    294294#if TARGET_OS_IPHONE
    295 - (size_t)_maximumImageSize;
    296295- (BOOL)_standalone;
    297296- (void)_setStandalone:(BOOL)flag;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r166661 r166665  
    22892289    // iOS-specific settings
    22902290    settings.setStandalone([preferences _standalone]);
    2291     settings.setMaximumDecodedImageSize([preferences _maximumImageSize]);
    22922291    settings.setTelephoneNumberParsingEnabled([preferences _telephoneNumberParsingEnabled]);
    22932292    settings.setAlwaysUseBaselineOfPrimaryFont([preferences _alwaysUseBaselineOfPrimaryFont]);
Note: See TracChangeset for help on using the changeset viewer.