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 #include <WebCore/PlatformString.h> 31 32 // DOMCSSStyleDeclaration - DOMCSSStyleDeclaration ---------------------------- 33 34 DOMCSSStyleDeclaration::DOMCSSStyleDeclaration(WebCore::CSSStyleDeclaration* s) 35 : m_style(0) 36 { 37 if (s) 38 s->ref(); 39 40 m_style = s; 41 } 42 43 DOMCSSStyleDeclaration::~DOMCSSStyleDeclaration() 44 { 45 if (m_style) 46 m_style->deref(); 47 } 48 49 IDOMCSSStyleDeclaration* DOMCSSStyleDeclaration::createInstance(WebCore::CSSStyleDeclaration* s) 50 { 51 if (!s) 52 return 0; 53 54 HRESULT hr; 55 IDOMCSSStyleDeclaration* domStyle = 0; 56 57 DOMCSSStyleDeclaration* newStyle = new DOMCSSStyleDeclaration(s); 58 hr = newStyle->QueryInterface(IID_IDOMCSSStyleDeclaration, (void**)&domStyle); 59 60 if (FAILED(hr)) 61 return 0; 62 63 return domStyle; 64 } 65 66 // DOMCSSStyleDeclaration - IUnknown ------------------------------------------ 67 68 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::QueryInterface(REFIID riid, void** ppvObject) 69 { 70 *ppvObject = 0; 71 if (IsEqualGUID(riid, IID_IDOMCSSStyleDeclaration)) 72 *ppvObject = static_cast<IDOMCSSStyleDeclaration*>(this); 73 else 74 return DOMObject::QueryInterface(riid, ppvObject); 75 76 AddRef(); 77 return S_OK; 78 } 79 80 // DOMCSSStyleDeclaration - IDOMCSSStyleDeclaration --------------------------- 81 82 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::cssText( 83 /* [retval][out] */ BSTR* /*result*/) 84 { 85 ASSERT_NOT_REACHED(); 86 return E_NOTIMPL; 87 } 88 89 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::setCssText( 90 /* [in] */ BSTR cssText) 91 { 92 WTF::String cssTextString(cssText); 93 // FIXME: <rdar://5148045> return DOM exception info 94 WebCore::ExceptionCode ec; 95 m_style->setCssText(cssTextString, ec); 96 return S_OK; 97 } 98 99 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue( 100 /* [in] */ BSTR propertyName, 101 /* [retval][out] */ BSTR* result) 102 { 103 WTF::String propertyNameString(propertyName); 104 WTF::String value = m_style->getPropertyValue(propertyNameString); 105 *result = SysAllocStringLen(value.characters(), value.length()); 106 if (value.length() && !*result) 107 return E_OUTOFMEMORY; 108 return S_OK; 109 } 110 111 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyCSSValue( 112 /* [in] */ BSTR /*propertyName*/, 113 /* [retval][out] */ IDOMCSSValue** /*result*/) 114 { 115 ASSERT_NOT_REACHED(); 116 return E_NOTIMPL; 117 } 118 119 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::removeProperty( 120 /* [in] */ BSTR /*propertyName*/, 121 /* [retval][out] */ BSTR* /*result*/) 122 { 123 ASSERT_NOT_REACHED(); 124 return E_NOTIMPL; 125 } 126 127 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyPriority( 128 /* [in] */ BSTR /*propertyName*/, 129 /* [retval][out] */ BSTR* /*result*/) 130 { 131 ASSERT_NOT_REACHED(); 132 return E_NOTIMPL; 133 } 134 135 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::setProperty( 136 /* [in] */ BSTR propertyName, 137 /* [in] */ BSTR value, 138 /* [in] */ BSTR priority) 139 { 140 WTF::String propertyNameString(propertyName); 141 WTF::String valueString(value); 142 WTF::String priorityString(priority); 143 // FIXME: <rdar://5148045> return DOM exception info 144 WebCore::ExceptionCode code; 145 m_style->setProperty(propertyNameString, valueString, priorityString, code); 146 return S_OK; 147 } 148 149 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::length( 150 /* [retval][out] */ UINT* /*result*/) 151 { 152 ASSERT_NOT_REACHED(); 153 return E_NOTIMPL; 154 } 155 156 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::item( 157 /* [in] */ UINT /*index*/, 158 /* [retval][out] */ BSTR* /*result*/) 159 { 160 ASSERT_NOT_REACHED(); 161 return E_NOTIMPL; 162 } 163 164 HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::parentRule( 165 /* [retval][out] */ IDOMCSSRule** /*result*/) 166 { 167 ASSERT_NOT_REACHED(); 168 return E_NOTIMPL; 169 } 170