From 86281adbe4f9e4c2eae038cf15706bf0d105483e Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Wed, 7 Oct 2009 20:07:17 +0000 Subject: Move classes depending on Skia out of base/gfx and into app/gfx. Rename native_theme to native_theme_win since its Windows-specific. BUG=none TEST=none Review URL: http://codereview.chromium.org/259047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28300 0039d316-1c4b-4281-b951-d872f2087c98 --- app/app.gyp | 16 + app/gfx/blit.cc | 101 +++ app/gfx/blit.h | 47 ++ app/gfx/gdi_util.cc | 79 +++ app/gfx/gdi_util.h | 36 ++ app/gfx/gtk_util.cc | 86 +++ app/gfx/gtk_util.h | 67 ++ app/gfx/native_theme_win.cc | 710 +++++++++++++++++++++ app/gfx/native_theme_win.h | 296 +++++++++ app/gfx/native_theme_win_unittest.cc | 11 + app/resource_bundle_linux.cc | 2 +- app/win_util.cc | 2 +- base/base.gyp | 17 - base/gfx/DEPS | 3 - base/gfx/blit.cc | 101 --- base/gfx/blit.h | 47 -- base/gfx/gdi_util.cc | 79 --- base/gfx/gdi_util.h | 36 -- base/gfx/gtk_util.cc | 86 --- base/gfx/gtk_util.h | 67 -- base/gfx/native_theme.cc | 710 --------------------- base/gfx/native_theme.h | 296 --------- base/gfx/native_theme_unittest.cc | 11 - base/gfx/platform_canvas.h | 0 base/gfx/platform_canvas_linux.h | 0 base/gfx/platform_canvas_mac.h | 0 base/gfx/platform_device_linux.h | 0 base/gfx/platform_device_mac.h | 0 .../autocomplete/autocomplete_edit_view_gtk.cc | 2 +- .../autocomplete/autocomplete_popup_view_gtk.cc | 2 +- chrome/browser/browser_theme_provider_gtk.cc | 2 +- chrome/browser/gtk/about_chrome_dialog.cc | 2 +- .../gtk/blocked_popup_container_view_gtk.cc | 2 +- chrome/browser/gtk/bookmark_bar_gtk.cc | 2 +- chrome/browser/gtk/bookmark_bubble_gtk.cc | 2 +- chrome/browser/gtk/bookmark_editor_gtk.cc | 2 +- chrome/browser/gtk/bookmark_menu_controller_gtk.cc | 2 +- chrome/browser/gtk/bookmark_utils_gtk.cc | 2 +- chrome/browser/gtk/browser_titlebar.cc | 2 +- chrome/browser/gtk/browser_toolbar_gtk.cc | 2 +- chrome/browser/gtk/browser_window_gtk.cc | 2 +- chrome/browser/gtk/custom_button.cc | 2 +- chrome/browser/gtk/download_shelf_gtk.cc | 2 +- chrome/browser/gtk/extension_install_prompt_gtk.cc | 2 +- chrome/browser/gtk/extension_shelf_gtk.cc | 2 +- chrome/browser/gtk/find_bar_gtk.cc | 2 +- chrome/browser/gtk/first_run_bubble.cc | 2 +- chrome/browser/gtk/gtk_chrome_button.cc | 2 +- chrome/browser/gtk/gtk_theme_provider.cc | 2 +- chrome/browser/gtk/hung_renderer_dialog_gtk.cc | 2 +- chrome/browser/gtk/info_bubble_gtk.cc | 2 +- chrome/browser/gtk/infobar_gtk.cc | 2 +- chrome/browser/gtk/keyword_editor_view.cc | 2 +- chrome/browser/gtk/list_store_favicon_loader.cc | 2 +- chrome/browser/gtk/location_bar_view_gtk.cc | 2 +- chrome/browser/gtk/menu_gtk.cc | 2 +- chrome/browser/gtk/nine_box.cc | 2 +- chrome/browser/gtk/options/content_page_gtk.cc | 2 +- chrome/browser/gtk/options/cookies_view.cc | 2 +- chrome/browser/gtk/options/exceptions_page_gtk.cc | 2 +- chrome/browser/gtk/options/passwords_page_gtk.cc | 2 +- .../browser/gtk/options/url_picker_dialog_gtk.cc | 2 +- chrome/browser/gtk/status_bubble_gtk.cc | 2 +- chrome/browser/gtk/tabs/dragged_tab_gtk.cc | 2 +- chrome/browser/gtk/tabs/tab_strip_gtk.cc | 2 +- chrome/browser/gtk/task_manager_gtk.cc | 2 +- chrome/browser/printing/printing_layout_uitest.cc | 2 +- chrome/browser/renderer_host/backing_store_win.cc | 4 +- chrome/browser/renderer_host/render_widget_host.cc | 5 - .../renderer_host/render_widget_host_view_gtk.cc | 2 +- .../renderer_host/render_widget_host_view_win.cc | 4 +- .../views/options/advanced_contents_view.cc | 2 +- chrome/browser/views/options/content_page_view.cc | 2 +- chrome/browser/views/options/fonts_page_view.cc | 4 +- .../browser/views/options/languages_page_view.cc | 2 +- chrome/browser/views/options/options_group_view.cc | 4 +- chrome/plugin/webplugin_proxy.cc | 7 +- chrome/renderer/render_view.cc | 2 +- .../renderer_main_platform_delegate_win.cc | 2 +- chrome/renderer/webmediaplayer_impl.h | 2 +- chrome/renderer/webplugin_delegate_proxy.cc | 2 +- printing/image.cc | 2 +- skia/ext/vector_canvas_unittest.cc | 21 +- skia/ext/vector_platform_device_win.cc | 30 +- views/controls/combobox/native_combobox_win.cc | 2 +- views/controls/menu/menu_config_win.cc | 2 +- views/controls/menu/menu_item_view_win.cc | 2 +- views/controls/menu/menu_scroll_view_container.cc | 2 +- views/controls/menu/menu_separator_win.cc | 4 +- views/controls/menu/native_menu_gtk.cc | 2 +- views/controls/native_control.cc | 4 +- views/controls/slider/native_slider_gtk.cc | 2 +- .../controls/tabbed_pane/native_tabbed_pane_win.cc | 2 +- views/controls/textfield/native_textfield_gtk.cc | 2 +- views/controls/textfield/native_textfield_win.cc | 5 +- views/controls/textfield/native_textfield_win.h | 1 + views/drag_utils_win.cc | 4 +- views/widget/widget_win.cc | 4 +- views/window/dialog_client_view.cc | 2 +- .../glue/plugins/gtk_plugin_container_manager.cc | 2 +- webkit/glue/plugins/webplugin_delegate_impl_gtk.cc | 2 +- webkit/glue/webcursor_win.cc | 4 +- webkit/glue/webthemeengine_impl_win.cc | 2 +- .../test_shell/test_shell_platform_delegate_win.cc | 5 +- .../tools/test_shell/test_webview_delegate_gtk.cc | 2 +- .../tools/test_shell/test_webview_delegate_win.cc | 4 +- 106 files changed, 1582 insertions(+), 1560 deletions(-) create mode 100644 app/gfx/blit.cc create mode 100644 app/gfx/blit.h create mode 100644 app/gfx/gdi_util.cc create mode 100644 app/gfx/gdi_util.h create mode 100644 app/gfx/gtk_util.cc create mode 100644 app/gfx/gtk_util.h create mode 100644 app/gfx/native_theme_win.cc create mode 100644 app/gfx/native_theme_win.h create mode 100644 app/gfx/native_theme_win_unittest.cc delete mode 100644 base/gfx/DEPS delete mode 100644 base/gfx/blit.cc delete mode 100644 base/gfx/blit.h delete mode 100644 base/gfx/gdi_util.cc delete mode 100644 base/gfx/gdi_util.h delete mode 100644 base/gfx/gtk_util.cc delete mode 100644 base/gfx/gtk_util.h delete mode 100644 base/gfx/native_theme.cc delete mode 100644 base/gfx/native_theme.h delete mode 100644 base/gfx/native_theme_unittest.cc delete mode 100644 base/gfx/platform_canvas.h delete mode 100644 base/gfx/platform_canvas_linux.h delete mode 100644 base/gfx/platform_canvas_mac.h delete mode 100644 base/gfx/platform_device_linux.h delete mode 100644 base/gfx/platform_device_mac.h diff --git a/app/app.gyp b/app/app.gyp index 1ae1335..c35ba0e 100644 --- a/app/app.gyp +++ b/app/app.gyp @@ -81,6 +81,8 @@ 'drag_drop_types_gtk.cc', 'drag_drop_types_win.cc', 'drag_drop_types.h', + 'gfx/blit.cc', + 'gfx/blit.h', 'gfx/canvas.cc', 'gfx/canvas.h', 'gfx/canvas_linux.cc', @@ -98,9 +100,15 @@ 'gfx/color_utils.cc', 'gfx/color_utils.h', 'gfx/favicon_size.h', + 'gfx/gdi_util.cc', + 'gfx/gdi_util.h', + 'gfx/gtk_util.cc', + 'gfx/gtk_util.h', 'gfx/icon_util.cc', 'gfx/icon_util.h', 'gfx/insets.h', + 'gfx/native_theme_win.cc', + 'gfx/native_theme_win.h', 'gfx/path_gtk.cc', 'gfx/path_win.cc', 'gfx/path.h', @@ -190,13 +198,19 @@ ['OS!="win"', { 'sources!': [ 'drag_drop_types.h', + 'gfx/gdi_util.cc', + 'gfx/gdi_util.h', 'gfx/icon_util.cc', 'gfx/icon_util.h', + 'gfx/native_theme_win.cc', + 'gfx/native_theme_win.h', 'os_exchange_data.cc', ], }], ['OS!="linux"', { 'sources!': [ + 'gfx/gtk_util.cc', + 'gfx/gtk_util.h', 'gtk_dnd_util.cc', 'gtk_dnd_util.h', ], @@ -228,6 +242,7 @@ 'gfx/color_utils_unittest.cc', 'gfx/font_unittest.cc', 'gfx/icon_util_unittest.cc', + 'gfx/native_theme_win_unittest.cc', 'gfx/skbitmap_operations_unittest.cc', 'gfx/text_elider_unittest.cc', 'l10n_util_mac_unittest.mm', @@ -254,6 +269,7 @@ ['OS!="win"', { 'sources!': [ 'gfx/icon_util_unittest.cc', + 'gfx/native_theme_win_unittest.cc', 'os_exchange_data_win_unittest.cc', 'win_util_unittest.cc', ], diff --git a/app/gfx/blit.cc b/app/gfx/blit.cc new file mode 100644 index 0000000..359e142 --- /dev/null +++ b/app/gfx/blit.cc @@ -0,0 +1,101 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/gfx/blit.h" + +#if defined(OS_LINUX) +#include <cairo/cairo.h> +#endif + +#include "base/gfx/point.h" +#include "base/gfx/rect.h" +#if defined(OS_MACOSX) +#include "base/scoped_cftyperef.h" +#endif +#include "skia/ext/platform_canvas.h" +#include "skia/ext/platform_device.h" + +namespace gfx { + +void BlitContextToContext(NativeDrawingContext dst_context, + const Rect& dst_rect, + NativeDrawingContext src_context, + const Point& src_origin) { +#if defined(OS_WIN) + BitBlt(dst_context, dst_rect.x(), dst_rect.y(), + dst_rect.width(), dst_rect.height(), + src_context, src_origin.x(), src_origin.y(), SRCCOPY); +#elif defined(OS_MACOSX) + // Only translations and/or vertical flips in the source context are + // supported; more complex source context transforms will be ignored. + + // If there is a translation on the source context, we need to account for + // it ourselves since CGBitmapContextCreateImage will bypass it. + Rect src_rect(src_origin, dst_rect.size()); + CGAffineTransform transform = CGContextGetCTM(src_context); + bool flipped = fabs(transform.d + 1) < 0.0001; + CGFloat delta_y = flipped ? CGBitmapContextGetHeight(src_context) - + transform.ty + : transform.ty; + src_rect.Offset(transform.tx, delta_y); + + scoped_cftyperef<CGImageRef> + src_image(CGBitmapContextCreateImage(src_context)); + scoped_cftyperef<CGImageRef> src_sub_image( + CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect())); + CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image); +#elif defined(OS_LINUX) + // Only translations in the source context are supported; more complex + // source context transforms will be ignored. + cairo_save(dst_context); + double surface_x = src_origin.x(); + double surface_y = src_origin.y(); + cairo_user_to_device(src_context, &surface_x, &surface_y); + cairo_set_source_surface(dst_context, cairo_get_target(src_context), + dst_rect.x()-surface_x, dst_rect.y()-surface_y); + cairo_rectangle(dst_context, dst_rect.x(), dst_rect.y(), + dst_rect.width(), dst_rect.height()); + cairo_clip(dst_context); + cairo_paint(dst_context); + cairo_restore(dst_context); +#endif +} + +static NativeDrawingContext GetContextFromCanvas( + skia::PlatformCanvas *canvas) { + skia::PlatformDevice& device = canvas->getTopPlatformDevice(); +#if defined(OS_WIN) + return device.getBitmapDC(); +#elif defined(OS_MACOSX) + return device.GetBitmapContext(); +#elif defined(OS_LINUX) + return device.beginPlatformPaint(); +#endif +} + +void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, + const Rect& dst_rect, + NativeDrawingContext src_context, + const Point& src_origin) { + BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, + src_context, src_origin); +} + +void BlitCanvasToContext(NativeDrawingContext dst_context, + const Rect& dst_rect, + skia::PlatformCanvas *src_canvas, + const Point& src_origin) { + BlitContextToContext(dst_context, dst_rect, + GetContextFromCanvas(src_canvas), src_origin); +} + +void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, + const Rect& dst_rect, + skia::PlatformCanvas *src_canvas, + const Point& src_origin) { + BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, + GetContextFromCanvas(src_canvas), src_origin); +} + +} // namespace gfx diff --git a/app/gfx/blit.h b/app/gfx/blit.h new file mode 100644 index 0000000..f2460ca --- /dev/null +++ b/app/gfx/blit.h @@ -0,0 +1,47 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef APP_GFX_BLIT_H_ +#define APP_GFX_BLIT_H_ + +#include "base/gfx/native_widget_types.h" +#include "base/gfx/point.h" +#include "base/gfx/rect.h" + +namespace skia { +class PlatformCanvas; +} // namespace skia + +namespace gfx { + +class Point; +class Rect; + +// Blits a rectangle from the source context into the destination context. +void BlitContextToContext(NativeDrawingContext dst_context, + const Rect& dst_rect, + NativeDrawingContext src_context, + const Point& src_origin); + +// Blits a rectangle from the source context into the destination canvas. +void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, + const Rect& dst_rect, + NativeDrawingContext src_context, + const Point& src_origin); + +// Blits a rectangle from the source canvas into the destination context. +void BlitCanvasToContext(NativeDrawingContext dst_context, + const Rect& dst_rect, + skia::PlatformCanvas *src_canvas, + const Point& src_origin); + +// Blits a rectangle from the source canvas into the destination canvas. +void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, + const Rect& dst_rect, + skia::PlatformCanvas *src_canvas, + const Point& src_origin); + +} // namespace gfx + +#endif // APP_GFX_BLIT_H_ diff --git a/app/gfx/gdi_util.cc b/app/gfx/gdi_util.cc new file mode 100644 index 0000000..2711280 --- /dev/null +++ b/app/gfx/gdi_util.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/gfx/gdi_util.h" + +namespace gfx { + +void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr) { + CreateBitmapHeaderWithColorDepth(width, height, 32, hdr); +} + +void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth, + BITMAPINFOHEADER* hdr) { + // These values are shared with gfx::PlatformDevice + hdr->biSize = sizeof(BITMAPINFOHEADER); + hdr->biWidth = width; + hdr->biHeight = -height; // minus means top-down bitmap + hdr->biPlanes = 1; + hdr->biBitCount = color_depth; + hdr->biCompression = BI_RGB; // no compression + hdr->biSizeImage = 0; + hdr->biXPelsPerMeter = 1; + hdr->biYPelsPerMeter = 1; + hdr->biClrUsed = 0; + hdr->biClrImportant = 0; +} + + +void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr) { + // Because bmp v4 header is just an extension, we just create a v3 header and + // copy the bits over to the v4 header. + BITMAPINFOHEADER header_v3; + CreateBitmapHeader(width, height, &header_v3); + memset(hdr, 0, sizeof(BITMAPV4HEADER)); + memcpy(hdr, &header_v3, sizeof(BITMAPINFOHEADER)); + + // Correct the size of the header and fill in the mask values. + hdr->bV4Size = sizeof(BITMAPV4HEADER); + hdr->bV4RedMask = 0x00ff0000; + hdr->bV4GreenMask = 0x0000ff00; + hdr->bV4BlueMask = 0x000000ff; + hdr->bV4AlphaMask = 0xff000000; +} + +// Creates a monochrome bitmap header. +void CreateMonochromeBitmapHeader(int width, + int height, + BITMAPINFOHEADER* hdr) { + hdr->biSize = sizeof(BITMAPINFOHEADER); + hdr->biWidth = width; + hdr->biHeight = -height; + hdr->biPlanes = 1; + hdr->biBitCount = 1; + hdr->biCompression = BI_RGB; + hdr->biSizeImage = 0; + hdr->biXPelsPerMeter = 1; + hdr->biYPelsPerMeter = 1; + hdr->biClrUsed = 0; + hdr->biClrImportant = 0; +} + +void SubtractRectanglesFromRegion(HRGN hrgn, + const std::vector<gfx::Rect>& cutouts) { + if (cutouts.size()) { + HRGN cutout = ::CreateRectRgn(0, 0, 0, 0); + for (size_t i = 0; i < cutouts.size(); i++) { + ::SetRectRgn(cutout, + cutouts[i].x(), + cutouts[i].y(), + cutouts[i].right(), + cutouts[i].bottom()); + ::CombineRgn(hrgn, hrgn, cutout, RGN_DIFF); + } + ::DeleteObject(cutout); + } +} + +} // namespace gfx diff --git a/app/gfx/gdi_util.h b/app/gfx/gdi_util.h new file mode 100644 index 0000000..c458d9f --- /dev/null +++ b/app/gfx/gdi_util.h @@ -0,0 +1,36 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef APP_GFX_GDI_UTIL_H_ +#define APP_GFX_GDI_UTIL_H_ + +#include <vector> +#include <windows.h> +#include "base/gfx/rect.h" + +namespace gfx { + +// Creates a BITMAPINFOHEADER structure given the bitmap's size. +void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); + +// Creates a BITMAPINFOHEADER structure given the bitmap's size and +// color depth in bits per pixel. +void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth, + BITMAPINFOHEADER* hdr); + +// Creates a BITMAPV4HEADER structure given the bitmap's size. You probably +// only need to use BMP V4 if you need transparency (alpha channel). This +// function sets the AlphaMask to 0xff000000. +void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr); + +// Creates a monochrome bitmap header. +void CreateMonochromeBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); + +// Modify the given hrgn by subtracting the given rectangles. +void SubtractRectanglesFromRegion(HRGN hrgn, + const std::vector<gfx::Rect>& cutouts); + +} // namespace gfx + +#endif // APP_GFX_GDI_UTIL_H_ diff --git a/app/gfx/gtk_util.cc b/app/gfx/gtk_util.cc new file mode 100644 index 0000000..03d0504 --- /dev/null +++ b/app/gfx/gtk_util.cc @@ -0,0 +1,86 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/gfx/gtk_util.h" + +#include <gdk/gdk.h> +#include <gtk/gtk.h> +#include <stdlib.h> + +#include "base/basictypes.h" +#include "base/gfx/rect.h" +#include "base/linux_util.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkUnPreMultiply.h" + +namespace { + +void FreePixels(guchar* pixels, gpointer data) { + free(data); +} + +} // namespace + +namespace gfx { + +const GdkColor kGdkWhite = GDK_COLOR_RGB(0xff, 0xff, 0xff); +const GdkColor kGdkBlack = GDK_COLOR_RGB(0x00, 0x00, 0x00); +const GdkColor kGdkGreen = GDK_COLOR_RGB(0x00, 0xff, 0x00); + +GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) { + bitmap->lockPixels(); + int width = bitmap->width(); + int height = bitmap->height(); + int stride = bitmap->rowBytes(); + + // SkBitmaps are premultiplied, we need to unpremultiply them. + const int kBytesPerPixel = 4; + uint8* divided = static_cast<uint8*>(malloc(height * stride)); + + for (int y = 0, i = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + uint32 pixel = bitmap->getAddr32(0, y)[x]; + + int alpha = SkColorGetA(pixel); + if (alpha != 0 && alpha != 255) { + SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel); + divided[i + 0] = SkColorGetR(unmultiplied); + divided[i + 1] = SkColorGetG(unmultiplied); + divided[i + 2] = SkColorGetB(unmultiplied); + divided[i + 3] = alpha; + } else { + divided[i + 0] = SkColorGetR(pixel); + divided[i + 1] = SkColorGetG(pixel); + divided[i + 2] = SkColorGetB(pixel); + divided[i + 3] = alpha; + } + i += kBytesPerPixel; + } + } + + // This pixbuf takes ownership of our malloc()ed data and will + // free it for us when it is destroyed. + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( + divided, + GDK_COLORSPACE_RGB, // The only colorspace gtk supports. + true, // There is an alpha channel. + 8, + width, height, stride, &FreePixels, divided); + + bitmap->unlockPixels(); + return pixbuf; +} + +void SubtractRectanglesFromRegion(GdkRegion* region, + const std::vector<Rect>& cutouts) { + for (size_t i = 0; i < cutouts.size(); ++i) { + GdkRectangle rect = cutouts[i].ToGdkRectangle(); + GdkRegion* rect_region = gdk_region_rectangle(&rect); + gdk_region_subtract(region, rect_region); + // TODO(deanm): It would be nice to be able to reuse the GdkRegion here. + gdk_region_destroy(rect_region); + } +} + +} // namespace gfx diff --git a/app/gfx/gtk_util.h b/app/gfx/gtk_util.h new file mode 100644 index 0000000..523f7bf --- /dev/null +++ b/app/gfx/gtk_util.h @@ -0,0 +1,67 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_GFX_GTK_UTIL_H_ +#define BASE_GFX_GTK_UTIL_H_ + +#include <stdint.h> +#include <vector> + +#include <glib-object.h> + +#include "base/scoped_ptr.h" + +typedef struct _GdkColor GdkColor; +typedef struct _GdkPixbuf GdkPixbuf; +typedef struct _GdkRegion GdkRegion; + +class SkBitmap; + +const int kSkiaToGDKMultiplier = 257; + +// Define a macro for creating GdkColors from RGB values. This is a macro to +// allow static construction of literals, etc. Use this like: +// GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff); +#define GDK_COLOR_RGB(r, g, b) {0, r * kSkiaToGDKMultiplier, \ + g * kSkiaToGDKMultiplier, b * kSkiaToGDKMultiplier} + +namespace gfx { + +class Rect; + +extern const GdkColor kGdkWhite; +extern const GdkColor kGdkBlack; +extern const GdkColor kGdkGreen; + +// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so +// it is an expensive operation. +GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); + +// Modify the given region by subtracting the given rectangles. +void SubtractRectanglesFromRegion(GdkRegion* region, + const std::vector<Rect>& cutouts); + +} // namespace gfx + +namespace { +// A helper class that will g_object_unref |p| when it goes out of scope. +// This never adds a ref, it only unrefs. +template <typename Type> +struct GObjectUnrefer { + void operator()(Type* ptr) const { + if (ptr) + g_object_unref(ptr); + } +}; +} // namespace + +// It's not legal C++ to have a templatized typedefs, so we wrap it in a +// struct. When using this, you need to include ::Type. E.g., +// ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); +template<class T> +struct ScopedGObject { + typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; +}; + +#endif // BASE_GFX_GTK_UTIL_H_ diff --git a/app/gfx/native_theme_win.cc b/app/gfx/native_theme_win.cc new file mode 100644 index 0000000..594042b --- /dev/null +++ b/app/gfx/native_theme_win.cc @@ -0,0 +1,710 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/gfx/native_theme_win.h" + +#include <windows.h> +#include <uxtheme.h> +#include <vsstyle.h> +#include <vssym32.h> + +#include "app/gfx/gdi_util.h" +#include "base/gfx/rect.h" +#include "base/logging.h" +#include "base/scoped_handle.h" +#include "skia/ext/platform_canvas.h" +#include "skia/ext/skia_utils_win.h" +#include "third_party/skia/include/core/SkShader.h" + +namespace { + +void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { + // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. + SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); + SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); + SkColor buffer[] = { face, highlight, highlight, face }; + // Confusing bit: we first create a temporary bitmap with our desired pattern, + // then copy it to another bitmap. The temporary bitmap doesn't take + // ownership of the pixel data, and so will point to garbage when this + // function returns. The copy will copy the pixel data into a place owned by + // the bitmap, which is in turn owned by the shader, etc., so it will live + // until we're done using it. + SkBitmap temp_bitmap; + temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); + temp_bitmap.setPixels(buffer); + SkBitmap bitmap; + temp_bitmap.copyTo(&bitmap, temp_bitmap.config()); + SkShader* shader = SkShader::CreateBitmapShader(bitmap, + SkShader::kRepeat_TileMode, + SkShader::kRepeat_TileMode); + + // Align the pattern with the upper corner of |align_rect|. + SkMatrix matrix; + matrix.setTranslate(SkIntToScalar(align_rect.left), + SkIntToScalar(align_rect.top)); + shader->setLocalMatrix(matrix); + paint->setShader(shader)->safeUnref(); +} + +} // namespace + +namespace gfx { + +/* static */ +const NativeTheme* NativeTheme::instance() { + // The global NativeTheme instance. + static const NativeTheme s_native_theme; + return &s_native_theme; +} + +NativeTheme::NativeTheme() + : theme_dll_(LoadLibrary(L"uxtheme.dll")), + draw_theme_(NULL), + draw_theme_ex_(NULL), + get_theme_color_(NULL), + get_theme_content_rect_(NULL), + get_theme_part_size_(NULL), + open_theme_(NULL), + close_theme_(NULL), + set_theme_properties_(NULL), + is_theme_active_(NULL), + get_theme_int_(NULL) { + if (theme_dll_) { + draw_theme_ = reinterpret_cast<DrawThemeBackgroundPtr>( + GetProcAddress(theme_dll_, "DrawThemeBackground")); + draw_theme_ex_ = reinterpret_cast<DrawThemeBackgroundExPtr>( + GetProcAddress(theme_dll_, "DrawThemeBackgroundEx")); + get_theme_color_ = reinterpret_cast<GetThemeColorPtr>( + GetProcAddress(theme_dll_, "GetThemeColor")); + get_theme_content_rect_ = reinterpret_cast<GetThemeContentRectPtr>( + GetProcAddress(theme_dll_, "GetThemeBackgroundContentRect")); + get_theme_part_size_ = reinterpret_cast<GetThemePartSizePtr>( + GetProcAddress(theme_dll_, "GetThemePartSize")); + open_theme_ = reinterpret_cast<OpenThemeDataPtr>( + GetProcAddress(theme_dll_, "OpenThemeData")); + close_theme_ = reinterpret_cast<CloseThemeDataPtr>( + GetProcAddress(theme_dll_, "CloseThemeData")); + set_theme_properties_ = reinterpret_cast<SetThemeAppPropertiesPtr>( + GetProcAddress(theme_dll_, "SetThemeAppProperties")); + is_theme_active_ = reinterpret_cast<IsThemeActivePtr>( + GetProcAddress(theme_dll_, "IsThemeActive")); + get_theme_int_ = reinterpret_cast<GetThemeIntPtr>( + GetProcAddress(theme_dll_, "GetThemeInt")); + } + memset(theme_handles_, 0, sizeof(theme_handles_)); +} + +NativeTheme::~NativeTheme() { + if (theme_dll_) { + // todo (cpu): fix this soon. + // CloseHandles(); + FreeLibrary(theme_dll_); + } +} + +HRESULT NativeTheme::PaintButton(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const { + HANDLE handle = GetThemeHandle(BUTTON); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + + // Draw it manually. + // All pressed states have both low bits set, and no other states do. + const bool focused = ((state_id & ETS_FOCUSED) == ETS_FOCUSED); + const bool pressed = ((state_id & PBS_PRESSED) == PBS_PRESSED); + if ((BP_PUSHBUTTON == part_id) && (pressed || focused)) { + // BP_PUSHBUTTON has a focus rect drawn around the outer edge, and the + // button itself is shrunk by 1 pixel. + HBRUSH brush = GetSysColorBrush(COLOR_3DDKSHADOW); + if (brush) { + FrameRect(hdc, rect, brush); + InflateRect(rect, -1, -1); + } + } + DrawFrameControl(hdc, rect, DFC_BUTTON, classic_state); + + // Draw the focus rectangle (the dotted line box) only on buttons. For radio + // and checkboxes, we let webkit draw the focus rectangle (orange glow). + if ((BP_PUSHBUTTON == part_id) && focused) { + // The focus rect is inside the button. The exact number of pixels depends + // on whether we're in classic mode or using uxtheme. + if (handle && get_theme_content_rect_) { + get_theme_content_rect_(handle, hdc, part_id, state_id, rect, rect); + } else { + InflateRect(rect, -GetSystemMetrics(SM_CXEDGE), + -GetSystemMetrics(SM_CYEDGE)); + } + DrawFocusRect(hdc, rect); + } + + return S_OK; +} + +HRESULT NativeTheme::PaintDialogBackground(HDC hdc, bool active, + RECT* rect) const { + HANDLE handle = GetThemeHandle(WINDOW); + if (handle && draw_theme_) { + return draw_theme_(handle, hdc, WP_DIALOG, + active ? FS_ACTIVE : FS_INACTIVE, rect, NULL); + } + + // Classic just renders a flat color background. + FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); + return S_OK; +} + +HRESULT NativeTheme::PaintListBackground(HDC hdc, + bool enabled, + RECT* rect) const { + HANDLE handle = GetThemeHandle(LIST); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, 1, TS_NORMAL, rect, NULL); + + // Draw it manually. + HBRUSH bg_brush = GetSysColorBrush(COLOR_WINDOW); + FillRect(hdc, rect, bg_brush); + DrawEdge(hdc, rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); + return S_OK; +} + +HRESULT NativeTheme::PaintMenuArrow(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + MenuArrowDirection arrow_direction, + bool is_highlighted) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) { + if (arrow_direction == RIGHT_POINTING_ARROW) { + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + } else { + // There is no way to tell the uxtheme API to draw a left pointing arrow; + // it doesn't have a flag equivalent to DFCS_MENUARROWRIGHT. But they + // are needed for RTL locales on Vista. So use a memory DC and mirror + // the region with GDI's StretchBlt. + Rect r(*rect); + ScopedHDC mem_dc(CreateCompatibleDC(hdc)); + ScopedBitmap mem_bitmap(CreateCompatibleBitmap(hdc, r.width(), + r.height())); + HGDIOBJ old_bitmap = SelectObject(mem_dc, mem_bitmap); + // Copy and horizontally mirror the background from hdc into mem_dc. Use + // a negative-width source rect, starting at the rightmost pixel. + StretchBlt(mem_dc, 0, 0, r.width(), r.height(), + hdc, r.right()-1, r.y(), -r.width(), r.height(), SRCCOPY); + // Draw the arrow. + RECT theme_rect = {0, 0, r.width(), r.height()}; + HRESULT result = draw_theme_(handle, mem_dc, part_id, + state_id, &theme_rect, NULL); + // Copy and mirror the result back into mem_dc. + StretchBlt(hdc, r.x(), r.y(), r.width(), r.height(), + mem_dc, r.width()-1, 0, -r.width(), r.height(), SRCCOPY); + SelectObject(mem_dc, old_bitmap); + return result; + } + } + + // For some reason, Windows uses the name DFCS_MENUARROWRIGHT to indicate a + // left pointing arrow. This makes the following 'if' statement slightly + // counterintuitive. + UINT state; + if (arrow_direction == RIGHT_POINTING_ARROW) + state = DFCS_MENUARROW; + else + state = DFCS_MENUARROWRIGHT; + return PaintFrameControl(hdc, rect, DFC_MENU, state, is_highlighted); +} + +HRESULT NativeTheme::PaintMenuBackground(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) { + HRESULT result = draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + FrameRect(hdc, rect, GetSysColorBrush(COLOR_3DSHADOW)); + return result; + } + + FillRect(hdc, rect, GetSysColorBrush(COLOR_MENU)); + DrawEdge(hdc, rect, EDGE_RAISED, BF_RECT); + return S_OK; +} + +HRESULT NativeTheme::PaintMenuCheckBackground(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + // Nothing to do for background. + return S_OK; +} + +HRESULT NativeTheme::PaintMenuCheck(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + bool is_highlighted) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) { + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + } + return PaintFrameControl(hdc, rect, DFC_MENU, DFCS_MENUCHECK, is_highlighted); +} + +HRESULT NativeTheme::PaintMenuGutter(HDC hdc, + int part_id, + int state_id, + RECT* rect) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + return E_NOTIMPL; +} + +HRESULT NativeTheme::PaintMenuItemBackground(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + bool selected, + RECT* rect) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + if (selected) + FillRect(hdc, rect, GetSysColorBrush(COLOR_HIGHLIGHT)); + return S_OK; +} + +HRESULT NativeTheme::PaintMenuList(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const { + HANDLE handle = GetThemeHandle(MENULIST); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + + // Draw it manually. + DrawFrameControl(hdc, rect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | classic_state); + return S_OK; +} + +HRESULT NativeTheme::PaintMenuSeparator(HDC hdc, + int part_id, + int state_id, + RECT* rect) const { + HANDLE handle = GetThemeHandle(MENU); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + DrawEdge(hdc, rect, EDGE_ETCHED, BF_TOP); + return S_OK; +} + +HRESULT NativeTheme::PaintScrollbarArrow(HDC hdc, + int state_id, + int classic_state, + RECT* rect) const { + HANDLE handle = GetThemeHandle(SCROLLBAR); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, SBP_ARROWBTN, state_id, rect, NULL); + + // Draw it manually. + DrawFrameControl(hdc, rect, DFC_SCROLL, classic_state); + return S_OK; +} + +HRESULT NativeTheme::PaintScrollbarTrack( + HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* target_rect, + RECT* align_rect, + skia::PlatformCanvas* canvas) const { + HANDLE handle = GetThemeHandle(SCROLLBAR); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL); + + // Draw it manually. + const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR); + const DWORD color3DFace = GetSysColor(COLOR_3DFACE); + if ((colorScrollbar != color3DFace) && + (colorScrollbar != GetSysColor(COLOR_WINDOW))) { + FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); + } else { + SkPaint paint; + SetCheckerboardShader(&paint, *align_rect); + canvas->drawIRect(skia::RECTToSkIRect(*target_rect), paint); + } + if (classic_state & DFCS_PUSHED) + InvertRect(hdc, target_rect); + return S_OK; +} + +HRESULT NativeTheme::PaintScrollbarThumb(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const { + HANDLE handle = GetThemeHandle(SCROLLBAR); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + + // Draw it manually. + if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) + DrawEdge(hdc, rect, EDGE_RAISED, BF_RECT | BF_MIDDLE); + // Classic mode doesn't have a gripper. + return S_OK; +} + +HRESULT NativeTheme::PaintStatusGripper(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const { + HANDLE handle = GetThemeHandle(STATUS); + if (handle && draw_theme_) { + // Paint the status bar gripper. There doesn't seem to be a + // standard gripper in Windows for the space between + // scrollbars. This is pretty close, but it's supposed to be + // painted over a status bar. + return draw_theme_(handle, hdc, SP_GRIPPER, 0, rect, NULL); + } + + // Draw a windows classic scrollbar gripper. + DrawFrameControl(hdc, rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); + return S_OK; +} + +HRESULT NativeTheme::PaintTabPanelBackground(HDC hdc, RECT* rect) const { + HANDLE handle = GetThemeHandle(TAB); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, TABP_BODY, 0, rect, NULL); + + // Classic just renders a flat color background. + FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); + return S_OK; +} + +HRESULT NativeTheme::PaintTrackbar(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect, + skia::PlatformCanvas* canvas) const { + // Make the channel be 4 px thick in the center of the supplied rect. (4 px + // matches what XP does in various menus; GetThemePartSize() doesn't seem to + // return good values here.) + RECT channel_rect = *rect; + const int channel_thickness = 4; + if (part_id == TKP_TRACK) { + channel_rect.top += + ((channel_rect.bottom - channel_rect.top - channel_thickness) / 2); + channel_rect.bottom = channel_rect.top + channel_thickness; + } else if (part_id == TKP_TRACKVERT) { + channel_rect.left += + ((channel_rect.right - channel_rect.left - channel_thickness) / 2); + channel_rect.right = channel_rect.left + channel_thickness; + } // else this isn't actually a channel, so |channel_rect| == |rect|. + + HANDLE handle = GetThemeHandle(TRACKBAR); + if (handle && draw_theme_) + return draw_theme_(handle, hdc, part_id, state_id, &channel_rect, NULL); + + // Classic mode, draw it manually. + if ((part_id == TKP_TRACK) || (part_id == TKP_TRACKVERT)) { + DrawEdge(hdc, &channel_rect, EDGE_SUNKEN, BF_RECT); + } else if (part_id == TKP_THUMBVERT) { + DrawEdge(hdc, rect, EDGE_RAISED, BF_RECT | BF_SOFT | BF_MIDDLE); + } else { + // Split rect into top and bottom pieces. + RECT top_section = *rect; + RECT bottom_section = *rect; + top_section.bottom -= ((bottom_section.right - bottom_section.left) / 2); + bottom_section.top = top_section.bottom; + DrawEdge(hdc, &top_section, EDGE_RAISED, + BF_LEFT | BF_TOP | BF_RIGHT | BF_SOFT | BF_MIDDLE | BF_ADJUST); + + // Split triangular piece into two diagonals. + RECT& left_half = bottom_section; + RECT right_half = bottom_section; + right_half.left += ((bottom_section.right - bottom_section.left) / 2); + left_half.right = right_half.left; + DrawEdge(hdc, &left_half, EDGE_RAISED, + BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); + DrawEdge(hdc, &right_half, EDGE_RAISED, + BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); + + // If the button is pressed, draw hatching. + if (classic_state & DFCS_PUSHED) { + SkPaint paint; + SetCheckerboardShader(&paint, *rect); + + // Fill all three pieces with the pattern. + canvas->drawIRect(skia::RECTToSkIRect(top_section), paint); + + SkScalar left_triangle_top = SkIntToScalar(left_half.top); + SkScalar left_triangle_right = SkIntToScalar(left_half.right); + SkPath left_triangle; + left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top); + left_triangle.lineTo(left_triangle_right, left_triangle_top); + left_triangle.lineTo(left_triangle_right, + SkIntToScalar(left_half.bottom)); + left_triangle.close(); + canvas->drawPath(left_triangle, paint); + + SkScalar right_triangle_left = SkIntToScalar(right_half.left); + SkScalar right_triangle_top = SkIntToScalar(right_half.top); + SkPath right_triangle; + right_triangle.moveTo(right_triangle_left, right_triangle_top); + right_triangle.lineTo(SkIntToScalar(right_half.right), + right_triangle_top); + right_triangle.lineTo(right_triangle_left, + SkIntToScalar(right_half.bottom)); + right_triangle.close(); + canvas->drawPath(right_triangle, paint); + } + } + return S_OK; +} + +HRESULT NativeTheme::PaintTextField(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect, + COLORREF color, + bool fill_content_area, + bool draw_edges) const { + // TODO(ojan): http://b/1210017 Figure out how to give the ability to + // exclude individual edges from being drawn. + + HANDLE handle = GetThemeHandle(TEXTFIELD); + // TODO(mpcomplete): can we detect if the color is specified by the user, + // and if not, just use the system color? + // CreateSolidBrush() accepts a RGB value but alpha must be 0. + HBRUSH bg_brush = CreateSolidBrush(color); + HRESULT hr; + // DrawThemeBackgroundEx was introduced in XP SP2, so that it's possible + // draw_theme_ex_ is NULL and draw_theme_ is non-null. + if (handle && (draw_theme_ex_ || (draw_theme_ && draw_edges))) { + if (draw_theme_ex_) { + static DTBGOPTS omit_border_options = { + sizeof(DTBGOPTS), + DTBG_OMITBORDER, + {0,0,0,0} + }; + DTBGOPTS* draw_opts = draw_edges ? NULL : &omit_border_options; + hr = draw_theme_ex_(handle, hdc, part_id, state_id, rect, draw_opts); + } else { + hr = draw_theme_(handle, hdc, part_id, state_id, rect, NULL); + } + + // TODO(maruel): Need to be fixed if get_theme_content_rect_ is NULL. + if (fill_content_area && get_theme_content_rect_) { + RECT content_rect; + hr = get_theme_content_rect_(handle, hdc, part_id, state_id, rect, + &content_rect); + FillRect(hdc, &content_rect, bg_brush); + } + } else { + // Draw it manually. + if (draw_edges) + DrawEdge(hdc, rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); + + if (fill_content_area) { + FillRect(hdc, rect, (classic_state & DFCS_INACTIVE) ? + reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1) : bg_brush); + } + hr = S_OK; + } + DeleteObject(bg_brush); + return hr; +} + +bool NativeTheme::IsThemingActive() const { + if (is_theme_active_) + return !!is_theme_active_(); + return false; +} + +HRESULT NativeTheme::GetThemePartSize(ThemeName theme_name, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + int ts, + SIZE* size) const { + HANDLE handle = GetThemeHandle(theme_name); + if (handle && get_theme_part_size_) + return get_theme_part_size_(handle, hdc, part_id, state_id, rect, ts, size); + + return E_NOTIMPL; +} + +HRESULT NativeTheme::GetThemeColor(ThemeName theme, + int part_id, + int state_id, + int prop_id, + SkColor* color) const { + HANDLE handle = GetThemeHandle(theme); + if (handle && get_theme_color_) { + COLORREF color_ref; + if (get_theme_color_(handle, part_id, state_id, prop_id, &color_ref) == + S_OK) { + *color = skia::COLORREFToSkColor(color_ref); + return S_OK; + } + } + return E_NOTIMPL; +} + +SkColor NativeTheme::GetThemeColorWithDefault(ThemeName theme, + int part_id, + int state_id, + int prop_id, + int default_sys_color) const { + SkColor color; + if (GetThemeColor(theme, part_id, state_id, prop_id, &color) != S_OK) + color = skia::COLORREFToSkColor(GetSysColor(default_sys_color)); + return color; +} + +HRESULT NativeTheme::GetThemeInt(ThemeName theme, + int part_id, + int state_id, + int prop_id, + int *value) const { + HANDLE handle = GetThemeHandle(theme); + if (handle && get_theme_int_) + return get_theme_int_(handle, part_id, state_id, prop_id, value); + return E_NOTIMPL; +} + +Size NativeTheme::GetThemeBorderSize(ThemeName theme) const { + // For simplicity use the wildcard state==0, part==0, since it works + // for the cases we currently depend on. + int border; + if (GetThemeInt(theme, 0, 0, TMT_BORDERSIZE, &border) == S_OK) + return Size(border, border); + else + return Size(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); +} + + +void NativeTheme::DisableTheming() const { + if (!set_theme_properties_) + return; + set_theme_properties_(0); +} + +HRESULT NativeTheme::PaintFrameControl(HDC hdc, + RECT* rect, + UINT type, + UINT state, + bool is_highlighted) const { + const int width = rect->right - rect->left; + const int height = rect->bottom - rect->top; + + // DrawFrameControl for menu arrow/check wants a monochrome bitmap. + ScopedBitmap mask_bitmap(CreateBitmap(width, height, 1, 1, NULL)); + + if (mask_bitmap == NULL) + return E_OUTOFMEMORY; + + ScopedHDC bitmap_dc(CreateCompatibleDC(NULL)); + HGDIOBJ org_bitmap = SelectObject(bitmap_dc, mask_bitmap); + RECT local_rect = { 0, 0, width, height }; + DrawFrameControl(bitmap_dc, &local_rect, type, state); + + // We're going to use BitBlt with a b&w mask. This results in using the dest + // dc's text color for the black bits in the mask, and the dest dc's + // background color for the white bits in the mask. DrawFrameControl draws the + // check in black, and the background in white. + COLORREF old_bg_color = + SetBkColor(hdc, + GetSysColor(is_highlighted ? COLOR_HIGHLIGHT : COLOR_MENU)); + COLORREF old_text_color = + SetTextColor(hdc, + GetSysColor(is_highlighted ? COLOR_HIGHLIGHTTEXT : + COLOR_MENUTEXT)); + BitBlt(hdc, rect->left, rect->top, width, height, bitmap_dc, 0, 0, SRCCOPY); + SetBkColor(hdc, old_bg_color); + SetTextColor(hdc, old_text_color); + + SelectObject(bitmap_dc, org_bitmap); + + return S_OK; +} + +void NativeTheme::CloseHandles() const +{ + if (!close_theme_) + return; + + for (int i = 0; i < LAST; ++i) { + if (theme_handles_[i]) + close_theme_(theme_handles_[i]); + theme_handles_[i] = NULL; + } +} + +HANDLE NativeTheme::GetThemeHandle(ThemeName theme_name) const +{ + if (!open_theme_ || theme_name < 0 || theme_name >= LAST) + return 0; + + if (theme_handles_[theme_name]) + return theme_handles_[theme_name]; + + // Not found, try to load it. + HANDLE handle = 0; + switch (theme_name) { + case BUTTON: + handle = open_theme_(NULL, L"Button"); + break; + case LIST: + handle = open_theme_(NULL, L"Listview"); + break; + case MENU: + handle = open_theme_(NULL, L"Menu"); + break; + case MENULIST: + handle = open_theme_(NULL, L"Combobox"); + break; + case SCROLLBAR: + handle = open_theme_(NULL, L"Scrollbar"); + break; + case STATUS: + handle = open_theme_(NULL, L"Status"); + break; + case TAB: + handle = open_theme_(NULL, L"Tab"); + break; + case TEXTFIELD: + handle = open_theme_(NULL, L"Edit"); + break; + case TRACKBAR: + handle = open_theme_(NULL, L"Trackbar"); + break; + case WINDOW: + handle = open_theme_(NULL, L"Window"); + break; + default: + NOTREACHED(); + } + theme_handles_[theme_name] = handle; + return handle; +} + +} // namespace gfx diff --git a/app/gfx/native_theme_win.h b/app/gfx/native_theme_win.h new file mode 100644 index 0000000..62415b4 --- /dev/null +++ b/app/gfx/native_theme_win.h @@ -0,0 +1,296 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// A wrapper class for working with custom XP/Vista themes provided in +// uxtheme.dll. This is a singleton class that can be grabbed using +// NativeTheme::instance(). +// For more information on visual style parts and states, see: +// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp + +#ifndef APP_GFX_NATIVE_THEME_WIN_H_ +#define APP_GFX_NATIVE_THEME_WIN_H_ + +#include <windows.h> +#include <uxtheme.h> +#include "base/basictypes.h" +#include "base/gfx/size.h" +#include "third_party/skia/include/core/SkColor.h" + +namespace skia { +class PlatformCanvas; +} // namespace skia + +namespace gfx { + +// TODO: Define class member enums to replace part_id and state_id parameters +// that are currently defined in <vssym32.h>. Afterward, classic_state should +// be removed and class users wouldn't need to include <vssym32.h> anymore. +// This would enable HOT state on non-themed UI (like when RDP'ing) and would +// simplify usage. +// TODO: This class should probably be changed to be platform independent at +// the same time. +class NativeTheme { + public: + enum ThemeName { + BUTTON, + LIST, + MENU, + MENULIST, + SCROLLBAR, + STATUS, + TAB, + TEXTFIELD, + TRACKBAR, + WINDOW, + LAST + }; + + // This enumeration is used within PaintMenuArrow in order to indicate the + // direction the menu arrow should point to. + enum MenuArrowDirection { + LEFT_POINTING_ARROW, + RIGHT_POINTING_ARROW + }; + + typedef HRESULT (WINAPI* DrawThemeBackgroundPtr)(HANDLE theme, + HDC hdc, + int part_id, + int state_id, + const RECT* rect, + const RECT* clip_rect); + typedef HRESULT (WINAPI* DrawThemeBackgroundExPtr)(HANDLE theme, + HDC hdc, + int part_id, + int state_id, + const RECT* rect, + const DTBGOPTS* opts); + typedef HRESULT (WINAPI* GetThemeColorPtr)(HANDLE hTheme, + int part_id, + int state_id, + int prop_id, + COLORREF* color); + typedef HRESULT (WINAPI* GetThemeContentRectPtr)(HANDLE hTheme, + HDC hdc, + int part_id, + int state_id, + const RECT* rect, + RECT* content_rect); + typedef HRESULT (WINAPI* GetThemePartSizePtr)(HANDLE hTheme, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + int ts, + SIZE* size); + typedef HANDLE (WINAPI* OpenThemeDataPtr)(HWND window, + LPCWSTR class_list); + typedef HRESULT (WINAPI* CloseThemeDataPtr)(HANDLE theme); + + typedef void (WINAPI* SetThemeAppPropertiesPtr) (DWORD flags); + typedef BOOL (WINAPI* IsThemeActivePtr)(); + typedef HRESULT (WINAPI* GetThemeIntPtr)(HANDLE hTheme, + int part_id, + int state_id, + int prop_id, + int *value); + + HRESULT PaintButton(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const; + + HRESULT PaintDialogBackground(HDC dc, bool active, RECT* rect) const; + + HRESULT PaintListBackground(HDC dc, bool enabled, RECT* rect) const; + + // |arrow_direction| determines whether the arrow is pointing to the left or + // to the right. In RTL locales, sub-menus open from right to left and + // therefore the menu arrow should point to the left and not to the right. + HRESULT PaintMenuArrow(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + MenuArrowDirection arrow_direction, + bool is_highlighted) const; + + HRESULT PaintMenuBackground(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect) const; + + HRESULT PaintMenuCheck(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + bool is_highlighted) const; + + HRESULT PaintMenuCheckBackground(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + RECT* rect) const; + + HRESULT PaintMenuGutter(HDC hdc, + int part_id, + int state_id, + RECT* rect) const; + + HRESULT PaintMenuItemBackground(ThemeName theme, + HDC hdc, + int part_id, + int state_id, + bool selected, + RECT* rect) const; + + HRESULT PaintMenuList(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const; + + HRESULT PaintMenuSeparator(HDC hdc, + int part_id, + int state_id, + RECT* rect) const; + + // Paints a scrollbar arrow. |classic_state| should have the appropriate + // classic part number ORed in already. + HRESULT PaintScrollbarArrow(HDC hdc, + int state_id, + int classic_state, + RECT* rect) const; + + // Paints a scrollbar track section. |align_rect| is only used in classic + // mode, and makes sure the checkerboard pattern in |target_rect| is aligned + // with one presumed to be in |align_rect|. + HRESULT PaintScrollbarTrack(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* target_rect, + RECT* align_rect, + skia::PlatformCanvas* canvas) const; + + // Paints a scrollbar thumb or gripper. + HRESULT PaintScrollbarThumb(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const; + + HRESULT PaintStatusGripper(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect) const; + + HRESULT PaintTabPanelBackground(HDC dc, RECT* rect) const; + + HRESULT PaintTextField(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect, + COLORREF color, + bool fill_content_area, + bool draw_edges) const; + + HRESULT PaintTrackbar(HDC hdc, + int part_id, + int state_id, + int classic_state, + RECT* rect, + skia::PlatformCanvas* canvas) const; + + bool IsThemingActive() const; + + HRESULT GetThemePartSize(ThemeName themeName, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + int ts, + SIZE* size) const; + + HRESULT GetThemeColor(ThemeName theme, + int part_id, + int state_id, + int prop_id, + SkColor* color) const; + + // Get the theme color if theming is enabled. If theming is unsupported + // for this part, use Win32's GetSysColor to find the color specified + // by default_sys_color. + SkColor GetThemeColorWithDefault(ThemeName theme, + int part_id, + int state_id, + int prop_id, + int default_sys_color) const; + + HRESULT GetThemeInt(ThemeName theme, + int part_id, + int state_id, + int prop_id, + int *result) const; + + // Get the thickness of the border associated with the specified theme, + // defaulting to GetSystemMetrics edge size if themes are disabled. + // In Classic Windows, borders are typically 2px; on XP+, they are 1px. + Size GetThemeBorderSize(ThemeName theme) const; + + // Disables all theming for top-level windows in the entire process, from + // when this method is called until the process exits. All the other + // methods in this class will continue to work, but their output will ignore + // the user's theme. This is meant for use when running tests that require + // consistent visual results. + void DisableTheming() const; + + // Closes cached theme handles so we can unload the DLL or update our UI + // for a theme change. + void CloseHandles() const; + + // Gets our singleton instance. + static const NativeTheme* instance(); + + private: + NativeTheme(); + ~NativeTheme(); + + HRESULT PaintFrameControl(HDC hdc, + RECT* rect, + UINT type, + UINT state, + bool is_highlighted) const; + + // Returns a handle to the theme data. + HANDLE GetThemeHandle(ThemeName theme_name) const; + + // Function pointers into uxtheme.dll. + DrawThemeBackgroundPtr draw_theme_; + DrawThemeBackgroundExPtr draw_theme_ex_; + GetThemeColorPtr get_theme_color_; + GetThemeContentRectPtr get_theme_content_rect_; + GetThemePartSizePtr get_theme_part_size_; + OpenThemeDataPtr open_theme_; + CloseThemeDataPtr close_theme_; + SetThemeAppPropertiesPtr set_theme_properties_; + IsThemeActivePtr is_theme_active_; + GetThemeIntPtr get_theme_int_; + + // Handle to uxtheme.dll. + HMODULE theme_dll_; + + // A cache of open theme handles. + mutable HANDLE theme_handles_[LAST]; + + DISALLOW_COPY_AND_ASSIGN(NativeTheme); +}; + +} // namespace gfx + +#endif // APP_GFX_NATIVE_THEME_WIN_H_ diff --git a/app/gfx/native_theme_win_unittest.cc b/app/gfx/native_theme_win_unittest.cc new file mode 100644 index 0000000..fea87eab --- /dev/null +++ b/app/gfx/native_theme_win_unittest.cc @@ -0,0 +1,11 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/gfx/native_theme_win.h" + +#include "testing/gtest/include/gtest/gtest.h" + +TEST(NativeThemeTest, Init) { + ASSERT_TRUE(gfx::NativeTheme::instance() != NULL); +} diff --git a/app/resource_bundle_linux.cc b/app/resource_bundle_linux.cc index 85f00c6..911cc03 100644 --- a/app/resource_bundle_linux.cc +++ b/app/resource_bundle_linux.cc @@ -8,12 +8,12 @@ #include "app/app_paths.h" #include "app/gfx/font.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "base/base_paths.h" #include "base/data_pack.h" #include "base/file_path.h" #include "base/file_util.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/path_service.h" #include "base/string_piece.h" diff --git a/app/win_util.cc b/app/win_util.cc index 0e985ce..b3b66c2 100644 --- a/app/win_util.cc +++ b/app/win_util.cc @@ -13,12 +13,12 @@ #include <algorithm> #include "app/gfx/codec/png_codec.h" +#include "app/gfx/gdi_util.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "base/base_switches.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/gfx/gdi_util.h" #include "base/logging.h" #include "base/native_library.h" #include "base/registry.h" diff --git a/base/base.gyp b/base/base.gyp index 2f0e9da..41108dd 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -518,16 +518,8 @@ 'type': '<(library)', 'msvs_guid': 'A508ADD3-CECE-4E0F-8448-2F5E454DF551', 'sources': [ - 'gfx/blit.cc', - 'gfx/blit.h', - 'gfx/gdi_util.cc', - 'gfx/gdi_util.h', 'gfx/gtk_native_view_id_manager.cc', 'gfx/gtk_native_view_id_manager.h', - 'gfx/gtk_util.cc', - 'gfx/gtk_util.h', - 'gfx/native_theme.cc', - 'gfx/native_theme.h', 'gfx/native_widget_types.h', 'gfx/native_widget_types_gtk.cc', 'gfx/point.cc', @@ -542,7 +534,6 @@ ], 'dependencies': [ 'base', - '../skia/skia.gyp:skia', ], 'export_dependent_settings': [ 'base', @@ -553,14 +544,8 @@ '../build/linux/system.gyp:gtk', ], }], - [ 'OS != "win"', { 'sources!': [ - 'gfx/gdi_util.cc', - 'gfx/native_theme.cc', - ], - }], [ 'OS != "linux" and OS != "freebsd"', { 'sources!': [ 'gfx/gtk_native_view_id_manager.cc', - 'gfx/gtk_util.cc', 'gfx/native_widget_types_gtk.cc', ], }], @@ -592,7 +577,6 @@ 'file_path_unittest.cc', 'file_util_unittest.cc', 'file_version_info_unittest.cc', - 'gfx/native_theme_unittest.cc', 'gfx/rect_unittest.cc', 'gmock_unittest.cc', 'histogram_unittest.cc', @@ -663,7 +647,6 @@ 'dependencies': [ 'base', 'base_gfx', - '../skia/skia.gyp:skia', '../testing/gmock.gyp:gmock', '../testing/gtest.gyp:gtest', ], diff --git a/base/gfx/DEPS b/base/gfx/DEPS deleted file mode 100644 index 2a3980b..0000000 --- a/base/gfx/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+skia", -] diff --git a/base/gfx/blit.cc b/base/gfx/blit.cc deleted file mode 100644 index 4b94255..0000000 --- a/base/gfx/blit.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/gfx/blit.h" - -#if defined(OS_LINUX) -#include <cairo/cairo.h> -#endif - -#include "base/gfx/point.h" -#include "base/gfx/rect.h" -#if defined(OS_MACOSX) -#include "base/scoped_cftyperef.h" -#endif -#include "skia/ext/platform_canvas.h" -#include "skia/ext/platform_device.h" - -namespace gfx { - -void BlitContextToContext(NativeDrawingContext dst_context, - const Rect& dst_rect, - NativeDrawingContext src_context, - const Point& src_origin) { -#if defined(OS_WIN) - BitBlt(dst_context, dst_rect.x(), dst_rect.y(), - dst_rect.width(), dst_rect.height(), - src_context, src_origin.x(), src_origin.y(), SRCCOPY); -#elif defined(OS_MACOSX) - // Only translations and/or vertical flips in the source context are - // supported; more complex source context transforms will be ignored. - - // If there is a translation on the source context, we need to account for - // it ourselves since CGBitmapContextCreateImage will bypass it. - Rect src_rect(src_origin, dst_rect.size()); - CGAffineTransform transform = CGContextGetCTM(src_context); - bool flipped = fabs(transform.d + 1) < 0.0001; - CGFloat delta_y = flipped ? CGBitmapContextGetHeight(src_context) - - transform.ty - : transform.ty; - src_rect.Offset(transform.tx, delta_y); - - scoped_cftyperef<CGImageRef> - src_image(CGBitmapContextCreateImage(src_context)); - scoped_cftyperef<CGImageRef> src_sub_image( - CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect())); - CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image); -#elif defined(OS_LINUX) - // Only translations in the source context are supported; more complex - // source context transforms will be ignored. - cairo_save(dst_context); - double surface_x = src_origin.x(); - double surface_y = src_origin.y(); - cairo_user_to_device(src_context, &surface_x, &surface_y); - cairo_set_source_surface(dst_context, cairo_get_target(src_context), - dst_rect.x()-surface_x, dst_rect.y()-surface_y); - cairo_rectangle(dst_context, dst_rect.x(), dst_rect.y(), - dst_rect.width(), dst_rect.height()); - cairo_clip(dst_context); - cairo_paint(dst_context); - cairo_restore(dst_context); -#endif -} - -static NativeDrawingContext GetContextFromCanvas( - skia::PlatformCanvas *canvas) { - skia::PlatformDevice& device = canvas->getTopPlatformDevice(); -#if defined(OS_WIN) - return device.getBitmapDC(); -#elif defined(OS_MACOSX) - return device.GetBitmapContext(); -#elif defined(OS_LINUX) - return device.beginPlatformPaint(); -#endif -} - -void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, - const Rect& dst_rect, - NativeDrawingContext src_context, - const Point& src_origin) { - BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, - src_context, src_origin); -} - -void BlitCanvasToContext(NativeDrawingContext dst_context, - const Rect& dst_rect, - skia::PlatformCanvas *src_canvas, - const Point& src_origin) { - BlitContextToContext(dst_context, dst_rect, - GetContextFromCanvas(src_canvas), src_origin); -} - -void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, - const Rect& dst_rect, - skia::PlatformCanvas *src_canvas, - const Point& src_origin) { - BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, - GetContextFromCanvas(src_canvas), src_origin); -} - -} // namespace gfx diff --git a/base/gfx/blit.h b/base/gfx/blit.h deleted file mode 100644 index 25f7a5e..0000000 --- a/base/gfx/blit.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_GFX_BLIT_H_ -#define BASE_GFX_BLIT_H_ - -#include "base/gfx/native_widget_types.h" -#include "base/gfx/point.h" -#include "base/gfx/rect.h" - -namespace skia { -class PlatformCanvas; -} // namespace skia - -namespace gfx { - -class Point; -class Rect; - -// Blits a rectangle from the source context into the destination context. -void BlitContextToContext(NativeDrawingContext dst_context, - const Rect& dst_rect, - NativeDrawingContext src_context, - const Point& src_origin); - -// Blits a rectangle from the source context into the destination canvas. -void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, - const Rect& dst_rect, - NativeDrawingContext src_context, - const Point& src_origin); - -// Blits a rectangle from the source canvas into the destination context. -void BlitCanvasToContext(NativeDrawingContext dst_context, - const Rect& dst_rect, - skia::PlatformCanvas *src_canvas, - const Point& src_origin); - -// Blits a rectangle from the source canvas into the destination canvas. -void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, - const Rect& dst_rect, - skia::PlatformCanvas *src_canvas, - const Point& src_origin); - -} // namespace gfx - -#endif // BASE_GFX_BLIT_H_ diff --git a/base/gfx/gdi_util.cc b/base/gfx/gdi_util.cc deleted file mode 100644 index 152698f..0000000 --- a/base/gfx/gdi_util.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/gfx/gdi_util.h" - -namespace gfx { - -void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr) { - CreateBitmapHeaderWithColorDepth(width, height, 32, hdr); -} - -void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth, - BITMAPINFOHEADER* hdr) { - // These values are shared with gfx::PlatformDevice - hdr->biSize = sizeof(BITMAPINFOHEADER); - hdr->biWidth = width; - hdr->biHeight = -height; // minus means top-down bitmap - hdr->biPlanes = 1; - hdr->biBitCount = color_depth; - hdr->biCompression = BI_RGB; // no compression - hdr->biSizeImage = 0; - hdr->biXPelsPerMeter = 1; - hdr->biYPelsPerMeter = 1; - hdr->biClrUsed = 0; - hdr->biClrImportant = 0; -} - - -void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr) { - // Because bmp v4 header is just an extension, we just create a v3 header and - // copy the bits over to the v4 header. - BITMAPINFOHEADER header_v3; - CreateBitmapHeader(width, height, &header_v3); - memset(hdr, 0, sizeof(BITMAPV4HEADER)); - memcpy(hdr, &header_v3, sizeof(BITMAPINFOHEADER)); - - // Correct the size of the header and fill in the mask values. - hdr->bV4Size = sizeof(BITMAPV4HEADER); - hdr->bV4RedMask = 0x00ff0000; - hdr->bV4GreenMask = 0x0000ff00; - hdr->bV4BlueMask = 0x000000ff; - hdr->bV4AlphaMask = 0xff000000; -} - -// Creates a monochrome bitmap header. -void CreateMonochromeBitmapHeader(int width, - int height, - BITMAPINFOHEADER* hdr) { - hdr->biSize = sizeof(BITMAPINFOHEADER); - hdr->biWidth = width; - hdr->biHeight = -height; - hdr->biPlanes = 1; - hdr->biBitCount = 1; - hdr->biCompression = BI_RGB; - hdr->biSizeImage = 0; - hdr->biXPelsPerMeter = 1; - hdr->biYPelsPerMeter = 1; - hdr->biClrUsed = 0; - hdr->biClrImportant = 0; -} - -void SubtractRectanglesFromRegion(HRGN hrgn, - const std::vector<gfx::Rect>& cutouts) { - if (cutouts.size()) { - HRGN cutout = ::CreateRectRgn(0, 0, 0, 0); - for (size_t i = 0; i < cutouts.size(); i++) { - ::SetRectRgn(cutout, - cutouts[i].x(), - cutouts[i].y(), - cutouts[i].right(), - cutouts[i].bottom()); - ::CombineRgn(hrgn, hrgn, cutout, RGN_DIFF); - } - ::DeleteObject(cutout); - } -} - -} // namespace gfx diff --git a/base/gfx/gdi_util.h b/base/gfx/gdi_util.h deleted file mode 100644 index cc15e92..0000000 --- a/base/gfx/gdi_util.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_GFX_GDI_UTIL_H__ -#define BASE_GFX_GDI_UTIL_H__ - -#include <vector> -#include <windows.h> -#include "base/gfx/rect.h" - -namespace gfx { - -// Creates a BITMAPINFOHEADER structure given the bitmap's size. -void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); - -// Creates a BITMAPINFOHEADER structure given the bitmap's size and -// color depth in bits per pixel. -void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth, - BITMAPINFOHEADER* hdr); - -// Creates a BITMAPV4HEADER structure given the bitmap's size. You probably -// only need to use BMP V4 if you need transparency (alpha channel). This -// function sets the AlphaMask to 0xff000000. -void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr); - -// Creates a monochrome bitmap header. -void CreateMonochromeBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); - -// Modify the given hrgn by subtracting the given rectangles. -void SubtractRectanglesFromRegion(HRGN hrgn, - const std::vector<gfx::Rect>& cutouts); - -} // namespace gfx - -#endif // BASE_GFX_GDI_UTIL_H__ diff --git a/base/gfx/gtk_util.cc b/base/gfx/gtk_util.cc deleted file mode 100644 index 1611c94..0000000 --- a/base/gfx/gtk_util.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/gfx/gtk_util.h" - -#include <gdk/gdk.h> -#include <gtk/gtk.h> -#include <stdlib.h> - -#include "base/basictypes.h" -#include "base/gfx/rect.h" -#include "base/linux_util.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/skia/include/core/SkUnPreMultiply.h" - -namespace { - -void FreePixels(guchar* pixels, gpointer data) { - free(data); -} - -} // namespace - -namespace gfx { - -const GdkColor kGdkWhite = GDK_COLOR_RGB(0xff, 0xff, 0xff); -const GdkColor kGdkBlack = GDK_COLOR_RGB(0x00, 0x00, 0x00); -const GdkColor kGdkGreen = GDK_COLOR_RGB(0x00, 0xff, 0x00); - -GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) { - bitmap->lockPixels(); - int width = bitmap->width(); - int height = bitmap->height(); - int stride = bitmap->rowBytes(); - - // SkBitmaps are premultiplied, we need to unpremultiply them. - const int kBytesPerPixel = 4; - uint8* divided = static_cast<uint8*>(malloc(height * stride)); - - for (int y = 0, i = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - uint32 pixel = bitmap->getAddr32(0, y)[x]; - - int alpha = SkColorGetA(pixel); - if (alpha != 0 && alpha != 255) { - SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel); - divided[i + 0] = SkColorGetR(unmultiplied); - divided[i + 1] = SkColorGetG(unmultiplied); - divided[i + 2] = SkColorGetB(unmultiplied); - divided[i + 3] = alpha; - } else { - divided[i + 0] = SkColorGetR(pixel); - divided[i + 1] = SkColorGetG(pixel); - divided[i + 2] = SkColorGetB(pixel); - divided[i + 3] = alpha; - } - i += kBytesPerPixel; - } - } - - // This pixbuf takes ownership of our malloc()ed data and will - // free it for us when it is destroyed. - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( - divided, - GDK_COLORSPACE_RGB, // The only colorspace gtk supports. - true, // There is an alpha channel. - 8, - width, height, stride, &FreePixels, divided); - - bitmap->unlockPixels(); - return pixbuf; -} - -void SubtractRectanglesFromRegion(GdkRegion* region, - const std::vector<Rect>& cutouts) { - for (size_t i = 0; i < cutouts.size(); ++i) { - GdkRectangle rect = cutouts[i].ToGdkRectangle(); - GdkRegion* rect_region = gdk_region_rectangle(&rect); - gdk_region_subtract(region, rect_region); - // TODO(deanm): It would be nice to be able to reuse the GdkRegion here. - gdk_region_destroy(rect_region); - } -} - -} // namespace gfx diff --git a/base/gfx/gtk_util.h b/base/gfx/gtk_util.h deleted file mode 100644 index 523f7bf..0000000 --- a/base/gfx/gtk_util.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_GFX_GTK_UTIL_H_ -#define BASE_GFX_GTK_UTIL_H_ - -#include <stdint.h> -#include <vector> - -#include <glib-object.h> - -#include "base/scoped_ptr.h" - -typedef struct _GdkColor GdkColor; -typedef struct _GdkPixbuf GdkPixbuf; -typedef struct _GdkRegion GdkRegion; - -class SkBitmap; - -const int kSkiaToGDKMultiplier = 257; - -// Define a macro for creating GdkColors from RGB values. This is a macro to -// allow static construction of literals, etc. Use this like: -// GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff); -#define GDK_COLOR_RGB(r, g, b) {0, r * kSkiaToGDKMultiplier, \ - g * kSkiaToGDKMultiplier, b * kSkiaToGDKMultiplier} - -namespace gfx { - -class Rect; - -extern const GdkColor kGdkWhite; -extern const GdkColor kGdkBlack; -extern const GdkColor kGdkGreen; - -// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so -// it is an expensive operation. -GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); - -// Modify the given region by subtracting the given rectangles. -void SubtractRectanglesFromRegion(GdkRegion* region, - const std::vector<Rect>& cutouts); - -} // namespace gfx - -namespace { -// A helper class that will g_object_unref |p| when it goes out of scope. -// This never adds a ref, it only unrefs. -template <typename Type> -struct GObjectUnrefer { - void operator()(Type* ptr) const { - if (ptr) - g_object_unref(ptr); - } -}; -} // namespace - -// It's not legal C++ to have a templatized typedefs, so we wrap it in a -// struct. When using this, you need to include ::Type. E.g., -// ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); -template<class T> -struct ScopedGObject { - typedef scoped_ptr_malloc<T, GObjectUnrefer<T> > Type; -}; - -#endif // BASE_GFX_GTK_UTIL_H_ diff --git a/base/gfx/native_theme.cc b/base/gfx/native_theme.cc deleted file mode 100644 index 75bf67b..0000000 --- a/base/gfx/native_theme.cc +++ /dev/null @@ -1,710 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/gfx/native_theme.h" - -#include <windows.h> -#include <uxtheme.h> -#include <vsstyle.h> -#include <vssym32.h> - -#include "base/gfx/gdi_util.h" -#include "base/gfx/rect.h" -#include "base/logging.h" -#include "base/scoped_handle.h" -#include "skia/ext/platform_canvas.h" -#include "skia/ext/skia_utils_win.h" -#include "third_party/skia/include/core/SkShader.h" - -namespace { - -void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { - // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. - SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); - SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); - SkColor buffer[] = { face, highlight, highlight, face }; - // Confusing bit: we first create a temporary bitmap with our desired pattern, - // then copy it to another bitmap. The temporary bitmap doesn't take - // ownership of the pixel data, and so will point to garbage when this - // function returns. The copy will copy the pixel data into a place owned by - // the bitmap, which is in turn owned by the shader, etc., so it will live - // until we're done using it. - SkBitmap temp_bitmap; - temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); - temp_bitmap.setPixels(buffer); - SkBitmap bitmap; - temp_bitmap.copyTo(&bitmap, temp_bitmap.config()); - SkShader* shader = SkShader::CreateBitmapShader(bitmap, - SkShader::kRepeat_TileMode, - SkShader::kRepeat_TileMode); - - // Align the pattern with the upper corner of |align_rect|. - SkMatrix matrix; - matrix.setTranslate(SkIntToScalar(align_rect.left), - SkIntToScalar(align_rect.top)); - shader->setLocalMatrix(matrix); - paint->setShader(shader)->safeUnref(); -} - -} // namespace - -namespace gfx { - -/* static */ -const NativeTheme* NativeTheme::instance() { - // The global NativeTheme instance. - static const NativeTheme s_native_theme; - return &s_native_theme; -} - -NativeTheme::NativeTheme() - : theme_dll_(LoadLibrary(L"uxtheme.dll")), - draw_theme_(NULL), - draw_theme_ex_(NULL), - get_theme_color_(NULL), - get_theme_content_rect_(NULL), - get_theme_part_size_(NULL), - open_theme_(NULL), - close_theme_(NULL), - set_theme_properties_(NULL), - is_theme_active_(NULL), - get_theme_int_(NULL) { - if (theme_dll_) { - draw_theme_ = reinterpret_cast<DrawThemeBackgroundPtr>( - GetProcAddress(theme_dll_, "DrawThemeBackground")); - draw_theme_ex_ = reinterpret_cast<DrawThemeBackgroundExPtr>( - GetProcAddress(theme_dll_, "DrawThemeBackgroundEx")); - get_theme_color_ = reinterpret_cast<GetThemeColorPtr>( - GetProcAddress(theme_dll_, "GetThemeColor")); - get_theme_content_rect_ = reinterpret_cast<GetThemeContentRectPtr>( - GetProcAddress(theme_dll_, "GetThemeBackgroundContentRect")); - get_theme_part_size_ = reinterpret_cast<GetThemePartSizePtr>( - GetProcAddress(theme_dll_, "GetThemePartSize")); - open_theme_ = reinterpret_cast<OpenThemeDataPtr>( - GetProcAddress(theme_dll_, "OpenThemeData")); - close_theme_ = reinterpret_cast<CloseThemeDataPtr>( - GetProcAddress(theme_dll_, "CloseThemeData")); - set_theme_properties_ = reinterpret_cast<SetThemeAppPropertiesPtr>( - GetProcAddress(theme_dll_, "SetThemeAppProperties")); - is_theme_active_ = reinterpret_cast<IsThemeActivePtr>( - GetProcAddress(theme_dll_, "IsThemeActive")); - get_theme_int_ = reinterpret_cast<GetThemeIntPtr>( - GetProcAddress(theme_dll_, "GetThemeInt")); - } - memset(theme_handles_, 0, sizeof(theme_handles_)); -} - -NativeTheme::~NativeTheme() { - if (theme_dll_) { - // todo (cpu): fix this soon. - // CloseHandles(); - FreeLibrary(theme_dll_); - } -} - -HRESULT NativeTheme::PaintButton(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const { - HANDLE handle = GetThemeHandle(BUTTON); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - - // Draw it manually. - // All pressed states have both low bits set, and no other states do. - const bool focused = ((state_id & ETS_FOCUSED) == ETS_FOCUSED); - const bool pressed = ((state_id & PBS_PRESSED) == PBS_PRESSED); - if ((BP_PUSHBUTTON == part_id) && (pressed || focused)) { - // BP_PUSHBUTTON has a focus rect drawn around the outer edge, and the - // button itself is shrunk by 1 pixel. - HBRUSH brush = GetSysColorBrush(COLOR_3DDKSHADOW); - if (brush) { - FrameRect(hdc, rect, brush); - InflateRect(rect, -1, -1); - } - } - DrawFrameControl(hdc, rect, DFC_BUTTON, classic_state); - - // Draw the focus rectangle (the dotted line box) only on buttons. For radio - // and checkboxes, we let webkit draw the focus rectangle (orange glow). - if ((BP_PUSHBUTTON == part_id) && focused) { - // The focus rect is inside the button. The exact number of pixels depends - // on whether we're in classic mode or using uxtheme. - if (handle && get_theme_content_rect_) { - get_theme_content_rect_(handle, hdc, part_id, state_id, rect, rect); - } else { - InflateRect(rect, -GetSystemMetrics(SM_CXEDGE), - -GetSystemMetrics(SM_CYEDGE)); - } - DrawFocusRect(hdc, rect); - } - - return S_OK; -} - -HRESULT NativeTheme::PaintDialogBackground(HDC hdc, bool active, - RECT* rect) const { - HANDLE handle = GetThemeHandle(WINDOW); - if (handle && draw_theme_) { - return draw_theme_(handle, hdc, WP_DIALOG, - active ? FS_ACTIVE : FS_INACTIVE, rect, NULL); - } - - // Classic just renders a flat color background. - FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); - return S_OK; -} - -HRESULT NativeTheme::PaintListBackground(HDC hdc, - bool enabled, - RECT* rect) const { - HANDLE handle = GetThemeHandle(LIST); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, 1, TS_NORMAL, rect, NULL); - - // Draw it manually. - HBRUSH bg_brush = GetSysColorBrush(COLOR_WINDOW); - FillRect(hdc, rect, bg_brush); - DrawEdge(hdc, rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); - return S_OK; -} - -HRESULT NativeTheme::PaintMenuArrow(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - MenuArrowDirection arrow_direction, - bool is_highlighted) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) { - if (arrow_direction == RIGHT_POINTING_ARROW) { - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - } else { - // There is no way to tell the uxtheme API to draw a left pointing arrow; - // it doesn't have a flag equivalent to DFCS_MENUARROWRIGHT. But they - // are needed for RTL locales on Vista. So use a memory DC and mirror - // the region with GDI's StretchBlt. - Rect r(*rect); - ScopedHDC mem_dc(CreateCompatibleDC(hdc)); - ScopedBitmap mem_bitmap(CreateCompatibleBitmap(hdc, r.width(), - r.height())); - HGDIOBJ old_bitmap = SelectObject(mem_dc, mem_bitmap); - // Copy and horizontally mirror the background from hdc into mem_dc. Use - // a negative-width source rect, starting at the rightmost pixel. - StretchBlt(mem_dc, 0, 0, r.width(), r.height(), - hdc, r.right()-1, r.y(), -r.width(), r.height(), SRCCOPY); - // Draw the arrow. - RECT theme_rect = {0, 0, r.width(), r.height()}; - HRESULT result = draw_theme_(handle, mem_dc, part_id, - state_id, &theme_rect, NULL); - // Copy and mirror the result back into mem_dc. - StretchBlt(hdc, r.x(), r.y(), r.width(), r.height(), - mem_dc, r.width()-1, 0, -r.width(), r.height(), SRCCOPY); - SelectObject(mem_dc, old_bitmap); - return result; - } - } - - // For some reason, Windows uses the name DFCS_MENUARROWRIGHT to indicate a - // left pointing arrow. This makes the following 'if' statement slightly - // counterintuitive. - UINT state; - if (arrow_direction == RIGHT_POINTING_ARROW) - state = DFCS_MENUARROW; - else - state = DFCS_MENUARROWRIGHT; - return PaintFrameControl(hdc, rect, DFC_MENU, state, is_highlighted); -} - -HRESULT NativeTheme::PaintMenuBackground(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) { - HRESULT result = draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - FrameRect(hdc, rect, GetSysColorBrush(COLOR_3DSHADOW)); - return result; - } - - FillRect(hdc, rect, GetSysColorBrush(COLOR_MENU)); - DrawEdge(hdc, rect, EDGE_RAISED, BF_RECT); - return S_OK; -} - -HRESULT NativeTheme::PaintMenuCheckBackground(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - // Nothing to do for background. - return S_OK; -} - -HRESULT NativeTheme::PaintMenuCheck(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - bool is_highlighted) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) { - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - } - return PaintFrameControl(hdc, rect, DFC_MENU, DFCS_MENUCHECK, is_highlighted); -} - -HRESULT NativeTheme::PaintMenuGutter(HDC hdc, - int part_id, - int state_id, - RECT* rect) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - return E_NOTIMPL; -} - -HRESULT NativeTheme::PaintMenuItemBackground(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - bool selected, - RECT* rect) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - if (selected) - FillRect(hdc, rect, GetSysColorBrush(COLOR_HIGHLIGHT)); - return S_OK; -} - -HRESULT NativeTheme::PaintMenuList(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const { - HANDLE handle = GetThemeHandle(MENULIST); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - - // Draw it manually. - DrawFrameControl(hdc, rect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | classic_state); - return S_OK; -} - -HRESULT NativeTheme::PaintMenuSeparator(HDC hdc, - int part_id, - int state_id, - RECT* rect) const { - HANDLE handle = GetThemeHandle(MENU); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - DrawEdge(hdc, rect, EDGE_ETCHED, BF_TOP); - return S_OK; -} - -HRESULT NativeTheme::PaintScrollbarArrow(HDC hdc, - int state_id, - int classic_state, - RECT* rect) const { - HANDLE handle = GetThemeHandle(SCROLLBAR); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, SBP_ARROWBTN, state_id, rect, NULL); - - // Draw it manually. - DrawFrameControl(hdc, rect, DFC_SCROLL, classic_state); - return S_OK; -} - -HRESULT NativeTheme::PaintScrollbarTrack( - HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* target_rect, - RECT* align_rect, - skia::PlatformCanvas* canvas) const { - HANDLE handle = GetThemeHandle(SCROLLBAR); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, target_rect, NULL); - - // Draw it manually. - const DWORD colorScrollbar = GetSysColor(COLOR_SCROLLBAR); - const DWORD color3DFace = GetSysColor(COLOR_3DFACE); - if ((colorScrollbar != color3DFace) && - (colorScrollbar != GetSysColor(COLOR_WINDOW))) { - FillRect(hdc, target_rect, reinterpret_cast<HBRUSH>(COLOR_SCROLLBAR + 1)); - } else { - SkPaint paint; - SetCheckerboardShader(&paint, *align_rect); - canvas->drawIRect(skia::RECTToSkIRect(*target_rect), paint); - } - if (classic_state & DFCS_PUSHED) - InvertRect(hdc, target_rect); - return S_OK; -} - -HRESULT NativeTheme::PaintScrollbarThumb(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const { - HANDLE handle = GetThemeHandle(SCROLLBAR); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - - // Draw it manually. - if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) - DrawEdge(hdc, rect, EDGE_RAISED, BF_RECT | BF_MIDDLE); - // Classic mode doesn't have a gripper. - return S_OK; -} - -HRESULT NativeTheme::PaintStatusGripper(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const { - HANDLE handle = GetThemeHandle(STATUS); - if (handle && draw_theme_) { - // Paint the status bar gripper. There doesn't seem to be a - // standard gripper in Windows for the space between - // scrollbars. This is pretty close, but it's supposed to be - // painted over a status bar. - return draw_theme_(handle, hdc, SP_GRIPPER, 0, rect, NULL); - } - - // Draw a windows classic scrollbar gripper. - DrawFrameControl(hdc, rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); - return S_OK; -} - -HRESULT NativeTheme::PaintTabPanelBackground(HDC hdc, RECT* rect) const { - HANDLE handle = GetThemeHandle(TAB); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, TABP_BODY, 0, rect, NULL); - - // Classic just renders a flat color background. - FillRect(hdc, rect, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); - return S_OK; -} - -HRESULT NativeTheme::PaintTrackbar(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect, - skia::PlatformCanvas* canvas) const { - // Make the channel be 4 px thick in the center of the supplied rect. (4 px - // matches what XP does in various menus; GetThemePartSize() doesn't seem to - // return good values here.) - RECT channel_rect = *rect; - const int channel_thickness = 4; - if (part_id == TKP_TRACK) { - channel_rect.top += - ((channel_rect.bottom - channel_rect.top - channel_thickness) / 2); - channel_rect.bottom = channel_rect.top + channel_thickness; - } else if (part_id == TKP_TRACKVERT) { - channel_rect.left += - ((channel_rect.right - channel_rect.left - channel_thickness) / 2); - channel_rect.right = channel_rect.left + channel_thickness; - } // else this isn't actually a channel, so |channel_rect| == |rect|. - - HANDLE handle = GetThemeHandle(TRACKBAR); - if (handle && draw_theme_) - return draw_theme_(handle, hdc, part_id, state_id, &channel_rect, NULL); - - // Classic mode, draw it manually. - if ((part_id == TKP_TRACK) || (part_id == TKP_TRACKVERT)) { - DrawEdge(hdc, &channel_rect, EDGE_SUNKEN, BF_RECT); - } else if (part_id == TKP_THUMBVERT) { - DrawEdge(hdc, rect, EDGE_RAISED, BF_RECT | BF_SOFT | BF_MIDDLE); - } else { - // Split rect into top and bottom pieces. - RECT top_section = *rect; - RECT bottom_section = *rect; - top_section.bottom -= ((bottom_section.right - bottom_section.left) / 2); - bottom_section.top = top_section.bottom; - DrawEdge(hdc, &top_section, EDGE_RAISED, - BF_LEFT | BF_TOP | BF_RIGHT | BF_SOFT | BF_MIDDLE | BF_ADJUST); - - // Split triangular piece into two diagonals. - RECT& left_half = bottom_section; - RECT right_half = bottom_section; - right_half.left += ((bottom_section.right - bottom_section.left) / 2); - left_half.right = right_half.left; - DrawEdge(hdc, &left_half, EDGE_RAISED, - BF_DIAGONAL_ENDTOPLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); - DrawEdge(hdc, &right_half, EDGE_RAISED, - BF_DIAGONAL_ENDBOTTOMLEFT | BF_SOFT | BF_MIDDLE | BF_ADJUST); - - // If the button is pressed, draw hatching. - if (classic_state & DFCS_PUSHED) { - SkPaint paint; - SetCheckerboardShader(&paint, *rect); - - // Fill all three pieces with the pattern. - canvas->drawIRect(skia::RECTToSkIRect(top_section), paint); - - SkScalar left_triangle_top = SkIntToScalar(left_half.top); - SkScalar left_triangle_right = SkIntToScalar(left_half.right); - SkPath left_triangle; - left_triangle.moveTo(SkIntToScalar(left_half.left), left_triangle_top); - left_triangle.lineTo(left_triangle_right, left_triangle_top); - left_triangle.lineTo(left_triangle_right, - SkIntToScalar(left_half.bottom)); - left_triangle.close(); - canvas->drawPath(left_triangle, paint); - - SkScalar right_triangle_left = SkIntToScalar(right_half.left); - SkScalar right_triangle_top = SkIntToScalar(right_half.top); - SkPath right_triangle; - right_triangle.moveTo(right_triangle_left, right_triangle_top); - right_triangle.lineTo(SkIntToScalar(right_half.right), - right_triangle_top); - right_triangle.lineTo(right_triangle_left, - SkIntToScalar(right_half.bottom)); - right_triangle.close(); - canvas->drawPath(right_triangle, paint); - } - } - return S_OK; -} - -HRESULT NativeTheme::PaintTextField(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect, - COLORREF color, - bool fill_content_area, - bool draw_edges) const { - // TODO(ojan): http://b/1210017 Figure out how to give the ability to - // exclude individual edges from being drawn. - - HANDLE handle = GetThemeHandle(TEXTFIELD); - // TODO(mpcomplete): can we detect if the color is specified by the user, - // and if not, just use the system color? - // CreateSolidBrush() accepts a RGB value but alpha must be 0. - HBRUSH bg_brush = CreateSolidBrush(color); - HRESULT hr; - // DrawThemeBackgroundEx was introduced in XP SP2, so that it's possible - // draw_theme_ex_ is NULL and draw_theme_ is non-null. - if (handle && (draw_theme_ex_ || (draw_theme_ && draw_edges))) { - if (draw_theme_ex_) { - static DTBGOPTS omit_border_options = { - sizeof(DTBGOPTS), - DTBG_OMITBORDER, - {0,0,0,0} - }; - DTBGOPTS* draw_opts = draw_edges ? NULL : &omit_border_options; - hr = draw_theme_ex_(handle, hdc, part_id, state_id, rect, draw_opts); - } else { - hr = draw_theme_(handle, hdc, part_id, state_id, rect, NULL); - } - - // TODO(maruel): Need to be fixed if get_theme_content_rect_ is NULL. - if (fill_content_area && get_theme_content_rect_) { - RECT content_rect; - hr = get_theme_content_rect_(handle, hdc, part_id, state_id, rect, - &content_rect); - FillRect(hdc, &content_rect, bg_brush); - } - } else { - // Draw it manually. - if (draw_edges) - DrawEdge(hdc, rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); - - if (fill_content_area) { - FillRect(hdc, rect, (classic_state & DFCS_INACTIVE) ? - reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1) : bg_brush); - } - hr = S_OK; - } - DeleteObject(bg_brush); - return hr; -} - -bool NativeTheme::IsThemingActive() const { - if (is_theme_active_) - return !!is_theme_active_(); - return false; -} - -HRESULT NativeTheme::GetThemePartSize(ThemeName theme_name, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - int ts, - SIZE* size) const { - HANDLE handle = GetThemeHandle(theme_name); - if (handle && get_theme_part_size_) - return get_theme_part_size_(handle, hdc, part_id, state_id, rect, ts, size); - - return E_NOTIMPL; -} - -HRESULT NativeTheme::GetThemeColor(ThemeName theme, - int part_id, - int state_id, - int prop_id, - SkColor* color) const { - HANDLE handle = GetThemeHandle(theme); - if (handle && get_theme_color_) { - COLORREF color_ref; - if (get_theme_color_(handle, part_id, state_id, prop_id, &color_ref) == - S_OK) { - *color = skia::COLORREFToSkColor(color_ref); - return S_OK; - } - } - return E_NOTIMPL; -} - -SkColor NativeTheme::GetThemeColorWithDefault(ThemeName theme, - int part_id, - int state_id, - int prop_id, - int default_sys_color) const { - SkColor color; - if (GetThemeColor(theme, part_id, state_id, prop_id, &color) != S_OK) - color = skia::COLORREFToSkColor(GetSysColor(default_sys_color)); - return color; -} - -HRESULT NativeTheme::GetThemeInt(ThemeName theme, - int part_id, - int state_id, - int prop_id, - int *value) const { - HANDLE handle = GetThemeHandle(theme); - if (handle && get_theme_int_) - return get_theme_int_(handle, part_id, state_id, prop_id, value); - return E_NOTIMPL; -} - -Size NativeTheme::GetThemeBorderSize(ThemeName theme) const { - // For simplicity use the wildcard state==0, part==0, since it works - // for the cases we currently depend on. - int border; - if (GetThemeInt(theme, 0, 0, TMT_BORDERSIZE, &border) == S_OK) - return Size(border, border); - else - return Size(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); -} - - -void NativeTheme::DisableTheming() const { - if (!set_theme_properties_) - return; - set_theme_properties_(0); -} - -HRESULT NativeTheme::PaintFrameControl(HDC hdc, - RECT* rect, - UINT type, - UINT state, - bool is_highlighted) const { - const int width = rect->right - rect->left; - const int height = rect->bottom - rect->top; - - // DrawFrameControl for menu arrow/check wants a monochrome bitmap. - ScopedBitmap mask_bitmap(CreateBitmap(width, height, 1, 1, NULL)); - - if (mask_bitmap == NULL) - return E_OUTOFMEMORY; - - ScopedHDC bitmap_dc(CreateCompatibleDC(NULL)); - HGDIOBJ org_bitmap = SelectObject(bitmap_dc, mask_bitmap); - RECT local_rect = { 0, 0, width, height }; - DrawFrameControl(bitmap_dc, &local_rect, type, state); - - // We're going to use BitBlt with a b&w mask. This results in using the dest - // dc's text color for the black bits in the mask, and the dest dc's - // background color for the white bits in the mask. DrawFrameControl draws the - // check in black, and the background in white. - COLORREF old_bg_color = - SetBkColor(hdc, - GetSysColor(is_highlighted ? COLOR_HIGHLIGHT : COLOR_MENU)); - COLORREF old_text_color = - SetTextColor(hdc, - GetSysColor(is_highlighted ? COLOR_HIGHLIGHTTEXT : - COLOR_MENUTEXT)); - BitBlt(hdc, rect->left, rect->top, width, height, bitmap_dc, 0, 0, SRCCOPY); - SetBkColor(hdc, old_bg_color); - SetTextColor(hdc, old_text_color); - - SelectObject(bitmap_dc, org_bitmap); - - return S_OK; -} - -void NativeTheme::CloseHandles() const -{ - if (!close_theme_) - return; - - for (int i = 0; i < LAST; ++i) { - if (theme_handles_[i]) - close_theme_(theme_handles_[i]); - theme_handles_[i] = NULL; - } -} - -HANDLE NativeTheme::GetThemeHandle(ThemeName theme_name) const -{ - if (!open_theme_ || theme_name < 0 || theme_name >= LAST) - return 0; - - if (theme_handles_[theme_name]) - return theme_handles_[theme_name]; - - // Not found, try to load it. - HANDLE handle = 0; - switch (theme_name) { - case BUTTON: - handle = open_theme_(NULL, L"Button"); - break; - case LIST: - handle = open_theme_(NULL, L"Listview"); - break; - case MENU: - handle = open_theme_(NULL, L"Menu"); - break; - case MENULIST: - handle = open_theme_(NULL, L"Combobox"); - break; - case SCROLLBAR: - handle = open_theme_(NULL, L"Scrollbar"); - break; - case STATUS: - handle = open_theme_(NULL, L"Status"); - break; - case TAB: - handle = open_theme_(NULL, L"Tab"); - break; - case TEXTFIELD: - handle = open_theme_(NULL, L"Edit"); - break; - case TRACKBAR: - handle = open_theme_(NULL, L"Trackbar"); - break; - case WINDOW: - handle = open_theme_(NULL, L"Window"); - break; - default: - NOTREACHED(); - } - theme_handles_[theme_name] = handle; - return handle; -} - -} // namespace gfx diff --git a/base/gfx/native_theme.h b/base/gfx/native_theme.h deleted file mode 100644 index 4516cba..0000000 --- a/base/gfx/native_theme.h +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// A wrapper class for working with custom XP/Vista themes provided in -// uxtheme.dll. This is a singleton class that can be grabbed using -// NativeTheme::instance(). -// For more information on visual style parts and states, see: -// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp - -#ifndef BASE_GFX_NATIVE_THEME_H__ -#define BASE_GFX_NATIVE_THEME_H__ - -#include <windows.h> -#include <uxtheme.h> -#include "base/basictypes.h" -#include "base/gfx/size.h" -#include "third_party/skia/include/core/SkColor.h" - -namespace skia { -class PlatformCanvas; -} // namespace skia - -namespace gfx { - -// TODO: Define class member enums to replace part_id and state_id parameters -// that are currently defined in <vssym32.h>. Afterward, classic_state should -// be removed and class users wouldn't need to include <vssym32.h> anymore. -// This would enable HOT state on non-themed UI (like when RDP'ing) and would -// simplify usage. -// TODO: This class should probably be changed to be platform independent at -// the same time. -class NativeTheme { - public: - enum ThemeName { - BUTTON, - LIST, - MENU, - MENULIST, - SCROLLBAR, - STATUS, - TAB, - TEXTFIELD, - TRACKBAR, - WINDOW, - LAST - }; - - // This enumeration is used within PaintMenuArrow in order to indicate the - // direction the menu arrow should point to. - enum MenuArrowDirection { - LEFT_POINTING_ARROW, - RIGHT_POINTING_ARROW - }; - - typedef HRESULT (WINAPI* DrawThemeBackgroundPtr)(HANDLE theme, - HDC hdc, - int part_id, - int state_id, - const RECT* rect, - const RECT* clip_rect); - typedef HRESULT (WINAPI* DrawThemeBackgroundExPtr)(HANDLE theme, - HDC hdc, - int part_id, - int state_id, - const RECT* rect, - const DTBGOPTS* opts); - typedef HRESULT (WINAPI* GetThemeColorPtr)(HANDLE hTheme, - int part_id, - int state_id, - int prop_id, - COLORREF* color); - typedef HRESULT (WINAPI* GetThemeContentRectPtr)(HANDLE hTheme, - HDC hdc, - int part_id, - int state_id, - const RECT* rect, - RECT* content_rect); - typedef HRESULT (WINAPI* GetThemePartSizePtr)(HANDLE hTheme, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - int ts, - SIZE* size); - typedef HANDLE (WINAPI* OpenThemeDataPtr)(HWND window, - LPCWSTR class_list); - typedef HRESULT (WINAPI* CloseThemeDataPtr)(HANDLE theme); - - typedef void (WINAPI* SetThemeAppPropertiesPtr) (DWORD flags); - typedef BOOL (WINAPI* IsThemeActivePtr)(); - typedef HRESULT (WINAPI* GetThemeIntPtr)(HANDLE hTheme, - int part_id, - int state_id, - int prop_id, - int *value); - - HRESULT PaintButton(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const; - - HRESULT PaintDialogBackground(HDC dc, bool active, RECT* rect) const; - - HRESULT PaintListBackground(HDC dc, bool enabled, RECT* rect) const; - - // |arrow_direction| determines whether the arrow is pointing to the left or - // to the right. In RTL locales, sub-menus open from right to left and - // therefore the menu arrow should point to the left and not to the right. - HRESULT PaintMenuArrow(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - MenuArrowDirection arrow_direction, - bool is_highlighted) const; - - HRESULT PaintMenuBackground(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect) const; - - HRESULT PaintMenuCheck(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - bool is_highlighted) const; - - HRESULT PaintMenuCheckBackground(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - RECT* rect) const; - - HRESULT PaintMenuGutter(HDC hdc, - int part_id, - int state_id, - RECT* rect) const; - - HRESULT PaintMenuItemBackground(ThemeName theme, - HDC hdc, - int part_id, - int state_id, - bool selected, - RECT* rect) const; - - HRESULT PaintMenuList(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const; - - HRESULT PaintMenuSeparator(HDC hdc, - int part_id, - int state_id, - RECT* rect) const; - - // Paints a scrollbar arrow. |classic_state| should have the appropriate - // classic part number ORed in already. - HRESULT PaintScrollbarArrow(HDC hdc, - int state_id, - int classic_state, - RECT* rect) const; - - // Paints a scrollbar track section. |align_rect| is only used in classic - // mode, and makes sure the checkerboard pattern in |target_rect| is aligned - // with one presumed to be in |align_rect|. - HRESULT PaintScrollbarTrack(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* target_rect, - RECT* align_rect, - skia::PlatformCanvas* canvas) const; - - // Paints a scrollbar thumb or gripper. - HRESULT PaintScrollbarThumb(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const; - - HRESULT PaintStatusGripper(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect) const; - - HRESULT PaintTabPanelBackground(HDC dc, RECT* rect) const; - - HRESULT PaintTextField(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect, - COLORREF color, - bool fill_content_area, - bool draw_edges) const; - - HRESULT PaintTrackbar(HDC hdc, - int part_id, - int state_id, - int classic_state, - RECT* rect, - skia::PlatformCanvas* canvas) const; - - bool IsThemingActive() const; - - HRESULT GetThemePartSize(ThemeName themeName, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - int ts, - SIZE* size) const; - - HRESULT GetThemeColor(ThemeName theme, - int part_id, - int state_id, - int prop_id, - SkColor* color) const; - - // Get the theme color if theming is enabled. If theming is unsupported - // for this part, use Win32's GetSysColor to find the color specified - // by default_sys_color. - SkColor GetThemeColorWithDefault(ThemeName theme, - int part_id, - int state_id, - int prop_id, - int default_sys_color) const; - - HRESULT GetThemeInt(ThemeName theme, - int part_id, - int state_id, - int prop_id, - int *result) const; - - // Get the thickness of the border associated with the specified theme, - // defaulting to GetSystemMetrics edge size if themes are disabled. - // In Classic Windows, borders are typically 2px; on XP+, they are 1px. - Size GetThemeBorderSize(ThemeName theme) const; - - // Disables all theming for top-level windows in the entire process, from - // when this method is called until the process exits. All the other - // methods in this class will continue to work, but their output will ignore - // the user's theme. This is meant for use when running tests that require - // consistent visual results. - void DisableTheming() const; - - // Closes cached theme handles so we can unload the DLL or update our UI - // for a theme change. - void CloseHandles() const; - - // Gets our singleton instance. - static const NativeTheme* instance(); - - private: - NativeTheme(); - ~NativeTheme(); - - HRESULT PaintFrameControl(HDC hdc, - RECT* rect, - UINT type, - UINT state, - bool is_highlighted) const; - - // Returns a handle to the theme data. - HANDLE GetThemeHandle(ThemeName theme_name) const; - - // Function pointers into uxtheme.dll. - DrawThemeBackgroundPtr draw_theme_; - DrawThemeBackgroundExPtr draw_theme_ex_; - GetThemeColorPtr get_theme_color_; - GetThemeContentRectPtr get_theme_content_rect_; - GetThemePartSizePtr get_theme_part_size_; - OpenThemeDataPtr open_theme_; - CloseThemeDataPtr close_theme_; - SetThemeAppPropertiesPtr set_theme_properties_; - IsThemeActivePtr is_theme_active_; - GetThemeIntPtr get_theme_int_; - - // Handle to uxtheme.dll. - HMODULE theme_dll_; - - // A cache of open theme handles. - mutable HANDLE theme_handles_[LAST]; - - DISALLOW_EVIL_CONSTRUCTORS(NativeTheme); -}; - -} // namespace gfx - -#endif // BASE_GFX_NATIVE_THEME_H__ diff --git a/base/gfx/native_theme_unittest.cc b/base/gfx/native_theme_unittest.cc deleted file mode 100644 index 257e031..0000000 --- a/base/gfx/native_theme_unittest.cc +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/gfx/native_theme.h" - -#include "testing/gtest/include/gtest/gtest.h" - -TEST(NativeThemeTest, Init) { - ASSERT_TRUE(gfx::NativeTheme::instance() != NULL); -} diff --git a/base/gfx/platform_canvas.h b/base/gfx/platform_canvas.h deleted file mode 100644 index e69de29..0000000 diff --git a/base/gfx/platform_canvas_linux.h b/base/gfx/platform_canvas_linux.h deleted file mode 100644 index e69de29..0000000 diff --git a/base/gfx/platform_canvas_mac.h b/base/gfx/platform_canvas_mac.h deleted file mode 100644 index e69de29..0000000 diff --git a/base/gfx/platform_device_linux.h b/base/gfx/platform_device_linux.h deleted file mode 100644 index e69de29..0000000 diff --git a/base/gfx/platform_device_mac.h b/base/gfx/platform_device_mac.h deleted file mode 100644 index e69de29..0000000 diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index 6dfb45d..5bc33ef 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -10,8 +10,8 @@ #include <algorithm> #include "app/gfx/font.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/app/chrome_dll_resource.h" diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc index a49055e..78d8708 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc @@ -9,10 +9,10 @@ #include <algorithm> #include "app/gfx/font.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "base/gfx/rect.h" #include "base/logging.h" #include "base/string_util.h" diff --git a/chrome/browser/browser_theme_provider_gtk.cc b/chrome/browser/browser_theme_provider_gtk.cc index ac04e65..d551662 100644 --- a/chrome/browser/browser_theme_provider_gtk.cc +++ b/chrome/browser/browser_theme_provider_gtk.cc @@ -4,8 +4,8 @@ #include "chrome/browser/browser_theme_provider.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "third_party/skia/include/core/SkBitmap.h" diff --git a/chrome/browser/gtk/about_chrome_dialog.cc b/chrome/browser/gtk/about_chrome_dialog.cc index 0a12d34..a2bb512 100644 --- a/chrome/browser/gtk/about_chrome_dialog.cc +++ b/chrome/browser/gtk/about_chrome_dialog.cc @@ -6,10 +6,10 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/file_version_info.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/gtk/gtk_chrome_link_button.h" #include "chrome/browser/profile.h" diff --git a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc index fa3979e..ad1eb4d 100644 --- a/chrome/browser/gtk/blocked_popup_container_view_gtk.cc +++ b/chrome/browser/gtk/blocked_popup_container_view_gtk.cc @@ -4,8 +4,8 @@ #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/string_util.h" #include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/gtk_chrome_button.h" diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 33fa70e..c7cb635 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -6,12 +6,12 @@ #include <vector> +#include "app/gfx/gtk_util.h" #include "app/gfx/canvas_paint.h" #include "app/gfx/text_elider.h" #include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "base/pickle.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/bookmarks/bookmark_model.h" diff --git a/chrome/browser/gtk/bookmark_bubble_gtk.cc b/chrome/browser/gtk/bookmark_bubble_gtk.cc index 94ef5ac..3c71a9c 100644 --- a/chrome/browser/gtk/bookmark_bubble_gtk.cc +++ b/chrome/browser/gtk/bookmark_bubble_gtk.cc @@ -6,10 +6,10 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/message_loop.h" #include "chrome/browser/bookmarks/bookmark_editor.h" diff --git a/chrome/browser/gtk/bookmark_editor_gtk.cc b/chrome/browser/gtk/bookmark_editor_gtk.cc index 1ff0197..17bd8d1 100644 --- a/chrome/browser/gtk/bookmark_editor_gtk.cc +++ b/chrome/browser/gtk/bookmark_editor_gtk.cc @@ -6,9 +6,9 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/browser/gtk/bookmark_tree_model.h" diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc index 7f8a7e6..b16fad3 100644 --- a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc @@ -6,10 +6,10 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "base/string_util.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/gtk/bookmark_context_menu.h" diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc index 16d1c7f..0bd80a3 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.cc +++ b/chrome/browser/gtk/bookmark_utils_gtk.cc @@ -4,10 +4,10 @@ #include "chrome/browser/gtk/bookmark_utils_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "base/pickle.h" #include "base/string_util.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc index 791b1f3..5f5bc5c 100644 --- a/chrome/browser/gtk/browser_titlebar.cc +++ b/chrome/browser/gtk/browser_titlebar.cc @@ -10,10 +10,10 @@ #include <string> #include <vector> +#include "app/gfx/gtk_util.h" #include "app/gfx/skbitmap_operations.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" #include "chrome/browser/encoding_menu_controller.h" diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index b629b24..f2bba91 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -7,11 +7,11 @@ #include <gdk/gdkkeysyms.h> #include <X11/XF86keysym.h> +#include "app/gfx/gtk_util.h" #include "app/gtk_dnd_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/base_paths_linux.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/path_service.h" #include "chrome/app/chrome_dll_resource.h" diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 7013294..0f54c18 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -10,12 +10,12 @@ #include <string> #include "app/gfx/color_utils.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/base_paths_linux.h" #include "base/command_line.h" -#include "base/gfx/gtk_util.h" #include "base/gfx/rect.h" #include "base/logging.h" #include "base/message_loop.h" diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index 3e4e1cf..e21e62d 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -4,12 +4,12 @@ #include "chrome/browser/gtk/custom_button.h" +#include "app/gfx/gtk_util.h" #include "app/gfx/skbitmap_operations.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/gtk/cairo_cached_surface.h" #include "chrome/browser/gtk/gtk_chrome_button.h" #include "chrome/browser/gtk/gtk_theme_provider.h" diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index 5ced45d..7820097 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -4,9 +4,9 @@ #include "chrome/browser/gtk/download_shelf_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" diff --git a/chrome/browser/gtk/extension_install_prompt_gtk.cc b/chrome/browser/gtk/extension_install_prompt_gtk.cc index 28f4c56..943cb0e 100644 --- a/chrome/browser/gtk/extension_install_prompt_gtk.cc +++ b/chrome/browser/gtk/extension_install_prompt_gtk.cc @@ -4,8 +4,8 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/rand_util.h" #include "base/string_util.h" #include "chrome/browser/browser_list.h" diff --git a/chrome/browser/gtk/extension_shelf_gtk.cc b/chrome/browser/gtk/extension_shelf_gtk.cc index 437f91f..112a214 100644 --- a/chrome/browser/gtk/extension_shelf_gtk.cc +++ b/chrome/browser/gtk/extension_shelf_gtk.cc @@ -4,7 +4,7 @@ #include "chrome/browser/gtk/extension_shelf_gtk.h" -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/gtk/browser_window_gtk.h" #include "chrome/browser/gtk/gtk_theme_provider.h" diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index f3378c3..5ff2606 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -6,8 +6,8 @@ #include <gdk/gdkkeysyms.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/profile.h" diff --git a/chrome/browser/gtk/first_run_bubble.cc b/chrome/browser/gtk/first_run_bubble.cc index 1d90194..4711c6f 100644 --- a/chrome/browser/gtk/first_run_bubble.cc +++ b/chrome/browser/gtk/first_run_bubble.cc @@ -6,8 +6,8 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/options_window.h" #include "chrome/browser/search_engines/template_url_model.h" diff --git a/chrome/browser/gtk/gtk_chrome_button.cc b/chrome/browser/gtk/gtk_chrome_button.cc index 01d6db7..309c4a8 100644 --- a/chrome/browser/gtk/gtk_chrome_button.cc +++ b/chrome/browser/gtk/gtk_chrome_button.cc @@ -4,8 +4,8 @@ #include "chrome/browser/gtk/gtk_chrome_button.h" +#include "app/gfx/gtk_util.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/gtk/nine_box.h" #include "grit/app_resources.h" diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 296b72c..63dccfd 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -7,7 +7,7 @@ #include <gtk/gtk.h> #include "app/gfx/color_utils.h" -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/profile.h" #include "chrome/browser/gtk/cairo_cached_surface.h" diff --git a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc index 8c67ab4..75f7bca 100644 --- a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc +++ b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc @@ -6,9 +6,9 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "base/process_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/tab_contents/tab_contents.h" diff --git a/chrome/browser/gtk/info_bubble_gtk.cc b/chrome/browser/gtk/info_bubble_gtk.cc index 2e6adb6..b889628 100644 --- a/chrome/browser/gtk/info_bubble_gtk.cc +++ b/chrome/browser/gtk/info_bubble_gtk.cc @@ -7,10 +7,10 @@ #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/gfx/path.h" #include "app/l10n_util.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "base/gfx/rect.h" #include "base/logging.h" #include "chrome/browser/gtk/gtk_theme_provider.h" diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index 52d9844..1f95e93 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -6,7 +6,7 @@ #include <gtk/gtk.h> -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "base/string_util.h" #include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/gtk_chrome_link_button.h" diff --git a/chrome/browser/gtk/keyword_editor_view.cc b/chrome/browser/gtk/keyword_editor_view.cc index 5021fc1..028de54 100644 --- a/chrome/browser/gtk/keyword_editor_view.cc +++ b/chrome/browser/gtk/keyword_editor_view.cc @@ -4,8 +4,8 @@ #include "chrome/browser/gtk/keyword_editor_view.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/gtk/edit_search_engine_dialog.h" #include "chrome/browser/profile.h" #include "chrome/browser/metrics/user_metrics.h" diff --git a/chrome/browser/gtk/list_store_favicon_loader.cc b/chrome/browser/gtk/list_store_favicon_loader.cc index eb1e327..f0a146b 100644 --- a/chrome/browser/gtk/list_store_favicon_loader.cc +++ b/chrome/browser/gtk/list_store_favicon_loader.cc @@ -7,7 +7,7 @@ #include <vector> #include "app/gfx/codec/png_codec.h" -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/profile.h" #include "third_party/skia/include/core/SkBitmap.h" diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index d1761e6..a728022 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -6,10 +6,10 @@ #include <string> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/app/chrome_dll_resource.h" diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc index e166030..7ae146f 100644 --- a/chrome/browser/gtk/menu_gtk.cc +++ b/chrome/browser/gtk/menu_gtk.cc @@ -4,8 +4,8 @@ #include "chrome/browser/gtk/menu_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/stl_util-inl.h" diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc index 6f6d77f..369c40e 100644 --- a/chrome/browser/gtk/nine_box.cc +++ b/chrome/browser/gtk/nine_box.cc @@ -4,11 +4,11 @@ #include "chrome/browser/gtk/nine_box.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/basictypes.h" -#include "base/gfx/gtk_util.h" #include "base/gfx/point.h" #include "base/logging.h" diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index afc1ca8..4f1ae36 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -4,9 +4,9 @@ #include "chrome/browser/gtk/options/content_page_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/defaults.h" #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc index bfe1590..1cface4 100644 --- a/chrome/browser/gtk/options/cookies_view.cc +++ b/chrome/browser/gtk/options/cookies_view.cc @@ -7,8 +7,8 @@ #include <set> #include <string> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/time_format.h" diff --git a/chrome/browser/gtk/options/exceptions_page_gtk.cc b/chrome/browser/gtk/options/exceptions_page_gtk.cc index bcebb90..164a821 100644 --- a/chrome/browser/gtk/options/exceptions_page_gtk.cc +++ b/chrome/browser/gtk/options/exceptions_page_gtk.cc @@ -4,9 +4,9 @@ #include "chrome/browser/gtk/options/exceptions_page_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "chrome/common/gtk_tree.h" #include "chrome/common/gtk_util.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc index cab4fe2..8b2203b 100644 --- a/chrome/browser/gtk/options/passwords_page_gtk.cc +++ b/chrome/browser/gtk/options/passwords_page_gtk.cc @@ -4,9 +4,9 @@ #include "chrome/browser/gtk/options/passwords_page_gtk.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "chrome/common/gtk_tree.h" #include "chrome/common/gtk_util.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc index 4743bc5..2a9d712 100644 --- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc +++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc @@ -4,9 +4,9 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "base/message_loop.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/gtk/options/url_picker_dialog_gtk.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/possible_url_model.h" diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc index 80cfaa5..5ee330d 100644 --- a/chrome/browser/gtk/status_bubble_gtk.cc +++ b/chrome/browser/gtk/status_bubble_gtk.cc @@ -6,9 +6,9 @@ #include <gtk/gtk.h> +#include "app/gfx/gtk_util.h" #include "app/gfx/text_elider.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "base/message_loop.h" #include "base/string_util.h" #include "chrome/browser/gtk/gtk_theme_provider.h" diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc index 5809cd1..1764578 100644 --- a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc +++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc @@ -9,8 +9,8 @@ #include <algorithm> #include "app/gfx/canvas_paint.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "base/gfx/gtk_util.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 5838633..4c742ab 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -8,10 +8,10 @@ #include "app/gtk_dnd_util.h" #include "app/gfx/canvas_paint.h" +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/slide_animation.h" -#include "base/gfx/gtk_util.h" #include "base/gfx/point.h" #include "base/string_util.h" #include "chrome/browser/autocomplete/autocomplete.h" diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc index f9095d0..39fc6ab 100644 --- a/chrome/browser/gtk/task_manager_gtk.cc +++ b/chrome/browser/gtk/task_manager_gtk.cc @@ -9,9 +9,9 @@ #include <algorithm> #include <vector> +#include "app/gfx/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/gtk_util.h" #include "base/logging.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc index 6b86e83..2eaba30 100644 --- a/chrome/browser/printing/printing_layout_uitest.cc +++ b/chrome/browser/printing/printing_layout_uitest.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/gfx/gdi_util.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/gfx/gdi_util.h" #include "base/simple_thread.h" #include "base/win_util.h" #include "chrome/common/chrome_paths.h" diff --git a/chrome/browser/renderer_host/backing_store_win.cc b/chrome/browser/renderer_host/backing_store_win.cc index ef09f89..3f27161 100644 --- a/chrome/browser/renderer_host/backing_store_win.cc +++ b/chrome/browser/renderer_host/backing_store_win.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/renderer_host/backing_store.h" +#include "app/gfx/gdi_util.h" #include "base/command_line.h" -#include "base/gfx/gdi_util.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/transport_dib.h" diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 01ee015..c1ddaef 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -21,11 +21,6 @@ #include "views/view.h" #endif -#if defined(OS_WIN) -#include "base/gfx/gdi_util.h" -#include "chrome/app/chrome_dll_resource.h" -#endif // defined(OS_WIN) - #if defined (OS_MACOSX) #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/mac/WebScreenInfoFactory.h" diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index d382aff..250e0ab 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -18,7 +18,7 @@ #include <algorithm> #include <string> -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/string_util.h" diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 6ff0ed5..8225487 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -1,15 +1,15 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/renderer_host/render_widget_host_view_win.h" #include "app/gfx/canvas.h" +#include "app/gfx/gdi_util.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" #include "base/command_line.h" -#include "base/gfx/gdi_util.h" #include "base/gfx/rect.h" #include "base/histogram.h" #include "base/process_util.h" diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 448e5a5..3359783 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -14,11 +14,11 @@ #include "app/combobox_model.h" #include "app/gfx/canvas.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/file_util.h" #include "base/path_service.h" -#include "base/gfx/native_theme.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 14d2b49..69ec618 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -10,9 +10,9 @@ #include <vssym32.h> #include "app/gfx/canvas.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/native_theme.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc index a6e2d91..72b5c7f 100644 --- a/chrome/browser/views/options/fonts_page_view.cc +++ b/chrome/browser/views/options/fonts_page_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,10 +14,10 @@ #include "app/combobox_model.h" #include "app/gfx/canvas.h" #include "app/gfx/font.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/file_util.h" -#include "base/gfx/native_theme.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/character_encoding.h" diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc index b2eac08..733ad8a 100644 --- a/chrome/browser/views/options/languages_page_view.cc +++ b/chrome/browser/views/options/languages_page_view.cc @@ -10,12 +10,12 @@ #include "app/gfx/canvas.h" #include "app/gfx/font.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/string_util.h" -#include "base/gfx/native_theme.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/language_combobox_model.h" diff --git a/chrome/browser/views/options/options_group_view.cc b/chrome/browser/views/options/options_group_view.cc index 73cbf8d..5b93bb2 100644 --- a/chrome/browser/views/options/options_group_view.cc +++ b/chrome/browser/views/options/options_group_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,9 +9,9 @@ #include "app/gfx/canvas.h" #include "app/gfx/font.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/native_theme.h" #include "grit/locale_settings.h" #include "grit/generated_resources.h" #include "views/grid_layout.h" diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index ad0b1cb..252f3f2 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -8,9 +8,10 @@ #include "app/gfx/canvas.h" #if defined(OS_WIN) +#include "app/gfx/gdi_util.h" #include "app/win_util.h" #endif -#include "base/gfx/blit.h" +#include "app/gfx/blit.h" #if defined(OS_MACOSX) #include "base/mac_util.h" #endif @@ -30,10 +31,6 @@ #include "webkit/api/public/WebBindings.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" -#if defined(OS_WIN) -#include "base/gfx/gdi_util.h" -#endif - using WebKit::WebBindings; using webkit_glue::WebPluginResourceClient; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index b0e5ba0..ae98ac3 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -99,7 +99,7 @@ #if defined(OS_WIN) // TODO(port): these files are currently Windows only because they concern: // * theming -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #endif using base::Time; diff --git a/chrome/renderer/renderer_main_platform_delegate_win.cc b/chrome/renderer/renderer_main_platform_delegate_win.cc index 12f8242..430107a7 100644 --- a/chrome/renderer/renderer_main_platform_delegate_win.cc +++ b/chrome/renderer/renderer_main_platform_delegate_win.cc @@ -4,8 +4,8 @@ #include "chrome/renderer/renderer_main_platform_delegate.h" +#include "app/gfx/native_theme_win.h" #include "base/command_line.h" -#include "base/gfx/native_theme.h" #include "base/scoped_ptr.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/renderer/webmediaplayer_impl.h b/chrome/renderer/webmediaplayer_impl.h index 743e440..740c7db 100644 --- a/chrome/renderer/webmediaplayer_impl.h +++ b/chrome/renderer/webmediaplayer_impl.h @@ -45,11 +45,11 @@ #include <vector> -#include "base/gfx/platform_canvas.h" #include "base/lock.h" #include "base/message_loop.h" #include "media/base/filters.h" #include "media/base/pipeline_impl.h" +#include "skia/ext/platform_canvas.h" #include "webkit/api/public/WebMediaPlayer.h" #include "webkit/api/public/WebMediaPlayerClient.h" diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index ab787b0..2ebe048 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "app/gfx/blit.h" #include "app/gfx/canvas.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" @@ -14,7 +15,6 @@ #include "base/logging.h" #include "base/ref_counted.h" #include "base/string_util.h" -#include "base/gfx/blit.h" #include "base/gfx/size.h" #include "base/gfx/native_widget_types.h" #include "chrome/common/child_process_logging.h" diff --git a/printing/image.cc b/printing/image.cc index b9c86dd..beff637 100644 --- a/printing/image.cc +++ b/printing/image.cc @@ -12,7 +12,7 @@ #include "skia/ext/platform_device.h" #if defined(OS_WIN) -#include "base/gfx/gdi_util.h" // EMF support +#include "app/gfx/gdi_util.h" // EMF support #endif namespace { diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index 4cebf7b..59c6d0b 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -15,7 +15,6 @@ #include "app/gfx/codec/png_codec.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/gfx/gdi_util.h" #include "base/path_service.h" #include "base/string_util.h" #include "skia/ext/vector_canvas.h" @@ -43,7 +42,7 @@ class Context { private: HDC context_; - DISALLOW_EVIL_CONSTRUCTORS(Context); + DISALLOW_COPY_AND_ASSIGN(Context); }; // Lightweight HBITMAP management. @@ -51,7 +50,17 @@ class Bitmap { public: Bitmap(const Context& context, int x, int y) { BITMAPINFOHEADER hdr; - gfx::CreateBitmapHeader(x, y, &hdr); + hdr.biSize = sizeof(BITMAPINFOHEADER); + hdr.biWidth = x; + hdr.biHeight = -y; // Minus means top-down bitmap. + hdr.biPlanes = 1; + hdr.biBitCount = 32; + hdr.biCompression = BI_RGB; // No compression. + hdr.biSizeImage = 0; + hdr.biXPelsPerMeter = 1; + hdr.biYPelsPerMeter = 1; + hdr.biClrUsed = 0; + hdr.biClrImportant = 0; bitmap_ = CreateDIBSection(context.context(), reinterpret_cast<BITMAPINFO*>(&hdr), 0, &data_, NULL, 0); @@ -67,7 +76,7 @@ class Bitmap { void* data_; - DISALLOW_EVIL_CONSTRUCTORS(Bitmap); + DISALLOW_COPY_AND_ASSIGN(Bitmap); }; // Lightweight raw-bitmap management. The image, once initialized, is immuable. @@ -198,7 +207,7 @@ class Image { // Flag to signal if the comparison functions should ignore the alpha channel. const bool ignore_alpha_; - DISALLOW_EVIL_CONSTRUCTORS(Image); + DISALLOW_COPY_AND_ASSIGN(Image); }; // Base for tests. Capability to process an image. @@ -294,7 +303,7 @@ class ImageTest : public testing::Test { // Path to directory used to contain the test data. std::wstring test_dir_; - DISALLOW_EVIL_CONSTRUCTORS(ImageTest); + DISALLOW_COPY_AND_ASSIGN(ImageTest); }; // Premultiply the Alpha channel on the R, B and G channels. diff --git a/skia/ext/vector_platform_device_win.cc b/skia/ext/vector_platform_device_win.cc index 48375da..c89badd 100644 --- a/skia/ext/vector_platform_device_win.cc +++ b/skia/ext/vector_platform_device_win.cc @@ -6,12 +6,25 @@ #include "skia/ext/vector_platform_device_win.h" -#include "base/gfx/gdi_util.h" #include "skia/ext/skia_utils_win.h" #include "third_party/skia/include/core/SkUtils.h" namespace skia { +static void FillBitmapInfoHeader(int width, int height, BITMAPINFOHEADER* hdr) { + hdr->biSize = sizeof(BITMAPINFOHEADER); + hdr->biWidth = width; + hdr->biHeight = -height; // Minus means top-down bitmap. + hdr->biPlanes = 1; + hdr->biBitCount = 32; + hdr->biCompression = BI_RGB; // no compression + hdr->biSizeImage = 0; + hdr->biXPelsPerMeter = 1; + hdr->biYPelsPerMeter = 1; + hdr->biClrUsed = 0; + hdr->biClrImportant = 0; +} + VectorPlatformDevice* VectorPlatformDevice::create(HDC dc, int width, int height) { InitializeDC(dc); @@ -562,9 +575,18 @@ void VectorPlatformDevice::InternalDrawBitmap(const SkBitmap& bitmap, if (!src_size_x || !src_size_y) return; - // Create a BMP v4 header that we can serialize. + // Create a BMP v4 header that we can serialize. We use the shared "V3" + // fillter to fill the stardard items, then add in the "V4" stuff we want. BITMAPV4HEADER bitmap_header; - gfx::CreateBitmapV4Header(src_size_x, src_size_y, &bitmap_header); + memset(&bitmap_header, 0, sizeof(BITMAPV4HEADER)); + FillBitmapInfoHeader(src_size_x, src_size_y, + reinterpret_cast<BITMAPINFOHEADER*>(&bitmap_header)); + bitmap_header.bV4Size = sizeof(BITMAPV4HEADER); + bitmap_header.bV4RedMask = 0x00ff0000; + bitmap_header.bV4GreenMask = 0x0000ff00; + bitmap_header.bV4BlueMask = 0x000000ff; + bitmap_header.bV4AlphaMask = 0xff000000; + HDC dc = getBitmapDC(); SkAutoLockPixels lock(bitmap); SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); @@ -589,7 +611,7 @@ void VectorPlatformDevice::InternalDrawBitmap(const SkBitmap& bitmap, } BITMAPINFOHEADER hdr; - gfx::CreateBitmapHeader(src_size_x, src_size_y, &hdr); + FillBitmapInfoHeader(src_size_x, src_size_y, &hdr); if (is_translucent) { // The image must be loaded as a bitmap inside a device context. HDC bitmap_dc = ::CreateCompatibleDC(dc); diff --git a/views/controls/combobox/native_combobox_win.cc b/views/controls/combobox/native_combobox_win.cc index 31f47fc..a932d63 100644 --- a/views/controls/combobox/native_combobox_win.cc +++ b/views/controls/combobox/native_combobox_win.cc @@ -6,9 +6,9 @@ #include "app/combobox_model.h" #include "app/gfx/font.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/gfx/native_theme.h" #include "views/controls/combobox/combobox.h" #include "views/widget/widget.h" diff --git a/views/controls/menu/menu_config_win.cc b/views/controls/menu/menu_config_win.cc index 233eae68..f242f8c 100644 --- a/views/controls/menu/menu_config_win.cc +++ b/views/controls/menu/menu_config_win.cc @@ -8,7 +8,7 @@ #include <uxtheme.h> #include <Vssym32.h> -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #include "base/logging.h" #include "app/l10n_util_win.h" #include "base/win_util.h" diff --git a/views/controls/menu/menu_item_view_win.cc b/views/controls/menu/menu_item_view_win.cc index 8ec80eb3..a2f31fb 100644 --- a/views/controls/menu/menu_item_view_win.cc +++ b/views/controls/menu/menu_item_view_win.cc @@ -9,7 +9,7 @@ #include <Vssym32.h> #include "app/gfx/canvas.h" -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "grit/app_strings.h" #include "views/controls/menu/menu_config.h" diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc index 54bfbdc..64aa4ab 100644 --- a/views/controls/menu/menu_scroll_view_container.cc +++ b/views/controls/menu/menu_scroll_view_container.cc @@ -19,7 +19,7 @@ #include "views/controls/menu/submenu_view.h" #if defined(OS_WIN) -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #endif #if defined(OS_WIN) diff --git a/views/controls/menu/menu_separator_win.cc b/views/controls/menu/menu_separator_win.cc index b2ffe5e2..7273a0a 100644 --- a/views/controls/menu/menu_separator_win.cc +++ b/views/controls/menu/menu_separator_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include <Vssym32.h> #include "app/gfx/canvas.h" -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #include "views/controls/menu/menu_config.h" #include "views/controls/menu/menu_item_view.h" diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc index 7bcb7b9..cc78fb2 100644 --- a/views/controls/menu/native_menu_gtk.cc +++ b/views/controls/menu/native_menu_gtk.cc @@ -6,7 +6,7 @@ #include <string> -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "base/keyboard_codes.h" #include "base/string_util.h" #include "base/time.h" diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc index 700da66..69d8670 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include <atlframe.h> #include <atlmisc.h> +#include "app/gfx/native_theme_win.h" #include "app/l10n_util_win.h" #include "base/keyboard_codes.h" #include "base/logging.h" @@ -19,7 +20,6 @@ #include "views/controls/native/native_view_host.h" #include "views/focus/focus_manager.h" #include "views/widget/widget.h" -#include "base/gfx/native_theme.h" namespace views { diff --git a/views/controls/slider/native_slider_gtk.cc b/views/controls/slider/native_slider_gtk.cc index 201fcda..a394d70 100644 --- a/views/controls/slider/native_slider_gtk.cc +++ b/views/controls/slider/native_slider_gtk.cc @@ -6,7 +6,7 @@ #include "views/controls/slider/native_slider_gtk.h" -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "views/controls/slider/slider.h" namespace views { diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc index fa8a2c7..043ce83 100644 --- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc +++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc @@ -8,9 +8,9 @@ #include "app/gfx/canvas.h" #include "app/gfx/font.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" -#include "base/gfx/native_theme.h" #include "base/logging.h" #include "base/stl_util-inl.h" #include "views/controls/tabbed_pane/tabbed_pane.h" diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc index 3d9471f..ebaa614 100644 --- a/views/controls/textfield/native_textfield_gtk.cc +++ b/views/controls/textfield/native_textfield_gtk.cc @@ -6,7 +6,7 @@ #include "views/controls/textfield/native_textfield_gtk.h" -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "base/string_util.h" #include "skia/ext/skia_utils_gtk.h" #include "views/controls/textfield/textfield.h" diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index 39abb10..500ad72 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "views/controls/textfield/native_textfield_win.h" + #include <algorithm> #include "app/clipboard/clipboard.h" #include "app/clipboard/scoped_clipboard_writer.h" +#include "app/gfx/native_theme_win.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/win_util.h" -#include "base/gfx/native_theme.h" #include "base/keyboard_codes.h" #include "base/string_util.h" #include "base/win_util.h" @@ -17,7 +19,6 @@ #include "skia/ext/skia_utils_win.h" #include "views/controls/menu/menu_win.h" #include "views/controls/native/native_view_host.h" -#include "views/controls/textfield/native_textfield_win.h" #include "views/controls/textfield/textfield.h" #include "views/focus/focus_manager.h" #include "views/focus/focus_util_win.h" diff --git a/views/controls/textfield/native_textfield_win.h b/views/controls/textfield/native_textfield_win.h index 6ba8165..6955453 100644 --- a/views/controls/textfield/native_textfield_win.h +++ b/views/controls/textfield/native_textfield_win.h @@ -13,6 +13,7 @@ #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl #include <vsstyle.h> +#include "app/gfx/insets.h" #include "base/scoped_comptr_win.h" #include "views/controls/menu/simple_menu_model.h" #include "views/controls/textfield/native_textfield_wrapper.h" diff --git a/views/drag_utils_win.cc b/views/drag_utils_win.cc index b2d35f2..9b9bd26 100644 --- a/views/drag_utils_win.cc +++ b/views/drag_utils_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,9 +9,9 @@ #include <shobjidl.h> #include "app/gfx/canvas.h" +#include "app/gfx/gdi_util.h" #include "app/os_exchange_data.h" #include "app/os_exchange_data_provider_win.h" -#include "base/gfx/gdi_util.h" namespace drag_utils { diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index d272e1f..6f30622 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -1,14 +1,14 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "views/widget/widget_win.h" #include "app/gfx/canvas.h" +#include "app/gfx/native_theme_win.h" #include "app/gfx/path.h" #include "app/l10n_util_win.h" #include "app/win_util.h" -#include "base/gfx/native_theme.h" #include "base/string_util.h" #include "base/win_util.h" #include "views/accessibility/view_accessibility.h" diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index 5261679..40355d4 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -26,7 +26,7 @@ #include "views/window/dialog_delegate.h" #include "views/window/window.h" #if defined(OS_WIN) -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #else #include "views/window/hit_test.h" #include "views/widget/widget.h" diff --git a/webkit/glue/plugins/gtk_plugin_container_manager.cc b/webkit/glue/plugins/gtk_plugin_container_manager.cc index ecde3fb..8fe30a6 100644 --- a/webkit/glue/plugins/gtk_plugin_container_manager.cc +++ b/webkit/glue/plugins/gtk_plugin_container_manager.cc @@ -6,7 +6,7 @@ #include <gtk/gtk.h> -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "base/logging.h" #include "webkit/glue/plugins/gtk_plugin_container.h" #include "webkit/glue/webplugin.h" diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc index 61cb7ec..78ce170 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc @@ -10,9 +10,9 @@ #include <gtk/gtk.h> #include <gdk/gdkx.h> +#include "app/gfx/blit.h" #include "base/basictypes.h" #include "base/file_util.h" -#include "base/gfx/blit.h" #include "base/message_loop.h" #include "base/process_util.h" #include "base/stats_counters.h" diff --git a/webkit/glue/webcursor_win.cc b/webkit/glue/webcursor_win.cc index 8331c7a..63e1e3c 100644 --- a/webkit/glue/webcursor_win.cc +++ b/webkit/glue/webcursor_win.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this +// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. -#include "base/gfx/gdi_util.h" +#include "app/gfx/gdi_util.h" #include "base/logging.h" #include "base/pickle.h" #include "grit/webkit_resources.h" diff --git a/webkit/glue/webthemeengine_impl_win.cc b/webkit/glue/webthemeengine_impl_win.cc index 85de8cb..f60f9ac 100644 --- a/webkit/glue/webthemeengine_impl_win.cc +++ b/webkit/glue/webthemeengine_impl_win.cc @@ -4,7 +4,7 @@ #include "webkit/glue/webthemeengine_impl_win.h" -#include "base/gfx/native_theme.h" +#include "app/gfx/native_theme_win.h" #include "skia/ext/platform_canvas.h" #include "skia/ext/skia_utils_win.h" #include "webkit/api/public/WebRect.h" diff --git a/webkit/tools/test_shell/test_shell_platform_delegate_win.cc b/webkit/tools/test_shell/test_shell_platform_delegate_win.cc index 437c8bc..4c2e1b8 100644 --- a/webkit/tools/test_shell/test_shell_platform_delegate_win.cc +++ b/webkit/tools/test_shell/test_shell_platform_delegate_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,9 +6,10 @@ #include <list> #include <windows.h> #include <commctrl.h> + +#include "app/gfx/native_theme_win.h" #include "base/command_line.h" #include "base/event_recorder.h" -#include "base/gfx/native_theme.h" #include "base/resource_util.h" #include "base/win_util.h" #include "webkit/tools/test_shell/foreground_helper.h" diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index 8ba512b..728c5ad 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -9,7 +9,7 @@ #include <gtk/gtk.h> #include <gdk/gdkx.h> -#include "base/gfx/gtk_util.h" +#include "app/gfx/gtk_util.h" #include "base/gfx/point.h" #include "base/message_loop.h" #include "base/string_util.h" diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index 3afdfaa..ff790b1 100644 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,7 @@ #include <shlobj.h> #include <shlwapi.h> -#include "base/gfx/gdi_util.h" +#include "app/gfx/gdi_util.h" #include "base/gfx/native_widget_types.h" #include "base/gfx/point.h" #include "base/message_loop.h" -- cgit v1.1