diff options
-rw-r--r-- | webkit/SConscript.port | 1 | ||||
-rw-r--r-- | webkit/build/port/port.vcproj | 8 | ||||
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 104 | ||||
-rw-r--r-- | webkit/port/platform/chromium/ChromiumBridge.h | 25 | ||||
-rw-r--r-- | webkit/port/platform/chromium/ChromiumUtilsWin.cpp | 54 | ||||
-rw-r--r-- | webkit/port/platform/chromium/ChromiumUtilsWin.h | 38 | ||||
-rw-r--r-- | webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp | 93 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp | 66 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp | 43 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h | 10 | ||||
-rw-r--r-- | webkit/port/rendering/RenderThemeWin.cpp | 80 |
11 files changed, 326 insertions, 196 deletions
diff --git a/webkit/SConscript.port b/webkit/SConscript.port index accad95..4288838 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -111,6 +111,7 @@ input_files = [ if env.Bit('windows'):
# Windows specific implementations.
input_files.extend([
+ '$PORT_DIR/platform/chromium/ChromiumUtilsWin.cpp',
'$PORT_DIR/platform/chromium/FileSystemChromiumWin.cpp',
'$PORT_DIR/platform/chromium/ScrollBarThemeChromiumWin.cpp',
'$PORT_DIR/platform/chromium/SoundChromiumWin.cpp',
diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj index 0566b843..15265a9 100644 --- a/webkit/build/port/port.vcproj +++ b/webkit/build/port/port.vcproj @@ -848,6 +848,14 @@ > </File> <File + RelativePath="..\..\port\platform\chromium\ChromiumUtilsWin.cpp" + > + </File> + <File + RelativePath="..\..\port\platform\chromium\ChromiumUtilsWin.h" + > + </File> + <File RelativePath="..\..\port\platform\chromium\ClipboardChromium.cpp" > </File> diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index 617ea08..26d18f5 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -15,6 +15,7 @@ #include "NativeImageSkia.h" #include "Page.h" #include "PasteboardPrivate.h" +#include "PlatformContextSkia.h" #include "PlatformString.h" #include "PlatformWidget.h" #include "PluginData.h" @@ -35,6 +36,7 @@ #include "build/build_config.h" #include "googleurl/src/url_util.h" #include "net/base/mime_util.h" +#include "skia/ext/skia_utils_win.h" #if USE(V8) #include <v8.h> #endif @@ -58,6 +60,17 @@ namespace { +#if PLATFORM(WIN_OS) +static RECT IntRectToRECT(const WebCore::IntRect& r) { + RECT result; + result.left = r.x(); + result.top = r.y(); + result.right = r.right(); + result.bottom = r.bottom(); + return result; +} +#endif + PlatformWidget ToPlatform(WebCore::Widget* widget) { return widget ? widget->root()->hostWindow()->platformWindow() : 0; } @@ -498,7 +511,7 @@ void ChromiumBridge::initV8CounterFunction() { } #endif -// SystemTime ------------------------------------------------------------------ +// SystemTime ----------------------------------------------------------------- // Called by SystemTimeChromium.cpp double ChromiumBridge::currentTime() { @@ -506,6 +519,95 @@ double ChromiumBridge::currentTime() { return base::Time::Now().ToDoubleT(); } +// Theming -------------------------------------------------------------------- + +#if PLATFORM(WIN_OS) + +void ChromiumBridge::paintButton( + GraphicsContext* gc, int part, int state, int classic_state, + const IntRect& rect) { + skia::PlatformCanvas* canvas = gc->platformContext()->canvas(); + HDC hdc = canvas->beginPlatformPaint(); + + RECT native_rect = IntRectToRECT(rect); + gfx::NativeTheme::instance()->PaintButton( + hdc, part, state, classic_state, &native_rect); + + canvas->endPlatformPaint(); +} + +void ChromiumBridge::paintMenuList( + GraphicsContext* gc, int part, int state, int classic_state, + const IntRect& rect) { + skia::PlatformCanvas* canvas = gc->platformContext()->canvas(); + HDC hdc = canvas->beginPlatformPaint(); + + RECT native_rect = IntRectToRECT(rect); + gfx::NativeTheme::instance()->PaintMenuList( + hdc, part, state, classic_state, &native_rect); + + canvas->endPlatformPaint(); +} + +void ChromiumBridge::paintScrollbarArrow( + GraphicsContext* gc, int state, int classic_state, const IntRect& rect) { + skia::PlatformCanvas* canvas = gc->platformContext()->canvas(); + HDC hdc = canvas->beginPlatformPaint(); + + RECT native_rect = IntRectToRECT(rect); + gfx::NativeTheme::instance()->PaintScrollbarArrow( + hdc, state, classic_state, &native_rect); + + canvas->endPlatformPaint(); +} + +void ChromiumBridge::paintScrollbarThumb( + GraphicsContext* gc, int part, int state, int classic_state, + const IntRect& rect) { + skia::PlatformCanvas* canvas = gc->platformContext()->canvas(); + HDC hdc = canvas->beginPlatformPaint(); + + RECT native_rect = IntRectToRECT(rect); + gfx::NativeTheme::instance()->PaintScrollbarThumb( + hdc, part, state, classic_state, &native_rect); + + canvas->endPlatformPaint(); +} + +void ChromiumBridge::paintScrollbarTrack( + GraphicsContext* gc, int part, int state, int classic_state, + const IntRect& rect, const IntRect& align_rect) { + skia::PlatformCanvas* canvas = gc->platformContext()->canvas(); + HDC hdc = canvas->beginPlatformPaint(); + + RECT native_rect = IntRectToRECT(rect); + RECT native_align_rect = IntRectToRECT(align_rect); + gfx::NativeTheme::instance()->PaintScrollbarTrack( + hdc, part, state, classic_state, &native_rect, &native_align_rect, + canvas); + + canvas->endPlatformPaint(); +} + +void ChromiumBridge::paintTextField( + GraphicsContext* gc, int part, int state, int classic_state, + const IntRect& rect, const Color& color, bool fill_content_area, + bool draw_edges) { + skia::PlatformCanvas* canvas = gc->platformContext()->canvas(); + HDC hdc = canvas->beginPlatformPaint(); + + RECT native_rect = IntRectToRECT(rect); + COLORREF clr = skia::SkColorToCOLORREF(color.rgb()); + + gfx::NativeTheme::instance()->PaintTextField( + hdc, part, state, classic_state, &native_rect, clr, fill_content_area, + draw_edges); + + canvas->endPlatformPaint(); +} + +#endif + // Trace Event ---------------------------------------------------------------- void ChromiumBridge::traceEventBegin(const char* name, diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h index a882df9..15de72f 100644 --- a/webkit/port/platform/chromium/ChromiumBridge.h +++ b/webkit/port/platform/chromium/ChromiumBridge.h @@ -1,5 +1,4 @@ -// Copyright (c) 2008, Google Inc. -// All rights reserved. +// Copyright (c) 2008, Google Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -48,9 +47,11 @@ typedef struct HFONT__* HFONT; #endif namespace WebCore { + class Color; class Cursor; class Document; class Frame; + class GraphicsContext; class Image; class IntRect; class KURL; @@ -125,7 +126,7 @@ namespace WebCore { static IntRect screenRect(Widget*); static IntRect screenAvailableRect(Widget*); - // SharedTimers -------------------------------------------------------- + // SharedTimers ------------------------------------------------------- static void setSharedTimerFiredFunction(void (*func)()); static void setSharedTimerFireTime(double fire_time); static void stopSharedTimer(); @@ -135,9 +136,25 @@ namespace WebCore { static void incrementStatsCounter(const char* name); static void initV8CounterFunction(); - // SystemTime ---------------------------------------------------------- + // SystemTime --------------------------------------------------------- static double currentTime(); + // Theming ------------------------------------------------------------ +#if PLATFORM(WIN_OS) + static void paintButton( + GraphicsContext*, int part, int state, int classicState, const IntRect& rect); + static void paintMenuList( + GraphicsContext*, int part, int state, int classicState, const IntRect& rect); + static void paintScrollbarArrow( + GraphicsContext*, int state, int classicState, const IntRect& rect); + static void paintScrollbarThumb( + GraphicsContext*, int part, int state, int classicState, const IntRect& rect); + static void paintScrollbarTrack( + GraphicsContext*, int part, int state, int classicState, const IntRect& rect, const IntRect& alignRect); + static void paintTextField( + GraphicsContext*, int part, int state, int classicState, const IntRect& rect, const Color& color, bool fillContentArea, bool drawEdges); +#endif + // Trace Event -------------------------------------------------------- static void traceEventBegin(const char* name, void* id, const char* extra); static void traceEventEnd(const char* name, void* id, const char* extra); diff --git a/webkit/port/platform/chromium/ChromiumUtilsWin.cpp b/webkit/port/platform/chromium/ChromiumUtilsWin.cpp new file mode 100644 index 0000000..8889eab --- /dev/null +++ b/webkit/port/platform/chromium/ChromiumUtilsWin.cpp @@ -0,0 +1,54 @@ +// Copyright (c) 2008, Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "config.h" +#include "ChromiumUtilsWin.h" + +#include <windows.h> + +namespace WebCore { +namespace ChromiumUtils { + +bool isVistaOrGreater() +{ + // Cache the result to avoid asking every time. + static bool haveResult = false; + static bool result = false; + if (!haveResult) { + OSVERSIONINFO versionInfo; + versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); + GetVersionEx(&versionInfo); + + haveResult = true; + result = versionInfo.dwMajorVersion >= 6; + } + return result; +} + +} // namespace ChromiumUtils +} // namespace WebCore
\ No newline at end of file diff --git a/webkit/port/platform/chromium/ChromiumUtilsWin.h b/webkit/port/platform/chromium/ChromiumUtilsWin.h new file mode 100644 index 0000000..9bc3fb6 --- /dev/null +++ b/webkit/port/platform/chromium/ChromiumUtilsWin.h @@ -0,0 +1,38 @@ +// Copyright (c) 2008, Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef ChromiumUtilsWin_h +#define ChromiumUtilsWin_h + +namespace WebCore { + namespace ChromiumUtils { + bool isVistaOrGreater(); + } +} + +#endif // ChromiumUtilsWin_h diff --git a/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp b/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp index d7c0daa..90c5e21 100644 --- a/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp +++ b/webkit/port/platform/chromium/ScrollbarThemeChromiumWin.cpp @@ -30,36 +30,21 @@ #include <vsstyle.h> #include "ChromiumBridge.h" +#include "ChromiumUtilsWin.h" #include "GraphicsContext.h" #include "PlatformContextSkia.h" #include "PlatformMouseEvent.h" #include "Scrollbar.h" -#include "base/gfx/native_theme.h" -#include "base/win_util.h" - namespace WebCore { +using ChromiumUtils::isVistaOrGreater; + // The scrollbar size in DumpRenderTree on the Mac - so we can match their // layout results. Entries are for regular, small, and mini scrollbars. // Metrics obtained using [NSScroller scrollerWidthForControlSize:] static const int kMacScrollbarSize[3] = { 15, 11, 15 }; -static bool runningVista() -{ - return win_util::GetWinVersion() >= win_util::WINVERSION_VISTA; -} - -static RECT toRECT(const IntRect& input) -{ - RECT output; - output.left = input.x(); - output.right = input.right(); - output.top = input.y(); - output.bottom = input.bottom(); - return output; -} - int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize) { static int thickness; @@ -73,18 +58,13 @@ int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize) bool ScrollbarThemeChromium::invalidateOnMouseEnterExit() { - return runningVista(); + return isVistaOrGreater(); } void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType) { bool horz = scrollbar->orientation() == HorizontalScrollbar; - skia::PlatformCanvasWin* canvas = gc->platformContext()->canvas(); - HDC hdc = canvas->beginPlatformPaint(); - - RECT paintRect = toRECT(rect); - int partId; if (partType == BackTrackPart) { partId = horz ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT; @@ -92,30 +72,22 @@ void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scr partId = horz ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; } - RECT alignRect = toRECT(trackRect(scrollbar, false)); + IntRect alignRect = trackRect(scrollbar, false); // Draw the track area before/after the thumb on the scroll bar. - gfx::NativeTheme::instance()->PaintScrollbarTrack( - hdc, + ChromiumBridge::paintScrollbarTrack( + gc, partId, getThemeState(scrollbar, partType), getClassicThemeState(scrollbar, partType), - &paintRect, - &alignRect, - gc->platformContext()->canvas()); - - canvas->endPlatformPaint(); + rect, + alignRect); } void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part) { bool horz = scrollbar->orientation() == HorizontalScrollbar; - skia::PlatformCanvasWin* canvas = gc->platformContext()->canvas(); - HDC hdc = canvas->beginPlatformPaint(); - - RECT paintRect = toRECT(rect); - int partId; if (part == BackButtonStartPart || part == ForwardButtonStartPart) { partId = horz ? DFCS_SCROLLLEFT : DFCS_SCROLLUP; @@ -124,41 +96,32 @@ void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollb } // Draw the thumb (the box you drag in the scroll bar to scroll). - gfx::NativeTheme::instance()->PaintScrollbarArrow( - hdc, + ChromiumBridge::paintScrollbarArrow( + gc, getThemeArrowState(scrollbar, part), partId | getClassicThemeState(scrollbar, part), - &paintRect); - - canvas->endPlatformPaint(); + rect); } void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) { bool horz = scrollbar->orientation() == HorizontalScrollbar; - skia::PlatformCanvasWin* canvas = gc->platformContext()->canvas(); - HDC hdc = canvas->beginPlatformPaint(); - - RECT paintRect = toRECT(rect); - // Draw the thumb (the box you drag in the scroll bar to scroll). - gfx::NativeTheme::instance()->PaintScrollbarThumb( - hdc, + ChromiumBridge::paintScrollbarThumb( + gc, horz ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT, getThemeState(scrollbar, ThumbPart), getClassicThemeState(scrollbar, ThumbPart), - &paintRect); + rect); // Draw the gripper (the three little lines on the thumb). - gfx::NativeTheme::instance()->PaintScrollbarThumb( - hdc, + ChromiumBridge::paintScrollbarThumb( + gc, horz ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT, getThemeState(scrollbar, ThumbPart), getClassicThemeState(scrollbar, ThumbPart), - &paintRect); - - canvas->endPlatformPaint(); + rect); } int ScrollbarThemeChromium::getThemeState(Scrollbar* scrollbar, ScrollbarPart part) const @@ -169,12 +132,12 @@ int ScrollbarThemeChromium::getThemeState(Scrollbar* scrollbar, ScrollbarPart pa if (scrollbar->pressedPart() == ThumbPart) { if (part == ThumbPart) return SCRBS_PRESSED; - return runningVista() ? SCRBS_HOVER : SCRBS_NORMAL; + return isVistaOrGreater() ? SCRBS_HOVER : SCRBS_NORMAL; } if (!scrollbar->enabled()) return SCRBS_DISABLED; if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == ForwardTrackPart) - return (scrollbar->hoveredPart() == NoPart || !runningVista()) ? SCRBS_NORMAL : SCRBS_HOVER; + return (scrollbar->hoveredPart() == NoPart || !isVistaOrGreater()) ? SCRBS_NORMAL : SCRBS_HOVER; if (scrollbar->pressedPart() == NoPart) return SCRBS_HOT; return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL; @@ -188,43 +151,43 @@ int ScrollbarThemeChromium::getThemeArrowState(Scrollbar* scrollbar, ScrollbarPa if (part == BackButtonStartPart || part == ForwardButtonStartPart) { if (scrollbar->orientation() == HorizontalScrollbar) { if (scrollbar->pressedPart() == ThumbPart) - return !runningVista() ? ABS_LEFTNORMAL : ABS_LEFTHOVER; + return !isVistaOrGreater() ? ABS_LEFTNORMAL : ABS_LEFTHOVER; if (!scrollbar->enabled()) return ABS_LEFTDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !runningVista()) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; + return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_LEFTHOT; return (scrollbar->pressedPart() == part) ? ABS_LEFTPRESSED : ABS_LEFTNORMAL; } if (scrollbar->pressedPart() == ThumbPart) - return !runningVista() ? ABS_UPNORMAL : ABS_UPHOVER; + return !isVistaOrGreater() ? ABS_UPNORMAL : ABS_UPHOVER; if (!scrollbar->enabled()) return ABS_UPDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !runningVista()) ? ABS_UPNORMAL : ABS_UPHOVER; + return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_UPNORMAL : ABS_UPHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_UPHOT; return (scrollbar->pressedPart() == part) ? ABS_UPPRESSED : ABS_UPNORMAL; } if (scrollbar->orientation() == HorizontalScrollbar) { if (scrollbar->pressedPart() == ThumbPart) - return !runningVista() ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; + return !isVistaOrGreater() ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; if (!scrollbar->enabled()) return ABS_RIGHTDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !runningVista()) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; + return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_RIGHTHOT; return (scrollbar->pressedPart() == part) ? ABS_RIGHTPRESSED : ABS_RIGHTNORMAL; } if (scrollbar->pressedPart() == ThumbPart) - return !runningVista() ? ABS_DOWNNORMAL : ABS_DOWNHOVER; + return !isVistaOrGreater() ? ABS_DOWNNORMAL : ABS_DOWNHOVER; if (!scrollbar->enabled()) return ABS_DOWNDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !runningVista()) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; + return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrGreater()) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_DOWNHOT; return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL; diff --git a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp index 78a421b..bf5a6d7 100644 --- a/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp +++ b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp @@ -1,5 +1,4 @@ -// Copyright (c) 2008, Google Inc. -// All rights reserved. +// Copyright (c) 2008, Google Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -32,6 +31,7 @@ #include <vector> #include "ChromiumBridge.h" +#include "ChromiumUtilsWin.h" #include "Font.h" #include "GlyphPageTreeNode.h" #include "SimpleFontData.h" @@ -40,31 +40,17 @@ namespace WebCore { -static bool IsVistaOrGreater() -{ - // Cache the result to avoid asking every time. - static bool checkedVersion = false; - static bool isVistaOrGreater = false; - if (!checkedVersion) { - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - GetVersionEx(&versionInfo); - - checkedVersion = true; - isVistaOrGreater = versionInfo.dwMajorVersion >= 6; - } - return isVistaOrGreater; -} - // Fills one page of font data pointers with NULL to indicate that there // are no glyphs for the characters. -static void FillEmptyGlyphs(GlyphPage* page) { - for (int i = 0; i < GlyphPage::size; ++i) - page->setGlyphDataForIndex(i, NULL, NULL); +static void FillEmptyGlyphs(GlyphPage* page) +{ + for (int i = 0; i < GlyphPage::size; ++i) + page->setGlyphDataForIndex(i, NULL, NULL); } // Lazily initializes space glyph -static Glyph InitSpaceGlyph(HDC dc, Glyph* space_glyph) { +static Glyph InitSpaceGlyph(HDC dc, Glyph* space_glyph) +{ if (*space_glyph) return *space_glyph; static wchar_t space = ' '; @@ -85,24 +71,24 @@ static bool FillBMPGlyphs(UChar* buffer, TEXTMETRIC tm = {0}; if (!GetTextMetrics(dc, &tm)) { - SelectObject(dc, old_font); - ReleaseDC(0, dc); - - if (recurse) { - if (ChromiumBridge::ensureFontLoaded(fontData->m_font.hfont())) { - return FillBMPGlyphs(buffer, page, fontData, false); + SelectObject(dc, old_font); + ReleaseDC(0, dc); + + if (recurse) { + if (ChromiumBridge::ensureFontLoaded(fontData->m_font.hfont())) { + return FillBMPGlyphs(buffer, page, fontData, false); + } else { + FillEmptyGlyphs(page); + return false; + } } else { - FillEmptyGlyphs(page); - return false; + // TODO(nsylvain): This should never happen. We want to crash the + // process and receive a crash dump. We should revisit this code later. + // See bug 1136944. + ASSERT_NOT_REACHED(); + FillEmptyGlyphs(page); + return false; } - } else { - // TODO(nsylvain): This should never happen. We want to crash the - // process and receive a crash dump. We should revisit this code later. - // See bug 1136944. - ASSERT_NOT_REACHED(); - FillEmptyGlyphs(page); - return false; - } } // NOTE(hbono): GetGlyphIndices() sets each item of localGlyphBuffer[] @@ -145,8 +131,8 @@ static bool FillBMPGlyphs(UChar* buffer, // Copy the output to the GlyphPage bool have_glyphs = false; int invalid_glyph = 0xFFFF; - if (!IsVistaOrGreater() && !(tm.tmPitchAndFamily & TMPF_TRUETYPE)) - invalid_glyph = 0x1F; + if (!ChromiumUtils::isVistaOrGreater() && !(tm.tmPitchAndFamily & TMPF_TRUETYPE)) + invalid_glyph = 0x1F; Glyph space_glyph = 0; // Glyph for a space. Lazily filled. diff --git a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp index 546f660..4461d3c 100644 --- a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp +++ b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp @@ -24,20 +24,13 @@ */ #include "config.h" +#include "ThemeHelperChromiumWin.h" + #include "FloatRect.h" #include "GraphicsContext.h" -#include "ThemeHelperChromiumWin.h" namespace WebCore { -static void IntRectToRECT(const IntRect& ir, RECT* r) -{ - r->left = ir.x(); - r->top = ir.y(); - r->right = ir.right(); - r->bottom = ir.bottom(); -} - ThemeHelperWin::ThemeHelperWin(GraphicsContext* context, const IntRect& rect) : m_orgContext(context) @@ -48,10 +41,7 @@ ThemeHelperWin::ThemeHelperWin(GraphicsContext* context, m_orgMatrix.c() != 0) { // X skew // Complicated effects, make a copy and draw the bitmap there. m_type = COPY; - m_rect.left = 0; - m_rect.top = 0; - m_rect.right = rect.width(); - m_rect.bottom = rect.height(); + m_rect.setSize(rect.size()); m_newBuffer.set(ImageBuffer::create(rect.size(), false).release()); @@ -78,7 +68,7 @@ ThemeHelperWin::ThemeHelperWin(GraphicsContext* context, m_type = SCALE; // Save the transformed coordinates to draw. - IntRectToRECT(m_orgMatrix.mapRect(rect), &m_rect); + m_rect = m_orgMatrix.mapRect(rect); m_orgContext->save(); m_orgContext->concatCTM(m_orgContext->getCTM().inverse()); @@ -86,7 +76,7 @@ ThemeHelperWin::ThemeHelperWin(GraphicsContext* context, } // Nothing interesting. - IntRectToRECT(rect, &m_rect); + m_rect = rect; m_type = ORIGINAL; } @@ -109,25 +99,4 @@ ThemeHelperWin::~ThemeHelperWin() } } -RECT ThemeHelperWin::transformRect(const RECT& r) const -{ - IntRect src(r.left, r.top, r.right - r.left, r.bottom - r.top); - IntRect dest; - switch (m_type) { - case SCALE: - dest = m_orgMatrix.mapRect(src); - break; - case COPY: - dest = src; - dest.move(-m_orgRect.x(), -m_orgRect.y()); - break; - case ORIGINAL: - break; - } - - RECT output; - IntRectToRECT(dest, &output); - return output; -} - -} // namespace WebCore
\ No newline at end of file +} // namespace WebCore diff --git a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h index 3d7caf1..6141824 100644 --- a/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h +++ b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h @@ -26,8 +26,6 @@ #ifndef ThemeHelperWin_h #define ThemeHelperWin_h -#include <windows.h> - #include "AffineTransform.h" #include "ImageBuffer.h" #include "IntRect.h" @@ -72,9 +70,7 @@ public: } // Returns the rectangle in which to draw into the canvas() by Windows. - const RECT& rect() { return m_rect; } - - RECT transformRect(const RECT& r) const; + const IntRect& rect() { return m_rect; } private: Type m_type; @@ -88,8 +84,8 @@ private: // represents the copy. OwnPtr<ImageBuffer> m_newBuffer; - // The control rectangle in the cooredinate space of canvas(). - RECT m_rect; + // The control rectangle in the coordinate space of canvas(). + IntRect m_rect; }; } // namespace WebCore diff --git a/webkit/port/rendering/RenderThemeWin.cpp b/webkit/port/rendering/RenderThemeWin.cpp index 1916f99..aaaba5f 100644 --- a/webkit/port/rendering/RenderThemeWin.cpp +++ b/webkit/port/rendering/RenderThemeWin.cpp @@ -28,6 +28,7 @@ #include <vssym32.h> #include "ChromiumBridge.h" +#include "ChromiumUtilsWin.h" #include "CSSStyleSheet.h" #include "CSSValueKeywords.h" #include "Document.h" @@ -39,13 +40,26 @@ #include "ThemeHelperChromiumWin.h" #include "UserAgentStyleSheets.h" -// TODO(brettw) all of these dependencies should eventually be removed. -#include "base/gfx/native_theme.h" -#include "base/win_util.h" +// FIXME(brettw): this dependency should eventually be removed. #include "skia/ext/skia_utils_win.h" namespace { +#define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(structName, member) \ + offsetof(structName, member) + \ + (sizeof static_cast<structName*>(0)->member) +#define NONCLIENTMETRICS_SIZE_PRE_VISTA \ + SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) + +void getNonClientMetrics(NONCLIENTMETRICS* metrics) { + static UINT size = WebCore::ChromiumUtils::isVistaOrGreater() ? + sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; + metrics->cbSize = size; + bool success = + !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, size, metrics, 0); + ASSERT(success); +} + enum PaddingType { TopPadding, RightPadding, @@ -282,7 +296,7 @@ void RenderThemeWin::systemFont(int propId, Document* document, FontDescription& cachedDesc = &smallSystemFont; if (!smallSystemFont.isAbsoluteSize()) { NONCLIENTMETRICS metrics; - win_util::GetNonClientMetrics(&metrics); + getNonClientMetrics(&metrics); faceName = metrics.lfSmCaptionFont.lfFaceName; fontSize = systemFontSize(metrics.lfSmCaptionFont); } @@ -291,7 +305,7 @@ void RenderThemeWin::systemFont(int propId, Document* document, FontDescription& cachedDesc = &menuFont; if (!menuFont.isAbsoluteSize()) { NONCLIENTMETRICS metrics; - win_util::GetNonClientMetrics(&metrics); + getNonClientMetrics(&metrics); faceName = metrics.lfMenuFont.lfFaceName; fontSize = systemFontSize(metrics.lfMenuFont); } @@ -300,7 +314,7 @@ void RenderThemeWin::systemFont(int propId, Document* document, FontDescription& cachedDesc = &labelFont; if (!labelFont.isAbsoluteSize()) { NONCLIENTMETRICS metrics; - win_util::GetNonClientMetrics(&metrics); + getNonClientMetrics(&metrics); faceName = metrics.lfStatusFont.lfFaceName; fontSize = systemFontSize(metrics.lfStatusFont); } @@ -366,18 +380,11 @@ bool RenderThemeWin::paintButton(RenderObject* o, const ThemeData& themeData = getThemeData(o); WebCore::ThemeHelperWin helper(i.context, r); - skia::PlatformCanvas* canvas = helper.context()->platformContext()->canvas(); - - HDC hdc = canvas->beginPlatformPaint(); - int state = themeData.m_state; - RECT renderRect = helper.rect(); - - gfx::NativeTheme::instance()->PaintButton(hdc, - themeData.m_part, - state, - themeData.m_classicState, - &renderRect); - canvas->endPlatformPaint(); + ChromiumBridge::paintButton(helper.context(), + themeData.m_part, + themeData.m_state, + themeData.m_classicState, + helper.rect()); return false; } @@ -439,15 +446,11 @@ bool RenderThemeWin::paintMenuList(RenderObject* o, const RenderObject::PaintInf // Get the correct theme data for a textfield and paint the menu. WebCore::ThemeHelperWin helper(i.context, rect); - skia::PlatformCanvas* canvas = helper.context()->platformContext()->canvas(); - HDC hdc = canvas->beginPlatformPaint(); - RECT renderRect = helper.rect(); - gfx::NativeTheme::instance()->PaintMenuList(hdc, - CP_DROPDOWNBUTTON, - determineState(o), - determineClassicState(o), - &renderRect); - canvas->endPlatformPaint(); + ChromiumBridge::paintMenuList(helper.context(), + CP_DROPDOWNBUTTON, + determineState(o), + determineClassicState(o), + helper.rect()); return false; } @@ -580,21 +583,14 @@ bool RenderThemeWin::paintTextFieldInternal(RenderObject* o, const ThemeData& themeData = getThemeData(o); WebCore::ThemeHelperWin helper(i.context, r); - skia::PlatformCanvas* canvas = helper.context()->platformContext()->canvas(); - - HDC hdc = canvas->beginPlatformPaint(); - COLORREF clr = skia::SkColorToCOLORREF(o->style()->backgroundColor().rgb()); - RECT renderRect = helper.rect(); - - gfx::NativeTheme::instance()->PaintTextField(hdc, - themeData.m_part, - themeData.m_state, - themeData.m_classicState, - &renderRect, - clr, - true, - drawEdges); - canvas->endPlatformPaint(); + ChromiumBridge::paintTextField(helper.context(), + themeData.m_part, + themeData.m_state, + themeData.m_classicState, + helper.rect(), + o->style()->backgroundColor(), + true, + drawEdges); return false; } |