📄 domhtmlclasses.cpp
字号:
/* * Copyright (C) 2006, 2007 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 "DOMHTMLClasses.h"#include "COMPtr.h"#pragma warning(push, 0)#include <WebCore/BString.h>#include <WebCore/Document.h>#include <WebCore/Element.h>#include <WebCore/FrameView.h>#include <WebCore/HTMLDocument.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/IntRect.h>#include <WebCore/RenderObject.h>#include <WebCore/RenderTextControl.h>#pragma warning(pop)using namespace WebCore;using namespace HTMLNames;// DOMHTMLCollectionDOMHTMLCollection::DOMHTMLCollection(WebCore::HTMLCollection* c): m_collection(c){}IDOMHTMLCollection* DOMHTMLCollection::createInstance(WebCore::HTMLCollection* c){ if (!c) return 0; IDOMHTMLCollection* htmlCollection = 0; DOMHTMLCollection* newCollection = new DOMHTMLCollection(c); if (FAILED(newCollection->QueryInterface(IID_IDOMHTMLCollection, (void**)&htmlCollection))) { delete newCollection; return 0; } return htmlCollection;}// DOMHTMLCollection - IUnknown -----------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLCollection::QueryInterface(REFIID riid, void** ppvObject){ *ppvObject = 0; if (IsEqualGUID(riid, IID_IDOMHTMLCollection)) *ppvObject = static_cast<IDOMHTMLCollection*>(this); else return DOMObject::QueryInterface(riid, ppvObject); AddRef(); return S_OK;}// DOMHTMLCollection ----------------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLCollection::length( /* [retval][out] */ UINT* result){ *result = 0; if (!m_collection) return E_POINTER; *result = m_collection->length(); return S_OK;}HRESULT STDMETHODCALLTYPE DOMHTMLCollection::item( /* [in] */ UINT index, /* [retval][out] */ IDOMNode** node){ *node = 0; if (!m_collection) return E_POINTER; *node = DOMNode::createInstance(m_collection->item(index)); return *node ? S_OK : E_FAIL;}HRESULT STDMETHODCALLTYPE DOMHTMLCollection::namedItem( /* [in] */ BSTR /*name*/, /* [retval][out] */ IDOMNode** /*node*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}// DOMHTMLOptionsCollection - IUnknown ----------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::QueryInterface(REFIID riid, void** ppvObject){ *ppvObject = 0; if (IsEqualGUID(riid, IID_IDOMHTMLOptionsCollection)) *ppvObject = static_cast<IDOMHTMLOptionsCollection*>(this); else return DOMObject::QueryInterface(riid, ppvObject); AddRef(); return S_OK;}// DOMHTMLOptionsCollection ---------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::length( /* [retval][out] */ unsigned int* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::setLength( /* [in] */ unsigned int /*length*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::item( /* [in] */ unsigned int /*index*/, /* [retval][out] */ IDOMNode** /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}HRESULT STDMETHODCALLTYPE DOMHTMLOptionsCollection::namedItem( /* [in] */ BSTR /*name*/, /* [retval][out] */ IDOMNode* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}// DOMHTMLDocument - IUnknown -------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLDocument::QueryInterface(REFIID riid, void** ppvObject){ *ppvObject = 0; if (IsEqualGUID(riid, IID_IDOMHTMLDocument)) *ppvObject = static_cast<IDOMHTMLDocument*>(this); else return DOMDocument::QueryInterface(riid, ppvObject); AddRef(); return S_OK;}// DOMHTMLDocument ------------------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLDocument::title( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::setTitle( /* [in] */ BSTR /*title*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::referrer( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::domain( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::URL( /* [retval][out] */ BSTR* result){ if (!result) return E_POINTER; *result = BString(static_cast<HTMLDocument*>(m_document)->url()).release(); return S_OK;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::body( /* [retval][out] */ IDOMHTMLElement** bodyElement){ *bodyElement = 0; if (!m_document || !m_document->isHTMLDocument()) return E_FAIL; HTMLDocument* htmlDoc = static_cast<HTMLDocument*>(m_document); COMPtr<IDOMElement> domElement; domElement.adoptRef(DOMHTMLElement::createInstance(htmlDoc->body())); if (domElement) return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) bodyElement); return E_FAIL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::setBody( /* [in] */ IDOMHTMLElement* /*body*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::images( /* [retval][out] */ IDOMHTMLCollection** /*collection*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::applets( /* [retval][out] */ IDOMHTMLCollection** /*collection*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::links( /* [retval][out] */ IDOMHTMLCollection** /*collection*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::forms( /* [retval][out] */ IDOMHTMLCollection** collection){ *collection = 0; if (!m_document || !m_document->isHTMLDocument()) return E_FAIL; HTMLDocument* htmlDoc = static_cast<HTMLDocument*>(m_document); *collection = DOMHTMLCollection::createInstance(htmlDoc->forms().get()); return S_OK;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::anchors( /* [retval][out] */ IDOMHTMLCollection** /*collection*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::cookie( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::setCookie( /* [in] */ BSTR /*cookie*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::open( void){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::close( void){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::write( /* [in] */ BSTR /*text*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::writeln( /* [in] */ BSTR /*text*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::getElementById_( /* [in] */ BSTR /*elementId*/, /* [retval][out] */ IDOMElement** /*element*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLDocument::getElementsByName( /* [in] */ BSTR /*elementName*/, /* [retval][out] */ IDOMNodeList** /*nodeList*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}// DOMHTMLElement - IUnknown --------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLElement::QueryInterface(REFIID riid, void** ppvObject){ *ppvObject = 0; if (IsEqualGUID(riid, IID_IDOMHTMLElement)) *ppvObject = static_cast<IDOMHTMLElement*>(this); else return DOMElement::QueryInterface(riid, ppvObject); AddRef(); return S_OK;}// DOMHTMLElement -------------------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLElement::idName( /* [retval][out] */ BSTR* result){ if (!result) return E_POINTER; ASSERT(m_element && m_element->isHTMLElement()); String idString = static_cast<HTMLElement*>(m_element)->id(); *result = BString(idString).release(); return S_OK;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setIdName( /* [in] */ BSTR /*idName*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::title( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setTitle( /* [in] */ BSTR /*title*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::lang( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setLang( /* [in] */ BSTR /*lang*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::dir( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setDir( /* [in] */ BSTR /*dir*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::className( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setClassName( /* [in] */ BSTR /*className*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;}HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerHTML( /* [retval][out] */ BSTR* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setInnerHTML( /* [in] */ BSTR /*html*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText( /* [retval][out] */ BSTR* result){ ASSERT(m_element && m_element->isHTMLElement()); WebCore::String innerTextString = static_cast<HTMLElement*>(m_element)->innerText(); *result = BString(innerTextString.characters(), innerTextString.length()).release(); return S_OK;} HRESULT STDMETHODCALLTYPE DOMHTMLElement::setInnerText( /* [in] */ BSTR text){ ASSERT(m_element && m_element->isHTMLElement()); HTMLElement* htmlEle = static_cast<HTMLElement*>(m_element); WebCore::String textString(text, SysStringLen(text)); WebCore::ExceptionCode ec = 0; htmlEle->setInnerText(textString, ec); return S_OK;}// DOMHTMLFormElement - IUnknown ----------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::QueryInterface(REFIID riid, void** ppvObject){ *ppvObject = 0; if (IsEqualGUID(riid, IID_IDOMHTMLFormElement)) *ppvObject = static_cast<IDOMHTMLFormElement*>(this); else return DOMHTMLElement::QueryInterface(riid, ppvObject); AddRef(); return S_OK;}// DOMHTMLFormElement ---------------------------------------------------------HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::elements( /* [retval][out] */ IDOMHTMLCollection** /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::length( /* [retval][out] */ int* /*result*/){ ASSERT_NOT_REACHED(); return E_NOTIMPL;} HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::name(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -