Fix <rdar://5423441> Should get focus ring color from SafariTheme
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Sep 2007 00:30:39 +0000 (00:30 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Sep 2007 00:30:39 +0000 (00:30 +0000)
        Reviewed by Hyatt.

        No regression test possible.

        * WebCore.vcproj/WebCore.vcproj: Added ColorSafari.cpp.
        * platform/graphics/win/ColorSafari.cpp: Added.
        (WebCore::makeRGBAFromCGColor): Added.
        (WebCore::focusRingColor): Added. Gets the focus ring color from
        SafariTheme if SafariTheme has support for it.
        (WebCore::setFocusRingColorChangeFunction): Added.
        * platform/win/TemporaryLinkStubs.cpp: Removed focus ring color
        functions.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25610 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/platform/graphics/win/ColorSafari.cpp [new file with mode: 0644]
WebCore/platform/win/TemporaryLinkStubs.cpp

index 1e1627621510d0204b1e9f9f057cc3803190b519..1785631c0804143b7fa5d19ccf50491436ce3638 100644 (file)
@@ -1,3 +1,20 @@
+2007-09-17  Adam Roben  <aroben@apple.com>
+
+        Fix <rdar://5423441> Should get focus ring color from SafariTheme
+
+        Reviewed by Hyatt.
+
+        No regression test possible.
+
+        * WebCore.vcproj/WebCore.vcproj: Added ColorSafari.cpp.
+        * platform/graphics/win/ColorSafari.cpp: Added.
+        (WebCore::makeRGBAFromCGColor): Added.
+        (WebCore::focusRingColor): Added. Gets the focus ring color from
+        SafariTheme if SafariTheme has support for it.
+        (WebCore::setFocusRingColorChangeFunction): Added.
+        * platform/win/TemporaryLinkStubs.cpp: Removed focus ring color
+        functions.
+
 2007-09-17  Anders Carlsson  <andersca@apple.com>
 
         Fix Windows build.
index ef09d4464ece16bea71b680a52020197f536d69b..8fdc2ea83fe1ba758ecb17177570d425659c13af 100644 (file)
                                <Filter
                                        Name="win"
                                        >
+                                       <File
+                                               RelativePath="..\platform\graphics\win\ColorSafari.cpp"
+                                               >
+                                       </File>
                                        <File
                                                RelativePath="..\platform\graphics\win\IconWin.cpp"
                                                >
diff --git a/WebCore/platform/graphics/win/ColorSafari.cpp b/WebCore/platform/graphics/win/ColorSafari.cpp
new file mode 100644 (file)
index 0000000..e7fbf47
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "Color.h"
+
+#include "NotImplemented.h"
+#include <CoreGraphics/CGColor.h>
+#include <SafariTheme/SafariTheme.h>
+#include <wtf/Assertions.h>
+#include <wtf/RetainPtr.h>
+
+using namespace SafariTheme;
+
+namespace WebCore {
+
+typedef CGColorRef (APIENTRY*stCopyThemeColorPtr)(unsigned, SafariTheme::ThemeControlState);
+static const unsigned stFocusRingColorID = 4;
+
+static const unsigned aquaFocusRingColor = 0xFF7DADD9;
+
+static RGBA32 makeRGBAFromCGColor(CGColorRef c)
+{
+    const CGFloat* components = CGColorGetComponents(c);
+    return makeRGBA(255 * components[0], 255 * components[1], 255 * components[2], 255 * components[3]);
+}
+
+Color focusRingColor()
+{
+    static Color focusRingColor;
+    focusRingColor.isValid();
+
+    if (!focusRingColor.isValid()) {
+        if (HMODULE module = LoadLibrary(SAFARITHEMEDLL))
+            if (stCopyThemeColorPtr stCopyThemeColor = (stCopyThemeColorPtr)GetProcAddress(module, "STCopyThemeColor")) {
+                RetainPtr<CGColorRef> c(AdoptCF, stCopyThemeColor(stFocusRingColorID, SafariTheme::ActiveState));
+                focusRingColor = makeRGBAFromCGColor(c.get());
+            }
+        if (!focusRingColor.isValid())
+            focusRingColor = aquaFocusRingColor;
+    }
+
+    return focusRingColor;
+}
+
+void setFocusRingColorChangeFunction(void (*)())
+{
+    notImplemented();
+}
+
+} // namespace WebCore
index a2aa25dfd8a848a2f8a229e52f3113885cc58ef2..483b095153246d89a8e773a3abc1627879019132 100644 (file)
@@ -94,9 +94,6 @@ void Widget::setIsSelected(bool) { notImplemented(); }
 
 bool ScrollView::inWindow() const { notImplemented(); return true; }
 
-Color WebCore::focusRingColor() { notImplemented(); return 0xFF7DADD9; }
-void WebCore::setFocusRingColorChangeFunction(void (*)()) { notImplemented(); }
-
 void Frame::setNeedsReapplyStyles() { notImplemented(); }
 
 String FrameLoader::overrideMediaType()const { notImplemented(); return String(); }