Changeset 79771 in webkit


Ignore:
Timestamp:
Feb 26, 2011 1:32:19 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-02-26 Yongjun Zhang <yongjun_zhang@apple.com>

Reviewed by David Kilzer.

https://bugs.webkit.org/show_bug.cgi?id=48781

Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.

  • fast/images/resources/broken-image-with-invalid-format.png: Added.
  • fast/images/support-broken-image-delegate.html: Added.
  • platform/mac/fast/images/support-broken-image-delegate-expected.txt: Added.

2011-02-26 Yongjun Zhang <yongjun_zhang@apple.com>

Reviewed by David Kilzer.

https://bugs.webkit.org/show_bug.cgi?id=48781

Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.

Add a new resource load client method (shouldPaintBrokenImage). WebKit client can decide if WebCore
should paint the default broken image when an image fails to load or decode. The method also passes the
URL of the failed image.

Test: fast/images/support-broken-image-delegate.html

  • loader/FrameLoaderClient.h: (WebCore::FrameLoaderClient::shouldPaintBrokenImage):
  • loader/cache/CachedImage.cpp: (WebCore::CachedImage::CachedImage): (WebCore::CachedImage::image): (WebCore::CachedImage::checkShouldPaintBrokenImage): (WebCore::CachedImage::error):
  • loader/cache/CachedImage.h:

2011-02-26 Yongjun Zhang <yongjun_zhang@apple.com>

Reviewed by David Kilzer.

https://bugs.webkit.org/show_bug.cgi?id=48781

Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.

Add a new resource load client method (shouldPaintBrokenImage). WebKit client can decide if WebCore
should paint the default broken image when an image fails to load or decode. The method also passes the
URL of the failed image.

  • WebCoreSupport/WebFrameLoaderClient.h:
  • WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::shouldPaintBrokenImage):
  • WebView/WebDelegateImplementationCaching.h:
  • WebView/WebDelegateImplementationCaching.mm: Added case for passing one object. (CallResourceLoadDelegateReturningBoolean):
  • WebView/WebResourceLoadDelegatePrivate.h:
  • WebView/WebView.mm: (-[WebView _cacheResourceLoadDelegateImplementations]):

2011-02-26 Yongjun Zhang <yongjun_zhang@apple.com>

Reviewed by David Kilzer.

https://bugs.webkit.org/show_bug.cgi?id=48781

Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.

Add a new resource load client method (shouldPaintBrokenImage). WebKit client can decide if WebCore
should paint the default broken image when an image fails to load or decode.

  • DumpRenderTree/LayoutTestController.cpp: (LayoutTestController::LayoutTestController): (setShouldPaintBrokenImageCallback): (LayoutTestController::staticFunctions): (LayoutTestController::setShouldPaintBrokenImage):
  • DumpRenderTree/LayoutTestController.h: (LayoutTestController::shouldPaintBrokenImage):
  • DumpRenderTree/mac/ResourceLoadDelegate.mm: (-[ResourceLoadDelegate webView:shouldPaintBrokenImageForURL:]):
