Add [I]WebTextRenderer
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Oct 2007 05:22:56 +0000 (05:22 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Oct 2007 05:22:56 +0000 (05:22 +0000)
 WebKitTools:

         Use WebTextRenderer in DRT

         Reviewed by Ada.

         * DumpRenderTree/win/DumpRenderTree.cpp:
         (initialize): Use WebTextRenderer instead of using
         InitializeCoreGraphics/AddFontResourceEx.

 WebKit/win:

         Add [I]WebTextRenderer

         Right now this class can only be used to add private fonts for use by
         the running process, but will eventually be the home of the
         WebKitGraphics functions.

         Reviewed by Ada.

         * ForEachCoClass.h: Added WebTextRenderer.
         * Interfaces/WebKit.idl: Ditto.
         * WebKit.vcproj/Interfaces.vcproj: Ditto.
         * WebKit.vcproj/WebKit.vcproj: Ditto.
         * WebKit.vcproj/WebKitGUID.vcproj: Ditto.
         * WebKitClassFactory.cpp: Ditto.
         * WebTextRenderer.cpp: Added.
         (WebTextRenderer::createInstance):
         (WebTextRenderer::WebTextRenderer):
         (WebTextRenderer::~WebTextRenderer):
         (WebTextRenderer::QueryInterface):
         (WebTextRenderer::AddRef):
         (WebTextRenderer::Release):
         (WebTextRenderer::registerPrivateFont):
         * WebTextRenderer.h: Added.

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

WebKit/win/ChangeLog
WebKit/win/ForEachCoClass.h
WebKit/win/Interfaces/WebKit.idl
WebKit/win/WebKit.vcproj/Interfaces.vcproj
WebKit/win/WebKit.vcproj/WebKit.vcproj
WebKit/win/WebKit.vcproj/WebKitGUID.vcproj
WebKit/win/WebKitClassFactory.cpp
WebKit/win/WebTextRenderer.cpp [new file with mode: 0644]
WebKit/win/WebTextRenderer.h [new file with mode: 0644]
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp

index 91ce6b38d41ca32ba50095ce809ead3510f78da7..d2dcd43ec4783fa3c572695a298ffa51e3e89fa7 100644 (file)
@@ -1,3 +1,29 @@
+2007-10-24  Adam Roben  <aroben@apple.com>
+
+        Add [I]WebTextRenderer
+
+        Right now this class can only be used to add private fonts for use by
+        the running process, but will eventually be the home of the
+        WebKitGraphics functions.
+
+        Reviewed by Ada.
+
+        * ForEachCoClass.h: Added WebTextRenderer.
+        * Interfaces/WebKit.idl: Ditto.
+        * WebKit.vcproj/Interfaces.vcproj: Ditto.
+        * WebKit.vcproj/WebKit.vcproj: Ditto.
+        * WebKit.vcproj/WebKitGUID.vcproj: Ditto.
+        * WebKitClassFactory.cpp: Ditto.
+        * WebTextRenderer.cpp: Added.
+        (WebTextRenderer::createInstance):
+        (WebTextRenderer::WebTextRenderer):
+        (WebTextRenderer::~WebTextRenderer):
+        (WebTextRenderer::QueryInterface):
+        (WebTextRenderer::AddRef):
+        (WebTextRenderer::Release):
+        (WebTextRenderer::registerPrivateFont):
+        * WebTextRenderer.h: Added.
+
 2007-10-24  Adam Roben  <aroben@apple.com>
 
         Use FOR_EACH_COCLASS in WebKitClassFactory
index 39f50fc345343555ac0b21391820c6440b748305..ca7f589954c2317c6d7912f36c14aaff5cf1b8e8 100644 (file)
@@ -44,6 +44,7 @@
     macro(WebNotificationCenter) \
     macro(WebPreferences) \
     macro(WebScrollBar) \
+    macro(WebTextRenderer) \
     macro(WebURLCredential) \
     macro(WebURLProtectionSpace) \
     macro(WebURLRequest) \
index 2ff214442a1ccb8876b0ee7c1b4c4681b2e050d4..3541bb1d5c3ec059e17aff2f5a7660bfefd72e2d 100644 (file)
@@ -51,6 +51,7 @@ cpp_quote(" */")
 import "oaidl.idl";
 import "ocidl.idl";
 
+import "IWebTextRenderer.idl";
 import "IWebView.idl";
 import "IWebViewPrivate.idl";
 import "IWebUIDelegate.idl";
@@ -280,4 +281,13 @@ library OpenSourceWebKit
     coclass WebURLResponse {
         [default] interface IWebURLResponse;
     }
+
+#if __BUILDBOT__
+    [uuid(24040cd6-aff4-4a51-9c8b-71539580ee76)]
+#else
+    [uuid(1fbff564-5ff4-484f-b3d9-217483f9f5fc)]
+#endif
+    coclass WebTextRenderer {
+        [default] interface IWebTextRenderer;
+    }
 }
