Title: [137067] trunk
Revision
137067
Author
[email protected]
Date
2012-12-09 02:43:07 -0800 (Sun, 09 Dec 2012)

Log Message

[WK2] Move button image to injected bundle
https://bugs.webkit.org/show_bug.cgi?id=104107
<rdar://problem/12813842>

Reviewed by Simon Fraser.

Source/WebCore:

Update RenderSnapshottedPlugIn to retrieve the start button image from the ChromeClient. Expand the
kinds of images available for use as the button. Try to find the best sized button to use for the plug-in,
otherwise use no image at all.

* rendering/RenderSnapshottedPlugIn.h: Add an enum representing the size to use. Remove the label rect
variable since it is unneeded.
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::startLabelImage): Maintain a cache of the images for reuse. Index into the
array using the enum. If the image has been loaded, or an attempt was made, then return the result. Otherwise
ask the chrome client for the image.
(WebCore::RenderSnapshottedPlugIn::paintLabel): Determine the proper label to use, and paint if the image is
available.
(WebCore::RenderSnapshottedPlugIn::tryToFitStartLabel): Compare the label size with the provided content
box. Return a LayoutRect representing the label's placement. If it doesn't fit, return an empty rect.
(WebCore::RenderSnapshottedPlugIn::layout): The rect is not needed because it is all determined at paint time.

* page/ChromeClient.h:
(WebCore::ChromeClient::plugInStartLabelImage): Added.

* WebCore.exp.in: Expose GraphicsContext::drawNativeImage() for WKImageCG.cpp.
* WebCore.xcodeproj/project.pbxproj: Remove start button assets.
* Resources/startButton.png: Removed.
* Resources/[email protected]: Removed.

Source/WebKit2:

Rely on the injected bundle to create the image used for the button in snapshotted plug-ins.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::plugInStartLabelImage): Forward the call to the injected bundle UI client.
* WebProcess/WebCoreSupport/WebChromeClient.h: Implement plugInStartLabelImage().

* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::plugInStartLabelImage): Convert the WebCore enums to WK API enums.
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:

* WebProcess/InjectedBundle/API/c/WKBundlePage.h: Expose a new callback to generate the button image.

* Shared/API/c/cg/WKImageCG.cpp:
(WKImageCreateFromCGImage): Refactor to use GraphicsContext methods so that the image is flipped appropriately.

Tools:

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::InjectedBundlePage): Update the bundle page UI client.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (137066 => 137067)


--- trunk/Source/WebCore/ChangeLog	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebCore/ChangeLog	2012-12-09 10:43:07 UTC (rev 137067)
@@ -1,3 +1,35 @@
+2012-12-09  Jon Lee  <[email protected]>
+
+        [WK2] Move button image to injected bundle
+        https://bugs.webkit.org/show_bug.cgi?id=104107
+        <rdar://problem/12813842>
+
+        Reviewed by Simon Fraser.
+
+        Update RenderSnapshottedPlugIn to retrieve the start button image from the ChromeClient. Expand the
+        kinds of images available for use as the button. Try to find the best sized button to use for the plug-in,
+        otherwise use no image at all.
+
+        * rendering/RenderSnapshottedPlugIn.h: Add an enum representing the size to use. Remove the label rect
+        variable since it is unneeded.
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugIn::startLabelImage): Maintain a cache of the images for reuse. Index into the
+        array using the enum. If the image has been loaded, or an attempt was made, then return the result. Otherwise
+        ask the chrome client for the image.
+        (WebCore::RenderSnapshottedPlugIn::paintLabel): Determine the proper label to use, and paint if the image is
+        available.
+        (WebCore::RenderSnapshottedPlugIn::tryToFitStartLabel): Compare the label size with the provided content
+        box. Return a LayoutRect representing the label's placement. If it doesn't fit, return an empty rect.
+        (WebCore::RenderSnapshottedPlugIn::layout): The rect is not needed because it is all determined at paint time.
+
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::plugInStartLabelImage): Added.
+
+        * WebCore.exp.in: Expose GraphicsContext::drawNativeImage() for WKImageCG.cpp.
+        * WebCore.xcodeproj/project.pbxproj: Remove start button assets.
+        * Resources/startButton.png: Removed.
+        * Resources/[email protected]: Removed.
+
 2012-12-09  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r137053.

Deleted: trunk/Source/WebCore/Resources/startButton.png


(Binary files differ)

Deleted: trunk/Source/WebCore/Resources/[email protected]


(Binary files differ)