Location:
trunk
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r79770 r79771  
     12011-02-26  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48781
     6
     7        Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.
     8
     9        * fast/images/resources/broken-image-with-invalid-format.png: Added.
     10        * fast/images/support-broken-image-delegate.html: Added.
     11        * platform/mac/fast/images/support-broken-image-delegate-expected.txt: Added.
     12
    1132011-02-26  Eric Seidel  <eric@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r79769 r79771  
     12011-02-26  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48781
     6
     7        Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.
     8
     9        Add a new resource load client method (shouldPaintBrokenImage).  WebKit client can decide if WebCore
     10        should paint the default broken image when an image fails to load or decode.  The method also passes the
     11        URL of the failed image.
     12
     13        Test: fast/images/support-broken-image-delegate.html
     14
     15        * loader/FrameLoaderClient.h:
     16        (WebCore::FrameLoaderClient::shouldPaintBrokenImage):
     17        * loader/cache/CachedImage.cpp:
     18        (WebCore::CachedImage::CachedImage):
     19        (WebCore::CachedImage::image):
     20        (WebCore::CachedImage::checkShouldPaintBrokenImage):
     21        (WebCore::CachedImage::error):
     22        * loader/cache/CachedImage.h:
     23
    1242011-02-26  Chris Evans  <cevans@chromium.org>
    225
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r79107 r79771  
    306306
    307307        virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext() = 0;
     308
     309        virtual bool shouldPaintBrokenImage(const KURL&) const { return true; }
    308310    };
    309311
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r78297 r79771  
    3232#include "CachedResourceRequest.h"
    3333#include "Frame.h"
     34#include "FrameLoaderClient.h"
    3435#include "FrameLoaderTypes.h"
    3536#include "FrameView.h"
     
    5657    , m_image(0)
    5758    , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
     59    , m_shouldPaintBrokenImage(true)
    5860{
    5961    setStatus(Unknown);
     
    6466    , m_image(image)
    6567    , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
     68    , m_shouldPaintBrokenImage(true)
    6669{
    6770    setStatus(Cached);
     
    121124    ASSERT(!isPurgeable());
    122125
    123     if (errorOccurred())
     126    if (errorOccurred() && m_shouldPaintBrokenImage)
    124127        return brokenImage();
    125128
     
    215218    while (CachedResourceClient* c = w.next())
    216219        c->imageChanged(this, changeRect);
     220}
     221
     222void CachedImage::checkShouldPaintBrokenImage()
     223{
     224    Frame* frame = m_request ? m_request->cachedResourceLoader()->frame() : 0;
     225    if (!frame)
     226        return;
     227
     228    m_shouldPaintBrokenImage = frame->loader()->client()->shouldPaintBrokenImage(KURL(ParsedURLString, m_url));
    217229}
    218230
     
    297309void CachedImage::error(CachedResource::Status status)
    298310{
     311    checkShouldPaintBrokenImage();
    299312    clear();
    300313    setStatus(status);
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r75137 r79771  
    9696    void decodedDataDeletionTimerFired(Timer<CachedImage>*);
    9797    virtual PurgePriority purgePriority() const { return PurgeFirst; }
     98    void checkShouldPaintBrokenImage();
    9899
    99100    RefPtr<Image> m_image;
    100101    Timer<CachedImage> m_decodedDataDeletionTimer;
     102    bool m_shouldPaintBrokenImage;
    101103};
    102104
  • trunk/Source/WebKit/mac/ChangeLog

    r79764 r79771  
     12011-02-26  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48781
     6
     7        Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.
     8
     9        Add a new resource load client method (shouldPaintBrokenImage).  WebKit client can decide if WebCore
     10        should paint the default broken image when an image fails to load or decode.  The method also passes the
     11        URL of the failed image.
     12
     13        * WebCoreSupport/WebFrameLoaderClient.h:
     14        * WebCoreSupport/WebFrameLoaderClient.mm:
     15        (WebFrameLoaderClient::shouldPaintBrokenImage):
     16        * WebView/WebDelegateImplementationCaching.h:
     17        * WebView/WebDelegateImplementationCaching.mm: Added case for passing one object.
     18        (CallResourceLoadDelegateReturningBoolean):
     19        * WebView/WebResourceLoadDelegatePrivate.h:
     20        * WebView/WebView.mm:
     21        (-[WebView _cacheResourceLoadDelegateImplementations]):
     22
    1232011-02-26  Vsevolod Vlasov  <vsevik@chromium.org>
    224
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h

    r79107 r79771  
    240240   
    241241    virtual bool canCachePage() const;
    242    
     242
    243243    virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext();
     244
     245    virtual bool shouldPaintBrokenImage(const WebCore::KURL&) const;
    244246
    245247    RetainPtr<WebFrame> m_webFrame;
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r79107 r79771  
    440440#endif
    441441
     442bool WebFrameLoaderClient::shouldPaintBrokenImage(const KURL& imageURL) const
     443{
     444    WebView *webView = getWebView(m_webFrame.get());
     445    WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
     446
     447    if (implementations->shouldPaintBrokenImageForURLFunc) {
     448        NSURL* url = imageURL;
     449        return CallResourceLoadDelegateReturningBoolean(YES, implementations->shouldPaintBrokenImageForURLFunc, webView, @selector(webView:shouldPaintBrokenImageForURL:), url);
     450    }
     451    return true;
     452}
     453
    442454void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge&challenge)
    443455{
  • trunk/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h

    r76191 r79771  
    4949    IMP plugInFailedWithErrorFunc;
    5050    IMP shouldUseCredentialStorageFunc;
     51    IMP shouldPaintBrokenImageForURLFunc;
    5152};
    5253
     
    134135id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, NSInteger, id);
    135136
     137BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id);
    136138BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id, id);
    137139BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id, id, id);
  • trunk/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm

    r76191 r79771  
    550550}
    551551
     552BOOL CallResourceLoadDelegateReturningBoolean(BOOL result, IMP implementation, WebView *self, SEL selector, id object1)
     553{
     554    if (!self->_private->catchesDelegateExceptions)
     555        return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id)>(objc_msgSend)(self->_private->resourceProgressDelegate, selector, self, object1);
     556    @try {
     557        return reinterpret_cast<BOOL (*)(id, SEL, WebView *, id)>(objc_msgSend)(self->_private->resourceProgressDelegate, selector, self, object1);
     558    } @catch(id exception) {
     559        ReportDiscardedDelegateException(selector, exception);
     560    }
     561    return result;
     562}
     563
    552564BOOL CallResourceLoadDelegateReturningBoolean(BOOL result, IMP implementation, WebView *self, SEL selector, id object1, id object2)
    553565{
  • trunk/Source/WebKit/mac/WebView/WebResourceLoadDelegatePrivate.h

    r58442 r79771  
    5454#endif
    5555
     56/*!
     57 @method webView:shouldPaintBrokenImageForURL:(NSURL*)imageURL
     58 @abstract This message is sent when an image cannot be decoded or displayed.
     59 @param imageURL The url of the broken image.
     60 @result return YES if WebKit should paint the default broken image.
     61 */
     62- (BOOL)webView:(WebView*)sender shouldPaintBrokenImageForURL:(NSURL*)imageURL;
    5663@end
    5764
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r79589 r79771  
    15521552    cache->willSendRequestFunc = getMethod(delegate, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:));
    15531553    cache->shouldUseCredentialStorageFunc = getMethod(delegate, @selector(webView:resource:shouldUseCredentialStorageForDataSource:));
     1554    cache->shouldPaintBrokenImageForURLFunc = getMethod(delegate, @selector(webView:shouldPaintBrokenImageForURL:));
    15541555}
    15551556
  • trunk/Tools/ChangeLog

    r79764 r79771  
     12011-02-26  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48781
     6
     7        Add a resource load delegate method to query if WebCore should paint the default broken image for failed images.
     8
     9        Add a new resource load client method (shouldPaintBrokenImage).  WebKit client can decide if WebCore
     10        should paint the default broken image when an image fails to load or decode.
     11
     12        * DumpRenderTree/LayoutTestController.cpp:
     13        (LayoutTestController::LayoutTestController):
     14        (setShouldPaintBrokenImageCallback):
     15        (LayoutTestController::staticFunctions):
     16        (LayoutTestController::setShouldPaintBrokenImage):
     17        * DumpRenderTree/LayoutTestController.h:
     18        (LayoutTestController::shouldPaintBrokenImage):
     19        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
     20        (-[ResourceLoadDelegate webView:shouldPaintBrokenImageForURL:]):
     21
    1222011-02-26  Vsevolod Vlasov  <vsevik@chromium.org>
    223
  • trunk/Tools/DumpRenderTree/LayoutTestController.cpp

    r78620 r79771  
    8484    , m_isPrinting(false)
    8585    , m_deferMainResourceDataLoad(true)
     86    , m_shouldPaintBrokenImage(true)
    8687    , m_testPathOrURL(testPathOrURL)
    8788    , m_expectedPixelHash(expectedPixelHash)
     
    17781779    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    17791780    controller->addUserStyleSheet(source.get(), allFrames);
     1781    return JSValueMakeUndefined(context);
     1782}
     1783
     1784static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1785{
     1786    // Has Mac implementation
     1787    if (argumentCount < 1)
     1788        return JSValueMakeUndefined(context);
     1789
     1790    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     1791    controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0]));
     1792
    17801793    return JSValueMakeUndefined(context);
    17811794}
     
    21282141        { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    21292142        { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     2143        { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    21302144        { 0, 0, 0 }
    21312145    };
     
    22172231}
    22182232
     2233void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage)
     2234{
     2235    m_shouldPaintBrokenImage = shouldPaintBrokenImage;
     2236}
     2237
    22192238const unsigned LayoutTestController::maxViewWidth = 800;
    22202239const unsigned LayoutTestController::maxViewHeight = 600;
  • trunk/Tools/DumpRenderTree/LayoutTestController.h

    r78620 r79771  
    308308    JSRetainPtr<JSStringRef> markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const;
    309309
     310    void setShouldPaintBrokenImage(bool);
     311    bool shouldPaintBrokenImage() const { return m_shouldPaintBrokenImage; }
     312
    310313    static const unsigned maxViewWidth;
    311314    static const unsigned maxViewHeight;
     
    359362    bool m_isPrinting;
    360363    bool m_deferMainResourceDataLoad;
     364    bool m_shouldPaintBrokenImage;
    361365
    362366    std::string m_authenticationUsername;
  • trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm

    r75768 r79771  
    246246}
    247247
    248 @end
     248-(BOOL)webView: (WebView*)webView shouldPaintBrokenImageForURL:(NSURL*)imageURL
     249{
     250    // Only log the message when shouldPaintBrokenImage() returns NO; this avoids changing results of layout tests with failed
     251    // images, e.g., security/block-test-no-port.html.
     252    if (!done && gLayoutTestController->dumpResourceLoadCallbacks() && !gLayoutTestController->shouldPaintBrokenImage()) {
     253        NSString *string = [NSString stringWithFormat:@"%@ - shouldPaintBrokenImage: NO", [imageURL _drt_descriptionSuitableForTestResult]];
     254        printf("%s\n", [string UTF8String]);
     255    }
     256
     257    return gLayoutTestController->shouldPaintBrokenImage();
     258}
     259@end
Note: See TracChangeset for help on using the changeset viewer.