Changeset 225798 in webkit
- Timestamp:
- Dec 12, 2017 1:01:26 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r225797 r225798 1 2017-12-12 Zach Li <zachli@apple.com> 2 [WK2] Expose image via WKBundleHitTestResult API. 3 https://bugs.webkit.org/show_bug.cgi?id=180552. 4 rdar://problem/23951521 5 6 Reviewed by Simon Fraser. 7 8 * platform/graphics/ImageSource.h: 9 This method will be used by clients outside WebCore, so 10 add WEBCORE_EXPORT. 11 1 12 2017-12-12 Simon Fraser <simon.fraser@apple.com> 2 13 -
trunk/Source/WebCore/platform/graphics/ImageSource.h
r225428 r225798 96 96 97 97 // Image metadata which is calculated from the first ImageFrame. 98 IntSize size();98 WEBCORE_EXPORT IntSize size(); 99 99 IntSize sizeRespectingOrientation(); 100 100 Color singlePixelSolidColor(); -
trunk/Source/WebKit/ChangeLog
r225797 r225798 1 2017-12-12 Zach Li <zachli@apple.com> 2 3 [WK2] Expose image via WKBundleHitTestResult API. 4 https://bugs.webkit.org/show_bug.cgi?id=180552. 5 rdar://problem/23951521 6 7 Reviewed by Simon Fraser. 8 9 * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp: 10 (WKBundleHitTestResultGetImage): 11 * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h: 12 13 * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp: 14 (WebKit::InjectedBundleHitTestResult::image const): 15 Convert from WebCore::Image to WebImage by creating a WebImage 16 and paint the WebCore::Image into its graphics context. For now, 17 only handle bitmap images. 18 * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h: 19 1 20 2017-12-12 Simon Fraser <simon.fraser@apple.com> 2 21 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
r207579 r225798 32 32 #include "WKBundleAPICast.h" 33 33 #include "WebFrame.h" 34 #include "WebImage.h" 34 35 35 36 using namespace WebKit; … … 107 108 } 108 109 110 WKImageRef WKBundleHitTestResultCopyImage(WKBundleHitTestResultRef hitTestResultRef) 111 { 112 RefPtr<WebImage> webImage = toImpl(hitTestResultRef)->image(); 113 return toAPI(webImage.leakRef()); 114 } 115 109 116 bool WKBundleHitTestResultGetIsSelected(WKBundleHitTestResultRef hitTestResultRef) 110 117 { -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h
r207579 r225798 59 59 60 60 WK_EXPORT WKRect WKBundleHitTestResultGetImageRect(WKBundleHitTestResultRef hitTestResult); 61 WK_EXPORT WKImageRef WKBundleHitTestResultCopyImage(WKBundleHitTestResultRef hitTestResult); 61 62 WK_EXPORT bool WKBundleHitTestResultGetIsSelected(WKBundleHitTestResultRef hitTestResult); 62 63 -
trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
r216810 r225798 30 30 #include "WebFrame.h" 31 31 #include "WebFrameLoaderClient.h" 32 #include "WebImage.h" 33 #include <WebCore/BitmapImage.h> 32 34 #include <WebCore/Document.h> 33 35 #include <WebCore/Element.h> … … 35 37 #include <WebCore/FrameLoader.h> 36 38 #include <WebCore/FrameView.h> 39 #include <WebCore/GraphicsContext.h> 37 40 #include <WebCore/URL.h> 38 41 #include <wtf/text/WTFString.h> … … 168 171 } 169 172 173 RefPtr<WebImage> InjectedBundleHitTestResult::image() const 174 { 175 Image* image = m_hitTestResult.image(); 176 // For now, we only handle bitmap images. 177 if (!is<BitmapImage>(image)) 178 return nullptr; 179 180 BitmapImage& bitmapImage = downcast<BitmapImage>(*image); 181 IntSize size(bitmapImage.size()); 182 auto webImage = WebImage::create(size, static_cast<ImageOptions>(0)); 183 184 // FIXME: need to handle EXIF rotation. 185 auto graphicsContext = webImage->bitmap().createGraphicsContext(); 186 graphicsContext->drawImage(bitmapImage, {{ }, size}); 187 188 return webImage; 189 } 190 170 191 bool InjectedBundleHitTestResult::isSelected() const 171 192 { -
trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h
r216810 r225798 38 38 class InjectedBundleNodeHandle; 39 39 class WebFrame; 40 class WebImage; 40 41 41 42 class InjectedBundleHitTestResult : public API::ObjectImpl<API::Object::Type::BundleHitTestResult> { … … 64 65 65 66 WebCore::IntRect imageRect() const; 67 RefPtr<WebImage> image() const; 66 68 67 69 bool isSelected() const;
Note: See TracChangeset
for help on using the changeset viewer.