Add IDOMElementPrivate::font() to get an element's font
authorsfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2007 19:29:45 +0000 (19:29 +0000)
committersfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2007 19:29:45 +0000 (19:29 +0000)
        as a WebFontDescription.

        Reviewed by Darin.

        * DOMCoreClasses.cpp:
        (DOMElement::font):
        * DOMCoreClasses.h:
        * Interfaces/DOMPrivate.idl:

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

WebKit/win/ChangeLog
WebKit/win/DOMCoreClasses.cpp
WebKit/win/DOMCoreClasses.h
WebKit/win/Interfaces/DOMPrivate.idl

index 6bd4ca4c1f2f4f3d954690fa1de874597a4e02a1..684f925992589a4f2c2300040673f0a1c6b186cc 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-13  Steve Falkenburg  <sfalken@apple.com>
+
+        Add IDOMElementPrivate::font() to get an element's font
+        as a WebFontDescription.
+        
+        Reviewed by Darin.
+
+        * DOMCoreClasses.cpp:
+        (DOMElement::font):
+        * DOMCoreClasses.h:
+        * Interfaces/DOMPrivate.idl:
+
 2007-11-12  Adam Roben  <aroben@apple.com>
 
         Windows build fix
index 67030fa4ef1a7fab5f94e66507ac3f70abd4f433..f640c1385d82efb1effd5f28806123f4bcd01218 100644 (file)
 #include "DOMCSSClasses.h"
 #include "DOMEventsClasses.h"
 #include "DOMHTMLClasses.h"
+#include "WebKitGraphics.h"
+
 #pragma warning(push, 0)
 #include <WebCore/BString.h>
 #include <WebCore/DOMWindow.h>
 #include <WebCore/Document.h>
 #include <WebCore/Element.h>
+#include <WebCore/FontData.h>
 #include <WebCore/HTMLFormElement.h>
 #include <WebCore/HTMLInputElement.h>
 #include <WebCore/HTMLNames.h>
@@ -1036,6 +1039,30 @@ HRESULT STDMETHODCALLTYPE DOMElement::innerText(
     return S_OK;
 }
 
+HRESULT STDMETHODCALLTYPE DOMElement::font(WebFontDescription* webFontDescription)
+{
+    if (!webFontDescription) {
+        ASSERT_NOT_REACHED();
+        return E_POINTER;
+    }
+
+    ASSERT(m_element);
+
+    WebCore::RenderObject* renderer = m_element->renderer();
+    if (!renderer)
+        return E_FAIL;
+
+    FontDescription fontDescription = renderer->style()->font().fontDescription();
+    AtomicString family = fontDescription.family().family();
+    webFontDescription->family = family.characters();
+    webFontDescription->familyLength = family.length();
+    webFontDescription->size = fontDescription.computedSize();
+    webFontDescription->bold = fontDescription.bold();
+    webFontDescription->italic = fontDescription.italic();
+
+    return S_OK;
+}
+
 // IDOMElementCSSInlineStyle --------------------------------------------------
 
 HRESULT STDMETHODCALLTYPE DOMElement::style( 
index 70982e00506dacb8f79ea7653472e21907726428..8e12cfb42b3bfbaad29d1f2f2d8a3008c5ad500b 100644 (file)
@@ -781,6 +781,9 @@ public:
     virtual HRESULT STDMETHODCALLTYPE innerText(
         /* [retval][out] */ BSTR* result);
 
+    virtual HRESULT STDMETHODCALLTYPE font(
+        WebFontDescription* webFontDescription);
+
     // IDOMElementCSSInlineStyle
     virtual HRESULT STDMETHODCALLTYPE style( 
         /* [retval][out] */ IDOMCSSStyleDeclaration **result);
index 6d78172e07897da7ea3c9e389b5163930246e2cb..f7da64b6b512adf6ab42b9e609f89c84b499708d 100644 (file)
@@ -52,6 +52,8 @@ import "oaidl.idl";
 import "ocidl.idl";
 import "DOMCore.idl";
 
+typedef struct WebFontDescription WebFontDescription;
+
 [
     object,
     oleautomation,
@@ -64,6 +66,7 @@ interface IDOMElementPrivate : IUnknown
     HRESULT isEqual([in] IDOMElement* other, [out, retval] BOOL* result);
     HRESULT isFocused([out, retval] BOOL* result);
     HRESULT innerText([out, retval] BSTR* result);
+    [local] HRESULT font(WebFontDescription* webFontDescription);
 }
 
 /*