diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-18 21:08:02 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-18 21:08:02 +0000 |
commit | d055d8e56a5704b9e3104f5aa527d103815a093a (patch) | |
tree | 0afc7c91a4b487de77cc5536bc70678a1f141ad8 /webkit/glue/chromium_bridge_impl.cc | |
parent | 01f73451f5c113ea960e2cbd7ae574943e4cff9b (diff) | |
download | chromium_src-d055d8e56a5704b9e3104f5aa527d103815a093a.zip chromium_src-d055d8e56a5704b9e3104f5aa527d103815a093a.tar.gz chromium_src-d055d8e56a5704b9e3104f5aa527d103815a093a.tar.bz2 |
Remove most base dependencies from ImageSkia. Poke through the resource getting to the ChromiumBridge.
Review URL: http://codereview.chromium.org/11450
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/chromium_bridge_impl.cc')
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index c73d998..2e7300f 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -5,6 +5,7 @@ #include "config.h" #include "ChromiumBridge.h" +#include "BitmapImage.h" #include "ClipboardUtilitiesChromium.h" #include "Cursor.h" #include "Frame.h" @@ -28,6 +29,7 @@ #include "base/stats_counters.h" #include "base/string_util.h" #include "base/trace_event.h" +#include "build/build_config.h" #include "net/base/mime_util.h" #if USE(V8) #include <v8.h> @@ -42,6 +44,16 @@ #include "webkit/glue/webview_impl.h" #include "webkit/glue/webview_delegate.h" +#if defined(OS_WIN) +#include <windows.h> +#include <vssym32.h> + +#include "base/gfx/native_theme.h" + +// This is only needed on Windows right now. +#include "BitmapImageSingleFrameSkia.h" +#endif + namespace { PlatformWidget ToPlatform(WebCore::Widget* widget) { @@ -312,6 +324,68 @@ String ChromiumBridge::uiResourceProtocol() { return webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol()); } + +// Resources ------------------------------------------------------------------ + +#if defined(OS_WIN) +// Creates an Image for the text area resize corner. We do this by drawing the +// theme native control into a memory buffer then converting the memory buffer +// into an image. We don't bother caching this image because the caller holds +// onto a static copy (see WebCore/rendering/RenderLayer.cpp). +static PassRefPtr<Image> GetTextAreaResizeCorner() { + // Get the size of the resizer. + const int thickness = ScrollbarTheme::nativeTheme()->scrollbarThickness(); + + // Setup a memory buffer. + gfx::PlatformCanvasWin canvas(thickness, thickness, false); + gfx::PlatformDeviceWin& device = canvas.getTopPlatformDevice(); + device.prepareForGDI(0, 0, thickness, thickness); + HDC hdc = device.getBitmapDC(); + RECT widgetRect = { 0, 0, thickness, thickness }; + + // Do the drawing. + gfx::NativeTheme::instance()->PaintStatusGripper(hdc, SP_GRIPPER, 0, 0, + &widgetRect); + device.postProcessGDI(0, 0, thickness, thickness); + return BitmapImageSingleFrameSkia::create(device.accessBitmap(false)); +} +#endif + +PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) { + // Some need special handling. + if (!strcmp(name, "textAreaResizeCorner")) { +#if defined(OS_WIN) + return GetTextAreaResizeCorner(); +#else + DLOG(WARNING) << "This needs implementing on other platforms."; + return Image::nullImage(); +#endif + } + + // The rest get converted to a resource ID that we can pass to the glue. + int resource_id = 0; + if (!strcmp(name, "missingImage")) { + resource_id = IDR_BROKENIMAGE; + } else if (!strcmp(name, "tickmarkDash")) { + resource_id = IDR_TICKMARK_DASH; + } else if (!strcmp(name, "deleteButton") || + !strcmp(name, "deleteButtonPressed")) { + NOTREACHED() << "Image resource " << name << " does not exist yet."; + return Image::nullImage(); + } else { + NOTREACHED() << "Unknown image resource " << name; + return Image::nullImage(); + } + + std::string data = webkit_glue::GetDataResource(resource_id); + RefPtr<SharedBuffer> buffer( + SharedBuffer::create(data.empty() ? "" : data.data(), + data.length())); + RefPtr<Image> image = BitmapImage::create(); + image->setData(buffer, true); + return image; +} + // Screen --------------------------------------------------------------------- int ChromiumBridge::screenDepth(Widget* widget) { |