Commit ee5a5d14 authored by aroben@apple.com's avatar aroben@apple.com

Add SoftLinking.h for Windows and use it in a few places

 WebCore:

         Add SoftLinking.h for Windows and use it in a few places

         Reviewed by Oliver.

         * WebCore.vcproj/WebCore.vcproj: Added new file to project.
         * platform/win/PlatformScrollBarSafari.cpp: Use SoftLinking.h.
         (WebCore::PlatformScrollbar::PlatformScrollbar): Removed manual
         soft-linking calls.
         (WebCore::PlatformScrollbar::paintButton): Check for the presence of
         the SafariTheme library now that we can't check for the presence of
         paintThemePart directly.
         (WebCore::PlatformScrollbar::paintTrack): Ditto.
         (WebCore::PlatformScrollbar::paintThumb): Ditto.
         * platform/win/SoftLinking.h: Copied from WebCore/platform/mac/SoftLinking.h.
         * rendering/RenderThemeSafari.cpp: Same basic changes as to
         PlatformScrollBarSafari.cpp.
         (WebCore::RenderThemeSafari::RenderThemeSafari):
         (WebCore::RenderThemeSafari::isControlStyled):
         (WebCore::RenderThemeSafari::paintCapsLockIndicator):
         * rendering/RenderThemeSafari.h: Removed m_themeDLL member.

 WebKit/win:

         Use SoftLinking.h in WebKitClassFactory.

         Reviewed by Oliver.

         * WebKitClassFactory.cpp:
         (WebKitClassFactory::WebKitClassFactory): We don't have to worry about
         not finding STInitialize anymore now that a version of SafariTheme
         containing this function has shipped.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28526 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8ad18ea8
