From 8a2820a90f85f91c500a9d382f8e8ba870fb621c Mon Sep 17 00:00:00 2001 From: "ojan@google.com" Date: Thu, 9 Oct 2008 21:58:05 +0000 Subject: Patch by Thatcher Ulrich . Implement "iframe shim" behavior for windowed plugins. In FF and IE on windows, iframes are implemented as native HWNDs. This has the side effect that iframes display on top of windowed plugins. This side effect has long been known as a workaround for allowing HTML elements to appear above plugin content. BUG=1788 Review URL: http://codereview.chromium.org/7032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3137 0039d316-1c4b-4281-b951-d872f2087c98 --- base/gfx/bitmap_header.cc | 64 --------------------------- base/gfx/bitmap_header.h | 32 -------------- base/gfx/bitmap_platform_device_win.cc | 2 +- base/gfx/gdi_util.cc | 80 ++++++++++++++++++++++++++++++++++ base/gfx/gdi_util.h | 36 +++++++++++++++ base/gfx/native_theme.cc | 2 +- base/gfx/vector_canvas_unittest.cc | 2 +- base/gfx/vector_device.cc | 2 +- 8 files changed, 120 insertions(+), 100 deletions(-) delete mode 100644 base/gfx/bitmap_header.cc delete mode 100644 base/gfx/bitmap_header.h create mode 100644 base/gfx/gdi_util.cc create mode 100644 base/gfx/gdi_util.h (limited to 'base/gfx') diff --git a/base/gfx/bitmap_header.cc b/base/gfx/bitmap_header.cc deleted file mode 100644 index acaf0c0..0000000 --- a/base/gfx/bitmap_header.cc +++ /dev/null @@ -1,64 +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/bitmap_header.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; -} - -} // namespace gfx - diff --git a/base/gfx/bitmap_header.h b/base/gfx/bitmap_header.h deleted file mode 100644 index 0c8066b..0000000 --- a/base/gfx/bitmap_header.h +++ /dev/null @@ -1,32 +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_BITMAP_HEADER_H__ -#define BASE_GFX_BITMAP_HEADER_H__ - -#include - -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); - - -} // namespace gfx - -#endif // BASE_GFX_BITMAP_HEADER_H__ - diff --git a/base/gfx/bitmap_platform_device_win.cc b/base/gfx/bitmap_platform_device_win.cc index 1209db1..2031027 100644 --- a/base/gfx/bitmap_platform_device_win.cc +++ b/base/gfx/bitmap_platform_device_win.cc @@ -4,7 +4,7 @@ #include "base/gfx/bitmap_platform_device_win.h" -#include "base/gfx/bitmap_header.h" +#include "base/gfx/gdi_util.h" #include "base/logging.h" #include "base/process_util.h" #include "SkMatrix.h" diff --git a/base/gfx/gdi_util.cc b/base/gfx/gdi_util.cc new file mode 100644 index 0000000..48df853 --- /dev/null +++ b/base/gfx/gdi_util.cc @@ -0,0 +1,80 @@ +// 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& 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 new file mode 100644 index 0000000..cc15e92 --- /dev/null +++ b/base/gfx/gdi_util.h @@ -0,0 +1,36 @@ +// 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 +#include +#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& cutouts); + +} // namespace gfx + +#endif // BASE_GFX_GDI_UTIL_H__ diff --git a/base/gfx/native_theme.cc b/base/gfx/native_theme.cc index ea55502..b8aa30c 100644 --- a/base/gfx/native_theme.cc +++ b/base/gfx/native_theme.cc @@ -9,7 +9,7 @@ #include #include -#include "base/gfx/bitmap_header.h" +#include "base/gfx/gdi_util.h" #include "base/gfx/platform_canvas_win.h" #include "base/gfx/skia_utils.h" #include "base/gfx/rect.h" diff --git a/base/gfx/vector_canvas_unittest.cc b/base/gfx/vector_canvas_unittest.cc index 65d3d5f..60a79ba 100644 --- a/base/gfx/vector_canvas_unittest.cc +++ b/base/gfx/vector_canvas_unittest.cc @@ -8,7 +8,7 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/gfx/bitmap_header.h" +#include "base/gfx/gdi_util.h" #include "base/gfx/png_decoder.h" #include "base/gfx/png_encoder.h" #include "base/gfx/size.h" diff --git a/base/gfx/vector_device.cc b/base/gfx/vector_device.cc index 8778299..7230e2b 100644 --- a/base/gfx/vector_device.cc +++ b/base/gfx/vector_device.cc @@ -4,7 +4,7 @@ #include "base/gfx/vector_device.h" -#include "base/gfx/bitmap_header.h" +#include "base/gfx/gdi_util.h" #include "base/gfx/skia_utils.h" #include "base/logging.h" #include "base/scoped_handle.h" -- cgit v1.1