Changeset 79771 in webkit
- Timestamp:
- Feb 26, 2011 1:32:19 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r79770 r79771 1 2011-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 1 13 2011-02-26 Eric Seidel <eric@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r79769 r79771 1 2011-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 1 24 2011-02-26 Chris Evans <cevans@chromium.org> 2 25 -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r79107 r79771 306 306 307 307 virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext() = 0; 308 309 virtual bool shouldPaintBrokenImage(const KURL&) const { return true; } 308 310 }; 309 311 -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r78297 r79771 32 32 #include "CachedResourceRequest.h" 33 33 #include "Frame.h" 34 #include "FrameLoaderClient.h" 34 35 #include "FrameLoaderTypes.h" 35 36 #include "FrameView.h" … … 56 57 , m_image(0) 57 58 , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired) 59 , m_shouldPaintBrokenImage(true) 58 60 { 59 61 setStatus(Unknown); … … 64 66 , m_image(image) 65 67 , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired) 68 , m_shouldPaintBrokenImage(true) 66 69 { 67 70 setStatus(Cached); … … 121 124 ASSERT(!isPurgeable()); 122 125 123 if (errorOccurred() )126 if (errorOccurred() && m_shouldPaintBrokenImage) 124 127 return brokenImage(); 125 128 … … 215 218 while (CachedResourceClient* c = w.next()) 216 219 c->imageChanged(this, changeRect); 220 } 221 222 void 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)); 217 229 } 218 230 … … 297 309 void CachedImage::error(CachedResource::Status status) 298 310 { 311 checkShouldPaintBrokenImage(); 299 312 clear(); 300 313 setStatus(status); -
trunk/Source/WebCore/loader/cache/CachedImage.h
r75137 r79771 96 96 void decodedDataDeletionTimerFired(Timer<CachedImage>*); 97 97 virtual PurgePriority purgePriority() const { return PurgeFirst; } 98 void checkShouldPaintBrokenImage(); 98 99 99 100 RefPtr<Image> m_image; 100 101 Timer<CachedImage> m_decodedDataDeletionTimer; 102 bool m_shouldPaintBrokenImage; 101 103 }; 102 104 -
trunk/Source/WebKit/mac/ChangeLog
r79764 r79771 1 2011-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 1 23 2011-02-26 Vsevolod Vlasov <vsevik@chromium.org> 2 24 -
trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
r79107 r79771 240 240 241 241 virtual bool canCachePage() const; 242 242 243 243 virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext(); 244 245 virtual bool shouldPaintBrokenImage(const WebCore::KURL&) const; 244 246 245 247 RetainPtr<WebFrame> m_webFrame; -
trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
r79107 r79771 440 440 #endif 441 441 442 bool 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 442 454 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge&challenge) 443 455 { -
trunk/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h
r76191 r79771 49 49 IMP plugInFailedWithErrorFunc; 50 50 IMP shouldUseCredentialStorageFunc; 51 IMP shouldPaintBrokenImageForURLFunc; 51 52 }; 52 53 … … 134 135 id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, NSInteger, id); 135 136 137 BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id); 136 138 BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id, id); 137 139 BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id, id, id); -
trunk/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm
r76191 r79771 550 550 } 551 551 552 BOOL 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 552 564 BOOL CallResourceLoadDelegateReturningBoolean(BOOL result, IMP implementation, WebView *self, SEL selector, id object1, id object2) 553 565 { -
trunk/Source/WebKit/mac/WebView/WebResourceLoadDelegatePrivate.h
r58442 r79771 54 54 #endif 55 55 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; 56 63 @end 57 64 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r79589 r79771 1552 1552 cache->willSendRequestFunc = getMethod(delegate, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:)); 1553 1553 cache->shouldUseCredentialStorageFunc = getMethod(delegate, @selector(webView:resource:shouldUseCredentialStorageForDataSource:)); 1554 cache->shouldPaintBrokenImageForURLFunc = getMethod(delegate, @selector(webView:shouldPaintBrokenImageForURL:)); 1554 1555 } 1555 1556 -
trunk/Tools/ChangeLog
r79764 r79771 1 2011-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 1 22 2011-02-26 Vsevolod Vlasov <vsevik@chromium.org> 2 23 -
trunk/Tools/DumpRenderTree/LayoutTestController.cpp
r78620 r79771 84 84 , m_isPrinting(false) 85 85 , m_deferMainResourceDataLoad(true) 86 , m_shouldPaintBrokenImage(true) 86 87 , m_testPathOrURL(testPathOrURL) 87 88 , m_expectedPixelHash(expectedPixelHash) … … 1778 1779 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 1779 1780 controller->addUserStyleSheet(source.get(), allFrames); 1781 return JSValueMakeUndefined(context); 1782 } 1783 1784 static 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 1780 1793 return JSValueMakeUndefined(context); 1781 1794 } … … 2128 2141 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2129 2142 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2143 { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2130 2144 { 0, 0, 0 } 2131 2145 }; … … 2217 2231 } 2218 2232 2233 void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage) 2234 { 2235 m_shouldPaintBrokenImage = shouldPaintBrokenImage; 2236 } 2237 2219 2238 const unsigned LayoutTestController::maxViewWidth = 800; 2220 2239 const unsigned LayoutTestController::maxViewHeight = 600; -
trunk/Tools/DumpRenderTree/LayoutTestController.h
r78620 r79771 308 308 JSRetainPtr<JSStringRef> markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const; 309 309 310 void setShouldPaintBrokenImage(bool); 311 bool shouldPaintBrokenImage() const { return m_shouldPaintBrokenImage; } 312 310 313 static const unsigned maxViewWidth; 311 314 static const unsigned maxViewHeight; … … 359 362 bool m_isPrinting; 360 363 bool m_deferMainResourceDataLoad; 364 bool m_shouldPaintBrokenImage; 361 365 362 366 std::string m_authenticationUsername; -
trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm
r75768 r79771 246 246 } 247 247 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.