2007-12-07 Adam Roben <aroben@apple.com>
Add SoftLinking.h for Windows and use it in a few places
Reviewed by Oliver.
* WebCore.vcproj/WebCore.vcproj: Added new file to project.
* platform/win/PlatformScrollBarSafari.cpp: Use SoftLinking.h.
(WebCore::PlatformScrollbar::PlatformScrollbar): Removed manual
soft-linking calls.
(WebCore::PlatformScrollbar::paintButton): Check for the presence of
the SafariTheme library now that we can't check for the presence of
paintThemePart directly.
(WebCore::PlatformScrollbar::paintTrack): Ditto.
(WebCore::PlatformScrollbar::paintThumb): Ditto.
* platform/win/SoftLinking.h: Copied from WebCore/platform/mac/SoftLinking.h.
* rendering/RenderThemeSafari.cpp: Same basic changes as to
PlatformScrollBarSafari.cpp.
(WebCore::RenderThemeSafari::RenderThemeSafari):
(WebCore::RenderThemeSafari::isControlStyled):
(WebCore::RenderThemeSafari::paintCapsLockIndicator):
* rendering/RenderThemeSafari.h: Removed m_themeDLL member.
2007-12-07 Darin Adler <darin@apple.com>
Reviewed by Adele.
......
......@@ -3581,6 +3581,10 @@
RelativePath="..\platform\win\SharedTimerWin.cpp"
>
</File>
<File
RelativePath="..\platform\win\SoftLinking.h"
>
</File>
<File
RelativePath="..\platform\win\SoundWin.cpp"
>
......
......@@ -35,6 +35,7 @@
#include "GraphicsContext.h"
#include "IntRect.h"
#include "PlatformMouseEvent.h"
#include "SoftLinking.h"
#include <CoreGraphics/CoreGraphics.h>
#include <SafariTheme/SafariTheme.h>
......@@ -61,9 +62,13 @@ static int cThumbWidth[] = { 15, 11 };
static int cThumbHeight[] = { 15, 11 };
static int cThumbMinLength[] = { 26, 20 };
static paintThemePartPtr paintThemePart;
#if !defined(NDEBUG) && defined(USE_DEBUG_SAFARI_THEME)
SOFT_LINK_DEBUG_LIBRARY(SafariTheme)
#else
SOFT_LINK_LIBRARY(SafariTheme)
#endif
static HMODULE themeDLL;
SOFT_LINK(SafariTheme, paintThemePart, void, __stdcall, (ThemePart part, CGContextRef context, const CGRect& rect, NSControlSize size, ThemeControlState state), (part, context, rect, size, state))
const double cInitialTimerDelay = 0.25;
const double cNormalTimerDelay = 0.05;
......@@ -78,12 +83,6 @@ PlatformScrollbar::PlatformScrollbar(ScrollbarClient* client, ScrollbarOrientati
// FIXME: Get metics from SafariTheme
}
if (!themeDLL)
themeDLL = ::LoadLibrary(SAFARITHEMEDLL);
if (themeDLL)
paintThemePart = (paintThemePartPtr)GetProcAddress(themeDLL, "paintThemePart");
if (orientation == VerticalScrollbar)
setFrameGeometry(IntRect(0, 0, cVerticalWidth[controlSize()], cVerticalHeight[controlSize()]));
else
......@@ -351,7 +350,7 @@ int PlatformScrollbar::trackLength() const
void PlatformScrollbar::paintButton(GraphicsContext* context, const IntRect& rect, bool start, const IntRect& damageRect) const
{
if (!paintThemePart)
if (!SafariThemeLibrary())
return;
IntRect paintRect = buttonRepaintRect(rect, m_orientation, controlSize(), start);
......@@ -377,7 +376,7 @@ void PlatformScrollbar::paintButton(GraphicsContext* context, const IntRect& rec
void PlatformScrollbar::paintTrack(GraphicsContext* context, const IntRect& rect, bool start, const IntRect& damageRect) const
{
if (!paintThemePart)
if (!SafariThemeLibrary())
return;
IntRect paintRect = hasButtons() ? trackRepaintRect(rect, m_orientation, controlSize()) : rect;
......@@ -395,7 +394,7 @@ void PlatformScrollbar::paintTrack(GraphicsContext* context, const IntRect& rect
void PlatformScrollbar::paintThumb(GraphicsContext* context, const IntRect& rect, const IntRect& damageRect) const
{
if (!paintThemePart)
if (!SafariThemeLibrary())
return;
if (!damageRect.intersects(rect))
......
/*
* Copyright (C) 2007 Apple 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:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 SoftLinking_h
#define SoftLinking_h
#include <windows.h>
#include <wtf/Assertions.h>
#define SOFT_LINK_LIBRARY_HELPER(lib, suffix) \
static HMODULE lib##Library() \
{ \
static HMODULE library = LoadLibraryW(L###lib suffix); \
ASSERT(library); \
return library; \
}
#define SOFT_LINK_LIBRARY(lib) SOFT_LINK_LIBRARY_HELPER(lib, L".dll")
#define SOFT_LINK_DEBUG_LIBRARY(lib) SOFT_LINK_LIBRARY_HELPER(lib, L"_debug.dll")
#define SOFT_LINK(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \
static resultType callingConvention init##functionName parameterDeclarations; \
static resultType (callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \
\
static resultType callingConvention init##functionName parameterDeclarations \
{ \
softLink##functionName = (resultType (callingConvention*) parameterDeclarations) GetProcAddress(library##Library(), #functionName); \
ASSERT(softLink##functionName); \
return softLink##functionName parameterNames; \
}\
\
inline resultType functionName parameterDeclarations \
{\
return softLink##functionName parameterNames; \
}
#endif // SoftLinking_h
......@@ -32,6 +32,7 @@
#include "RenderSlider.h"
#include "RenderView.h"
#include "RetainPtr.h"
#include "SoftLinking.h"
#include "cssstyleselector.h"
#include <CoreGraphics/CoreGraphics.h>
......@@ -63,7 +64,13 @@ RenderTheme* theme()
return &safariTheme;
}
static paintThemePartPtr paintThemePart;
#if !defined(NDEBUG) && defined(USE_DEBUG_SAFARI_THEME)
SOFT_LINK_DEBUG_LIBRARY(SafariTheme)
#else
SOFT_LINK_LIBRARY(SafariTheme)
#endif
SOFT_LINK(SafariTheme, paintThemePart, void, __stdcall, (ThemePart part, CGContextRef context, const CGRect& rect, NSControlSize size, ThemeControlState state), (part, context, rect, size, state))
ThemeControlState RenderThemeSafari::determineState(RenderObject* o) const
{
......@@ -92,23 +99,11 @@ static NSControlSize controlSizeFromRect(const IntRect& rect, const IntSize size
}
RenderThemeSafari::RenderThemeSafari()
: m_themeDLL(0)
{
m_themeDLL = ::LoadLibrary(SAFARITHEMEDLL);
if (m_themeDLL) {
paintThemePart = (paintThemePartPtr)GetProcAddress(m_themeDLL, "paintThemePart");
}
}
RenderThemeSafari::~RenderThemeSafari()
{
if (!m_themeDLL)
return;
// we don't need to close the themes here because uxtheme should do that for us
// anyway (and we could crash if uxtheme has done cleanup already)
::FreeLibrary(m_themeDLL);
}
Color RenderThemeSafari::platformActiveSelectionBackgroundColor() const
......@@ -198,7 +193,7 @@ bool RenderThemeSafari::isControlStyled(const RenderStyle* style, const BorderDa
const BackgroundLayer& background, const Color& backgroundColor) const
{
// If we didn't find SafariTheme.dll we won't be able to paint any themed controls.
if (!paintThemePart)
if (!SafariThemeLibrary())
return true;
if (style->appearance() == TextFieldAppearance || style->appearance() == TextAreaAppearance || style->appearance() == ListboxAppearance)
......@@ -353,7 +348,7 @@ NSControlSize RenderThemeSafari::controlSizeForSystemFont(RenderStyle* style) co
bool RenderThemeSafari::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
NSControlSize controlSize = controlSizeForFont(o->style());
......@@ -392,7 +387,7 @@ void RenderThemeSafari::setCheckboxSize(RenderStyle* style) const
bool RenderThemeSafari::paintRadio(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
NSControlSize controlSize = controlSizeForFont(o->style());
......@@ -516,7 +511,7 @@ void RenderThemeSafari::setButtonSize(RenderStyle* style) const
bool RenderThemeSafari::paintButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
// We inflate the rect as needed to account for padding included in the cell to accommodate the button
// shadow. We don't consider this part of the bounds of the control in WebKit.
......@@ -549,7 +544,7 @@ bool RenderThemeSafari::paintButton(RenderObject* o, const RenderObject::PaintIn
bool RenderThemeSafari::paintTextField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
paintThemePart(TextFieldPart, paintInfo.context->platformContext(), r, (NSControlSize)0, determineState(o) & ~FocusedState);
return false;
......@@ -562,7 +557,7 @@ void RenderThemeSafari::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, El
bool RenderThemeSafari::paintCapsLockIndicator(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
#if defined(SAFARI_THEME_VERSION) && SAFARI_THEME_VERSION >= 1
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
if (paintInfo.context->paintingDisabled())
return true;
......@@ -577,7 +572,7 @@ bool RenderThemeSafari::paintCapsLockIndicator(RenderObject* o, const RenderObje
bool RenderThemeSafari::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
paintThemePart(TextAreaPart, paintInfo.context->platformContext(), r, (NSControlSize)0, determineState(o) & ~FocusedState);
return false;
......@@ -617,7 +612,7 @@ const int* RenderThemeSafari::popupButtonPadding(NSControlSize size) const
bool RenderThemeSafari::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& info, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
NSControlSize controlSize = controlSizeFromRect(r, popupButtonSizes());
IntRect inflatedRect = r;
......@@ -938,7 +933,7 @@ const float verticalSliderHeightPadding = 0.1f;
bool RenderThemeSafari::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
ASSERT(o->parent()->isSlider());
......@@ -965,7 +960,7 @@ void RenderThemeSafari::adjustSliderThumbSize(RenderObject* o) const
bool RenderThemeSafari::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
paintThemePart(SearchFieldPart, paintInfo.context->platformContext(), r, controlSizeFromRect(r, searchFieldSizes()), determineState(o));
return false;
......@@ -1018,7 +1013,7 @@ void RenderThemeSafari::adjustSearchFieldStyle(CSSStyleSelector* selector, Rende
bool RenderThemeSafari::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect&)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
Node* input = o->node()->shadowAncestorNode();
ASSERT(input);
......@@ -1072,7 +1067,7 @@ void RenderThemeSafari::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector
bool RenderThemeSafari::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect&)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
Node* input = o->node()->shadowAncestorNode();
ASSERT(input);
......@@ -1095,7 +1090,7 @@ void RenderThemeSafari::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* se
bool RenderThemeSafari::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect&)
{
ASSERT(paintThemePart);
ASSERT(SafariThemeLibrary());
Node* input = o->node()->shadowAncestorNode();
ASSERT(input);
......
......@@ -156,9 +156,6 @@ private:
void setSearchFieldSize(RenderStyle*) const;
ThemeControlState determineState(RenderObject*) const;
private:
HMODULE m_themeDLL;
};
} // namespace WebCore
......
2007-12-07 Adam Roben <aroben@apple.com>
Use SoftLinking.h in WebKitClassFactory.
Reviewed by Oliver.
* WebKitClassFactory.cpp:
(WebKitClassFactory::WebKitClassFactory): We don't have to worry about
not finding STInitialize anymore now that a version of SafariTheme
containing this function has shipped.
2007-12-06 Ada Chan <adachan@apple.com>
<rdar://problem/5556378> Implemented database related UI delegate methods (prompts for new/enlarged databases)
......
......@@ -50,14 +50,20 @@
#include "WebURLResponse.h"
#include "WebScriptDebugServer.h"
#include "WebView.h"
#include <SafariTheme/SafariTheme.h>
#pragma warning(push, 0)
#include <WebCore/FontDatabase.h>
#include <WebCore/SoftLinking.h>
#pragma warning(pop)
// WebKitClassFactory ---------------------------------------------------------
typedef void (APIENTRY*STInitializePtr)();
#if !defined(NDEBUG) && defined(USE_DEBUG_SAFARI_THEME)
SOFT_LINK_DEBUG_LIBRARY(SafariTheme)
#else
SOFT_LINK_LIBRARY(SafariTheme)
#endif
SOFT_LINK(SafariTheme, STInitialize, void, APIENTRY, (), ())
WebKitClassFactory::WebKitClassFactory(CLSID targetClass)
: m_targetClass(targetClass)
......@@ -65,9 +71,8 @@ WebKitClassFactory::WebKitClassFactory(CLSID targetClass)
{
static bool didInitializeSafariTheme;
if (!didInitializeSafariTheme) {
if (HMODULE module = LoadLibrary(SAFARITHEMEDLL))
if (STInitializePtr stInit = (STInitializePtr)GetProcAddress(module, "STInitialize"))
stInit();
if (SafariThemeLibrary())
STInitialize();
didInitializeSafariTheme = true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment