webengine/osswebengine/WebKit/win/DOMCSSClasses.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions
       
     6  * are met:
       
     7  * 1. Redistributions of source code must retain the above copyright
       
     8  *    notice, this list of conditions and the following disclaimer.
       
     9  * 2. Redistributions in binary form must reproduce the above copyright
       
    10  *    notice, this list of conditions and the following disclaimer in the
       
    11  *    documentation and/or other materials provided with the distribution.
       
    12  *
       
    13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
       
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
       
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
       
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
       
    24  */
       
    25 
       
    26 #include "config.h"
       
    27 #include "WebKitDLL.h"
       
    28 #include "DOMCSSClasses.h"
       
    29 
       
    30 #pragma warning(push, 0)
       
    31 #include <WebCore/PlatformString.h>
       
    32 #pragma warning(pop)
       
    33 
       
    34 // DOMCSSStyleDeclaration - DOMCSSStyleDeclaration ----------------------------
       
    35 
       
    36 DOMCSSStyleDeclaration::DOMCSSStyleDeclaration(WebCore::CSSStyleDeclaration* s)
       
    37 : m_style(0)
       
    38 {
       
    39     if (s)
       
    40         s->ref();
       
    41 
       
    42     m_style = s;
       
    43 }
       
    44 
       
    45 DOMCSSStyleDeclaration::~DOMCSSStyleDeclaration()
       
    46 {
       
    47     if (m_style)
       
    48         m_style->deref();
       
    49 }
       
    50 
       
    51 IDOMCSSStyleDeclaration* DOMCSSStyleDeclaration::createInstance(WebCore::CSSStyleDeclaration* s)
       
    52 {
       
    53     if (!s)
       
    54         return 0;
       
    55 
       
    56     HRESULT hr;
       
    57     IDOMCSSStyleDeclaration* domStyle = 0;
       
    58 
       
    59     DOMCSSStyleDeclaration* newStyle = new DOMCSSStyleDeclaration(s);
       
    60     hr = newStyle->QueryInterface(IID_IDOMCSSStyleDeclaration, (void**)&domStyle);
       
    61 
       
    62     if (FAILED(hr))
       
    63         return 0;
       
    64 
       
    65     return domStyle;
       
    66 }
       
    67 
       
    68 // DOMCSSStyleDeclaration - IUnknown ------------------------------------------
       
    69 
       
    70 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::QueryInterface(REFIID riid, void** ppvObject)
       
    71 {
       
    72     *ppvObject = 0;
       
    73     if (IsEqualGUID(riid, IID_IDOMCSSStyleDeclaration))
       
    74         *ppvObject = static_cast<IDOMCSSStyleDeclaration*>(this);
       
    75     else
       
    76         return DOMObject::QueryInterface(riid, ppvObject);
       
    77 
       
    78     AddRef();
       
    79     return S_OK;
       
    80 }
       
    81 
       
    82 // DOMCSSStyleDeclaration - IDOMCSSStyleDeclaration ---------------------------
       
    83 
       
    84 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::cssText( 
       
    85     /* [retval][out] */ BSTR* /*result*/)
       
    86 {
       
    87     ASSERT_NOT_REACHED();
       
    88     return E_NOTIMPL;
       
    89 }
       
    90 
       
    91 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::setCssText( 
       
    92     /* [in] */ BSTR cssText)
       
    93 {
       
    94     WebCore::String cssTextString(cssText);
       
    95     // FIXME: <rdar://5148045> return DOM exception info
       
    96     WebCore::ExceptionCode ec;
       
    97     m_style->setCssText(cssTextString, ec);
       
    98     return S_OK;
       
    99 }
       
   100 
       
   101 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue( 
       
   102     /* [in] */ BSTR propertyName,
       
   103     /* [retval][out] */ BSTR* result)
       
   104 {
       
   105     WebCore::String propertyNameString(propertyName);
       
   106     WebCore::String value = m_style->getPropertyValue(propertyNameString);
       
   107     *result = SysAllocStringLen(value.characters(), value.length());
       
   108     if (value.length() && !*result)
       
   109         return E_OUTOFMEMORY;
       
   110     return S_OK;
       
   111 }
       
   112 
       
   113 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyCSSValue( 
       
   114     /* [in] */ BSTR /*propertyName*/,
       
   115     /* [retval][out] */ IDOMCSSValue** /*result*/)
       
   116 {
       
   117     ASSERT_NOT_REACHED();
       
   118     return E_NOTIMPL;
       
   119 }
       
   120 
       
   121 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::removeProperty( 
       
   122     /* [in] */ BSTR /*propertyName*/,
       
   123     /* [retval][out] */ BSTR* /*result*/)
       
   124 {
       
   125     ASSERT_NOT_REACHED();
       
   126     return E_NOTIMPL;
       
   127 }
       
   128 
       
   129 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyPriority( 
       
   130     /* [in] */ BSTR /*propertyName*/,
       
   131     /* [retval][out] */ BSTR* /*result*/)
       
   132 {
       
   133     ASSERT_NOT_REACHED();
       
   134     return E_NOTIMPL;
       
   135 }
       
   136 
       
   137 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::setProperty( 
       
   138     /* [in] */ BSTR propertyName,
       
   139     /* [in] */ BSTR value,
       
   140     /* [in] */ BSTR priority)
       
   141 {
       
   142     WebCore::String propertyNameString(propertyName);
       
   143     WebCore::String valueString(value);
       
   144     WebCore::String priorityString(priority);
       
   145     // FIXME: <rdar://5148045> return DOM exception info
       
   146     WebCore::ExceptionCode code;
       
   147     m_style->setProperty(propertyNameString, valueString, priorityString, code);
       
   148     return S_OK;
       
   149 }
       
   150 
       
   151 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::length( 
       
   152     /* [retval][out] */ UINT* /*result*/)
       
   153 {
       
   154     ASSERT_NOT_REACHED();
       
   155     return E_NOTIMPL;
       
   156 }
       
   157 
       
   158 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::item( 
       
   159     /* [in] */ UINT /*index*/,
       
   160     /* [retval][out] */ BSTR* /*result*/)
       
   161 {
       
   162     ASSERT_NOT_REACHED();
       
   163     return E_NOTIMPL;
       
   164 }
       
   165 
       
   166 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::parentRule( 
       
   167     /* [retval][out] */ IDOMCSSRule** /*result*/)
       
   168 {
       
   169     ASSERT_NOT_REACHED();
       
   170     return E_NOTIMPL;
       
   171 }