Modified: trunk/Source/WebCore/WebCore.exp.in (137066 => 137067)


--- trunk/Source/WebCore/WebCore.exp.in	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-12-09 10:43:07 UTC (rev 137067)
@@ -1637,6 +1637,7 @@
 __ZN7WebCore12PopupMenuMacC1EPNS_15PopupMenuClientE
 __ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
 __ZN7WebCore15GraphicsContextC1EP9CGContext
+__ZN7WebCore15GraphicsContext15drawNativeImageEP7CGImageRKNS_9FloatSizeENS_10ColorSpaceERKNS_9FloatRectES9_NS_17CompositeOperatorENS_9BlendModeENS_16ImageOrientationE
 __ZN7WebCore16FontPlatformDataC1EP6NSFontfbbbNS_15FontOrientationENS_16FontWidthVariantE
 __ZN7WebCore16FontPlatformDataC2EP6NSFontfbbbNS_15FontOrientationENS_16FontWidthVariantE
 __ZN7WebCore16colorFromNSColorEP7NSColor

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (137066 => 137067)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-12-09 10:43:07 UTC (rev 137067)
@@ -931,8 +931,6 @@
 		319E69B513299BBD004AC91A /* WebKitAnimationList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319E69AF13299BBD004AC91A /* WebKitAnimationList.cpp */; };
 		319E69B613299BBD004AC91A /* WebKitAnimationList.h in Headers */ = {isa = PBXBuildFile; fileRef = 319E69B013299BBD004AC91A /* WebKitAnimationList.h */; };
 		319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 319FBD5D15D2F444009640A6 /* CachedImageClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		31A963A51655D426000D4645 /* startButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A11655D426000D4645 /* startButton.png */; };
-		31A963A61655D426000D4645 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 31A963A21655D426000D4645 /* [email protected] */; };
 		31C0FF210E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */; };
 		31C0FF220E4CEB6E007D6FE5 /* WebKitAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */; };
 		31C0FF240E4CEB6E007D6FE5 /* WebKitTransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1E0E4CEB6E007D6FE5 /* WebKitTransitionEvent.cpp */; };
@@ -8128,8 +8126,6 @@
 		319E69B013299BBD004AC91A /* WebKitAnimationList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAnimationList.h; sourceTree = "<group>"; };
 		319E69B113299BBD004AC91A /* WebKitAnimationList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitAnimationList.idl; sourceTree = "<group>"; };
 		319FBD5D15D2F444009640A6 /* CachedImageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedImageClient.h; sourceTree = "<group>"; };
-		31A963A11655D426000D4645 /* startButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = startButton.png; sourceTree = "<group>"; };
-		31A963A21655D426000D4645 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
 		31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitAnimationEvent.cpp; sourceTree = "<group>"; };
 		31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAnimationEvent.h; sourceTree = "<group>"; };
 		31C0FF1D0E4CEB6E007D6FE5 /* WebKitAnimationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitAnimationEvent.idl; sourceTree = "<group>"; };
@@ -14537,8 +14533,6 @@
 				85136C940AED665900F90A3D /* southEastResizeCursor.png */,
 				85136C950AED665900F90A3D /* southResizeCursor.png */,
 				85136C960AED665900F90A3D /* southWestResizeCursor.png */,
-				31A963A11655D426000D4645 /* startButton.png */,
-				31A963A21655D426000D4645 /* [email protected] */,
 				93153BDB141959BB00FCF5BE /* textAreaResizeCorner.png */,
 				9370918C1416D86B00477333 /* [email protected] */,
 				46D4F2480AF97E810035385A /* verticalTextCursor.png */,
@@ -26051,8 +26045,6 @@
 				85136CA80AED665900F90A3D /* westResizeCursor.png in Resources */,
 				1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */,
 				1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
