1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528 |
- /*
- * Copyright (C) 2006, 2007, 2009 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
- * 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 "WebKitDLL.h"
- #include "DOMCoreClasses.h"
- #include "DOMCSSClasses.h"
- #include "DOMEventsClasses.h"
- #include "DOMHTMLClasses.h"
- #include "WebKitGraphics.h"
- #include <WebCore/BString.h>
- #include <WebCore/COMPtr.h>
- #include <WebCore/DOMWindow.h>
- #include <WebCore/Document.h>
- #include <WebCore/Element.h>
- #include <WebCore/Font.h>
- #include <WebCore/Frame.h>
- #include <WebCore/SimpleFontData.h>
- #include <WebCore/HTMLFormElement.h>
- #include <WebCore/HTMLInputElement.h>
- #include <WebCore/HTMLNames.h>
- #include <WebCore/HTMLOptionElement.h>
- #include <WebCore/HTMLSelectElement.h>
- #include <WebCore/HTMLTextAreaElement.h>
- #include <WebCore/NodeList.h>
- #include <WebCore/RenderObject.h>
- #include <WebCore/RenderTreeAsText.h>
- #include <initguid.h>
- // {3B0C0EFF-478B-4b0b-8290-D2321E08E23E}
- DEFINE_GUID(IID_DOMElement, 0x3b0c0eff, 0x478b, 0x4b0b, 0x82, 0x90, 0xd2, 0x32, 0x1e, 0x8, 0xe2, 0x3e);
- // Our normal style is just to say "using namespace WebCore" rather than having
- // individual using directives for each type from that namespace. But
- // "DOMObject" exists both in the WebCore namespace and unnamespaced in this
- // file, which leads to ambiguities if we say "using namespace WebCore".
- using namespace WebCore::HTMLNames;
- using WTF::AtomicString;
- using WebCore::BString;
- using WebCore::Element;
- using WebCore::ExceptionCode;
- using WebCore::FontDescription;
- using WebCore::Frame;
- using WebCore::IntRect;
- using WTF::String;
- // DOMObject - IUnknown -------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMObject::QueryInterface(REFIID riid, void** ppvObject)
- {
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IDOMObject))
- *ppvObject = static_cast<IDOMObject*>(this);
- else
- return WebScriptObject::QueryInterface(riid, ppvObject);
- AddRef();
- return S_OK;
- }
- // DOMNode - IUnknown ---------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMNode::QueryInterface(REFIID riid, void** ppvObject)
- {
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IDOMNode))
- *ppvObject = static_cast<IDOMNode*>(this);
- else if (IsEqualGUID(riid, __uuidof(DOMNode)))
- *ppvObject = static_cast<DOMNode*>(this);
- else if (IsEqualGUID(riid, __uuidof(IDOMEventTarget)))
- *ppvObject = static_cast<IDOMEventTarget*>(this);
- else
- return DOMObject::QueryInterface(riid, ppvObject);
- AddRef();
- return S_OK;
- }
- // DOMNode --------------------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMNode::nodeName(
- /* [retval][out] */ BSTR* result)
- {
- if (!result)
- return E_POINTER;
- if (!m_node)
- return E_FAIL;
- *result = BString(m_node->nodeName()).release();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::nodeValue(
- /* [retval][out] */ BSTR* result)
- {
- if (!m_node)
- return E_FAIL;
- WTF::String nodeValueStr = m_node->nodeValue();
- *result = SysAllocStringLen(nodeValueStr.characters(), nodeValueStr.length());
- if (nodeValueStr.length() && !*result)
- return E_OUTOFMEMORY;
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::setNodeValue(
- /* [in] */ BSTR /*value*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::nodeType(
- /* [retval][out] */ unsigned short* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::parentNode(
- /* [retval][out] */ IDOMNode** result)
- {
- *result = 0;
- if (!m_node || !m_node->parentNode())
- return E_FAIL;
- *result = DOMNode::createInstance(m_node->parentNode());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::childNodes(
- /* [retval][out] */ IDOMNodeList** result)
- {
- if (!m_node)
- return E_FAIL;
- if (!result)
- return E_POINTER;
- *result = DOMNodeList::createInstance(m_node->childNodes().get());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::firstChild(
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::lastChild(
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::previousSibling(
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::nextSibling(
- /* [retval][out] */ IDOMNode** result)
- {
- if (!result)
- return E_POINTER;
- *result = 0;
- if (!m_node)
- return E_FAIL;
- *result = DOMNode::createInstance(m_node->nextSibling());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::attributes(
- /* [retval][out] */ IDOMNamedNodeMap** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::ownerDocument(
- /* [retval][out] */ IDOMDocument** result)
- {
- if (!result)
- return E_POINTER;
- *result = 0;
- if (!m_node)
- return E_FAIL;
- *result = DOMDocument::createInstance(m_node->ownerDocument());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::insertBefore(
- /* [in] */ IDOMNode* newChild,
- /* [in] */ IDOMNode* refChild,
- /* [retval][out] */ IDOMNode** result)
- {
- if (!result)
- return E_POINTER;
- *result = 0;
- if (!m_node)
- return E_FAIL;
- COMPtr<DOMNode> newChildNode(Query, newChild);
- if (!newChildNode)
- return E_FAIL;
- COMPtr<DOMNode> refChildNode(Query, refChild);
- ExceptionCode ec;
- if (!m_node->insertBefore(newChildNode->node(), refChildNode ? refChildNode->node() : 0, ec))
- return E_FAIL;
- *result = newChild;
- (*result)->AddRef();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::replaceChild(
- /* [in] */ IDOMNode* /*newChild*/,
- /* [in] */ IDOMNode* /*oldChild*/,
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::removeChild(
- /* [in] */ IDOMNode* oldChild,
- /* [retval][out] */ IDOMNode** result)
- {
- if (!result)
- return E_POINTER;
- *result = 0;
- if (!m_node)
- return E_FAIL;
- COMPtr<DOMNode> oldChildNode(Query, oldChild);
- if (!oldChildNode)
- return E_FAIL;
- ExceptionCode ec;
- if (!m_node->removeChild(oldChildNode->node(), ec))
- return E_FAIL;
- *result = oldChild;
- (*result)->AddRef();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::appendChild(
- /* [in] */ IDOMNode* /*oldChild*/,
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::hasChildNodes(
- /* [retval][out] */ BOOL* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::cloneNode(
- /* [in] */ BOOL /*deep*/,
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::normalize( void)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::isSupported(
- /* [in] */ BSTR /*feature*/,
- /* [in] */ BSTR /*version*/,
- /* [retval][out] */ BOOL* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::namespaceURI(
- /* [retval][out] */ BSTR* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::prefix(
- /* [retval][out] */ BSTR* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::setPrefix(
- /* [in] */ BSTR /*prefix*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::localName(
- /* [retval][out] */ BSTR* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::hasAttributes(
- /* [retval][out] */ BOOL* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::isSameNode(
- /* [in] */ IDOMNode* other,
- /* [retval][out] */ BOOL* result)
- {
- if (!result) {
- ASSERT_NOT_REACHED();
- return E_POINTER;
- }
- *result = FALSE;
- if (!other)
- return E_POINTER;
- COMPtr<DOMNode> domOther;
- HRESULT hr = other->QueryInterface(__uuidof(DOMNode), (void**)&domOther);
- if (FAILED(hr))
- return hr;
- *result = m_node->isSameNode(domOther->node()) ? TRUE : FALSE;
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::isEqualNode(
- /* [in] */ IDOMNode* /*other*/,
- /* [retval][out] */ BOOL* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::textContent(
- /* [retval][out] */ BSTR* result)
- {
- if (!result)
- return E_POINTER;
- *result = BString(m_node->textContent()).release();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMNode::setTextContent(
- /* [in] */ BSTR /*text*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- // DOMNode - IDOMEventTarget --------------------------------------------------
- HRESULT DOMNode::addEventListener(
- /* [in] */ BSTR type,
- /* [in] */ IDOMEventListener* listener,
- /* [in] */ BOOL useCapture)
- {
- RefPtr<WebEventListener> webListener = WebEventListener::create(listener);
- m_node->addEventListener(type, webListener, useCapture);
- return S_OK;
- }
- HRESULT DOMNode::removeEventListener(
- /* [in] */ BSTR type,
- /* [in] */ IDOMEventListener* listener,
- /* [in] */ BOOL useCapture)
- {
- if (!listener || !type)
- return E_POINTER;
- if (!m_node)
- return E_FAIL;
- RefPtr<WebEventListener> webListener = WebEventListener::create(listener);
- m_node->removeEventListener(type, webListener.get(), useCapture);
- return S_OK;
- }
- HRESULT DOMNode::dispatchEvent(
- /* [in] */ IDOMEvent* evt,
- /* [retval][out] */ BOOL* result)
- {
- if (!evt || !result)
- return E_POINTER;
- if (!m_node)
- return E_FAIL;
- COMPtr<DOMEvent> domEvent;
- HRESULT hr = evt->QueryInterface(IID_DOMEvent, (void**) &domEvent);
- if (FAILED(hr))
- return hr;
- WebCore::ExceptionCode ec = 0;
- *result = m_node->dispatchEvent(domEvent->coreEvent(), ec) ? TRUE : FALSE;
- return ec ? E_FAIL : S_OK;
- }
- // DOMNode - DOMNode ----------------------------------------------------------
- DOMNode::DOMNode(WebCore::Node* n)
- : m_node(0)
- {
- if (n)
- n->ref();
- m_node = n;
- }
- DOMNode::~DOMNode()
- {
- if (m_node)
- m_node->deref();
- }
- IDOMNode* DOMNode::createInstance(WebCore::Node* n)
- {
- if (!n)
- return 0;
- HRESULT hr = S_OK;
- IDOMNode* domNode = 0;
- WebCore::Node::NodeType nodeType = n->nodeType();
- switch (nodeType) {
- case WebCore::Node::ELEMENT_NODE:
- {
- IDOMElement* newElement = DOMElement::createInstance(static_cast<WebCore::Element*>(n));
- if (newElement) {
- hr = newElement->QueryInterface(IID_IDOMNode, (void**)&domNode);
- newElement->Release();
- }
- }
- break;
- case WebCore::Node::DOCUMENT_NODE:
- {
- IDOMDocument* newDocument = DOMDocument::createInstance(n->document());
- if (newDocument) {
- hr = newDocument->QueryInterface(IID_IDOMNode, (void**)&domNode);
- newDocument->Release();
- }
- }
- break;
- default:
- {
- DOMNode* newNode = new DOMNode(n);
- hr = newNode->QueryInterface(IID_IDOMNode, (void**)&domNode);
- }
- break;
- }
- if (FAILED(hr))
- return 0;
- return domNode;
- }
- // DOMNodeList - IUnknown -----------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMNodeList::QueryInterface(REFIID riid, void** ppvObject)
- {
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IDOMNodeList))
- *ppvObject = static_cast<IDOMNodeList*>(this);
- else
- return DOMObject::QueryInterface(riid, ppvObject);
- AddRef();
- return S_OK;
- }
- // IDOMNodeList ---------------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMNodeList::item(
- /* [in] */ UINT index,
- /* [retval][out] */ IDOMNode **result)
- {
- *result = 0;
- if (!m_nodeList)
- return E_FAIL;
- WebCore::Node* itemNode = m_nodeList->item(index);
- if (!itemNode)
- return E_FAIL;
- *result = DOMNode::createInstance(itemNode);
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMNodeList::length(
- /* [retval][out] */ UINT *result)
- {
- *result = 0;
- if (!m_nodeList)
- return E_FAIL;
- *result = m_nodeList->length();
- return S_OK;
- }
- // DOMNodeList - DOMNodeList --------------------------------------------------
- DOMNodeList::DOMNodeList(WebCore::NodeList* l)
- : m_nodeList(0)
- {
- if (l)
- l->ref();
- m_nodeList = l;
- }
- DOMNodeList::~DOMNodeList()
- {
- if (m_nodeList)
- m_nodeList->deref();
- }
- IDOMNodeList* DOMNodeList::createInstance(WebCore::NodeList* l)
- {
- if (!l)
- return 0;
- IDOMNodeList* domNodeList = 0;
- DOMNodeList* newNodeList = new DOMNodeList(l);
- if (FAILED(newNodeList->QueryInterface(IID_IDOMNodeList, (void**)&domNodeList)))
- return 0;
- return domNodeList;
- }
- // DOMDocument - IUnknown -----------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMDocument::QueryInterface(REFIID riid, void** ppvObject)
- {
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IDOMDocument))
- *ppvObject = static_cast<IDOMDocument*>(this);
- else if (IsEqualGUID(riid, IID_IDOMViewCSS))
- *ppvObject = static_cast<IDOMViewCSS*>(this);
- else if (IsEqualGUID(riid, IID_IDOMDocumentEvent))
- *ppvObject = static_cast<IDOMDocumentEvent*>(this);
- else
- return DOMNode::QueryInterface(riid, ppvObject);
- AddRef();
- return S_OK;
- }
- // DOMDocument ----------------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMDocument::doctype(
- /* [retval][out] */ IDOMDocumentType** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::implementation(
- /* [retval][out] */ IDOMImplementation** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::documentElement(
- /* [retval][out] */ IDOMElement** result)
- {
- *result = DOMElement::createInstance(m_document->documentElement());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createElement(
- /* [in] */ BSTR tagName,
- /* [retval][out] */ IDOMElement** result)
- {
- if (!m_document)
- return E_FAIL;
- String tagNameString(tagName);
- ExceptionCode ec;
- *result = DOMElement::createInstance(m_document->createElement(tagNameString, ec).get());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createDocumentFragment(
- /* [retval][out] */ IDOMDocumentFragment** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createTextNode(
- /* [in] */ BSTR /*data*/,
- /* [retval][out] */ IDOMText** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createComment(
- /* [in] */ BSTR /*data*/,
- /* [retval][out] */ IDOMComment** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createCDATASection(
- /* [in] */ BSTR /*data*/,
- /* [retval][out] */ IDOMCDATASection** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createProcessingInstruction(
- /* [in] */ BSTR /*target*/,
- /* [in] */ BSTR /*data*/,
- /* [retval][out] */ IDOMProcessingInstruction** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createAttribute(
- /* [in] */ BSTR /*name*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createEntityReference(
- /* [in] */ BSTR /*name*/,
- /* [retval][out] */ IDOMEntityReference** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::getElementsByTagName(
- /* [in] */ BSTR tagName,
- /* [retval][out] */ IDOMNodeList** result)
- {
- if (!m_document)
- return E_FAIL;
- String tagNameString(tagName);
- *result = DOMNodeList::createInstance(m_document->getElementsByTagName(tagNameString).get());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::importNode(
- /* [in] */ IDOMNode* /*importedNode*/,
- /* [in] */ BOOL /*deep*/,
- /* [retval][out] */ IDOMNode** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createElementNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*qualifiedName*/,
- /* [retval][out] */ IDOMElement** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::createAttributeNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*qualifiedName*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::getElementsByTagNameNS(
- /* [in] */ BSTR namespaceURI,
- /* [in] */ BSTR localName,
- /* [retval][out] */ IDOMNodeList** result)
- {
- if (!m_document)
- return E_FAIL;
- String namespaceURIString(namespaceURI);
- String localNameString(localName);
- *result = DOMNodeList::createInstance(m_document->getElementsByTagNameNS(namespaceURIString, localNameString).get());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT STDMETHODCALLTYPE DOMDocument::getElementById(
- /* [in] */ BSTR elementId,
- /* [retval][out] */ IDOMElement** result)
- {
- if (!m_document)
- return E_FAIL;
- String idString(elementId);
- *result = DOMElement::createInstance(m_document->getElementById(idString));
- return *result ? S_OK : E_FAIL;
- }
- // DOMDocument - IDOMViewCSS --------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMDocument::getComputedStyle(
- /* [in] */ IDOMElement* elt,
- /* [in] */ BSTR pseudoElt,
- /* [retval][out] */ IDOMCSSStyleDeclaration** result)
- {
- if (!elt || !result)
- return E_POINTER;
- COMPtr<DOMElement> domEle;
- HRESULT hr = elt->QueryInterface(IID_DOMElement, (void**)&domEle);
- if (FAILED(hr))
- return hr;
- Element* element = domEle->element();
- WebCore::DOMWindow* dv = m_document->defaultView();
- String pseudoEltString(pseudoElt);
-
- if (!dv)
- return E_FAIL;
-
- *result = DOMCSSStyleDeclaration::createInstance(dv->getComputedStyle(element, pseudoEltString.impl()).get());
- return *result ? S_OK : E_FAIL;
- }
- // DOMDocument - IDOMDocumentEvent --------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMDocument::createEvent(
- /* [in] */ BSTR eventType,
- /* [retval][out] */ IDOMEvent **result)
- {
- String eventTypeString(eventType, SysStringLen(eventType));
- WebCore::ExceptionCode ec = 0;
- *result = DOMEvent::createInstance(m_document->createEvent(eventTypeString, ec));
- return *result ? S_OK : E_FAIL;
- }
- // DOMDocument - DOMDocument --------------------------------------------------
- DOMDocument::DOMDocument(WebCore::Document* d)
- : DOMNode(d)
- , m_document(d)
- {
- }
- DOMDocument::~DOMDocument()
- {
- }
- IDOMDocument* DOMDocument::createInstance(WebCore::Document* d)
- {
- if (!d)
- return 0;
- HRESULT hr;
- IDOMDocument* domDocument = 0;
- if (d->isHTMLDocument()) {
- DOMHTMLDocument* newDocument = new DOMHTMLDocument(d);
- hr = newDocument->QueryInterface(IID_IDOMDocument, (void**)&domDocument);
- } else {
- DOMDocument* newDocument = new DOMDocument(d);
- hr = newDocument->QueryInterface(IID_IDOMDocument, (void**)&domDocument);
- }
- if (FAILED(hr))
- return 0;
- return domDocument;
- }
- // DOMWindow - IUnknown ------------------------------------------------------
- HRESULT DOMWindow::QueryInterface(REFIID riid, void** ppvObject)
- {
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IDOMWindow))
- *ppvObject = static_cast<IDOMWindow*>(this);
- else if (IsEqualGUID(riid, IID_IDOMEventTarget))
- *ppvObject = static_cast<IDOMEventTarget*>(this);
- else
- return DOMObject::QueryInterface(riid, ppvObject);
- AddRef();
- return S_OK;
- }
- // DOMWindow - IDOMWindow ------------------------------------------------------
- HRESULT DOMWindow::document(
- /* [out, retval] */ IDOMDocument** result)
- {
- if (!result) {
- ASSERT_NOT_REACHED();
- return E_POINTER;
- }
- *result = DOMDocument::createInstance(m_window->document());
- return *result ? S_OK : E_FAIL;
- }
- HRESULT DOMWindow::getComputedStyle(
- /* [in] */ IDOMElement* element,
- /* [in] */ BSTR pseudoElement)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT DOMWindow::getMatchedCSSRules(
- /* [in] */ IDOMElement* element,
- /* [in] */ BSTR pseudoElement,
- /* [in] */ BOOL authorOnly,
- /* [out, retval] */ IDOMCSSRuleList** result)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT DOMWindow::devicePixelRatio(
- /* [out, retval] */ double* result)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- // DOMWindow - IDOMEventTarget ------------------------------------------------------
- HRESULT DOMWindow::addEventListener(
- /* [in] */ BSTR type,
- /* [in] */ IDOMEventListener* listener,
- /* [in] */ BOOL useCapture)
- {
- if (!type || !listener)
- return E_POINTER;
- if (!m_window)
- return E_FAIL;
- RefPtr<WebEventListener> webListener = WebEventListener::create(listener);
- m_window->addEventListener(type, webListener, useCapture);
- return S_OK;
- }
- HRESULT DOMWindow::removeEventListener(
- /* [in] */ BSTR type,
- /* [in] */ IDOMEventListener* listener,
- /* [in] */ BOOL useCapture)
- {
- if (!type || !listener)
- return E_POINTER;
- if (!m_window)
- return E_FAIL;
- RefPtr<WebEventListener> webListener = WebEventListener::create(listener);
- m_window->removeEventListener(type, webListener.get(), useCapture);
- return S_OK;
- }
- HRESULT DOMWindow::dispatchEvent(
- /* [in] */ IDOMEvent* evt,
- /* [retval][out] */ BOOL* result)
- {
- if (!result || !evt)
- return E_POINTER;
- if (!m_window)
- return E_FAIL;
- COMPtr<DOMEvent> domEvent;
- HRESULT hr = evt->QueryInterface(IID_DOMEvent, (void**) &domEvent);
- if (FAILED(hr))
- return hr;
- WebCore::ExceptionCode ec = 0;
- *result = m_window->dispatchEvent(domEvent->coreEvent(), ec) ? TRUE : FALSE;
- return ec ? E_FAIL : S_OK;
- }
- // DOMWindow - DOMWindow --------------------------------------------------
- DOMWindow::DOMWindow(WebCore::DOMWindow* w)
- : m_window(w)
- {
- }
- DOMWindow::~DOMWindow()
- {
- }
- IDOMWindow* DOMWindow::createInstance(WebCore::DOMWindow* w)
- {
- if (!w)
- return 0;
- DOMWindow* newWindow = new DOMWindow(w);
- IDOMWindow* domWindow = 0;
- HRESULT hr = newWindow->QueryInterface(IID_IDOMWindow, reinterpret_cast<void**>(&domWindow));
- if (FAILED(hr))
- return 0;
- return domWindow;
- }
- // DOMElement - IUnknown ------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMElement::QueryInterface(REFIID riid, void** ppvObject)
- {
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IDOMElement))
- *ppvObject = static_cast<IDOMElement*>(this);
- else if (IsEqualGUID(riid, IID_DOMElement))
- *ppvObject = static_cast<DOMElement*>(this);
- else if (IsEqualGUID(riid, IID_IDOMElementPrivate))
- *ppvObject = static_cast<IDOMElementPrivate*>(this);
- else if (IsEqualGUID(riid, IID_IDOMNodeExtensions))
- *ppvObject = static_cast<IDOMNodeExtensions*>(this);
- else if (IsEqualGUID(riid, IID_IDOMElementCSSInlineStyle))
- *ppvObject = static_cast<IDOMElementCSSInlineStyle*>(this);
- else if (IsEqualGUID(riid, IID_IDOMElementExtensions))
- *ppvObject = static_cast<IDOMElementExtensions*>(this);
- else
- return DOMNode::QueryInterface(riid, ppvObject);
- AddRef();
- return S_OK;
- }
- // DOMElement - IDOMNodeExtensions---------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMElement::boundingBox(
- /* [retval][out] */ LPRECT rect)
- {
- ::SetRectEmpty(rect);
- if (!m_element)
- return E_FAIL;
- WebCore::RenderObject *renderer = m_element->renderer();
- if (renderer) {
- IntRect boundsIntRect = renderer->absoluteBoundingBoxRect();
- rect->left = boundsIntRect.x();
- rect->top = boundsIntRect.y();
- rect->right = boundsIntRect.x() + boundsIntRect.width();
- rect->bottom = boundsIntRect.y() + boundsIntRect.height();
- }
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::lineBoxRects(
- /* [size_is][in] */ RECT* /*rects*/,
- /* [in] */ int /*cRects*/)
- {
- return E_NOTIMPL;
- }
- // IDOMElement ----------------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMElement::tagName(
- /* [retval][out] */ BSTR* result)
- {
- if (!m_element)
- return E_FAIL;
- if (!result)
- return E_POINTER;
- *result = BString(m_element->tagName()).release();
- return S_OK;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::getAttribute(
- /* [in] */ BSTR name,
- /* [retval][out] */ BSTR* result)
- {
- if (!m_element)
- return E_FAIL;
- WTF::String nameString(name, SysStringLen(name));
- WTF::String& attrValueString = (WTF::String&) m_element->getAttribute(nameString);
- *result = SysAllocStringLen(attrValueString.characters(), attrValueString.length());
- if (attrValueString.length() && !*result)
- return E_OUTOFMEMORY;
- return S_OK;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::setAttribute(
- /* [in] */ BSTR name,
- /* [in] */ BSTR value)
- {
- if (!m_element)
- return E_FAIL;
- WTF::String nameString(name, SysStringLen(name));
- WTF::String valueString(value, SysStringLen(value));
- WebCore::ExceptionCode ec = 0;
- m_element->setAttribute(nameString, valueString, ec);
- return ec ? E_FAIL : S_OK;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::removeAttribute(
- /* [in] */ BSTR /*name*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::getAttributeNode(
- /* [in] */ BSTR /*name*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::setAttributeNode(
- /* [in] */ IDOMAttr* /*newAttr*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::removeAttributeNode(
- /* [in] */ IDOMAttr* /*oldAttr*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::getElementsByTagName(
- /* [in] */ BSTR /*name*/,
- /* [retval][out] */ IDOMNodeList** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::getAttributeNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*localName*/,
- /* [retval][out] */ BSTR* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::setAttributeNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*qualifiedName*/,
- /* [in] */ BSTR /*value*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::removeAttributeNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*localName*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::getAttributeNodeNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*localName*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::setAttributeNodeNS(
- /* [in] */ IDOMAttr* /*newAttr*/,
- /* [retval][out] */ IDOMAttr** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::getElementsByTagNameNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*localName*/,
- /* [retval][out] */ IDOMNodeList** /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::hasAttribute(
- /* [in] */ BSTR /*name*/,
- /* [retval][out] */ BOOL* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
-
- HRESULT STDMETHODCALLTYPE DOMElement::hasAttributeNS(
- /* [in] */ BSTR /*namespaceURI*/,
- /* [in] */ BSTR /*localName*/,
- /* [retval][out] */ BOOL* /*result*/)
- {
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::focus( void)
- {
- if (!m_element)
- return E_FAIL;
- m_element->focus();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::blur( void)
- {
- if (!m_element)
- return E_FAIL;
- m_element->blur();
- return S_OK;
- }
- // IDOMElementPrivate ---------------------------------------------------------
- HRESULT DOMElement::coreElement(void **element)
- {
- if (!m_element)
- return E_FAIL;
- *element = (void*) m_element;
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::isEqual(
- /* [in] */ IDOMElement *other,
- /* [retval][out] */ BOOL *result)
- {
- *result = FALSE;
- if (!other || !result)
- return E_POINTER;
- IDOMElementPrivate* otherPriv;
- HRESULT hr = other->QueryInterface(IID_IDOMElementPrivate, (void**) &otherPriv);
- if (FAILED(hr))
- return hr;
-
- void* otherCoreEle;
- hr = otherPriv->coreElement(&otherCoreEle);
- otherPriv->Release();
- if (FAILED(hr))
- return hr;
- *result = (otherCoreEle == (void*)m_element) ? TRUE : FALSE;
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::isFocused(
- /* [retval][out] */ BOOL *result)
- {
- if (!m_element)
- return E_FAIL;
- if (m_element->document()->focusedElement() == m_element)
- *result = TRUE;
- else
- *result = FALSE;
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::innerText(
- /* [retval][out] */ BSTR* result)
- {
- if (!result) {
- ASSERT_NOT_REACHED();
- return E_POINTER;
- }
- if (!m_element) {
- ASSERT_NOT_REACHED();
- return E_FAIL;
- }
- *result = BString(m_element->innerText()).release();
- 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.firstFamily();
- webFontDescription->family = family.characters();
- webFontDescription->familyLength = family.length();
- webFontDescription->size = fontDescription.computedSize();
- webFontDescription->bold = fontDescription.weight() >= WebCore::FontWeight600;
- webFontDescription->italic = fontDescription.italic();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::renderedImage(HBITMAP* image)
- {
- if (!image) {
- ASSERT_NOT_REACHED();
- return E_POINTER;
- }
- *image = 0;
- ASSERT(m_element);
- Frame* frame = m_element->document()->frame();
- if (!frame)
- return E_FAIL;
- *image = frame->nodeImage(m_element);
- if (!*image)
- return E_FAIL;
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::markerTextForListItem(
- /* [retval][out] */ BSTR* markerText)
- {
- if (!markerText)
- return E_POINTER;
- ASSERT(m_element);
- *markerText = BString(WebCore::markerTextForListItem(m_element)).release();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::shadowPseudoId(
- /* [retval][out] */ BSTR* result)
- {
- if (!result)
- return E_POINTER;
- ASSERT(m_element);
- *result = BString(m_element->shadowPseudoId().string()).release();
- return S_OK;
- }
- // IDOMElementCSSInlineStyle --------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMElement::style(
- /* [retval][out] */ IDOMCSSStyleDeclaration** result)
- {
- if (!result)
- return E_POINTER;
- if (!m_element)
- return E_FAIL;
- WebCore::CSSStyleDeclaration* style = m_element->style();
- if (!style)
- return E_FAIL;
- *result = DOMCSSStyleDeclaration::createInstance(style);
- return *result ? S_OK : E_FAIL;
- }
- // IDOMElementExtensions ------------------------------------------------------
- HRESULT STDMETHODCALLTYPE DOMElement::offsetLeft(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->offsetLeft();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::offsetTop(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->offsetTop();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::offsetWidth(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->offsetWidth();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::offsetHeight(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->offsetHeight();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::offsetParent(
- /* [retval][out] */ IDOMElement** /*result*/)
- {
- // FIXME
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::clientWidth(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->clientWidth();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::clientHeight(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->clientHeight();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::scrollLeft(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->scrollLeft();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::setScrollLeft(
- /* [in] */ int /*newScrollLeft*/)
- {
- // FIXME
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::scrollTop(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->scrollTop();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::setScrollTop(
- /* [in] */ int /*newScrollTop*/)
- {
- // FIXME
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::scrollWidth(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->scrollWidth();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::scrollHeight(
- /* [retval][out] */ int* result)
- {
- if (!m_element)
- return E_FAIL;
- *result = m_element->scrollHeight();
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::scrollIntoView(
- /* [in] */ BOOL alignWithTop)
- {
- if (!m_element)
- return E_FAIL;
- m_element->scrollIntoView(!!alignWithTop);
- return S_OK;
- }
- HRESULT STDMETHODCALLTYPE DOMElement::scrollIntoViewIfNeeded(
- /* [in] */ BOOL centerIfNeeded)
- {
- if (!m_element)
- return E_FAIL;
- m_element->scrollIntoViewIfNeeded(!!centerIfNeeded);
- return S_OK;
- }
- // DOMElement -----------------------------------------------------------------
- DOMElement::DOMElement(WebCore::Element* e)
- : DOMNode(e)
- , m_element(e)
- {
- }
- DOMElement::~DOMElement()
- {
- }
- IDOMElement* DOMElement::createInstance(WebCore::Element* e)
- {
- if (!e)
- return 0;
- HRESULT hr;
- IDOMElement* domElement = 0;
- if (e->hasTagName(formTag)) {
- DOMHTMLFormElement* newElement = new DOMHTMLFormElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (e->hasTagName(iframeTag)) {
- DOMHTMLIFrameElement* newElement = new DOMHTMLIFrameElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (e->hasTagName(inputTag)) {
- DOMHTMLInputElement* newElement = new DOMHTMLInputElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (e->hasTagName(optionTag)) {
- DOMHTMLOptionElement* newElement = new DOMHTMLOptionElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (e->hasTagName(selectTag)) {
- DOMHTMLSelectElement* newElement = new DOMHTMLSelectElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (e->hasTagName(textareaTag)) {
- DOMHTMLTextAreaElement* newElement = new DOMHTMLTextAreaElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (e->isHTMLElement()) {
- DOMHTMLElement* newElement = new DOMHTMLElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else {
- DOMElement* newElement = new DOMElement(e);
- hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- }
- if (FAILED(hr))
- return 0;
- return domElement;
- }
|