index e651a20b7ff104decf2f5aa2b446b2118214788c..585c75ba7996b70a771d955d8dee67f27e6480ba 100644 (file)
                        RelativePath="..\Interfaces\IWebScrollBarPrivate.idl"\r
                        >\r
                </File>\r
+               <File\r
+                       RelativePath="..\Interfaces\IWebTextRenderer.idl"\r
+                       >\r
+               </File>\r
                <File\r
                        RelativePath="..\Interfaces\IWebUIDelegate.idl"\r
                        >\r
index 51d98a6c8e4dbbf69cd5582aa5a1268e9331c4d4..f9b01ecbf2f8d123cf2cab2f0c3a0c71cb30e4f9 100644 (file)
@@ -56,7 +56,6 @@
                                DebugInformationFormat="3"\r
                                DisableSpecificWarnings="4127;4355"\r
                                ForcedIncludeFiles="CodeAnalysisConfig.h"\r
-                               EnablePREfast="$(EnablePREfast)"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                                DebugInformationFormat="3"\r
                                DisableSpecificWarnings="4127;4355"\r
                                ForcedIncludeFiles="CodeAnalysisConfig.h"\r
-                               EnablePREfast="$(EnablePREfast)"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                                DebugInformationFormat="3"\r
                                DisableSpecificWarnings="4127;4355"\r
                                ForcedIncludeFiles="CodeAnalysisConfig.h"\r
-                               EnablePREfast="$(EnablePREfast)"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                                RelativePath="..\WebScrollBar.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\WebTextRenderer.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\WebURLAuthenticationChallenge.h"\r
                                >\r
                                RelativePath="..\WebScrollBar.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\WebTextRenderer.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\WebURLAuthenticationChallenge.cpp"\r
                                >\r
index 69bc66f7a0375b09720f4a0dbd9d98d0b8ed975a..a33ba874e2f49aca93fed3f28fbd4452cd98482b 100644 (file)
                        RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebScrollBarPrivate_i.c"\r
                        >\r
                </File>\r
+               <File\r
+                       RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebTextRenderer_i.c"\r
+                       >\r
+               </File>\r
                <File\r
                        RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebUIDelegate_i.c"\r
                        >\r
index d589b6ff20a6dd5da8c606a1c6037abcbb5d2a62..bbaa793d3aad9cb1d67b67d0289b7d0c67e3eca1 100644 (file)
@@ -43,6 +43,7 @@
 #include "WebMutableURLRequest.h"
 #include "WebNotificationCenter.h"
 #include "WebPreferences.h"
+#include "WebTextRenderer.h"
 #include "WebURLCredential.h"
 #include "WebURLProtectionSpace.h"
 #include "WebURLResponse.h"