-				31A963A51655D426000D4645 /* startButton.png in Resources */,
-				31A963A61655D426000D4645 /* [email protected] in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/page/ChromeClient.h (137066 => 137067)


--- trunk/Source/WebCore/page/ChromeClient.h	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebCore/page/ChromeClient.h	2012-12-09 10:43:07 UTC (rev 137067)
@@ -32,6 +32,7 @@
 #include "PopupMenu.h"
 #include "PopupMenuClient.h"
 #include "RenderEmbeddedObject.h"
+#include "RenderSnapshottedPlugIn.h"
 #include "ScrollTypes.h"
 #include "SearchPopupMenu.h"
 #include "WebCoreKeyboardUIMode.h"
@@ -372,6 +373,8 @@
 
         virtual bool isEmptyChromeClient() const { return false; }
 
+        virtual PassRefPtr<Image> plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize) const { return 0; }
+
     protected:
         virtual ~ChromeClient() { }
     };

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (137066 => 137067)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2012-12-09 10:43:07 UTC (rev 137067)
@@ -26,12 +26,15 @@
 #include "config.h"
 #include "RenderSnapshottedPlugIn.h"
 
+#include "Chrome.h"
+#include "ChromeClient.h"
 #include "Cursor.h"
 #include "FrameLoaderClient.h"
 #include "FrameView.h"
 #include "Gradient.h"
 #include "HTMLPlugInImageElement.h"
 #include "MouseEvent.h"
+#include "Page.h"
 #include "PaintInfo.h"
 #include "Path.h"
 
@@ -125,24 +128,50 @@
     context->drawImage(image.get(), style()->colorSpace(), alignedRect, CompositeSourceOver, shouldRespectImageOrientation(), useLowQualityScaling);
 }
 
-static Image* startLabelImage()
+Image* RenderSnapshottedPlugIn::startLabelImage(LabelSize size) const
 {
-    static Image* labelImage = Image::loadPlatformResource("startButton").leakRef();
-    return labelImage;
+    static Image* labelImages[2] = { 0, 0 };
+    static bool initializedImages[2] = { false, false };
+
+    int arrayIndex = static_cast<int>(size);
+    if (labelImages[arrayIndex])
+        return labelImages[arrayIndex];
+    if (initializedImages[arrayIndex])
+        return 0;
+
+    if (document()->page()) {
+        labelImages[arrayIndex] = document()->page()->chrome()->client()->plugInStartLabelImage(size).leakRef();
+        initializedImages[arrayIndex] = true;
+    }
+    return labelImages[arrayIndex];
 }
 
 void RenderSnapshottedPlugIn::paintLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    LayoutRect contentRect = contentBoxRect();
-    if (contentRect.isEmpty())
+    if (contentBoxRect().isEmpty())
         return;
 
     if (!plugInImageElement()->hovered())
         return;
 
-    Image* labelImage = startLabelImage();
-    LayoutPoint contentLocation = paintOffset + contentRect.maxXMaxYCorner() - labelImage->size() - LayoutSize(startLabelPadding, startLabelPadding);
-    paintInfo.context->drawImage(labelImage, ColorSpaceDeviceRGB, roundedIntPoint(contentLocation), labelImage->rect());
+    LayoutRect rect = contentBoxRect();
+    LayoutRect labelRect = tryToFitStartLabel(LabelSizeLarge, rect);
+    LabelSize size = NoLabel;
+    if (!labelRect.isEmpty())
+        size = LabelSizeLarge;
+    else {
+        labelRect = tryToFitStartLabel(LabelSizeSmall, rect);
+        if (!labelRect.isEmpty())
+            size = LabelSizeSmall;
+        else
+            return;
+    }
+
+    Image* labelImage = startLabelImage(size);
+    if (!labelImage)
+        return;
+
+    paintInfo.context->drawImage(labelImage, ColorSpaceDeviceRGB, roundedIntPoint(paintOffset + labelRect.location()), labelImage->rect());
 }
 
 void RenderSnapshottedPlugIn::repaintLabel()
@@ -206,6 +235,20 @@
     }
 }
 
+LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const LayoutRect& contentBox) const
+{
+    Image* labelImage = startLabelImage(size);
+    if (!labelImage)
+        return LayoutRect();
+
+    LayoutSize labelSize = labelImage->size();
+    LayoutRect candidateRect(contentBox.maxXMinYCorner() + LayoutSize(-startLabelPadding, startLabelPadding) + LayoutSize(-labelSize.width(), 0), labelSize);
+    // The minimum allowed content box size is the label image placed in the center of the box, surrounded by startLabelPadding.
+    if (candidateRect.x() < startLabelPadding || candidateRect.maxY() > contentBox.height() - startLabelPadding)
+        return LayoutRect();
+    return candidateRect;
+}
+
 void RenderSnapshottedPlugIn::layout()
 {
     RenderEmbeddedObject::layout();
@@ -216,9 +259,6 @@
         if (!width || !height || (width <= autoStartPlugInSizeThresholdWidth && height <= autoStartPlugInSizeThresholdHeight))
             plugInImageElement()->setDisplayState(HTMLPlugInElement::Playing);
     }
-
-    LayoutSize labelSize = startLabelImage()->size();
-    m_labelRect = LayoutRect(contentBoxRect().maxXMaxYCorner() - LayoutSize(startLabelPadding, startLabelPadding) - labelSize, labelSize);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h (137066 => 137067)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h	2012-12-09 10:43:07 UTC (rev 137067)
@@ -29,7 +29,6 @@
 #include "RenderEmbeddedObject.h"
 
 #include "RenderImageResource.h"
-#include "RenderTheme.h"
 #include "Timer.h"
 
 namespace WebCore {
@@ -41,6 +40,12 @@
     RenderSnapshottedPlugIn(HTMLPlugInImageElement*);
     virtual ~RenderSnapshottedPlugIn();
 
+    enum LabelSize {
+        LabelSizeSmall,
+        LabelSizeLarge,
+        NoLabel,
+    };
+
     void updateSnapshot(PassRefPtr<Image>);
 
     void handleEvent(Event*);
@@ -59,10 +64,12 @@
     void paintLabel(PaintInfo&, const LayoutPoint&);
     void repaintLabel();
 
+    LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const;
+    Image* startLabelImage(LabelSize) const;
+
     virtual void layout() OVERRIDE;
 
     OwnPtr<RenderImageResource> m_snapshotResource;
-    LayoutRect m_labelRect;
     bool m_shouldShowLabel;
     DeferrableOneShotTimer<RenderSnapshottedPlugIn> m_hoverDelayTimer;
 };

Modified: trunk/Source/WebKit2/ChangeLog (137066 => 137067)


--- trunk/Source/WebKit2/ChangeLog	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-09 10:43:07 UTC (rev 137067)
@@ -1,3 +1,26 @@
+2012-12-09  Jon Lee  <[email protected]>
+
+        [WK2] Move button image to injected bundle
+        https://bugs.webkit.org/show_bug.cgi?id=104107
+        <rdar://problem/12813842>
+
+        Reviewed by Simon Fraser.
+
+        Rely on the injected bundle to create the image used for the button in snapshotted plug-ins.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::plugInStartLabelImage): Forward the call to the injected bundle UI client.
+        * WebProcess/WebCoreSupport/WebChromeClient.h: Implement plugInStartLabelImage().
+
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
+        (WebKit::InjectedBundlePageUIClient::plugInStartLabelImage): Convert the WebCore enums to WK API enums.
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Expose a new callback to generate the button image.
+
+        * Shared/API/c/cg/WKImageCG.cpp:
+        (WKImageCreateFromCGImage): Refactor to use GraphicsContext methods so that the image is flipped appropriately.
+
 2012-12-09  Kangil Han  <[email protected]>
 
         Fix unused parameter compile warnings

Modified: trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp (137066 => 137067)


--- trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp	2012-12-09 10:43:07 UTC (rev 137067)
@@ -29,6 +29,7 @@
 #include "ShareableBitmap.h"
 #include "WKSharedAPICast.h"
 #include "WebImage.h"
+#include <WebCore/ColorSpace.h>
 #include <WebCore/GraphicsContext.h>
 
 using namespace WebKit;
@@ -54,6 +55,8 @@
         return 0;
 
     OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext();
-    CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, imageSize.width(), imageSize.height()), imageRef);
+    FloatRect rect(FloatPoint(0, 0), imageSize);
+    graphicsContext->clearRect(rect);
+    graphicsContext->drawNativeImage(imageRef, imageSize, WebCore::ColorSpaceDeviceRGB, rect, rect);
     return toAPI(webImage.release().leakRef());
 }

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (137066 => 137067)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2012-12-09 10:43:07 UTC (rev 137067)
@@ -225,7 +225,13 @@
     WKBundlePageUIElementHidden
 };
 typedef uint32_t WKBundlePageUIElementVisibility;
-    
+
+enum {
+    WKBundlePageLabelSizeSmall,
+    WKBundlePageLabelSizeLarge,
+};
+typedef uint32_t WKBundlePageLabelSize;
+
 // UI Client
 typedef void (*WKBundlePageWillAddMessageToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo);
 typedef void (*WKBundlePageWillSetStatusbarTextCallback)(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo);
@@ -242,6 +248,7 @@
 typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
 typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo);
 typedef uint64_t (*WKBundlePageExceededDatabaseQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void *clientInfo);
+typedef WKImageRef (*WKBundlePagePlugInStartLabelImageCallback)(WKBundlePageLabelSize size, const void *clientInfo);
 
 struct WKBundlePageUIClient {
     int                                                                 version;
@@ -266,7 +273,7 @@
 
     // Version 2.
     WKBundlePageExceededDatabaseQuotaCallback                           didExceedDatabaseQuota;
-
+    WKBundlePagePlugInStartLabelImageCallback                           plugInStartLabelImage;
 };
 typedef struct WKBundlePageUIClient WKBundlePageUIClient;
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp (137066 => 137067)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp	2012-12-09 10:43:07 UTC (rev 137067)
@@ -163,4 +163,24 @@
     return m_client.didExceedDatabaseQuota(toAPI(page), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuotaBytes, currentOriginUsageBytes, currentDatabaseUsageBytes, expectedUsageBytes, m_client.clientInfo);
 }
 
+PassRefPtr<WebImage> InjectedBundlePageUIClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const
+{
+    if (!m_client.plugInStartLabelImage)
+        return 0;
+
+    WKBundlePageLabelSize wkSize;
+    switch (size) {
+    case RenderSnapshottedPlugIn::LabelSizeSmall:
+        wkSize = WKBundlePageLabelSizeSmall;
+        break;
+    case RenderSnapshottedPlugIn::LabelSizeLarge:
+        wkSize = WKBundlePageLabelSizeLarge;
+        break;
+    default:
+        return 0;
+    }
+
+    return adoptRef(toImpl(m_client.plugInStartLabelImage(wkSize, m_client.clientInfo)));
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h (137066 => 137067)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h	2012-12-09 10:43:07 UTC (rev 137067)
@@ -29,12 +29,14 @@
 #include "APIClient.h"
 #include "WKBundlePage.h"
 #include "WebEvent.h"
+#include "WebImage.h"
+#include <WebCore/RenderSnapshottedPlugIn.h>
 #include <wtf/Forward.h>
 
 namespace WebCore {
-    class GraphicsContext;
-    class HitTestResult;
-    class IntRect;
+class GraphicsContext;
+class HitTestResult;
+class IntRect;
 }
 
 namespace WebKit {
@@ -68,6 +70,8 @@
 
     void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded);
     uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes);
+
+    PassRefPtr<WebImage> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (137066 => 137067)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2012-12-09 10:43:07 UTC (rev 137067)
@@ -36,6 +36,7 @@
 #include "WebFrame.h"
 #include "WebFrameLoaderClient.h"
 #include "WebFullScreenManager.h"
+#include "WebImage.h"
 #include "WebOpenPanelParameters.h"
 #include "WebOpenPanelResultListener.h"
 #include "WebPage.h"
@@ -818,4 +819,9 @@
     m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success);
 }
 
+PassRefPtr<Image> WebChromeClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const
+{
+    return m_page->injectedBundleUIClient().plugInStartLabelImage(size)->bitmap()->createImage();
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (137066 => 137067)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2012-12-09 10:43:07 UTC (rev 137067)
@@ -28,6 +28,7 @@
 #define WebChromeClient_h
 
 #include <WebCore/ChromeClient.h>
+#include <WebCore/Image.h>
 #include <WebCore/ViewportArguments.h>
 #include <wtf/text/WTFString.h>
 
@@ -225,6 +226,8 @@
 
     virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE;
 
+    virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE;
+
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
     mutable bool m_cachedMainFrameHasHorizontalScrollbar;

Modified: trunk/Tools/ChangeLog (137066 => 137067)


--- trunk/Tools/ChangeLog	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Tools/ChangeLog	2012-12-09 10:43:07 UTC (rev 137067)
@@ -1,3 +1,14 @@
+2012-12-09  Jon Lee  <[email protected]>
+
+        [WK2] Move button image to injected bundle
+        https://bugs.webkit.org/show_bug.cgi?id=104107
+        <rdar://problem/12813842>
+
+        Reviewed by Simon Fraser.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::InjectedBundlePage): Update the bundle page UI client.
+
 2012-12-08  Halton Huo  <[email protected]>
 
         [CMake] Add CMake style checker

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (137066 => 137067)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2012-12-09 10:39:50 UTC (rev 137066)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2012-12-09 10:43:07 UTC (rev 137067)
@@ -376,6 +376,7 @@
         0, /*toolbarsAreVisible*/
         didReachApplicationCacheOriginQuota,
         didExceedDatabaseQuota,
+        0, /*plugInStartLabelImage*/
     };
     WKBundlePageSetUIClient(m_page, &uiClient);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to