#include "WebKitDLL.h"
#include "DOMCSSClasses.h"
#include <WebCore/BString.h>
#include <wtf/text/WTFString.h>
DOMCSSStyleDeclaration::DOMCSSStyleDeclaration(WebCore::CSSStyleDeclaration* s)
{
if (s)
s->ref();
m_style = s;
}
DOMCSSStyleDeclaration::~DOMCSSStyleDeclaration()
{
if (m_style)
m_style->deref();
}
IDOMCSSStyleDeclaration* DOMCSSStyleDeclaration::createInstance(WebCore::CSSStyleDeclaration* s)
{
if (!s)
return nullptr;
HRESULT hr;
IDOMCSSStyleDeclaration* domStyle = 0;
DOMCSSStyleDeclaration* newStyle = new DOMCSSStyleDeclaration(s);
hr = newStyle->QueryInterface(IID_IDOMCSSStyleDeclaration, (void**)&domStyle);
if (FAILED(hr))
return nullptr;
return domStyle;
}
HRESULT DOMCSSStyleDeclaration::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
{
if (!ppvObject)
return E_POINTER;
*ppvObject = nullptr;
if (IsEqualGUID(riid, IID_IDOMCSSStyleDeclaration))
*ppvObject = static_cast<IDOMCSSStyleDeclaration*>(this);
else
return DOMObject::QueryInterface(riid, ppvObject);
AddRef();
return S_OK;
}
HRESULT DOMCSSStyleDeclaration::cssText(__deref_opt_out BSTR* result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = nullptr;
return E_NOTIMPL;
}
HRESULT DOMCSSStyleDeclaration::setCssText(_In_ BSTR cssText)
{
WTF::String cssTextString(cssText);
m_style->setCssText(cssTextString);
return S_OK;
}
HRESULT DOMCSSStyleDeclaration::getPropertyValue(_In_ BSTR propertyName, __deref_opt_out BSTR* result)
{
if (!result)
return E_POINTER;
*result = nullptr;
WTF::String propertyNameString(propertyName);
WTF::String value = m_style->getPropertyValue(propertyNameString);
*result = WebCore::BString(value).release();
if (value.length() && !*result)
return E_OUTOFMEMORY;
return S_OK;
}
HRESULT DOMCSSStyleDeclaration::getPropertyCSSValue(_In_ BSTR , _COM_Outptr_opt_ IDOMCSSValue** result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = nullptr;
return E_NOTIMPL;
}
HRESULT DOMCSSStyleDeclaration::removeProperty(_In_ BSTR , __deref_opt_out BSTR* result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = nullptr;
return E_NOTIMPL;
}
HRESULT DOMCSSStyleDeclaration::getPropertyPriority(_In_ BSTR , __deref_opt_out BSTR* result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = nullptr;
return E_NOTIMPL;
}
HRESULT DOMCSSStyleDeclaration::setProperty(_In_ BSTR propertyName, _In_ BSTR value, _In_ BSTR priority)
{
WTF::String propertyNameString(propertyName);
WTF::String valueString(value);
WTF::String priorityString(priority);
m_style->setProperty(propertyNameString, valueString, priorityString);
return S_OK;
}
HRESULT DOMCSSStyleDeclaration::length(_Out_ UINT* result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = 0;
return E_NOTIMPL;
}
HRESULT DOMCSSStyleDeclaration::item(UINT , __deref_opt_out BSTR* result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = nullptr;
return E_NOTIMPL;
}
HRESULT DOMCSSStyleDeclaration::parentRule(_COM_Outptr_opt_ IDOMCSSRule** result)
{
ASSERT_NOT_REACHED();
if (!result)
return E_POINTER;
*result = nullptr;
return E_NOTIMPL;
}