diff --git a/WebKit/win/WebTextRenderer.cpp b/WebKit/win/WebTextRenderer.cpp
new file mode 100644 (file)
index 0000000..43a0c82
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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 "WebTextRenderer.h"
+
+#include <CoreFoundation/CFString.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <wtf/RetainPtr.h>
+
+WebTextRenderer* WebTextRenderer::createInstance()
+{
+    WebTextRenderer* instance = new WebTextRenderer;
+    instance->AddRef();
+    return instance;
+}
+
+WebTextRenderer::WebTextRenderer()
+    : m_refCount(0)
+{
+}
+
+WebTextRenderer::~WebTextRenderer()
+{
+}
+
+HRESULT STDMETHODCALLTYPE WebTextRenderer::QueryInterface(const IID &riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = static_cast<IWebTextRenderer*>(this);
+    else if (IsEqualGUID(riid, IID_IWebTextRenderer))
+        *ppvObject = static_cast<IWebTextRenderer*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE WebTextRenderer::AddRef()
+{
+    return ++m_refCount;
+}
+
+ULONG STDMETHODCALLTYPE WebTextRenderer::Release()
+{
+    ULONG newRef = --m_refCount;
+    if (!newRef)
+        delete this;
+
+    return newRef;
+}
+
+HRESULT STDMETHODCALLTYPE WebTextRenderer::registerPrivateFont(
+    /* [in] */ LPCOLESTR fontFilePath)
+{
+    if (!AddFontResourceEx(fontFilePath, FR_PRIVATE, 0))
+        return E_FAIL;
+
+    RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(fontFilePath), static_cast<CFIndex>(wcslen(fontFilePath))));
+    wkAddFontsAtPath(string.get());
+    return S_OK;
+}
diff --git a/WebKit/win/WebTextRenderer.h b/WebKit/win/WebTextRenderer.h
new file mode 100644 (file)
index 0000000..6424b3d
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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 WebTextRenderer_h
+#define WebTextRenderer_h
+
+#include "IWebTextRenderer.h"
+
+class WebTextRenderer : public IWebTextRenderer {
+public:
+    static WebTextRenderer* createInstance();
+
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+        /* [in] */ REFIID riid,
+        /* [iid_is][out] */ void** ppvObject);
+    
+    virtual ULONG STDMETHODCALLTYPE AddRef();
+    
+    virtual ULONG STDMETHODCALLTYPE Release();
+
+    virtual HRESULT STDMETHODCALLTYPE registerPrivateFont(
+        /* [in] */ LPCOLESTR fontFilePath);
+    
+private:
+    WebTextRenderer();
+    ~WebTextRenderer();
+
+    ULONG m_refCount;
+};
+
+#endif // !defined(WebTextRenderer_h)
index db9e36b7210e0b2a3aa697e787521891ff9aef7e..6cc6a31b9fa52a20a929829bf2cb5f21d45e7582 100644 (file)
@@ -1,3 +1,12 @@
+2007-10-24  Adam Roben  <aroben@apple.com>
+
+        Use WebTextRenderer in DRT
+
+        Reviewed by Ada.
+
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (initialize): Use WebTextRenderer instead of using AddFontResourceEx.
+
 2007-10-24  Sven Herzberg  <sven@imendio.com>
 
         Reviewed by Mark Rowe.
index 86add33b9baa1bdc65566d65e8a31f753bb50619..3cfbd8f760bc929ee2fac79132b9dee0f98f57b9 100644 (file)
@@ -123,6 +123,9 @@ static wstring initialize(HMODULE hModule)
         if (FARPROC dllRegisterServer = GetProcAddress(webKitModule, "DllRegisterServer"))
             dllRegisterServer();
 
+    // Init COM
+    OleInitialize(0);
+
     static LPCTSTR fontsToInstall[] = {
         TEXT("AHEM____.ttf"),
         TEXT("Apple Chancery.ttf"),
@@ -159,11 +162,10 @@ static wstring initialize(HMODULE hModule)
     
     wstring resourcesPath(exePath + TEXT("DumpRenderTree.resources\\"));
 
-    for (int i = 0; i < ARRAYSIZE(fontsToInstall); ++i)
-        AddFontResourceEx(wstring(resourcesPath + fontsToInstall[i]).c_str(), FR_PRIVATE, 0);
-
-    // Init COM
-    OleInitialize(0);
+    COMPtr<IWebTextRenderer> textRenderer;
+    if (SUCCEEDED(CoCreateInstance(CLSID_WebTextRenderer, 0, CLSCTX_ALL, IID_IWebTextRenderer, (void**)&textRenderer)))
+        for (int i = 0; i < ARRAYSIZE(fontsToInstall); ++i)
+            textRenderer->registerPrivateFont(wstring(resourcesPath + fontsToInstall[i]).c_str());
 
     // Initialize CG
     InitializeCoreGraphics();