diff options
Diffstat (limited to 'tdehtml/dom')
59 files changed, 30640 insertions, 0 deletions
diff --git a/tdehtml/dom/CMakeLists.txt b/tdehtml/dom/CMakeLists.txt new file mode 100644 index 000000000..dd637f7bd --- /dev/null +++ b/tdehtml/dom/CMakeLists.txt @@ -0,0 +1,58 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${USE_EXCEPTIONS} ) + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdehtml + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/kio +) + + +##### headers ################################### + +install( FILES + dom_exception.h html_base.h html_inline.h + css_rule.h dom_html.h html_block.h html_list.h + css_stylesheet.h dom_misc.h html_document.h html_misc.h + css_value.h dom_node.h html_element.h html_object.h + dom_core.h dom_string.h html_form.h html_table.h + dom_doc.h dom_text.h html_head.h + dom_element.h dom_xml.h html_image.h + dom2_range.h dom2_traversal.h dom2_events.h + dom2_views.h + #css_extensions.h + DESTINATION ${INCLUDE_INSTALL_DIR}/dom ) + + +##### tdehtmldom-static ############################ + +set( target tdehtmldom ) + +set( ${target}_SRCS + dom_misc.cpp html_block.cpp html_inline.cpp css_rule.cpp + dom_node.cpp html_document.cpp html_list.cpp css_stylesheet.cpp + dom_string.cpp html_element.cpp html_misc.cpp css_value.cpp + dom_text.cpp html_object.cpp dom_doc.cpp dom_xml.cpp + html_head.cpp dom_element.cpp html_base.cpp html_image.cpp + html_form.cpp dom2_range.cpp html_table.cpp dom2_traversal.cpp + dom2_events.cpp dom2_views.cpp + #css_extensions.cpp +) + +tde_add_library( ${target} STATIC_PIC AUTOMOC + SOURCES ${${target}_SRCS} +) diff --git a/tdehtml/dom/Makefile.am b/tdehtml/dom/Makefile.am new file mode 100644 index 000000000..6a33de62d --- /dev/null +++ b/tdehtml/dom/Makefile.am @@ -0,0 +1,58 @@ +# This file is part of the KDE libraries +# Copyright (C) 1997 Martin Jones (mjones@kde.org) +# (C) 1997 Torben Weis (weis@kde.org) + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. + +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public License +# along with this library; see the file COPYING.LIB. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +KDE_CXXFLAGS = $(USE_EXCEPTIONS) $(WOVERLOADED_VIRTUAL) + +noinst_LTLIBRARIES = libtdehtmldom.la +libtdehtmldom_la_SOURCES = \ + dom_misc.cpp html_block.cpp html_inline.cpp \ + css_rule.cpp dom_node.cpp html_document.cpp html_list.cpp \ + css_stylesheet.cpp dom_string.cpp html_element.cpp html_misc.cpp \ + css_value.cpp dom_text.cpp html_object.cpp \ + dom_doc.cpp dom_xml.cpp html_head.cpp \ + dom_element.cpp html_base.cpp html_image.cpp html_form.cpp \ + dom2_range.cpp html_table.cpp dom2_traversal.cpp dom2_events.cpp \ + dom2_views.cpp +# css_extensions.cpp + +libtdehtmldom_la_METASOURCES = AUTO + +myincludedir = $(includedir)/dom +myinclude_HEADERS = \ + dom_exception.h html_base.h html_inline.h \ + css_rule.h dom_html.h html_block.h html_list.h \ + css_stylesheet.h dom_misc.h html_document.h html_misc.h \ + css_value.h dom_node.h html_element.h html_object.h \ + dom_core.h dom_string.h html_form.h html_table.h \ + dom_doc.h dom_text.h html_head.h \ + dom_element.h dom_xml.h html_image.h \ + dom2_range.h dom2_traversal.h dom2_events.h \ + dom2_views.h +# css_extensions.h + +INCLUDES = -I$(top_srcdir)/kimgio -I$(top_srcdir)/kio -I$(top_srcdir)/dcop \ + -I$(top_srcdir)/tdehtml -I$(top_srcdir) $(all_includes) + +SRCDOC_DEST=$(kde_htmldir)/en/tdelibs/tdehtml + +## generate lib documentation +srcdoc: + $(mkinstalldirs) $(SRCDOC_DEST) + kdoc -H -d $(SRCDOC_DEST) tdecore -lqt + diff --git a/tdehtml/dom/css_extensions.cpp b/tdehtml/dom/css_extensions.cpp new file mode 100644 index 000000000..23f7739dc --- /dev/null +++ b/tdehtml/dom/css_extensions.cpp @@ -0,0 +1,2043 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "dom_exception.h" +#include "dom_string.h" + +#include "css_extensions.h" +#include "css_extensionsimpl.h" +using namespace DOM; + + +CSS2Azimuth::CSS2Azimuth() : CSSValue() +{ +} + +CSS2Azimuth::CSS2Azimuth(const CSS2Azimuth &other) : CSSValue(other) +{ +} + +CSS2Azimuth::CSS2Azimuth(CSS2AzimuthImpl *impl) : CSSValue(impl) +{ +} + +CSS2Azimuth &CSS2Azimuth::operator = (const CSS2Azimuth &other) +{ + CSSValue::operator = (other); + return *this; +} + +CSS2Azimuth::~CSS2Azimuth() +{ +} + +unsigned short CSS2Azimuth::azimuthType() const +{ + if(!impl) return 0; + return ((CSS2AzimuthImpl *)impl)->azimuthType(); +} + +DOMString CSS2Azimuth::identifier() const +{ + if(!impl) return 0; + return ((CSS2AzimuthImpl *)impl)->identifier(); +} + +bool CSS2Azimuth::behind() const +{ + if(!impl) return 0; + return ((CSS2AzimuthImpl *)impl)->behind(); +} + +void CSS2Azimuth::setAngleValue( const unsigned short unitType, const float floatValue ) +{ + if(impl) + ((CSS2AzimuthImpl *)impl)->setAngleValue( unitType, floatValue ); +} + +float CSS2Azimuth::getAngleValue( const unsigned short unitType ) +{ + if(!impl) return 0; + return ((CSS2AzimuthImpl *)impl)->getAngleValue( unitType ); +} + +void CSS2Azimuth::setIdentifier( const DOMString &identifier, const bool behind ) +{ + if(impl) + ((CSS2AzimuthImpl *)impl)->setIdentifier( identifier, behind ); +} + + + +CSS2BackgroundPosition::CSS2BackgroundPosition() : CSSValue() +{ +} + +CSS2BackgroundPosition::CSS2BackgroundPosition(const CSS2BackgroundPosition &other) : CSSValue(other) +{ +} + +CSS2BackgroundPosition::CSS2BackgroundPosition(CSS2BackgroundPositionImpl *impl) : CSSValue(impl) +{ +} + +CSS2BackgroundPosition &CSS2BackgroundPosition::operator = (const CSS2BackgroundPosition &other) +{ + CSSValue::operator = (other); + return *this; +} + +CSS2BackgroundPosition::~CSS2BackgroundPosition() +{ +} + +unsigned short CSS2BackgroundPosition::horizontalType() const +{ + if(!impl) return 0; + return ((CSS2BackgroundPositionImpl *)impl)->horizontalType(); +} + +unsigned short CSS2BackgroundPosition::verticalType() const +{ + if(!impl) return 0; + return ((CSS2BackgroundPositionImpl *)impl)->verticalType(); +} + +DOMString CSS2BackgroundPosition::horizontalIdentifier() const +{ + if(!impl) return 0; + return ((CSS2BackgroundPositionImpl *)impl)->horizontalIdentifier(); +} + +DOMString CSS2BackgroundPosition::verticalIdentifier() const +{ + if(!impl) return 0; + return ((CSS2BackgroundPositionImpl *)impl)->verticalIdentifier(); +} + +float CSS2BackgroundPosition::getHorizontalPosition( const float horizontalType ) +{ + if(!impl) return 0; + return ((CSS2BackgroundPositionImpl *)impl)->getHorizontalPosition( horizontalType ); +} + +float CSS2BackgroundPosition::getVerticalPosition( const float verticalType ) +{ + if(!impl) return 0; + return ((CSS2BackgroundPositionImpl *)impl)->getVerticalPosition( verticalType ); +} + +void CSS2BackgroundPosition::setHorizontalPosition( const unsigned short horizontalType, const float value ) +{ + if(impl) + ((CSS2BackgroundPositionImpl *)impl)->setHorizontalPosition( horizontalType, value ); +} + +void CSS2BackgroundPosition::setVerticalPosition( const unsigned short verticalType, const float value ) +{ + if(impl) + ((CSS2BackgroundPositionImpl *)impl)->setVerticalPosition( verticalType, value ); +} + +void CSS2BackgroundPosition::setPositionIdentifier( const DOMString &horizontalIdentifier, const DOMString &verticalIdentifier ) +{ + if(impl) + ((CSS2BackgroundPositionImpl *)impl)->setPositionIdentifier( horizontalIdentifier, verticalIdentifier ); +} + + + +CSS2BorderSpacing::CSS2BorderSpacing() : CSSValue() +{ +} + +CSS2BorderSpacing::CSS2BorderSpacing(const CSS2BorderSpacing &other) : CSSValue(other) +{ +} + +CSS2BorderSpacing::CSS2BorderSpacing(CSS2BorderSpacingImpl *impl) : CSSValue(impl) +{ +} + +CSS2BorderSpacing &CSS2BorderSpacing::operator = (const CSS2BorderSpacing &other) +{ + CSSValue::operator = (other); + return *this; +} + +CSS2BorderSpacing::~CSS2BorderSpacing() +{ +} + +unsigned short CSS2BorderSpacing::horizontalType() const +{ + if(!impl) return 0; + return ((CSS2BorderSpacingImpl *)impl)->horizontalType(); +} + +unsigned short CSS2BorderSpacing::verticalType() const +{ + if(!impl) return 0; + return ((CSS2BorderSpacingImpl *)impl)->verticalType(); +} + +float CSS2BorderSpacing::getHorizontalSpacing( const float horizontalType ) +{ + if(!impl) return 0; + return ((CSS2BorderSpacingImpl *)impl)->getHorizontalSpacing( horizontalType ); +} + +float CSS2BorderSpacing::getVerticalSpacing( const float verticalType ) +{ + if(!impl) return 0; + return ((CSS2BorderSpacingImpl *)impl)->getVerticalSpacing( verticalType ); +} + +void CSS2BorderSpacing::setHorizontalSpacing( const unsigned short horizontalType, const float value ) +{ + if(impl) + ((CSS2BorderSpacingImpl *)impl)->setHorizontalSpacing( horizontalType, value ); +} + +void CSS2BorderSpacing::setVerticalSpacing( const unsigned short verticalType, const float value ) +{ + if(impl) + ((CSS2BorderSpacingImpl *)impl)->setVerticalSpacing( verticalType, value ); +} + +void CSS2BorderSpacing::setInherit() +{ + if(impl) + ((CSS2BorderSpacingImpl *)impl)->setInherit(); +} + + + +CSS2CounterIncrement::CSS2CounterIncrement() +{ +} + +CSS2CounterIncrement::CSS2CounterIncrement(const CSS2CounterIncrement &other) +{ +} + +CSS2CounterIncrement::CSS2CounterIncrement(CSS2CounterIncrementImpl *impl) +{ +} + +CSS2CounterIncrement &CSS2CounterIncrement::operator = (const CSS2CounterIncrement &other) +{ + ::operator = (other); + return *this; +} + +CSS2CounterIncrement::~CSS2CounterIncrement() +{ +} + +DOMString CSS2CounterIncrement::identifier() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("identifier"); +} + +void CSS2CounterIncrement::setIdentifier( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("identifier", value); +} + +short CSS2CounterIncrement::increment() const +{ + if(!impl) return 0; + return ((CSS2CounterIncrementImpl *)impl)->increment(); +} + +void CSS2CounterIncrement::setIncrement( const short _increment ) +{ + + if(impl) + ((CSS2CounterIncrementImpl *)impl)->setIncrement( _increment ); +} + + + + +CSS2CounterReset::CSS2CounterReset() +{ +} + +CSS2CounterReset::CSS2CounterReset(const CSS2CounterReset &other) +{ +} + +CSS2CounterReset::CSS2CounterReset(CSS2CounterResetImpl *impl) +{ +} + +CSS2CounterReset &CSS2CounterReset::operator = (const CSS2CounterReset &other) +{ + ::operator = (other); + return *this; +} + +CSS2CounterReset::~CSS2CounterReset() +{ +} + +DOMString CSS2CounterReset::identifier() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("identifier"); +} + +void CSS2CounterReset::setIdentifier( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("identifier", value); +} + +short CSS2CounterReset::reset() const +{ + if(!impl) return 0; + return ((CSS2CounterResetImpl *)impl)->reset(); +} + +void CSS2CounterReset::setReset( const short _reset ) +{ + + if(impl) + ((CSS2CounterResetImpl *)impl)->setReset( _reset ); +} + + + + +CSS2Cursor::CSS2Cursor() : CSSValue() +{ +} + +CSS2Cursor::CSS2Cursor(const CSS2Cursor &other) : CSSValue(other) +{ +} + +CSS2Cursor::CSS2Cursor(CSS2CursorImpl *impl) : CSSValue(impl) +{ +} + +CSS2Cursor &CSS2Cursor::operator = (const CSS2Cursor &other) +{ + CSSValue::operator = (other); + return *this; +} + +CSS2Cursor::~CSS2Cursor() +{ +} + +unsigned short CSS2Cursor::cursorType() const +{ + if(!impl) return 0; + return ((CSS2CursorImpl *)impl)->cursorType(); +} + +void CSS2Cursor::setCursorType( const unsigned short _cursorType ) +{ + + if(impl) + ((CSS2CursorImpl *)impl)->setCursorType( _cursorType ); +} + +CSSValueList CSS2Cursor::uris() const +{ + if(!impl) return 0; + return ((CSS2CursorImpl *)impl)->uris(); +} + +DOMString CSS2Cursor::predefinedCursor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("predefinedCursor"); +} + +void CSS2Cursor::setPredefinedCursor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("predefinedCursor", value); +} + + + +CSS2FontFaceSrc::CSS2FontFaceSrc() +{ +} + +CSS2FontFaceSrc::CSS2FontFaceSrc(const CSS2FontFaceSrc &other) +{ +} + +CSS2FontFaceSrc::CSS2FontFaceSrc(CSS2FontFaceSrcImpl *impl) +{ +} + +CSS2FontFaceSrc &CSS2FontFaceSrc::operator = (const CSS2FontFaceSrc &other) +{ + ::operator = (other); + return *this; +} + +CSS2FontFaceSrc::~CSS2FontFaceSrc() +{ +} + +DOMString CSS2FontFaceSrc::uri() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("uri"); +} + +void CSS2FontFaceSrc::setUri( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("uri", value); +} + +CSSValueList CSS2FontFaceSrc::format() const +{ + if(!impl) return 0; + return ((CSS2FontFaceSrcImpl *)impl)->format(); +} + +DOMString CSS2FontFaceSrc::fontFaceName() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontFaceName"); +} + +void CSS2FontFaceSrc::setFontFaceName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontFaceName", value); +} + + + +CSS2FontFaceWidths::CSS2FontFaceWidths() +{ +} + +CSS2FontFaceWidths::CSS2FontFaceWidths(const CSS2FontFaceWidths &other) +{ +} + +CSS2FontFaceWidths::CSS2FontFaceWidths(CSS2FontFaceWidthsImpl *impl) +{ +} + +CSS2FontFaceWidths &CSS2FontFaceWidths::operator = (const CSS2FontFaceWidths &other) +{ + ::operator = (other); + return *this; +} + +CSS2FontFaceWidths::~CSS2FontFaceWidths() +{ +} + +DOMString CSS2FontFaceWidths::urange() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("urange"); +} + +void CSS2FontFaceWidths::setUrange( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("urange", value); +} + +CSSValueList CSS2FontFaceWidths::numbers() const +{ + if(!impl) return 0; + return ((CSS2FontFaceWidthsImpl *)impl)->numbers(); +} + + + + +CSS2PageSize::CSS2PageSize() : CSSValue() +{ +} + +CSS2PageSize::CSS2PageSize(const CSS2PageSize &other) : CSSValue(other) +{ +} + +CSS2PageSize::CSS2PageSize(CSS2PageSizeImpl *impl) : CSSValue(impl) +{ +} + +CSS2PageSize &CSS2PageSize::operator = (const CSS2PageSize &other) +{ + CSSValue::operator = (other); + return *this; +} + +CSS2PageSize::~CSS2PageSize() +{ +} + +unsigned short CSS2PageSize::widthType() const +{ + if(!impl) return 0; + return ((CSS2PageSizeImpl *)impl)->widthType(); +} + +unsigned short CSS2PageSize::heightType() const +{ + if(!impl) return 0; + return ((CSS2PageSizeImpl *)impl)->heightType(); +} + +DOMString CSS2PageSize::identifier() const +{ + if(!impl) return 0; + return ((CSS2PageSizeImpl *)impl)->identifier(); +} + +float CSS2PageSize::getWidth( const float widthType ) +{ + if(!impl) return 0; + return ((CSS2PageSizeImpl *)impl)->getWidth( widthType ); +} + +float CSS2PageSize::getHeightSize( const float heightType ) +{ + if(!impl) return 0; + return ((CSS2PageSizeImpl *)impl)->getHeightSize( heightType ); +} + +void CSS2PageSize::setWidthSize( const unsigned short widthType, const float value ) +{ + if(impl) + ((CSS2PageSizeImpl *)impl)->setWidthSize( widthType, value ); +} + +void CSS2PageSize::setHeightSize( const unsigned short heightType, const float value ) +{ + if(impl) + ((CSS2PageSizeImpl *)impl)->setHeightSize( heightType, value ); +} + +void CSS2PageSize::setIdentifier( const DOMString &identifier ) +{ + if(impl) + ((CSS2PageSizeImpl *)impl)->setIdentifier( identifier ); +} + + + +CSS2PlayDuring::CSS2PlayDuring() : CSSValue() +{ +} + +CSS2PlayDuring::CSS2PlayDuring(const CSS2PlayDuring &other) : CSSValue(other) +{ +} + +CSS2PlayDuring::CSS2PlayDuring(CSS2PlayDuringImpl *impl) : CSSValue(impl) +{ +} + +CSS2PlayDuring &CSS2PlayDuring::operator = (const CSS2PlayDuring &other) +{ + CSSValue::operator = (other); + return *this; +} + +CSS2PlayDuring::~CSS2PlayDuring() +{ +} + +unsigned short CSS2PlayDuring::playDuringType() const +{ + if(!impl) return 0; + return ((CSS2PlayDuringImpl *)impl)->playDuringType(); +} + +DOMString CSS2PlayDuring::playDuringIdentifier() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("playDuringIdentifier"); +} + +void CSS2PlayDuring::setPlayDuringIdentifier( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("playDuringIdentifier", value); +} + +DOMString CSS2PlayDuring::uri() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("uri"); +} + +void CSS2PlayDuring::setUri( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("uri", value); +} + +bool CSS2PlayDuring::mix() const +{ + if(!impl) return 0; + return ((CSS2PlayDuringImpl *)impl)->mix(); +} + +void CSS2PlayDuring::setMix( const bool _mix ) +{ + + if(impl) + ((CSS2PlayDuringImpl *)impl)->setMix( _mix ); +} + +bool CSS2PlayDuring::repeat() const +{ + if(!impl) return 0; + return ((CSS2PlayDuringImpl *)impl)->repeat(); +} + +void CSS2PlayDuring::setRepeat( const bool _repeat ) +{ + + if(impl) + ((CSS2PlayDuringImpl *)impl)->setRepeat( _repeat ); +} + + + +CSS2Properties::CSS2Properties() +{ +} + +CSS2Properties::CSS2Properties(const CSS2Properties &other) +{ +} + +CSS2Properties::CSS2Properties(CSS2PropertiesImpl *impl) +{ +} + +CSS2Properties &CSS2Properties::operator = (const CSS2Properties &other) +{ + ::operator = (other); + return *this; +} + +CSS2Properties::~CSS2Properties() +{ +} + +DOMString CSS2Properties::azimuth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("azimuth"); +} + +void CSS2Properties::setAzimuth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("azimuth", value); +} + +DOMString CSS2Properties::background() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("background"); +} + +void CSS2Properties::setBackground( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("background", value); +} + +DOMString CSS2Properties::backgroundAttachment() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("backgroundAttachment"); +} + +void CSS2Properties::setBackgroundAttachment( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("backgroundAttachment", value); +} + +DOMString CSS2Properties::backgroundColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("backgroundColor"); +} + +void CSS2Properties::setBackgroundColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("backgroundColor", value); +} + +DOMString CSS2Properties::backgroundImage() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("backgroundImage"); +} + +void CSS2Properties::setBackgroundImage( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("backgroundImage", value); +} + +DOMString CSS2Properties::backgroundPosition() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("backgroundPosition"); +} + +void CSS2Properties::setBackgroundPosition( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("backgroundPosition", value); +} + +DOMString CSS2Properties::backgroundRepeat() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("backgroundRepeat"); +} + +void CSS2Properties::setBackgroundRepeat( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("backgroundRepeat", value); +} + +DOMString CSS2Properties::border() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("border"); +} + +void CSS2Properties::setBorder( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("border", value); +} + +DOMString CSS2Properties::borderCollapse() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderCollapse"); +} + +void CSS2Properties::setBorderCollapse( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderCollapse", value); +} + +DOMString CSS2Properties::borderColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderColor"); +} + +void CSS2Properties::setBorderColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderColor", value); +} + +DOMString CSS2Properties::borderSpacing() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderSpacing"); +} + +void CSS2Properties::setBorderSpacing( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderSpacing", value); +} + +DOMString CSS2Properties::borderStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderStyle"); +} + +void CSS2Properties::setBorderStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderStyle", value); +} + +DOMString CSS2Properties::borderTop() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderTop"); +} + +void CSS2Properties::setBorderTop( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderTop", value); +} + +DOMString CSS2Properties::borderRight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderRight"); +} + +void CSS2Properties::setBorderRight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderRight", value); +} + +DOMString CSS2Properties::borderBottom() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderBottom"); +} + +void CSS2Properties::setBorderBottom( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderBottom", value); +} + +DOMString CSS2Properties::borderLeft() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderLeft"); +} + +void CSS2Properties::setBorderLeft( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderLeft", value); +} + +DOMString CSS2Properties::borderTopColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderTopColor"); +} + +void CSS2Properties::setBorderTopColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderTopColor", value); +} + +DOMString CSS2Properties::borderRightColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderRightColor"); +} + +void CSS2Properties::setBorderRightColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderRightColor", value); +} + +DOMString CSS2Properties::borderBottomColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderBottomColor"); +} + +void CSS2Properties::setBorderBottomColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderBottomColor", value); +} + +DOMString CSS2Properties::borderLeftColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderLeftColor"); +} + +void CSS2Properties::setBorderLeftColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderLeftColor", value); +} + +DOMString CSS2Properties::borderTopStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderTopStyle"); +} + +void CSS2Properties::setBorderTopStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderTopStyle", value); +} + +DOMString CSS2Properties::borderRightStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderRightStyle"); +} + +void CSS2Properties::setBorderRightStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderRightStyle", value); +} + +DOMString CSS2Properties::borderBottomStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderBottomStyle"); +} + +void CSS2Properties::setBorderBottomStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderBottomStyle", value); +} + +DOMString CSS2Properties::borderLeftStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderLeftStyle"); +} + +void CSS2Properties::setBorderLeftStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderLeftStyle", value); +} + +DOMString CSS2Properties::borderTopWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderTopWidth"); +} + +void CSS2Properties::setBorderTopWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderTopWidth", value); +} + +DOMString CSS2Properties::borderRightWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderRightWidth"); +} + +void CSS2Properties::setBorderRightWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderRightWidth", value); +} + +DOMString CSS2Properties::borderBottomWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderBottomWidth"); +} + +void CSS2Properties::setBorderBottomWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderBottomWidth", value); +} + +DOMString CSS2Properties::borderLeftWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderLeftWidth"); +} + +void CSS2Properties::setBorderLeftWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderLeftWidth", value); +} + +DOMString CSS2Properties::borderWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("borderWidth"); +} + +void CSS2Properties::setBorderWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("borderWidth", value); +} + +DOMString CSS2Properties::bottom() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("bottom"); +} + +void CSS2Properties::setBottom( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("bottom", value); +} + +DOMString CSS2Properties::captionSide() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("captionSide"); +} + +void CSS2Properties::setCaptionSide( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("captionSide", value); +} + +DOMString CSS2Properties::clear() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("clear"); +} + +void CSS2Properties::setClear( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("clear", value); +} + +DOMString CSS2Properties::clip() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("clip"); +} + +void CSS2Properties::setClip( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("clip", value); +} + +DOMString CSS2Properties::color() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("color"); +} + +void CSS2Properties::setColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("color", value); +} + +DOMString CSS2Properties::content() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("content"); +} + +void CSS2Properties::setContent( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("content", value); +} + +DOMString CSS2Properties::counterIncrement() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("counterIncrement"); +} + +void CSS2Properties::setCounterIncrement( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("counterIncrement", value); +} + +DOMString CSS2Properties::counterReset() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("counterReset"); +} + +void CSS2Properties::setCounterReset( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("counterReset", value); +} + +DOMString CSS2Properties::cue() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("cue"); +} + +void CSS2Properties::setCue( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("cue", value); +} + +DOMString CSS2Properties::cueAfter() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("cueAfter"); +} + +void CSS2Properties::setCueAfter( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("cueAfter", value); +} + +DOMString CSS2Properties::cueBefore() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("cueBefore"); +} + +void CSS2Properties::setCueBefore( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("cueBefore", value); +} + +DOMString CSS2Properties::cursor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("cursor"); +} + +void CSS2Properties::setCursor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("cursor", value); +} + +DOMString CSS2Properties::direction() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("direction"); +} + +void CSS2Properties::setDirection( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("direction", value); +} + +DOMString CSS2Properties::display() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("display"); +} + +void CSS2Properties::setDisplay( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("display", value); +} + +DOMString CSS2Properties::elevation() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("elevation"); +} + +void CSS2Properties::setElevation( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("elevation", value); +} + +DOMString CSS2Properties::emptyCells() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("emptyCells"); +} + +void CSS2Properties::setEmptyCells( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("emptyCells", value); +} + +DOMString CSS2Properties::cssFloat() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("cssFloat"); +} + +void CSS2Properties::setCssFloat( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("cssFloat", value); +} + +DOMString CSS2Properties::font() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("font"); +} + +void CSS2Properties::setFont( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("font", value); +} + +DOMString CSS2Properties::fontFamily() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontFamily"); +} + +void CSS2Properties::setFontFamily( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontFamily", value); +} + +DOMString CSS2Properties::fontSize() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontSize"); +} + +void CSS2Properties::setFontSize( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontSize", value); +} + +DOMString CSS2Properties::fontSizeAdjust() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontSizeAdjust"); +} + +void CSS2Properties::setFontSizeAdjust( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontSizeAdjust", value); +} + +DOMString CSS2Properties::fontStretch() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontStretch"); +} + +void CSS2Properties::setFontStretch( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontStretch", value); +} + +DOMString CSS2Properties::fontStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontStyle"); +} + +void CSS2Properties::setFontStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontStyle", value); +} + +DOMString CSS2Properties::fontVariant() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontVariant"); +} + +void CSS2Properties::setFontVariant( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontVariant", value); +} + +DOMString CSS2Properties::fontWeight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("fontWeight"); +} + +void CSS2Properties::setFontWeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("fontWeight", value); +} + +DOMString CSS2Properties::height() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("height"); +} + +void CSS2Properties::setHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("height", value); +} + +DOMString CSS2Properties::left() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("left"); +} + +void CSS2Properties::setLeft( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("left", value); +} + +DOMString CSS2Properties::letterSpacing() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("letterSpacing"); +} + +void CSS2Properties::setLetterSpacing( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("letterSpacing", value); +} + +DOMString CSS2Properties::lineHeight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("lineHeight"); +} + +void CSS2Properties::setLineHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("lineHeight", value); +} + +DOMString CSS2Properties::listStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("listStyle"); +} + +void CSS2Properties::setListStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("listStyle", value); +} + +DOMString CSS2Properties::listStyleImage() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("listStyleImage"); +} + +void CSS2Properties::setListStyleImage( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("listStyleImage", value); +} + +DOMString CSS2Properties::listStylePosition() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("listStylePosition"); +} + +void CSS2Properties::setListStylePosition( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("listStylePosition", value); +} + +DOMString CSS2Properties::listStyleType() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("listStyleType"); +} + +void CSS2Properties::setListStyleType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("listStyleType", value); +} + +DOMString CSS2Properties::margin() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("margin"); +} + +void CSS2Properties::setMargin( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("margin", value); +} + +DOMString CSS2Properties::marginTop() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("marginTop"); +} + +void CSS2Properties::setMarginTop( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("marginTop", value); +} + +DOMString CSS2Properties::marginRight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("marginRight"); +} + +void CSS2Properties::setMarginRight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("marginRight", value); +} + +DOMString CSS2Properties::marginBottom() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("marginBottom"); +} + +void CSS2Properties::setMarginBottom( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("marginBottom", value); +} + +DOMString CSS2Properties::marginLeft() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("marginLeft"); +} + +void CSS2Properties::setMarginLeft( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("marginLeft", value); +} + +DOMString CSS2Properties::markerOffset() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("markerOffset"); +} + +void CSS2Properties::setMarkerOffset( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("markerOffset", value); +} + +DOMString CSS2Properties::marks() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("marks"); +} + +void CSS2Properties::setMarks( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("marks", value); +} + +DOMString CSS2Properties::maxHeight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("maxHeight"); +} + +void CSS2Properties::setMaxHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("maxHeight", value); +} + +DOMString CSS2Properties::maxWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("maxWidth"); +} + +void CSS2Properties::setMaxWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("maxWidth", value); +} + +DOMString CSS2Properties::minHeight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("minHeight"); +} + +void CSS2Properties::setMinHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("minHeight", value); +} + +DOMString CSS2Properties::minWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("minWidth"); +} + +void CSS2Properties::setMinWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("minWidth", value); +} + +DOMString CSS2Properties::orphans() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("orphans"); +} + +void CSS2Properties::setOrphans( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("orphans", value); +} + +DOMString CSS2Properties::outline() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("outline"); +} + +void CSS2Properties::setOutline( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("outline", value); +} + +DOMString CSS2Properties::outlineColor() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("outlineColor"); +} + +void CSS2Properties::setOutlineColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("outlineColor", value); +} + +DOMString CSS2Properties::outlineStyle() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("outlineStyle"); +} + +void CSS2Properties::setOutlineStyle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("outlineStyle", value); +} + +DOMString CSS2Properties::outlineWidth() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("outlineWidth"); +} + +void CSS2Properties::setOutlineWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("outlineWidth", value); +} + +DOMString CSS2Properties::overflow() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("overflow"); +} + +void CSS2Properties::setOverflow( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("overflow", value); +} + +DOMString CSS2Properties::padding() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("padding"); +} + +void CSS2Properties::setPadding( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("padding", value); +} + +DOMString CSS2Properties::paddingTop() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("paddingTop"); +} + +void CSS2Properties::setPaddingTop( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("paddingTop", value); +} + +DOMString CSS2Properties::paddingRight() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("paddingRight"); +} + +void CSS2Properties::setPaddingRight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("paddingRight", value); +} + +DOMString CSS2Properties::paddingBottom() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("paddingBottom"); +} + +void CSS2Properties::setPaddingBottom( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("paddingBottom", value); +} + +DOMString CSS2Properties::paddingLeft() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("paddingLeft"); +} + +void CSS2Properties::setPaddingLeft( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("paddingLeft", value); +} + +DOMString CSS2Properties::page() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("page"); +} + +void CSS2Properties::setPage( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("page", value); +} + +DOMString CSS2Properties::pageBreakAfter() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pageBreakAfter"); +} + +void CSS2Properties::setPageBreakAfter( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pageBreakAfter", value); +} + +DOMString CSS2Properties::pageBreakBefore() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pageBreakBefore"); +} + +void CSS2Properties::setPageBreakBefore( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pageBreakBefore", value); +} + +DOMString CSS2Properties::pageBreakInside() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pageBreakInside"); +} + +void CSS2Properties::setPageBreakInside( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pageBreakInside", value); +} + +DOMString CSS2Properties::pause() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pause"); +} + +void CSS2Properties::setPause( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pause", value); +} + +DOMString CSS2Properties::pauseAfter() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pauseAfter"); +} + +void CSS2Properties::setPauseAfter( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pauseAfter", value); +} + +DOMString CSS2Properties::pauseBefore() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pauseBefore"); +} + +void CSS2Properties::setPauseBefore( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pauseBefore", value); +} + +DOMString CSS2Properties::pitch() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pitch"); +} + +void CSS2Properties::setPitch( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pitch", value); +} + +DOMString CSS2Properties::pitchRange() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("pitchRange"); +} + +void CSS2Properties::setPitchRange( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("pitchRange", value); +} + +DOMString CSS2Properties::playDuring() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("playDuring"); +} + +void CSS2Properties::setPlayDuring( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("playDuring", value); +} + +DOMString CSS2Properties::position() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("position"); +} + +void CSS2Properties::setPosition( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("position", value); +} + +DOMString CSS2Properties::quotes() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("quotes"); +} + +void CSS2Properties::setQuotes( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("quotes", value); +} + +DOMString CSS2Properties::richness() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("richness"); +} + +void CSS2Properties::setRichness( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("richness", value); +} + +DOMString CSS2Properties::right() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("right"); +} + +void CSS2Properties::setRight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("right", value); +} + +DOMString CSS2Properties::size() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("size"); +} + +void CSS2Properties::setSize( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("size", value); +} + +DOMString CSS2Properties::speak() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("speak"); +} + +void CSS2Properties::setSpeak( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("speak", value); +} + +DOMString CSS2Properties::speakHeader() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("speakHeader"); +} + +void CSS2Properties::setSpeakHeader( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("speakHeader", value); +} + +DOMString CSS2Properties::speakNumeral() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("speakNumeral"); +} + +void CSS2Properties::setSpeakNumeral( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("speakNumeral", value); +} + +DOMString CSS2Properties::speakPunctuation() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("speakPunctuation"); +} + +void CSS2Properties::setSpeakPunctuation( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("speakPunctuation", value); +} + +DOMString CSS2Properties::speechRate() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("speechRate"); +} + +void CSS2Properties::setSpeechRate( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("speechRate", value); +} + +DOMString CSS2Properties::stress() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("stress"); +} + +void CSS2Properties::setStress( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("stress", value); +} + +DOMString CSS2Properties::tableLayout() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("tableLayout"); +} + +void CSS2Properties::setTableLayout( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("tableLayout", value); +} + +DOMString CSS2Properties::textAlign() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("textAlign"); +} + +void CSS2Properties::setTextAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("textAlign", value); +} + +DOMString CSS2Properties::textDecoration() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("textDecoration"); +} + +void CSS2Properties::setTextDecoration( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("textDecoration", value); +} + +DOMString CSS2Properties::textIndent() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("textIndent"); +} + +void CSS2Properties::setTextIndent( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("textIndent", value); +} + +DOMString CSS2Properties::textShadow() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("textShadow"); +} + +void CSS2Properties::setTextShadow( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("textShadow", value); +} + +DOMString CSS2Properties::textTransform() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("textTransform"); +} + +void CSS2Properties::setTextTransform( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("textTransform", value); +} + +DOMString CSS2Properties::top() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("top"); +} + +void CSS2Properties::setTop( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("top", value); +} + +DOMString CSS2Properties::unicodeBidi() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("unicodeBidi"); +} + +void CSS2Properties::setUnicodeBidi( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("unicodeBidi", value); +} + +DOMString CSS2Properties::verticalAlign() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("verticalAlign"); +} + +void CSS2Properties::setVerticalAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("verticalAlign", value); +} + +DOMString CSS2Properties::visibility() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("visibility"); +} + +void CSS2Properties::setVisibility( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("visibility", value); +} + +DOMString CSS2Properties::voiceFamily() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("voiceFamily"); +} + +void CSS2Properties::setVoiceFamily( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("voiceFamily", value); +} + +DOMString CSS2Properties::volume() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("volume"); +} + +void CSS2Properties::setVolume( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("volume", value); +} + +DOMString CSS2Properties::whiteSpace() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("whiteSpace"); +} + +void CSS2Properties::setWhiteSpace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("whiteSpace", value); +} + +DOMString CSS2Properties::widows() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("widows"); +} + +void CSS2Properties::setWidows( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("widows", value); +} + +DOMString CSS2Properties::width() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("width"); +} + +void CSS2Properties::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("width", value); +} + +DOMString CSS2Properties::wordSpacing() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("wordSpacing"); +} + +void CSS2Properties::setWordSpacing( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("wordSpacing", value); +} + +DOMString CSS2Properties::zIndex() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute("zIndex"); +} + +void CSS2Properties::setZIndex( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute("zIndex", value); +} + + + +CSS2TextShadow::CSS2TextShadow() +{ +} + +CSS2TextShadow::CSS2TextShadow(const CSS2TextShadow &other) +{ +} + +CSS2TextShadow::CSS2TextShadow(CSS2TextShadowImpl *impl) +{ +} + +CSS2TextShadow &CSS2TextShadow::operator = (const CSS2TextShadow &other) +{ + ::operator = (other); + return *this; +} + +CSS2TextShadow::~CSS2TextShadow() +{ +} + +CSSValue CSS2TextShadow::color() const +{ + if(!impl) return 0; + return ((CSS2TextShadowImpl *)impl)->color(); +} + +CSSValue CSS2TextShadow::horizontal() const +{ + if(!impl) return 0; + return ((CSS2TextShadowImpl *)impl)->horizontal(); +} + +CSSValue CSS2TextShadow::vertical() const +{ + if(!impl) return 0; + return ((CSS2TextShadowImpl *)impl)->vertical(); +} + +CSSValue CSS2TextShadow::blur() const +{ + if(!impl) return 0; + return ((CSS2TextShadowImpl *)impl)->blur(); +} + + + diff --git a/tdehtml/dom/css_extensions.h b/tdehtml/dom/css_extensions.h new file mode 100644 index 000000000..a6cdb2149 --- /dev/null +++ b/tdehtml/dom/css_extensions.h @@ -0,0 +1,2702 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 2 Specification (Candidate Recommendation) + * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/ + * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. + * + */ +#ifndef _CSS_css_extensions_h_ +#define _CSS_css_extensions_h_ + +#include <css_value.h> +#include <dom/dom_string.h> + +namespace DOM { + +/** + * The \c CSS2Azimuth interface represents the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-azimuth"> + * azimuth </a> CSS Level 2 property. + * + */ +class CSS2Azimuth : public CSSValue +{ +public: + CSS2Azimuth(); + CSS2Azimuth(const CSS2Azimuth &other); + CSS2Azimuth(CSS2AzimuthImpl *impl); +public: + + CSS2Azimuth & operator = (const CSS2Azimuth &other); + + ~CSS2Azimuth(); + + /** + * A code defining the type of the value as defined in + * \c CSSValue . It would be one of \c CSS_DEG , + * \c CSS_RAD , \c CSS_GRAD or + * \c CSS_IDENT . + * + */ + unsigned short azimuthType() const; + + /** + * If \c azimuthType is \c CSS_IDENT , + * \c identifier contains one of left-side, far-left, + * left, center-left, center, center-right, right, far-right, + * right-side, leftwards, rightwards. The empty string if none is + * set. + * + */ + DOM::DOMString identifier() const; + + /** + * \c behind indicates whether the behind identifier + * has been set. + * + */ + bool behind() const; + + /** + * A method to set the angle value with a specified unit. This + * method will unset any previously set identifiers values. + * + * @param unitType The unitType could only be one of + * \c CSS_DEG , \c CSS_RAD or \c CSS_GRAD ). + * + * @param floatValue The new float value of the angle. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raised if the unit type is invalid. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is + * readonly. + * + */ + void setAngleValue ( const unsigned short unitType, const float floatValue ); + + /** + * Used to retrieved the float value of the azimuth property. + * + * @param unitType The unit type can be only an angle unit type ( + * \c CSS_DEG , \c CSS_RAD or + * \c CSS_GRAD ). + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raised if the unit type is invalid. + * + */ + float getAngleValue ( const unsigned short unitType ); + + /** + * Setting the identifier for the azimuth property will unset any + * previously set angle value. The value of \c azimuthType + * is set to \c CSS_IDENT + * + * @param identifier The new identifier. If the identifier is + * "leftwards" or "rightward", the behind attribute is ignored. + * + * @param behind The new value for behind. + * + * @return + * @exception DOMException + * SYNTAX_ERR: Raised if the specified \c identifier + * has a syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is + * readonly. + * + */ + void setIdentifier ( const DOM::DOMString &identifier, const bool behind ); +}; + + +class CSS2BackgroundPositionImpl; + +/** + * The \c CSS2BackgroundPosition interface represents the + * <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-position"> + * background-position </a> CSS Level 2 property. + * + */ +class CSS2BackgroundPosition : public CSSValue +{ +public: + CSS2BackgroundPosition(); + CSS2BackgroundPosition(const CSS2BackgroundPosition &other); + CSS2BackgroundPosition(CSS2BackgroundPositionImpl *impl); +public: + + CSS2BackgroundPosition & operator = (const CSS2BackgroundPosition &other); + + ~CSS2BackgroundPosition(); + + /** + * A code defining the type of the horizontal value. It would be + * one \c CSS_PERCENTAGE , \c CSS_EMS , + * \c CSS_EXS , \c CSS_PX , \c CSS_CM , + * \c CSS_MM , \c CSS_IN , + * \c CSS_PT , \c CSS_PC , + * \c CSS_IDENT , \c CSS_INHERIT . If one of + * horizontal or vertical is \c CSS_IDENT or + * \c CSS_INHERIT , it's guaranteed that the other is the + * same. + * + */ + unsigned short horizontalType() const; + + /** + * A code defining the type of the horizontal value. The code can + * be one of the following units : \c CSS_PERCENTAGE , + * \c CSS_EMS , \c CSS_EXS , \c CSS_PX + * , \c CSS_CM , \c CSS_MM , + * \c CSS_IN , \c CSS_PT , \c CSS_PC + * , \c CSS_IDENT , \c CSS_INHERIT + * . If one of horizontal or vertical is \c CSS_IDENT + * or \c CSS_INHERIT , it's guaranteed that the other + * is the same. + * + */ + unsigned short verticalType() const; + + /** + * If \c horizontalType is \c CSS_IDENT or + * \c CSS_INHERIT , this attribute contains the string + * representation of the ident, otherwise it contains an empty + * string. + * + */ + DOM::DOMString horizontalIdentifier() const; + + /** + * If \c verticalType is \c CSS_IDENT or + * \c CSS_INHERIT , this attribute contains the string + * representation of the ident, otherwise it contains an empty + * string. The value is \c "center" if only the + * horizontalIdentifier has been set. The value is + * \c "inherit" if the horizontalIdentifier is + * \c "inherit" . + * + */ + DOM::DOMString verticalIdentifier() const; + + /** + * This method is used to get the float value in a specified unit + * if the \c horizontalPosition represents a length or + * a percentage. If the float doesn't contain a float value or + * can't be converted into the specified unit, a + * \c DOMException is raised. + * + * @param horizontalType The specified unit. + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the property doesn't contain a + * float or the value can't be converted. + * + */ + float getHorizontalPosition ( const float horizontalType ); + + /** + * This method is used to get the float value in a specified unit + * if the \c verticalPosition represents a length or a + * percentage. If the float doesn't contain a float value or can't + * be converted into the specified unit, a \c DOMException + * is raised. The value is \c 50% if only the + * horizontal value has been specified. + * + * @param verticalType The specified unit. + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the property doesn't contain a + * float or the value can't be converted. + * + */ + float getVerticalPosition ( const float verticalType ); + + /** + * This method is used to set the horizontal position with a + * specified unit. If the vertical value is not a percentage or a + * length, it sets the vertical position to \c 50% . + * + * @param horizontalType The specified unit (a length or a + * percentage). + * + * @param value The new value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the specified unit is not a + * length or a percentage. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setHorizontalPosition ( const unsigned short horizontalType, const float value ); + + /** + * This method is used to set the vertical position with a + * specified unit. If the horizontal value is not a percentage or + * a length, it sets the vertical position to \c 50% . + * + * @param verticalType The specified unit (a length or a + * percentage). + * + * @param value The new value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the specified unit is not a + * length or a percentage. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setVerticalPosition ( const unsigned short verticalType, const float value ); + + /** + * Sets the identifiers. If the second identifier is the empty + * string, the vertical identifier is set to his default value ( + * \c "center" ). If the first identfier is + * \c "inherit , the second identifier is ignored and is set + * to \c "inherit" . + * + * @param horizontalIdentifier The new horizontal identifier. + * + * @param verticalIdentifier The new vertical identifier. + * + * @return + * @exception DOMException + * SYNTAX_ERR: Raises if the identifiers have a syntax error and + * is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setPositionIdentifier ( const DOM::DOMString &horizontalIdentifier, const DOM::DOMString &verticalIdentifier ); +}; + + +class CSS2BorderSpacingImpl; + +/** + * The \c CSS2BorderSpacing interface represents the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-border-spacing"> + * border-spacing </a> CSS Level 2 property. + * + */ +class CSS2BorderSpacing : public CSSValue +{ +public: + CSS2BorderSpacing(); + CSS2BorderSpacing(const CSS2BorderSpacing &other); + CSS2BorderSpacing(CSS2BorderSpacingImpl *impl); +public: + + CSS2BorderSpacing & operator = (const CSS2BorderSpacing &other); + + ~CSS2BorderSpacing(); + + /** + * The A code defining the type of the value as defined in + * \c CSSValue . It would be one of \c CSS_EMS , + * \c CSS_EXS , \c CSS_PX , \c CSS_CM + * , \c CSS_MM , \c CSS_IN , + * \c CSS_PT , \c CSS_PC or + * \c CSS_INHERIT . + * + */ + unsigned short horizontalType() const; + + /** + * The A code defining the type of the value as defined in + * \c CSSValue . It would be one of \c CSS_EMS , + * \c CSS_EXS , \c CSS_PX , \c CSS_CM + * , \c CSS_MM , \c CSS_IN , + * \c CSS_PT , \c CSS_PC or + * \c CSS_INHERIT . + * + */ + unsigned short verticalType() const; + + /** + * This method is used to get the float value in a specified unit + * if the \c horizontalSpacing represents a length. If + * the float doesn't contain a float value or can't be converted + * into the specified unit, a \c DOMException is + * raised. + * + * @param horizontalType The specified unit. + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the property doesn't contain a + * float or the value can't be converted. + * + */ + float getHorizontalSpacing ( const float horizontalType ); + + /** + * This method is used to get the float value in a specified unit + * if the \c verticalSpacing represents a length. If + * the float doesn't contain a float value or can't be converted + * into the specified unit, a \c DOMException is + * raised. The value is \c 0 if only the horizontal + * value has been specified. + * + * @param verticalType The specified unit. + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the property doesn't contain a + * float or the value can't be converted. + * + */ + float getVerticalSpacing ( const float verticalType ); + + /** + * This method is used to set the horizontal spacing with a + * specified unit. If the vertical value is a length, it sets the + * vertical spacing to \c 0 . + * + * @param horizontalType The specified unit. + * + * @param value The new value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the specified unit is not a + * length. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setHorizontalSpacing ( const unsigned short horizontalType, const float value ); + + /** + * This method is used to set the vertical spacing with a + * specified unit. If the horizontal value is not a length, it + * sets the vertical spacing to \c 0 . + * + * @param verticalType The specified unit. + * + * @param value The new value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the specified unit is not a + * length or a percentage. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setVerticalSpacing ( const unsigned short verticalType, const float value ); + + /** + * Set this property as inherit. \c horizontalType and + * \c verticalType will be inherited. + * + * @return + */ + void setInherit(); +}; + + +class CSS2CounterIncrementImpl; + +/** + * The \c CSS2CounterIncrement interface represents a + * imple value for the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-counter-increment"> + * counter-increment </a> CSS Level 2 property. + * + */ +class CSS2CounterIncrement +{ +public: + CSS2CounterIncrement(); + CSS2CounterIncrement(const CSS2CounterIncrement &other); + CSS2CounterIncrement(CSS2CounterIncrementImpl *impl); +public: + + CSS2CounterIncrement & operator = (const CSS2CounterIncrement &other); + + ~CSS2CounterIncrement(); + + /** + * The element name. + * + */ + DOM::DOMString identifier() const; + + /** + * see identifier + * @exception DOMException + * SYNTAX_ERR: Raised if the specified identifier has a syntax + * error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is + * readonly. + * + */ + void setIdentifier( const DOM::DOMString & ); + + /** + * The increment (default value is 1). + * + */ + short increment() const; + + /** + * see increment + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is + * readonly. + * + */ + void setIncrement( const short ); +}; + + +class CSS2CounterResetImpl; + +/** + * The \c CSS2CounterReset interface represents a simple + * value for the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-counter-reset"> + * counter-reset </a> CSS Level 2 property. + * + */ +class CSS2CounterReset +{ +public: + CSS2CounterReset(); + CSS2CounterReset(const CSS2CounterReset &other); + CSS2CounterReset(CSS2CounterResetImpl *impl); +public: + + CSS2CounterReset & operator = (const CSS2CounterReset &other); + + ~CSS2CounterReset(); + + /** + * The element name. + * + */ + DOM::DOMString identifier() const; + + /** + * see identifier + * @exception DOMException + * SYNTAX_ERR: Raised if the specified identifier has a syntax + * error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is + * readonly. + * + */ + void setIdentifier( const DOM::DOMString & ); + + /** + * The reset (default value is 0). + * + */ + short reset() const; + + /** + * see reset + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this identifier is + * readonly. + * + */ + void setReset( const short ); +}; + + +class CSS2CursorImpl; +class CSSValueList; + +/** + * The \c CSS2Cursor interface represents the <a + * href="http://www.w3.org/TR/REC-CSS2/ui.html#propdef-cursor"> cursor + * </a> CSS Level 2 property. + * + */ +class CSS2Cursor : public CSSValue +{ +public: + CSS2Cursor(); + CSS2Cursor(const CSS2Cursor &other); + CSS2Cursor(CSS2CursorImpl *impl); +public: + + CSS2Cursor & operator = (const CSS2Cursor &other); + + ~CSS2Cursor(); + + /** + * A code defining the type of the property. It would one of + * \c CSS_UNKNOWN or \c CSS_INHERIT . If + * the type is \c CSS_UNKNOWN , then \c uris + * contains a list of URIs and \c predefinedCursor + * contains an ident. Setting this attribute from + * \c CSS_INHERIT to \c CSS_UNKNOWN will set the + * \c predefinedCursor to \c "auto" . + * + */ + unsigned short cursorType() const; + + /** + * see cursorType + */ + void setCursorType( const unsigned short ); + + /** + * \c uris represents the list of URIs ( + * \c CSS_URI ) on the cursor property. The list can be + * empty. + * + */ + CSSValueList uris() const; + + /** + * This identifier represents a generic cursor name or an empty + * string. + * + */ + DOM::DOMString predefinedCursor() const; + + /** + * see predefinedCursor + * @exception DOMException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setPredefinedCursor( const DOM::DOMString & ); +}; + + +class CSS2FontFaceSrcImpl; +class CSSValueList; + +/** + * The \c CSS2Cursor interface represents the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#descdef-src"> src + * </a> CSS Level 2 descriptor. + * + */ +class CSS2FontFaceSrc +{ +public: + CSS2FontFaceSrc(); + CSS2FontFaceSrc(const CSS2FontFaceSrc &other); + CSS2FontFaceSrc(CSS2FontFaceSrcImpl *impl); +public: + + CSS2FontFaceSrc & operator = (const CSS2FontFaceSrc &other); + + ~CSS2FontFaceSrc(); + + /** + * Specifies the source of the font, empty string otherwise. + * + */ + DOM::DOMString uri() const; + + /** + * see uri + * @exception DOMException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setUri( const DOM::DOMString & ); + + /** + * This attribute contains a list of strings for the format CSS + * function. + * + */ + CSSValueList format() const; + + /** + * Specifies the full font name of a locally installed font. + * + */ + DOM::DOMString fontFaceName() const; + + /** + * see fontFaceName + * @exception DOMException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setFontFaceName( const DOM::DOMString & ); +}; + + +class CSS2FontFaceWidthsImpl; +class CSSValueList; + +/** + * The \c CSS2Cursor interface represents a simple value + * for the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#descdef-widths"> + * widths </a> CSS Level 2 descriptor. + * + */ +class CSS2FontFaceWidths +{ +public: + CSS2FontFaceWidths(); + CSS2FontFaceWidths(const CSS2FontFaceWidths &other); + CSS2FontFaceWidths(CSS2FontFaceWidthsImpl *impl); +public: + + CSS2FontFaceWidths & operator = (const CSS2FontFaceWidths &other); + + ~CSS2FontFaceWidths(); + + /** + * The range for the characters. + * + */ + DOM::DOMString urange() const; + + /** + * see urange + * @exception DOMException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setUrange( const DOM::DOMString & ); + + /** + * A list of numbers representing the glyph widths. + * + */ + CSSValueList numbers() const; +}; + + +class CSS2PageSizeImpl; + +/** + * The \c CSS2Cursor interface represents the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-size"> size + * </a> CSS Level 2 descriptor. + * + */ +class CSS2PageSize : public CSSValue +{ +public: + CSS2PageSize(); + CSS2PageSize(const CSS2PageSize &other); + CSS2PageSize(CSS2PageSizeImpl *impl); +public: + + CSS2PageSize & operator = (const CSS2PageSize &other); + + ~CSS2PageSize(); + + /** + * A code defining the type of the width of the page. It would be + * one of \c CSS_EMS , \c CSS_EXS , + * \c CSS_PX , \c CSS_CM , \c CSS_MM + * , \c CSS_IN , \c CSS_PT , \c CSS_PC + * , \c CSS_IDENT , \c CSS_INHERIT + * . If one of width or height is \c CSS_IDENT or + * \c CSS_INHERIT , it's guaranteed that the other is + * the same. + * + */ + unsigned short widthType() const; + + /** + * A code defining the type of the height of the page. It would be + * one of \c CSS_EMS , \c CSS_EXS , + * \c CSS_PX , \c CSS_CM , \c CSS_MM + * , \c CSS_IN , \c CSS_PT , \c CSS_PC + * , \c CSS_IDENT , \c CSS_INHERIT + * . If one of width or height is \c CSS_IDENT or + * \c CSS_INHERIT , it's guaranteed that the other is + * the same. + * + */ + unsigned short heightType() const; + + /** + * If \c width is \c CSS_IDENT or + * \c CSS_INHERIT , this attribute contains the string + * representation of the ident, otherwise it contains an empty + * string. + * + */ + DOM::DOMString identifier() const; + + /** + * This method is used to get the float value in a specified unit + * if the \c widthType represents a length. If the + * float doesn't contain a float value or can't be converted into + * the specified unit, a \c DOMException is raised. + * + * @param widthType The specified unit. + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the property doesn't contain a + * float or the value can't be converted. + * + */ + float getWidth ( const float widthType ); + + /** + * This method is used to get the float value in a specified unit + * if the \c heightType represents a length. If the + * float doesn't contain a float value or can't be converted into + * the specified unit, a \c DOMException is raised. If + * only the width value has been specified, the height value is + * the same. + * + * @param heightType The specified unit. + * + * @return The float value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the property doesn't contain a + * float or the value can't be converted. + * + */ + float getHeightSize ( const float heightType ); + + /** + * This method is used to set the width position with a specified + * unit. If the \c heightType is not a length, it sets + * the height position to the same value. + * + * @param widthType The specified unit. + * + * @param value The new value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the specified unit is not a + * length or a percentage. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setWidthSize ( const unsigned short widthType, const float value ); + + /** + * This method is used to set the height position with a specified + * unit. If the \c widthType is not a length, it sets + * the width position to the same value. + * + * @param heightType The specified unit. + * + * @param value The new value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the specified unit is not a + * length or a percentage. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setHeightSize ( const unsigned short heightType, const float value ); + + /** + * Sets the identifier. + * + * @param identifier The new identifier. + * + * @return + * @exception DOMException + * SYNTAX_ERR: Raises if the identifier has a syntax error and is + * unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raises if this property is + * readonly. + * + */ + void setIdentifier ( const DOM::DOMString &identifier ); +}; + + +class CSS2PlayDuringImpl; + +/** + * The \c CSS2PlayDuring interface represents the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-play-during"> + * play-during </a> CSS Level 2 property. + * + */ +class CSS2PlayDuring : public CSSValue +{ +public: + CSS2PlayDuring(); + CSS2PlayDuring(const CSS2PlayDuring &other); + CSS2PlayDuring(CSS2PlayDuringImpl *impl); +public: + + CSS2PlayDuring & operator = (const CSS2PlayDuring &other); + + ~CSS2PlayDuring(); + + /** + * A code defining the type of the value as define in + * \c CSSvalue . It would be one of \c CSS_UNKNOWN + * , \c CSS_INHERIT , \c CSS_IDENT + * + */ + unsigned short playDuringType() const; + + /** + * One of \c "inherit" , \c "auto" , + * \c "none" or the empty string if the + * \c playDuringType is \c CSS_UNKNOWN . On + * setting, it will set the \c uri to the empty string + * and \c mix and \c repeat to + * \c false . + * + */ + DOM::DOMString playDuringIdentifier() const; + + /** + * see playDuringIdentifier + * @exception DOMException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setPlayDuringIdentifier( const DOM::DOMString & ); + + /** + * The sound specified by the \c uri . It will set the + * \c playDuringType attribute to \c CSS_UNKNOWN . + * + */ + DOM::DOMString uri() const; + + /** + * see uri + * @exception DOMException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setUri( const DOM::DOMString & ); + + /** + * \c true if the sound should be mixed. It will be + * ignored if the attribute doesn't contain a \c uri . + * + */ + bool mix() const; + + /** + * see mix + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setMix( const bool ); + + /** + * \c true if the sound should be repeated. It will be + * ignored if the attribute doesn't contain a \c uri . + * + */ + bool repeat() const; + + /** + * see repeat + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setRepeat( const bool ); +}; + + +class CSS2PropertiesImpl; + +/** + * The \c CSS2Properties interface represents a + * convenience mechanism for retrieving and setting properties within + * a \c CSSStyleDeclaration . The attributes of this + * interface correspond to all the <a + * href="http://www.w3.org/TR/REC-CSS2/propidx.html"> properties + * specified in CSS2 </a> . Getting an attribute of this interface is + * equivalent to calling the \c getPropertyValue method of + * the \c CSSStyleDeclaration interface. Setting an + * attribute of this interface is equivalent to calling the + * \c setProperty method of the \c CSSStyleDeclaration + * interface. + * + * A compliant implementation is not required to implement the + * \c CSS2Properties interface. If an implementation does + * implement this interface, the expectation is that language-specific + * methods can be used to cast from an instance of the + * \c CSSStyleDeclaration interface to the \c CSS2Properties + * interface. + * + * If an implementation does implement this interface, it is expected + * to understand the specific syntax of the shorthand properties, and + * apply their semantics; when the \c margin property is + * set, for example, the \c marginTop , \c marginRight + * , \c marginBottom and \c marginLeft + * properties are actually being set by the underlying implementation. + * + * When dealing with CSS "shorthand" properties, the shorthand + * properties should be decomposed into their component longhand + * properties as appropriate, and when querying for their value, the + * form returned should be the shortest form exactly equivalent to the + * declarations made in the ruleset. However, if there is no shorthand + * declaration that could be added to the ruleset without changing in + * any way the rules already declared in the ruleset (i.e., by adding + * longhand rules that were previously not declared in the ruleset), + * then the empty string should be returned for the shorthand + * property. + * + * For example, querying for the \c font property should + * not return "normal normal normal 14pt/normal Arial, sans-serif", + * when "14pt Arial, sans-serif" suffices (the normals are initial + * values, and are implied by use of the longhand property). + * + * If the values for all the longhand properties that compose a + * particular string are the initial values, then a string consisting + * of all the initial values should be returned (e.g. a + * \c border-width value of "medium" should be returned as such, + * not as ""). + * + * For some shorthand properties that take missing values from other + * sides, such as the \c margin , \c padding , + * and \c border-[width|style|color] properties, the + * minimum number of sides possible should be used, i.e., "0px 10px" + * will be returned instead of "0px 10px 0px 10px". + * + * If the value of a shorthand property can not be decomposed into + * its component longhand properties, as is the case for the + * \c font property with a value of "menu", querying for the + * values of the component longhand properties should return the empty + * string. + * + */ +class CSS2Properties +{ +public: + CSS2Properties(); + CSS2Properties(const CSS2Properties &other); + CSS2Properties(CSS2PropertiesImpl *impl); +public: + + CSS2Properties & operator = (const CSS2Properties &other); + + ~CSS2Properties(); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-azimuth"> + * azimuth property definition </a> in CSS2. + * + */ + DOM::DOMString azimuth() const; + + /** + * see azimuth + */ + void setAzimuth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background"> + * background property definition </a> in CSS2. + * + */ + DOM::DOMString background() const; + + /** + * see background + */ + void setBackground( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-attachment"> + * background-attachment property definition </a> in CSS2. + * + */ + DOM::DOMString backgroundAttachment() const; + + /** + * see backgroundAttachment + */ + void setBackgroundAttachment( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-color"> + * background-color property definition </a> in CSS2. + * + */ + DOM::DOMString backgroundColor() const; + + /** + * see backgroundColor + */ + void setBackgroundColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-image"> + * background-image property definition </a> in CSS2. + * + */ + DOM::DOMString backgroundImage() const; + + /** + * see backgroundImage + */ + void setBackgroundImage( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-position"> + * background-position property definition </a> in CSS2. + * + */ + DOM::DOMString backgroundPosition() const; + + /** + * see backgroundPosition + */ + void setBackgroundPosition( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-repeat"> + * background-repeat property definition </a> in CSS2. + * + */ + DOM::DOMString backgroundRepeat() const; + + /** + * see backgroundRepeat + */ + void setBackgroundRepeat( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border"> + * border property definition </a> in CSS2. + * + */ + DOM::DOMString border() const; + + /** + * see border + */ + void setBorder( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-border-collapse"> + * border-collapse property definition </a> in CSS2. + * + */ + DOM::DOMString borderCollapse() const; + + /** + * see borderCollapse + */ + void setBorderCollapse( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-color"> + * border-color property definition </a> in CSS2. + * + */ + DOM::DOMString borderColor() const; + + /** + * see borderColor + */ + void setBorderColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-border-spacing"> + * border-spacing property definition </a> in CSS2. + * + */ + DOM::DOMString borderSpacing() const; + + /** + * see borderSpacing + */ + void setBorderSpacing( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-style"> + * border-style property definition </a> in CSS2. + * + */ + DOM::DOMString borderStyle() const; + + /** + * see borderStyle + */ + void setBorderStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-top"> + * border-top property definition </a> in CSS2. + * + */ + DOM::DOMString borderTop() const; + + /** + * see borderTop + */ + void setBorderTop( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-right"> + * border-right property definition </a> in CSS2. + * + */ + DOM::DOMString borderRight() const; + + /** + * see borderRight + */ + void setBorderRight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-bottom"> + * border-bottom property definition </a> in CSS2. + * + */ + DOM::DOMString borderBottom() const; + + /** + * see borderBottom + */ + void setBorderBottom( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-left"> + * border-left property definition </a> in CSS2. + * + */ + DOM::DOMString borderLeft() const; + + /** + * see borderLeft + */ + void setBorderLeft( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-top-color"> + * border-top-color property definition </a> in CSS2. + * + */ + DOM::DOMString borderTopColor() const; + + /** + * see borderTopColor + */ + void setBorderTopColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-right-color"> + * border-right-color property definition </a> in CSS2. + * + */ + DOM::DOMString borderRightColor() const; + + /** + * see borderRightColor + */ + void setBorderRightColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/#propdef-border-bottom-color"> + * border-bottom-color property definition </a> in CSS2. + * + */ + DOM::DOMString borderBottomColor() const; + + /** + * see borderBottomColor + */ + void setBorderBottomColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-left-color"> + * border-left-color property definition </a> in CSS2. + * + */ + DOM::DOMString borderLeftColor() const; + + /** + * see borderLeftColor + */ + void setBorderLeftColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-top-style"> + * border-top-style property definition </a> in CSS2. + * + */ + DOM::DOMString borderTopStyle() const; + + /** + * see borderTopStyle + */ + void setBorderTopStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-right-style"> + * border-right-style property definition </a> in CSS2. + * + */ + DOM::DOMString borderRightStyle() const; + + /** + * see borderRightStyle + */ + void setBorderRightStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-bottom-style"> + * border-bottom-style property definition </a> in CSS2. + * + */ + DOM::DOMString borderBottomStyle() const; + + /** + * see borderBottomStyle + */ + void setBorderBottomStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-left-style"> + * border-left-style property definition </a> in CSS2. + * + */ + DOM::DOMString borderLeftStyle() const; + + /** + * see borderLeftStyle + */ + void setBorderLeftStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-top-width"> + * border-top-width property definition </a> in CSS2. + * + */ + DOM::DOMString borderTopWidth() const; + + /** + * see borderTopWidth + */ + void setBorderTopWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-right-width"> + * border-right-width property definition </a> in CSS2. + * + */ + DOM::DOMString borderRightWidth() const; + + /** + * see borderRightWidth + */ + void setBorderRightWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-bottom-width"> + * border-bottom-width property definition </a> in CSS2. + * + */ + DOM::DOMString borderBottomWidth() const; + + /** + * see borderBottomWidth + */ + void setBorderBottomWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-left-width"> + * border-left-width property definition </a> in CSS2. + * + */ + DOM::DOMString borderLeftWidth() const; + + /** + * see borderLeftWidth + */ + void setBorderLeftWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-border-width"> + * border-width property definition </a> in CSS2. + * + */ + DOM::DOMString borderWidth() const; + + /** + * see borderWidth + */ + void setBorderWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-bottom"> + * bottom property definition </a> in CSS2. + * + */ + DOM::DOMString bottom() const; + + /** + * see bottom + */ + void setBottom( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-caption-side"> + * caption-side property definition </a> in CSS2. + * + */ + DOM::DOMString captionSide() const; + + /** + * see captionSide + */ + void setCaptionSide( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-clear"> + * clear property definition </a> in CSS2. + * + */ + DOM::DOMString clear() const; + + /** + * see clear + */ + void setClear( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visufx#propdef-clip"> clip + * property definition </a> in CSS2. + * + */ + DOM::DOMString clip() const; + + /** + * see clip + */ + void setClip( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/colors.html#propdef-color"> + * color property definition </a> in CSS2. + * + */ + DOM::DOMString color() const; + + /** + * see color + */ + void setColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-content"> + * content property definition </a> in CSS2. + * + */ + DOM::DOMString content() const; + + /** + * see content + */ + void setContent( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-counter-increment"> + * counter-increment property definition </a> in CSS2. + * + */ + DOM::DOMString counterIncrement() const; + + /** + * see counterIncrement + */ + void setCounterIncrement( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-counter-reset"> + * counter-reset property definition </a> in CSS2. + * + */ + DOM::DOMString counterReset() const; + + /** + * see counterReset + */ + void setCounterReset( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-cue"> + * cue property definition </a> in CSS2. + * + */ + DOM::DOMString cue() const; + + /** + * see cue + */ + void setCue( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-cue-fter"> + * cue-after property definition </a> in CSS2. + * + */ + DOM::DOMString cueAfter() const; + + /** + * see cueAfter + */ + void setCueAfter( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-cue-before"> + * cue-before property definition </a> in CSS2. + * + */ + DOM::DOMString cueBefore() const; + + /** + * see cueBefore + */ + void setCueBefore( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/ui.html#propdef-cursor"> + * cursor property definition </a> in CSS2. + * + */ + DOM::DOMString cursor() const; + + /** + * see cursor + */ + void setCursor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-direction"> + * direction property definition </a> in CSS2. + * + */ + DOM::DOMString direction() const; + + /** + * see direction + */ + void setDirection( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-display"> + * display property definition </a> in CSS2. + * + */ + DOM::DOMString display() const; + + /** + * see display + */ + void setDisplay( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-elevation"> + * elevation property definition </a> in CSS2. + * + */ + DOM::DOMString elevation() const; + + /** + * see elevation + */ + void setElevation( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-empty-cells"> + * empty-cells property definition </a> in CSS2. + * + */ + DOM::DOMString emptyCells() const; + + /** + * see emptyCells + */ + void setEmptyCells( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-float"> + * float property definition </a> in CSS2. + * + */ + DOM::DOMString cssFloat() const; + + /** + * see cssFloat + */ + void setCssFloat( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font"> + * font property definition </a> in CSS2. + * + */ + DOM::DOMString font() const; + + /** + * see font + */ + void setFont( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-family"> + * font-family property definition </a> in CSS2. + * + */ + DOM::DOMString fontFamily() const; + + /** + * see fontFamily + */ + void setFontFamily( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-size"> + * font-size property definition </a> in CSS2. + * + */ + DOM::DOMString fontSize() const; + + /** + * see fontSize + */ + void setFontSize( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-size-adjust"> + * font-size-adjust property definition </a> in CSS2. + * + */ + DOM::DOMString fontSizeAdjust() const; + + /** + * see fontSizeAdjust + */ + void setFontSizeAdjust( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-stretch"> + * font-stretch property definition </a> in CSS2. + * + */ + DOM::DOMString fontStretch() const; + + /** + * see fontStretch + */ + void setFontStretch( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-style"> + * font-style property definition </a> in CSS2. + * + */ + DOM::DOMString fontStyle() const; + + /** + * see fontStyle + */ + void setFontStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-variant"> + * font-variant property definition </a> in CSS2. + * + */ + DOM::DOMString fontVariant() const; + + /** + * see fontVariant + */ + void setFontVariant( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-weight"> + * font-weight property definition </a> in CSS2. + * + */ + DOM::DOMString fontWeight() const; + + /** + * see fontWeight + */ + void setFontWeight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-height"> + * height property definition </a> in CSS2. + * + */ + DOM::DOMString height() const; + + /** + * see height + */ + void setHeight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-left"> + * left property definition </a> in CSS2. + * + */ + DOM::DOMString left() const; + + /** + * see left + */ + void setLeft( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-letter-spacing"> + * letter-spacing property definition </a> in CSS2. + * + */ + DOM::DOMString letterSpacing() const; + + /** + * see letterSpacing + */ + void setLetterSpacing( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-line-height"> + * line-height property definition </a> in CSS2. + * + */ + DOM::DOMString lineHeight() const; + + /** + * see lineHeight + */ + void setLineHeight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-list-style"> + * list-style property definition </a> in CSS2. + * + */ + DOM::DOMString listStyle() const; + + /** + * see listStyle + */ + void setListStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-list-style-image"> + * list-style-image property definition </a> in CSS2. + * + */ + DOM::DOMString listStyleImage() const; + + /** + * see listStyleImage + */ + void setListStyleImage( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-list-style-position"> + * list-style-position property definition </a> in CSS2. + * + */ + DOM::DOMString listStylePosition() const; + + /** + * see listStylePosition + */ + void setListStylePosition( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-list-style-type"> + * list-style-type property definition </a> in CSS2. + * + */ + DOM::DOMString listStyleType() const; + + /** + * see listStyleType + */ + void setListStyleType( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-margin"> + * margin property definition </a> in CSS2. + * + */ + DOM::DOMString margin() const; + + /** + * see margin + */ + void setMargin( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-margin-top"> + * margin-top property definition </a> in CSS2. + * + */ + DOM::DOMString marginTop() const; + + /** + * see marginTop + */ + void setMarginTop( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-margin-right"> + * margin-right property definition </a> in CSS2. + * + */ + DOM::DOMString marginRight() const; + + /** + * see marginRight + */ + void setMarginRight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-margin-bottom"> + * margin-bottom property definition </a> in CSS2. + * + */ + DOM::DOMString marginBottom() const; + + /** + * see marginBottom + */ + void setMarginBottom( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-margin-left"> + * margin-left property definition </a> in CSS2. + * + */ + DOM::DOMString marginLeft() const; + + /** + * see marginLeft + */ + void setMarginLeft( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-marker-offset"> + * marker-offset property definition </a> in CSS2. + * + */ + DOM::DOMString markerOffset() const; + + /** + * see markerOffset + */ + void setMarkerOffset( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-marks"> + * marks property definition </a> in CSS2. + * + */ + DOM::DOMString marks() const; + + /** + * see marks + */ + void setMarks( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-max-height"> + * max-height property definition </a> in CSS2. + * + */ + DOM::DOMString maxHeight() const; + + /** + * see maxHeight + */ + void setMaxHeight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-max-width"> + * max-width property definition </a> in CSS2. + * + */ + DOM::DOMString maxWidth() const; + + /** + * see maxWidth + */ + void setMaxWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-min-height"> + * min-height property definition </a> in CSS2. + * + */ + DOM::DOMString minHeight() const; + + /** + * see minHeight + */ + void setMinHeight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-min-width"> + * min-width property definition </a> in CSS2. + * + */ + DOM::DOMString minWidth() const; + + /** + * see minWidth + */ + void setMinWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-orphans"> + * orphans property definition </a> in CSS2. + * + */ + DOM::DOMString orphans() const; + + /** + * see orphans + */ + void setOrphans( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/ui.html#propdef-outline"> + * outline property definition </a> in CSS2. + * + */ + DOM::DOMString outline() const; + + /** + * see outline + */ + void setOutline( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/ui.html#propdef-outline-color"> + * outline-color property definition </a> in CSS2. + * + */ + DOM::DOMString outlineColor() const; + + /** + * see outlineColor + */ + void setOutlineColor( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/ui.html#propdef-outline-style"> + * outline-style property definition </a> in CSS2. + * + */ + DOM::DOMString outlineStyle() const; + + /** + * see outlineStyle + */ + void setOutlineStyle( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/ui.html#propdef-outline-width"> + * outline-width property definition </a> in CSS2. + * + */ + DOM::DOMString outlineWidth() const; + + /** + * see outlineWidth + */ + void setOutlineWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visufx.html#propdef-overflow"> + * overflow property definition </a> in CSS2. + * + */ + DOM::DOMString overflow() const; + + /** + * see overflow + */ + void setOverflow( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-padding"> + * padding property definition </a> in CSS2. + * + */ + DOM::DOMString padding() const; + + /** + * see padding + */ + void setPadding( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-padding-top"> + * padding-top property definition </a> in CSS2. + * + */ + DOM::DOMString paddingTop() const; + + /** + * see paddingTop + */ + void setPaddingTop( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-padding-right"> + * padding-right property definition </a> in CSS2. + * + */ + DOM::DOMString paddingRight() const; + + /** + * see paddingRight + */ + void setPaddingRight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-padding-bottom"> + * padding-bottom property definition </a> in CSS2. + * + */ + DOM::DOMString paddingBottom() const; + + /** + * see paddingBottom + */ + void setPaddingBottom( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/box.html#propdef-padding-left"> + * padding-left property definition </a> in CSS2. + * + */ + DOM::DOMString paddingLeft() const; + + /** + * see paddingLeft + */ + void setPaddingLeft( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-page"> + * page property definition </a> in CSS2. + * + */ + DOM::DOMString page() const; + + /** + * see page + */ + void setPage( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-page-break-after"> + * page-break-after property definition </a> in CSS2. + * + */ + DOM::DOMString pageBreakAfter() const; + + /** + * see pageBreakAfter + */ + void setPageBreakAfter( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-page-break-before"> + * page-break-before property definition </a> in CSS2. + * + */ + DOM::DOMString pageBreakBefore() const; + + /** + * see pageBreakBefore + */ + void setPageBreakBefore( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-page-break-inside"> + * page-break-inside property definition </a> in CSS2. + * + */ + DOM::DOMString pageBreakInside() const; + + /** + * see pageBreakInside + */ + void setPageBreakInside( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-pause"> + * pause property definition </a> in CSS2. + * + */ + DOM::DOMString pause() const; + + /** + * see pause + */ + void setPause( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-pause-after"> + * pause-after property definition </a> in CSS2. + * + */ + DOM::DOMString pauseAfter() const; + + /** + * see pauseAfter + */ + void setPauseAfter( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-pause-before"> + * pause-before property definition </a> in CSS2. + * + */ + DOM::DOMString pauseBefore() const; + + /** + * see pauseBefore + */ + void setPauseBefore( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-pitch"> + * pitch property definition </a> in CSS2. + * + */ + DOM::DOMString pitch() const; + + /** + * see pitch + */ + void setPitch( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-pitch-range"> + * pitch-range property definition </a> in CSS2. + * + */ + DOM::DOMString pitchRange() const; + + /** + * see pitchRange + */ + void setPitchRange( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-play-during"> + * play-during property definition </a> in CSS2. + * + */ + DOM::DOMString playDuring() const; + + /** + * see playDuring + */ + void setPlayDuring( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-position"> + * position property definition </a> in CSS2. + * + */ + DOM::DOMString position() const; + + /** + * see position + */ + void setPosition( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/generate.html#propdef-quotes"> + * quotes property definition </a> in CSS2. + * + */ + DOM::DOMString quotes() const; + + /** + * see quotes + */ + void setQuotes( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-richness"> + * richness property definition </a> in CSS2. + * + */ + DOM::DOMString richness() const; + + /** + * see richness + */ + void setRichness( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-right"> + * right property definition </a> in CSS2. + * + */ + DOM::DOMString right() const; + + /** + * see right + */ + void setRight( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-size"> + * size property definition </a> in CSS2. + * + */ + DOM::DOMString size() const; + + /** + * see size + */ + void setSize( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-speak"> + * speak property definition </a> in CSS2. + * + */ + DOM::DOMString speak() const; + + /** + * see speak + */ + void setSpeak( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-speak-header"> + * speak-header property definition </a> in CSS2. + * + */ + DOM::DOMString speakHeader() const; + + /** + * see speakHeader + */ + void setSpeakHeader( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-speak-numeral"> + * speak-numeral property definition </a> in CSS2. + * + */ + DOM::DOMString speakNumeral() const; + + /** + * see speakNumeral + */ + void setSpeakNumeral( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-speak-punctuation"> + * speak-punctuation property definition </a> in CSS2. + * + */ + DOM::DOMString speakPunctuation() const; + + /** + * see speakPunctuation + */ + void setSpeakPunctuation( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-speech-rate"> + * speech-rate property definition </a> in CSS2. + * + */ + DOM::DOMString speechRate() const; + + /** + * see speechRate + */ + void setSpeechRate( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-stress"> + * stress property definition </a> in CSS2. + * + */ + DOM::DOMString stress() const; + + /** + * see stress + */ + void setStress( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/tables.html#propdef-table-layout"> + * table-layout property definition </a> in CSS2. + * + */ + DOM::DOMString tableLayout() const; + + /** + * see tableLayout + */ + void setTableLayout( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-align"> + * text-align property definition </a> in CSS2. + * + */ + DOM::DOMString textAlign() const; + + /** + * see textAlign + */ + void setTextAlign( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-decoration"> + * text-decoration property definition </a> in CSS2. + * + */ + DOM::DOMString textDecoration() const; + + /** + * see textDecoration + */ + void setTextDecoration( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-indent"> + * text-indent property definition </a> in CSS2. + * + */ + DOM::DOMString textIndent() const; + + /** + * see textIndent + */ + void setTextIndent( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-shadow"> + * text-shadow property definition </a> in CSS2. + * + */ + DOM::DOMString textShadow() const; + + /** + * see textShadow + */ + void setTextShadow( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-transform"> + * text-transform property definition </a> in CSS2. + * + */ + DOM::DOMString textTransform() const; + + /** + * see textTransform + */ + void setTextTransform( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-top"> + * top property definition </a> in CSS2. + * + */ + DOM::DOMString top() const; + + /** + * see top + */ + void setTop( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-unicode-bidi"> + * unicode-bidi property definition </a> in CSS2. + * + */ + DOM::DOMString unicodeBidi() const; + + /** + * see unicodeBidi + */ + void setUnicodeBidi( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-vertical-align"> + * vertical-align property definition </a> in CSS2. + * + */ + DOM::DOMString verticalAlign() const; + + /** + * see verticalAlign + */ + void setVerticalAlign( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visufx.html#propdef-visibility"> + * visibility property definition </a> in CSS2. + * + */ + DOM::DOMString visibility() const; + + /** + * see visibility + */ + void setVisibility( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-voice-family"> + * voice-family property definition </a> in CSS2. + * + */ + DOM::DOMString voiceFamily() const; + + /** + * see voiceFamily + */ + void setVoiceFamily( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/aural.html#propdef-volume"> + * volume property definition </a> in CSS2. + * + */ + DOM::DOMString volume() const; + + /** + * see volume + */ + void setVolume( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-white-space"> + * white-space property definition </a> in CSS2. + * + */ + DOM::DOMString whiteSpace() const; + + /** + * see whiteSpace + */ + void setWhiteSpace( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#propdef-widows"> + * widows property definition </a> in CSS2. + * + */ + DOM::DOMString widows() const; + + /** + * see widows + */ + void setWidows( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-width"> + * width property definition </a> in CSS2. + * + */ + DOM::DOMString width() const; + + /** + * see width + */ + void setWidth( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-word-spacing"> + * word-spacing property definition </a> in CSS2. + * + */ + DOM::DOMString wordSpacing() const; + + /** + * see wordSpacing + */ + void setWordSpacing( const DOM::DOMString & ); + + /** + * See the <a + * href="http://www.w3.org/TR/REC-CSS2/visufx.html#propdef-z-index"> + * z-index property definition </a> in CSS2. + * + */ + DOM::DOMString zIndex() const; + + /** + * see zIndex + */ + void setZIndex( const DOM::DOMString & ); +}; + + +class CSS2TextShadowImpl; +class CSSValue; + +/** + * The \c CSS2TextShadow interface represents a simple + * value for the <a + * href="http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-shadow"> + * text-shadow </a> CSS Level 2 property. + * + */ +class CSS2TextShadow +{ +public: + CSS2TextShadow(); + CSS2TextShadow(const CSS2TextShadow &other); + CSS2TextShadow(CSS2TextShadowImpl *impl); +public: + + CSS2TextShadow & operator = (const CSS2TextShadow &other); + + ~CSS2TextShadow(); + + /** + * Specified the color of the text shadow. The CSS Value can + * contain an empty string if no color has been specified. + * + */ + CSSValue color() const; + + /** + * The horizontal position of the text shadow. \c 0 if + * no length has been specified. + * + */ + CSSValue horizontal() const; + + /** + * The vertical position of the text shadow. \c 0 if + * no length has been specified. + * + */ + CSSValue vertical() const; + + /** + * The blur radius of the text shadow. \c 0 if no + * length has been specified. + * + */ + CSSValue blur() const; +}; + + +}; // namespace + +#endif diff --git a/tdehtml/dom/css_rule.cpp b/tdehtml/dom/css_rule.cpp new file mode 100644 index 000000000..e73ff493a --- /dev/null +++ b/tdehtml/dom/css_rule.cpp @@ -0,0 +1,546 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "css/css_ruleimpl.h" + +using namespace DOM; + +CSSRule::CSSRule() +{ + impl = 0; +} + +CSSRule::CSSRule(const CSSRule &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +CSSRule::CSSRule(CSSRuleImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +CSSRule &CSSRule::operator = (const CSSRule &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +CSSRule::~CSSRule() +{ + if(impl) impl->deref(); +} + +unsigned short CSSRule::type() const +{ + if(!impl) return 0; + return ((CSSRuleImpl *)impl)->type(); +} + +DOMString CSSRule::cssText() const +{ + if(!impl) return DOMString(); + return impl->cssText(); +} + +void CSSRule::setCssText( const DOMString &value ) +{ + if(!impl) return; + impl->setCssText(value); +} + +CSSStyleSheet CSSRule::parentStyleSheet() const +{ + if(!impl) return CSSStyleSheet(); + return ((CSSRuleImpl *)impl)->parentStyleSheet(); +} + +CSSRule CSSRule::parentRule() const +{ + if(!impl) return 0; + return ((CSSRuleImpl *)impl)->parentRule(); +} + +CSSRuleImpl *CSSRule::handle() const +{ + return impl; +} + +bool CSSRule::isNull() const +{ + return (impl == 0); +} + +void CSSRule::assignOther( const CSSRule &other, RuleType thisType ) +{ + if (other.type() != thisType ) { + if ( impl ) impl->deref(); + impl = 0; + } else + CSSRule::operator = ( other ); +} + +// ---------------------------------------------------------- + + +CSSCharsetRule::CSSCharsetRule() + : CSSRule() +{ +} + +CSSCharsetRule::CSSCharsetRule(const CSSCharsetRule &other) : CSSRule(other) +{ +} + +CSSCharsetRule::CSSCharsetRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + +CSSCharsetRule::CSSCharsetRule(CSSCharsetRuleImpl *impl) : CSSRule(impl) +{ +} + +CSSCharsetRule &CSSCharsetRule::operator = (const CSSCharsetRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSCharsetRule &CSSCharsetRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::CHARSET_RULE); + return *this; +} + +CSSCharsetRule::~CSSCharsetRule() +{ +} + +DOMString CSSCharsetRule::encoding() const +{ + if(!impl) return DOMString(); + return ((CSSCharsetRuleImpl*)impl)->encoding(); +} + +void CSSCharsetRule::setEncoding( const DOMString &value ) +{ + ((CSSCharsetRuleImpl*)impl)->setEncoding(value); +} + + +// ---------------------------------------------------------- + + +CSSFontFaceRule::CSSFontFaceRule() : CSSRule() +{ +} + +CSSFontFaceRule::CSSFontFaceRule(const CSSFontFaceRule &other) : CSSRule(other) +{ +} + +CSSFontFaceRule::CSSFontFaceRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + +CSSFontFaceRule::CSSFontFaceRule(CSSFontFaceRuleImpl *impl) : CSSRule(impl) +{ +} + +CSSFontFaceRule &CSSFontFaceRule::operator = (const CSSFontFaceRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSFontFaceRule &CSSFontFaceRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::FONT_FACE_RULE ); + return *this; +} + +CSSFontFaceRule::~CSSFontFaceRule() +{ +} + +CSSStyleDeclaration CSSFontFaceRule::style() const +{ + if(!impl) return CSSStyleDeclaration(); + return ((CSSFontFaceRuleImpl *)impl)->style(); +} + + +// ---------------------------------------------------------- + + +CSSImportRule::CSSImportRule() : CSSRule() +{ +} + +CSSImportRule::CSSImportRule(const CSSImportRule &other) : CSSRule(other) +{ +} + +CSSImportRule::CSSImportRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + +CSSImportRule::CSSImportRule(CSSImportRuleImpl *impl) : CSSRule(impl) +{ +} + +CSSImportRule &CSSImportRule::operator = (const CSSImportRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSImportRule &CSSImportRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::IMPORT_RULE ); + return *this; +} + +CSSImportRule::~CSSImportRule() +{ +} + +DOMString CSSImportRule::href() const +{ + if(!impl) return DOMString(); + return ((CSSImportRuleImpl *)impl)->href(); +} + +MediaList CSSImportRule::media() const +{ + if(!impl) return MediaList(); + return ((CSSImportRuleImpl *)impl)->media(); +} + +CSSStyleSheet CSSImportRule::styleSheet() const +{ + if(!impl) return CSSStyleSheet(); + return ((CSSImportRuleImpl *)impl)->styleSheet(); +} + + +// ---------------------------------------------------------- + + +CSSMediaRule::CSSMediaRule() : CSSRule() +{ +} + +CSSMediaRule::CSSMediaRule(const CSSMediaRule &other) : CSSRule(other) +{ +} + +CSSMediaRule::CSSMediaRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + +CSSMediaRule::CSSMediaRule(CSSMediaRuleImpl *impl) : CSSRule(impl) +{ +} + +CSSMediaRule &CSSMediaRule::operator = (const CSSMediaRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSMediaRule &CSSMediaRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::MEDIA_RULE ); + return *this; +} + +CSSMediaRule::~CSSMediaRule() +{ +} + +MediaList CSSMediaRule::media() const +{ + if(!impl) return MediaList(); + return ((CSSMediaRuleImpl *)impl)->media(); +} + +CSSRuleList CSSMediaRule::cssRules() const +{ + if(!impl) return CSSRuleList(); + return ((CSSMediaRuleImpl *)impl)->cssRules(); +} + +unsigned long CSSMediaRule::insertRule( const DOMString &rule, unsigned long index ) +{ + if(!impl) return 0; + return ((CSSMediaRuleImpl *)impl)->insertRule( rule, index ); +} + +void CSSMediaRule::deleteRule( unsigned long index ) +{ + if(impl) + ((CSSMediaRuleImpl *)impl)->deleteRule( index ); +} + + +// ---------------------------------------------------------- + + +CSSPageRule::CSSPageRule() : CSSRule() +{ +} + +CSSPageRule::CSSPageRule(const CSSPageRule &other) : CSSRule(other) +{ +} + +CSSPageRule::CSSPageRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + +CSSPageRule::CSSPageRule(CSSPageRuleImpl *impl) : CSSRule(impl) +{ +} + +CSSPageRule &CSSPageRule::operator = (const CSSPageRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSPageRule &CSSPageRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::PAGE_RULE ); + return *this; +} + +CSSPageRule::~CSSPageRule() +{ +} + +DOMString CSSPageRule::selectorText() const +{ + if(!impl) return DOMString(); + return ((CSSPageRuleImpl*)impl)->selectorText(); +} + +void CSSPageRule::setSelectorText( const DOMString &value ) +{ + ((CSSPageRuleImpl*)impl)->setSelectorText(value); +} + +CSSStyleDeclaration CSSPageRule::style() const +{ + if(!impl) return CSSStyleDeclaration(); + return ((CSSPageRuleImpl *)impl)->style(); +} + + +// ---------------------------------------------------------- + +CSSStyleRule::CSSStyleRule() : CSSRule() +{ +} + +CSSStyleRule::CSSStyleRule(const CSSStyleRule &other) + : CSSRule(other) +{ +} + +CSSStyleRule::CSSStyleRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + + +CSSStyleRule::CSSStyleRule(CSSStyleRuleImpl *impl) + : CSSRule(impl) +{ +} + +CSSStyleRule &CSSStyleRule::operator = (const CSSStyleRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSStyleRule &CSSStyleRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::STYLE_RULE ); + return *this; +} + +CSSStyleRule::~CSSStyleRule() +{ +} + +DOMString CSSStyleRule::selectorText() const +{ + if(!impl) return DOMString(); + return ((CSSStyleRuleImpl*)impl)->selectorText(); +} + +void CSSStyleRule::setSelectorText( const DOMString &value ) +{ + ((CSSStyleRuleImpl*)impl)->setSelectorText(value); +} + +CSSStyleDeclaration CSSStyleRule::style() const +{ + if(!impl) return CSSStyleDeclaration(); + return ((CSSStyleRuleImpl *)impl)->style(); +} + + +// ---------------------------------------------------------- + + +CSSUnknownRule::CSSUnknownRule() : CSSRule() +{ +} + +CSSUnknownRule::CSSUnknownRule(const CSSUnknownRule &other) + : CSSRule(other) +{ +} + +CSSUnknownRule::CSSUnknownRule(const CSSRule &other) +{ + impl = 0; + operator=(other); +} + +CSSUnknownRule::CSSUnknownRule(CSSUnknownRuleImpl *impl) + : CSSRule(impl) +{ +} + +CSSUnknownRule &CSSUnknownRule::operator = (const CSSUnknownRule &other) +{ + CSSRule::operator = (other); + return *this; +} + +CSSUnknownRule &CSSUnknownRule::operator = (const CSSRule &other) +{ + assignOther( other, CSSRule::UNKNOWN_RULE ); + return *this; +} + +CSSUnknownRule::~CSSUnknownRule() +{ +} + + +// ---------------------------------------------------------- + +CSSRuleList::CSSRuleList() +{ + impl = 0; +} + +CSSRuleList::CSSRuleList(const CSSRuleList &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +CSSRuleList::CSSRuleList(CSSRuleListImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +CSSRuleList::CSSRuleList(StyleListImpl *lst) +{ + impl = new CSSRuleListImpl; + impl->ref(); + if (lst) + { + for( unsigned long i = 0; i < lst->length() ; ++i ) + { + StyleBaseImpl* style = lst->item( i ); + if ( style->isRule() ) + impl->insertRule( static_cast<CSSRuleImpl *>(style), impl->length() ); + } + } +} + +CSSRuleList &CSSRuleList::operator = (const CSSRuleList &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +CSSRuleList::~CSSRuleList() +{ + if(impl) impl->deref(); +} + +unsigned long CSSRuleList::length() const +{ + if(!impl) return 0; + return ((CSSRuleListImpl *)impl)->length(); + return 0; +} + +CSSRule CSSRuleList::item( unsigned long index ) +{ + if(!impl) return CSSRule(); + return ((CSSRuleListImpl *)impl)->item( index ); +} + +CSSRuleListImpl *CSSRuleList::handle() const +{ + return impl; +} + +bool CSSRuleList::isNull() const +{ + return (impl == 0); +} + + + + diff --git a/tdehtml/dom/css_rule.h b/tdehtml/dom/css_rule.h new file mode 100644 index 000000000..5f27e8f8a --- /dev/null +++ b/tdehtml/dom/css_rule.h @@ -0,0 +1,534 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 2 Specification (Candidate Recommendation) + * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/ + * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. + * + */ +#ifndef _CSS_css_rule_h_ +#define _CSS_css_rule_h_ + +#include <dom/dom_string.h> +#include <dom/css_stylesheet.h> +#include <dom/css_value.h> + +namespace DOM { + +class CSSRuleImpl; + +/** + * The \c CSSRule interface is the abstract base interface + * for any type of CSS <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#q5"> statement + * </a> . This includes both <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#q8"> rule sets + * </a> and <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#at-rules"> + * at-rules </a> . An implementation is expected to preserve all rules + * specified in a CSS style sheet, even if it is not recognized. + * Unrecognized rules are represented using the \c CSSUnknownRule + * interface. + * + */ +class KHTML_EXPORT CSSRule +{ +public: + CSSRule(); + CSSRule(const CSSRule &other); + CSSRule(CSSRuleImpl *impl); +public: + + CSSRule & operator = (const CSSRule &other); + + ~CSSRule(); + /** + * An integer indicating which type of rule this is. + * + */ + enum RuleType { + UNKNOWN_RULE = 0, + STYLE_RULE = 1, + CHARSET_RULE = 2, + IMPORT_RULE = 3, + MEDIA_RULE = 4, + FONT_FACE_RULE = 5, + PAGE_RULE = 6, + QUIRKS_RULE = 100 // KHTML CSS Extension + }; + + /** + * The type of the rule, as defined above. The expectation is that + * binding-specific casting methods can be used to cast down from + * an instance of the \c CSSRule interface to the + * specific derived interface implied by the \c type . + * + */ + unsigned short type() const; + + /** + * The parsable textual representation of the rule. This reflects + * the current state of the rule and not its initial value. + * + */ + DOM::DOMString cssText() const; + + /** + * see cssText + * @exception DOMException + * + * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted + * at this point in the style sheet. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is + * readonly. + * + * @exception CSSException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * INVALID_MODIFICATION_ERR: Raised if the specified CSS string value + * represents a different type of rule than the current one. + */ + void setCssText( const DOM::DOMString & ); + + /** + * The style sheet that contains this rule. + * + */ + CSSStyleSheet parentStyleSheet() const; + + /** + * If this rule is contained inside another rule (e.g. a style + * rule inside an \@media block), this is the containing rule. If + * this rule is not nested inside any other rules, this returns + * \c null . + * + */ + CSSRule parentRule() const; + + /** + * @internal + * not part of the DOM + */ + CSSRuleImpl *handle() const; + bool isNull() const; + +protected: + CSSRuleImpl *impl; + + void assignOther( const CSSRule &other, RuleType thisType ); +}; + +class CSSCharsetRuleImpl; + +/** + * The \c CSSCharsetRule interface a <a href=""> \@charset + * rule </a> in a CSS style sheet. A \c \@charset rule can + * be used to define the encoding of the style sheet. + * + */ +class KHTML_EXPORT CSSCharsetRule : public CSSRule +{ +public: + CSSCharsetRule(); + CSSCharsetRule(const CSSCharsetRule &other); + CSSCharsetRule(const CSSRule &other); + CSSCharsetRule(CSSCharsetRuleImpl *impl); +public: + + CSSCharsetRule & operator = (const CSSCharsetRule &other); + CSSCharsetRule & operator = (const CSSRule &other); + + ~CSSCharsetRule(); + + /** + * The encoding information used in this \c \@charset + * rule. + * + */ + DOM::DOMString encoding() const; + + /** + * see encoding + * @exception CSSException + * SYNTAX_ERR: Raised if the specified encoding value has a syntax + * error and is unparsable. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this encoding rule is + * readonly. + * + */ + void setEncoding( const DOM::DOMString & ); +}; + + +class CSSFontFaceRuleImpl; +/** + * The \c CSSFontFaceRule interface represents a <a + * href="http://www.w3.org/TR/REC-CSS2/fonts.html#font-descriptions"> + * \c \@font-face rule </a> in a CSS style sheet. The \c \@font-face + * rule is used to hold a set of font descriptions. + * + */ +class KHTML_EXPORT CSSFontFaceRule : public CSSRule +{ +public: + CSSFontFaceRule(); + CSSFontFaceRule(const CSSFontFaceRule &other); + CSSFontFaceRule(const CSSRule &other); + CSSFontFaceRule(CSSFontFaceRuleImpl *impl); +public: + + CSSFontFaceRule & operator = (const CSSFontFaceRule &other); + CSSFontFaceRule & operator = (const CSSRule &other); + + ~CSSFontFaceRule(); + + /** + * The <a href="http://www.w3.org/TR/REC-CSS2/syndata.html#q8"> + * declaration-block </a> of this rule. + * + */ + CSSStyleDeclaration style() const; +}; + +class CSSImportRuleImpl; +/** + * The \c CSSImportRule interface represents a <a + * href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import"> + * \c \@import rule </a> within a CSS style sheet. The \c \@import + * rule is used to import style rules from other style sheets. + * + */ +class KHTML_EXPORT CSSImportRule : public CSSRule +{ +public: + CSSImportRule(); + CSSImportRule(const CSSImportRule &other); + CSSImportRule(const CSSRule &other); + CSSImportRule(CSSImportRuleImpl *impl); +public: + + CSSImportRule & operator = (const CSSImportRule &other); + CSSImportRule & operator = (const CSSRule &other); + + ~CSSImportRule(); + + /** + * The location of the style sheet to be imported. The attribute + * will not contain the \c "url(...)" specifier around + * the URI. + * + */ + DOM::DOMString href() const; + + /** + * A list of media types for which this style sheet may be used. + * + */ + MediaList media() const; + + /** + * The style sheet referred to by this rule, if it has been + * loaded. The value of this attribute is null if the style sheet + * has not yet been loaded or if it will not be loaded (e.g. if + * the style sheet is for a media type not supported by the user + * agent). + * + */ + CSSStyleSheet styleSheet() const; +}; + +class CSSMediaRuleImpl; +/** + * The \c CSSMediaRule interface represents a <a + * href="http://www.w3.org/TR/REC-CSS2/media.html#at-media-rule"> + * \@media rule </a> in a CSS style sheet. A \c \@media rule + * can be used to delimit style rules for specific media types. + * + */ +class KHTML_EXPORT CSSMediaRule : public CSSRule +{ +public: + CSSMediaRule(); + CSSMediaRule(const CSSMediaRule &other); + CSSMediaRule(const CSSRule &other); + CSSMediaRule(CSSMediaRuleImpl *impl); +public: + + CSSMediaRule & operator = (const CSSMediaRule &other); + CSSMediaRule & operator = (const CSSRule &other); + + ~CSSMediaRule(); + + /** + * A list of <a + * href="http://www.w3.org/TR/REC-CSS2/media.html#media-types"> + * media types </a> for this rule. + * + */ + MediaList media() const; + + /** + * A list of all CSS rules contained within the media block. + * + */ + CSSRuleList cssRules() const; + + /** + * Used to insert a new rule into the media block. + * + * @param rule The parsable text representing the rule. For rule + * sets this contains both the selector and the style declaration. + * For at-rules, this specifies both the at-identifier and the + * rule content. + * + * @param index The index within the media block's rule collection + * of the rule before which to insert the specified rule. If the + * specified index is equal to the length of the media blocks's + * rule collection, the rule will be added to the end of the media + * block. + * + * @return The index within the media block's rule collection of + * the newly inserted rule. + * + * \exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at + * the specified index. e.g. if an \c \@import rule is + * inserted after a standard rule set or other at-rule. + * + * INDEX_SIZE_ERR: Raised if the specified index is not a valid + * insertion point. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is + * readonly. + * + * \exception CSSException + * SYNTAX_ERR: Raised if the specified rule has a syntax error + * and is unparsable. + * + */ + unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index ); + + /** + * Used to delete a rule from the media block. + * + * @param index The index within the media block's rule collection + * of the rule to remove. + * + * @return + * + * \exception DOMException + * INDEX_SIZE_ERR: Raised if the specified index does not + * correspond to a rule in the media rule list. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is + * readonly. + * + */ + void deleteRule ( unsigned long index ); +}; + + +class CSSPageRuleImpl; +/** + * The \c CSSPageRule interface represents a <a + * href="http://www.w3.org/TR/REC-CSS2/page.html#page-box"> page rule + * </a> within a CSS style sheet. The \c @page rule is + * used to specify the dimensions, orientation, margins, etc. of a + * page box for paged media. + * + */ +class KHTML_EXPORT CSSPageRule : public CSSRule +{ +public: + CSSPageRule(); + CSSPageRule(const CSSPageRule &other); + CSSPageRule(const CSSRule &other); + CSSPageRule(CSSPageRuleImpl *impl); +public: + + CSSPageRule & operator = (const CSSPageRule &other); + CSSPageRule & operator = (const CSSRule &other); + + ~CSSPageRule(); + + /** + * The parsable textual representation of the page selector for + * the rule. + * + */ + DOM::DOMString selectorText() const; + + /** + * see selectorText + * @exception CSSException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is + * readonly. + * + */ + void setSelectorText( const DOM::DOMString & ); + + /** + * The <a href="http://www.w3.org/TR/REC-CSS2/syndata.html#q8"> + * declaration-block </a> of this rule. + * + */ + CSSStyleDeclaration style() const; +}; + +class CSSStyleRuleImpl; +/** + * The \c CSSStyleRule interface represents a single <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#q8"> rule set </a> + * in a CSS style sheet. + * + */ +class KHTML_EXPORT CSSStyleRule : public CSSRule +{ +public: + CSSStyleRule(); + CSSStyleRule(const CSSStyleRule &other); + CSSStyleRule(const CSSRule &other); + CSSStyleRule(CSSStyleRuleImpl *impl); +public: + + CSSStyleRule & operator = (const CSSStyleRule &other); + CSSStyleRule & operator = (const CSSRule &other); + + ~CSSStyleRule(); + + /** + * The textual representation of the <a + * href="http://www.w3.org/TR/REC-CSS2/selector.html"> selector + * </a> for the rule set. The implementation may have stripped out + * insignificant whitespace while parsing the selector. + * + */ + DOM::DOMString selectorText() const; + + /** + * see selectorText + * @exception CSSException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is + * readonly. + * + */ + void setSelectorText( const DOM::DOMString & ); + + /** + * The <a href="http://www.w3.org/TR/REC-CSS2/syndata.html#q8"> + * declaration-block </a> of this rule set. + * + */ + CSSStyleDeclaration style() const; +}; + +class CSSUnknownRuleImpl; +/** + * The \c CSSUnkownRule interface represents an at-rule + * not supported by this user agent. + * + */ +class KHTML_EXPORT CSSUnknownRule : public CSSRule +{ +public: + CSSUnknownRule(); + CSSUnknownRule(const CSSUnknownRule &other); + CSSUnknownRule(const CSSRule &other); + CSSUnknownRule(CSSUnknownRuleImpl *impl); +public: + + CSSUnknownRule & operator = (const CSSUnknownRule &other); + CSSUnknownRule & operator = (const CSSRule &other); + + ~CSSUnknownRule(); +}; + + +class CSSRuleListImpl; +class StyleListImpl; +/** + * The \c CSSRuleList interface provides the abstraction + * of an ordered collection of CSS rules. + * + */ +class KHTML_EXPORT CSSRuleList +{ +public: + CSSRuleList(); + CSSRuleList(const CSSRuleList &other); + CSSRuleList(CSSRuleListImpl *i); + CSSRuleList(StyleListImpl *i); +public: + + CSSRuleList & operator = (const CSSRuleList &other); + + ~CSSRuleList(); + + /** + * The number of \c CSSRule s in the list. The range + * of valid child rule indices is \c 0 to + * \c length-1 inclusive. + * + */ + unsigned long length() const; + + /** + * Used to retrieve a CSS rule by ordinal index. The order in this + * collection represents the order of the rules in the CSS style + * sheet. + * + * @param index Index into the collection + * + * @return The style rule at the \c index position in + * the \c CSSRuleList , or \c null if that + * is not a valid index. + * + */ + CSSRule item ( unsigned long index ); + + /** + * @internal + * not part of the DOM + */ + CSSRuleListImpl *handle() const; + bool isNull() const; + +protected: + // we just need a pointer to an implementation here. + CSSRuleListImpl *impl; +}; + + +} // namespace + +#endif diff --git a/tdehtml/dom/css_stylesheet.cpp b/tdehtml/dom/css_stylesheet.cpp new file mode 100644 index 000000000..ab5ce1451 --- /dev/null +++ b/tdehtml/dom/css_stylesheet.cpp @@ -0,0 +1,457 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) + * (C) 2001-2003 Dirk Mueller (mueller@kde.org) + * (C) 2003 Apple Compputer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "dom/dom_exception.h" +#include "dom/css_rule.h" +#include "dom/dom_doc.h" + +#include "xml/dom_docimpl.h" + +#include "html/html_headimpl.h" + +#include "css/css_stylesheetimpl.h" +#include "misc/htmlhashes.h" + +#include <stdio.h> + +using namespace DOM; + +StyleSheet::StyleSheet() +{ + impl = 0; +} + +StyleSheet::StyleSheet(const StyleSheet &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +StyleSheet::StyleSheet(StyleSheetImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +StyleSheet &StyleSheet::operator = (const StyleSheet &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +StyleSheet::~StyleSheet() +{ + if(impl) impl->deref(); +} + +DOMString StyleSheet::type() const +{ + if(!impl) return DOMString(); + return ((StyleSheetImpl *)impl)->type(); +} + +bool StyleSheet::disabled() const +{ + if(!impl) return 0; + return ((StyleSheetImpl *)impl)->disabled(); +} + +void StyleSheet::setDisabled( bool _disabled ) +{ + if(impl) + ((StyleSheetImpl *)impl)->setDisabled( _disabled ); +} + +DOM::Node StyleSheet::ownerNode() const +{ + if(!impl) return Node(); + return ((StyleSheetImpl *)impl)->ownerNode(); +} + +StyleSheet StyleSheet::parentStyleSheet() const +{ + if(!impl) return 0; + return ((StyleSheetImpl *)impl)->parentStyleSheet(); +} + +DOMString StyleSheet::href() const +{ + if(!impl) return DOMString(); + return ((StyleSheetImpl *)impl)->href(); +} + +DOMString StyleSheet::title() const +{ + if(!impl) return DOMString(); + return ((StyleSheetImpl *)impl)->title(); +} + +MediaList StyleSheet::media() const +{ + if(!impl) return 0; + return ((StyleSheetImpl *)impl)->media(); +} + +bool StyleSheet::isCSSStyleSheet() const +{ + if(!impl) return false; + return ((StyleSheetImpl *)impl)->isCSSStyleSheet(); +} + +CSSStyleSheet::CSSStyleSheet() : StyleSheet() +{ +} + +CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other) +{ +} + +CSSStyleSheet::CSSStyleSheet(const StyleSheet &other) +{ + if (!other.isCSSStyleSheet()) + impl = 0; + else + operator=(other); +} + +CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) : StyleSheet(impl) +{ +} + +CSSStyleSheet &CSSStyleSheet::operator = (const CSSStyleSheet &other) +{ + StyleSheet::operator = (other); + return *this; +} + +CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other) +{ + if(!other.handle()->isCSSStyleSheet()) + { + if(impl) impl->deref(); + impl = 0; + } else { + StyleSheet::operator = (other); + } + return *this; +} + +CSSStyleSheet::~CSSStyleSheet() +{ +} + +CSSRule CSSStyleSheet::ownerRule() const +{ + if(!impl) return 0; + return ((CSSStyleSheetImpl *)impl)->ownerRule(); +} + +CSSRuleList CSSStyleSheet::cssRules() const +{ + if(!impl) return (CSSRuleListImpl*)0; + return ((CSSStyleSheetImpl *)impl)->cssRules(); +} + +unsigned long CSSStyleSheet::insertRule( const DOMString &rule, unsigned long index ) +{ + int exceptioncode = 0; + if(!impl) return 0; + unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode ); + if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET ) + throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return retval; +} + +void CSSStyleSheet::deleteRule( unsigned long index ) +{ + int exceptioncode = 0; + if(impl) + ((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode ); + if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET ) + throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + + + +StyleSheetList::StyleSheetList() +{ + impl = 0; +} + +StyleSheetList::StyleSheetList(const StyleSheetList &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +StyleSheetList::StyleSheetList(StyleSheetListImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +StyleSheetList::~StyleSheetList() +{ + if(impl) impl->deref(); +} + +unsigned long StyleSheetList::length() const +{ + if(!impl) return 0; + return ((StyleSheetListImpl *)impl)->length(); +} + +StyleSheet StyleSheetList::item( unsigned long index ) +{ + if(!impl) return StyleSheet(); + return ((StyleSheetListImpl *)impl)->item( index ); +} + +StyleSheetListImpl *StyleSheetList::handle() const +{ + return impl; +} + +bool StyleSheetList::isNull() const +{ + return (impl == 0); +} + +// ---------------------------------------------------------- + +MediaList::MediaList() +{ + impl = 0; +} + +MediaList::MediaList(const MediaList &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +MediaList::MediaList(MediaListImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +MediaList &MediaList::operator = (const MediaList &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +MediaList::~MediaList() +{ + if(impl) impl->deref(); +} + +DOM::DOMString MediaList::mediaText() const +{ + if(!impl) return DOMString(); + return static_cast<MediaListImpl *>(impl)->mediaText(); +} + +void MediaList::setMediaText(const DOM::DOMString &value ) +{ + if(impl) + static_cast<MediaListImpl *>(impl)->setMediaText( value ); +} + +unsigned long MediaList::length() const +{ + if(!impl) return 0; + return ((MediaListImpl *)impl)->length(); +} + +DOM::DOMString MediaList::item(unsigned long index) const +{ + if(!impl) return DOMString(); + return ((MediaListImpl *)impl)->item( index ); +} + +void MediaList::deleteMedium(const DOM::DOMString &oldMedium) +{ + if(impl) + ((MediaListImpl *)impl)->deleteMedium( oldMedium ); +} + +void MediaList::appendMedium(const DOM::DOMString &newMedium) +{ + if(impl) + ((MediaListImpl *)impl)->appendMedium( newMedium ); +} + +MediaListImpl *MediaList::handle() const +{ + return impl; +} + +bool MediaList::isNull() const +{ + return (impl == 0); +} + +// ---------------------------------------------------------- + +LinkStyle::LinkStyle() +{ + node = 0; +} + +LinkStyle::LinkStyle(const LinkStyle &other) +{ + node = other.node; + if(node) node->ref(); +} + +LinkStyle & LinkStyle::operator = (const LinkStyle &other) +{ + if ( node != other.node ) { + if(node) node->deref(); + node = other.node; + if(node) node->ref(); + } + return *this; +} + +LinkStyle & LinkStyle::operator = (const Node &other) +{ + if(node) node->deref(); + node = 0; + // ### add processing instructions + NodeImpl *n = other.handle(); + + // ### check link is really linking a style sheet + if( n && n->isElementNode() && + (n->id() == ID_STYLE || n->id() == ID_LINK) ) { + node = n; + if(node) node->ref(); + } + return *this; +} + +LinkStyle::~LinkStyle() +{ + if(node) node->deref(); +} + +StyleSheet LinkStyle::sheet() +{ + int id = node ? node->id() : 0; + // ### add PI + return + ( id == ID_STYLE) ? + static_cast<HTMLStyleElementImpl *>(node)->sheet() + : ( (id == ID_LINK) ? + static_cast<HTMLLinkElementImpl *>(node)->sheet() + : StyleSheet() ); +} + +bool LinkStyle::isNull() const +{ + return (node == 0); +} + + +// ---------------------------------------------------------- + +DocumentStyle::DocumentStyle() +{ + doc = 0; +} + +DocumentStyle::DocumentStyle(const DocumentStyle &other) +{ + doc = other.doc; + if(doc) doc->ref(); +} + +DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other) +{ + if ( doc != other.doc ) { + if(doc) doc->deref(); + doc = other.doc; + if(doc) doc->ref(); + } + return *this; +} + +DocumentStyle & DocumentStyle::operator = (const Document &other) +{ + DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle()); + if ( doc != odoc ) { + if(doc) doc->deref(); + doc = odoc; + if(doc) doc->ref(); + } + return *this; +} + +DocumentStyle::~DocumentStyle() +{ + if(doc) doc->deref(); +} + +StyleSheetList DocumentStyle::styleSheets() +{ + return doc->styleSheets(); +} + +DOMString DocumentStyle::preferredStylesheetSet() const +{ + return doc->preferredStylesheetSet(); +} + +void DocumentStyle::setSelectedStylesheetSet(const DOMString& aStr) +{ + return doc->setSelectedStylesheetSet(aStr); +} + +DOMString DocumentStyle::selectedStylesheetSet() const +{ + return doc->selectedStylesheetSet(); +} diff --git a/tdehtml/dom/css_stylesheet.h b/tdehtml/dom/css_stylesheet.h new file mode 100644 index 000000000..d220ffa76 --- /dev/null +++ b/tdehtml/dom/css_stylesheet.h @@ -0,0 +1,496 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 2 Specification (Candidate Recommendation) + * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/ + * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. + * + */ +#ifndef _CSS_css_stylesheet_h_ +#define _CSS_css_stylesheet_h_ + +#include <dom/dom_string.h> +#include <dom/dom_node.h> +#include <dom/dom_misc.h> + +#include <tdelibs_export.h> + +namespace DOM { + +class StyleSheetImpl; +class MediaList; +class NodeImpl; +class DocumentImpl; + +/** + * The \c StyleSheet interface is the abstract base + * interface for any type of style sheet. It represents a single style + * sheet associated with a structured document. In HTML, the + * StyleSheet interface represents either an external style sheet, + * included via the HTML <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#h-12.3"> + * LINK </a> element, or an inline <a + * href="http://www.w3.org/TR/REC-html40/present/styles.html#h-14.2.3"> + * STYLE </a> element. In XML, this interface represents an external + * style sheet, included via a <a + * href="http://www.w3.org/TR/xml-stylesheet"> style sheet processing + * instruction </a> . + * + */ +class KHTML_EXPORT StyleSheet +{ +public: + StyleSheet(); + StyleSheet(const StyleSheet &other); + StyleSheet(StyleSheetImpl *impl); +public: + + StyleSheet & operator = (const StyleSheet &other); + + ~StyleSheet(); + + /** + * This specifies the style sheet language for this style sheet. + * The style sheet language is specified as a content type (e.g. + * "text/css"). The content type is often specified in the + * \c ownerNode . A list of registered content types can be + * found at <a + * href="ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/"> + * ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/ </a> . + * Also see the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-type-A"> + * type attribute definition </a> for the \c LINK + * element in HTML 4.0, and the type pseudo-attribute for the XML + * <a href="http://www.w3.org/TR/xml-stylesheet"> style sheet + * processing instruction </a> . + * + */ + DOM::DOMString type() const; + + /** + * \c false if the style sheet is applied to the + * document. \c true if it is not. Modifying this + * attribute may cause a reresolution of style for the document. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * The node that associates this style sheet with the document. + * For HTML, this may be the corresponding \c LINK or + * \c STYLE element. For XML, it may be the linking + * processing instruction. For style sheets that are included by + * other style sheets, this attribute has a value of null. + * + */ + DOM::Node ownerNode() const; + + /** + * For style sheet languages that support the concept of style + * sheet inclusion, this attribute represents the including style + * sheet, if one exists. If the style sheet is a top-level style + * sheet, or the style sheet language does not support inclusion, + * the value of the attribute is null. + * + */ + StyleSheet parentStyleSheet() const; + + /** + * If the style sheet is a linked style sheet, the value of its + * attribute is its location. For inline style sheets, the value + * of this attribute is null. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-href"> + * href attribute definition </a> for the \c LINK + * element in HTML 4.0, and the href pseudo-attribute for the XML + * <a href="http://www.w3.org/TR/xml-stylesheet"> style sheet + * processing instruction </a> . + * + */ + DOM::DOMString href() const; + + /** + * The advisory title. The title is often specified in the + * \c ownerNode . See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-title"> + * title attribute definition </a> for the \c LINK + * element in HTML 4.0, and the title pseudo-attribute for the XML + * <a href="http://www.w3.org/TR/xml-stylesheet"> style sheet + * processing instruction </a> . + * + */ + DOM::DOMString title() const; + + /** + * The intended destination media for style information. The media + * is often specified in the \c ownerNode . See the <a + * href="http://www.w3.org/TR/REC-html40/present/styles.html#adef-media"> + * media attribute definition </a> for the \c LINK + * element in HTML 4.0, and the media pseudo-attribute for the XML + * <a href="http://www.w3.org/TR/WD-xml-stylesheet"> style sheet + * processing instruction </a> . + * + */ + MediaList media() const; + + /** + * @internal + */ + bool isCSSStyleSheet() const; + StyleSheetImpl *handle() const { return impl; } + bool isNull() const { return !impl; } +protected: + StyleSheetImpl *impl; +}; + + +/** + * This exception is raised when a specific CSS operation is impossible + * to perform. + */ +class KHTML_EXPORT CSSException +{ +public: + CSSException(unsigned short _code) { code = _code; } + CSSException(const CSSException &other) { code = other.code; } + + CSSException & operator = (const CSSException &other) + { code = other.code; return *this; } + + virtual ~CSSException() {} + /** + * An integer indicating the type of error generated. + * + */ + unsigned short code; + + enum ExceptionCode + { + SYNTAX_ERR = 0, + INVALID_MODIFICATION_ERR = 1, + _EXCEPTION_OFFSET = 1000 + }; +}; + +class CSSStyleSheetImpl; +class CSSRule; +class CSSRuleList; + +/** + * The \c CSSStyleSheet interface is a concrete interface + * used to represent a CSS style sheet i.e. a style sheet whose + * content type is "text/css". + * + */ +class KHTML_EXPORT CSSStyleSheet : public StyleSheet +{ +public: + CSSStyleSheet(); + CSSStyleSheet(const CSSStyleSheet &other); + CSSStyleSheet(const StyleSheet &other); + CSSStyleSheet(CSSStyleSheetImpl *impl); +public: + + CSSStyleSheet & operator = (const CSSStyleSheet &other); + CSSStyleSheet & operator = (const StyleSheet &other); + + ~CSSStyleSheet(); + + /** + * If this style sheet comes from an \c \@import rule, + * the \c ownerRule attribute will contain the + * \c CSSImportRule . In that case, the \c ownerNode + * attribute in the \c StyleSheet interface + * will be \c null . If the style sheet comes from an + * element or a processing instruction, the \c ownerRule + * attribute will be \c null and the + * \c ownerNode attribute will contain the \c Node . + * + */ + CSSRule ownerRule() const; + + /** + * The list of all CSS rules contained within the style sheet. + * This includes both <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#q8"> rule sets + * </a> and <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#at-rules"> + * at-rules </a> . + * + */ + CSSRuleList cssRules() const; + + /** + * Used to insert a new rule into the style sheet. The new rule + * now becomes part of the cascade. + * + * @param rule The parsable text representing the rule. For rule + * sets this contains both the selector and the style declaration. + * For at-rules, this specifies both the at-identifier and the + * rule content. + * + * @param index The index within the style sheet's rule list of + * the rule before which to insert the specified rule. If the + * specified index is equal to the length of the style sheet's + * rule collection, the rule will be added to the end of the style + * sheet. + * + * @return The index within the style sheet's rule collection of + * the newly inserted rule. + * + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at + * the specified index e.g. if an \c \@import rule is + * inserted after a standard rule set or other at-rule. + * + * INDEX_SIZE_ERR: Raised if the specified index is not a valid + * insertion point. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is + * readonly. + * + * @exception CSSException + * SYNTAX_ERR: Raised if the specified rule has a syntax error + * and is unparsable. + * + */ + unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index ); + + /** + * Used to delete a rule from the style sheet. + * + * @param index The index within the style sheet's rule list of + * the rule to remove. + * + * @return + * + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified index does not + * correspond to a rule in the style sheet's rule list. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is + * readonly. + * + */ + void deleteRule ( unsigned long index ); +}; + + +class StyleSheetListImpl; +class StyleSheet; + +/** + * The \c StyleSheetList interface provides the + * abstraction of an ordered collection of style sheets. + * + */ +class KHTML_EXPORT StyleSheetList +{ +public: + StyleSheetList(); + StyleSheetList(const StyleSheetList &other); + StyleSheetList(StyleSheetListImpl *impl); +public: + + StyleSheetList & operator = (const StyleSheetList &other); + + ~StyleSheetList(); + + /** + * The number of \c StyleSheet in the list. The range + * of valid child stylesheet indices is \c 0 to + * \c length-1 inclusive. + * + */ + unsigned long length() const; + + /** + * Used to retrieve a style sheet by ordinal index. + * + * @param index Index into the collection + * + * @return The style sheet at the \c index position in + * the \c StyleSheetList , or \c null if + * that is not a valid index. + * + */ + StyleSheet item ( unsigned long index ); + + /** + * @internal + */ + StyleSheetListImpl *handle() const; + bool isNull() const; + +protected: + StyleSheetListImpl *impl; +}; + + +class MediaListImpl; +class CSSRule; +class CSSStyleSheet; + +/** + * The \c MediaList interface provides the abstraction of + * an ordered collection of media, without defining or constraining + * how this collection is implemented. All media are lowercase + * strings. + * + */ +class KHTML_EXPORT MediaList +{ +public: + MediaList(); + MediaList(const MediaList &other); + MediaList(MediaListImpl *impl); +public: + + MediaList & operator = (const MediaList &other); + + ~MediaList(); + + /** + * The parsable textual representation of the media list. This is a + * comma-separated list of media. + * + * @exception DOMException + * SYNTAX_ERR: Raised if the specified string value has a syntax error and + * is unparsable. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this media list is readonly. + */ + DOM::DOMString mediaText() const; + + /** + * see mediaText + */ + void setMediaText(const DOM::DOMString &value); + + /** + * The number of media in the list. The range of valid media is 0 to length-1 inclusive. + */ + unsigned long length() const; + + + /** + * Returns the indexth in the list. If index is greater than or equal to + * the number of media in the list, this returns null. + * + * @param index Index into the collection. + * + * @return The medium at the indexth position in the MediaList, or null if + * that is not a valid index. + */ + DOM::DOMString item(unsigned long index) const; + + /** + * Deletes the medium indicated by oldMedium from the list. + * + * @param oldMedium The medium to delete in the media list. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this list is readonly. + * + * NOT_FOUND_ERR: Raised if oldMedium is not in the list. + */ + void deleteMedium(const DOM::DOMString &oldMedium); + + /** + * Adds the medium newMedium to the end of the list. If the newMedium is + * already used, it is first removed. + * + * @param newMedium The new medium to add. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: If the medium contains characters that are + * invalid in the underlying style language. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this list is readonly. + */ + void appendMedium(const DOM::DOMString &newMedium); + + /** + * @internal + */ + MediaListImpl *handle() const; + bool isNull() const; + +protected: + MediaListImpl *impl; +}; + +class LinkStyleImpl; + +class KHTML_EXPORT LinkStyle +{ +public: + LinkStyle(); + LinkStyle(const LinkStyle &other); + + LinkStyle & operator = (const LinkStyle &other); + LinkStyle & operator = (const Node &other); + + ~LinkStyle(); + + StyleSheet sheet(); + + bool isNull() const; + +protected: + DOM::NodeImpl *node; + LinkStyleImpl *impl; +}; + +class DocumentStyleImpl; + +class KHTML_EXPORT DocumentStyle +{ +public: + DocumentStyle(); + DocumentStyle(const DocumentStyle &other); + + DocumentStyle & operator = (const DocumentStyle &other); + DocumentStyle & operator = (const Document &other); + + ~DocumentStyle(); + + // KDE 4:: make const + StyleSheetList styleSheets(); + + DOMString preferredStylesheetSet() const; + DOMString selectedStylesheetSet() const; + void setSelectedStylesheetSet( const DOMString& aString ); + + bool isNull() const { return !impl; } + +protected: + DOM::DocumentImpl *doc; + DocumentStyleImpl *impl; +}; + +} // namespace + +#endif diff --git a/tdehtml/dom/css_value.cpp b/tdehtml/dom/css_value.cpp new file mode 100644 index 000000000..4e365644a --- /dev/null +++ b/tdehtml/dom/css_value.cpp @@ -0,0 +1,587 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/css_rule.h" +#include "dom/dom_exception.h" + +#include "css/css_renderstyledeclarationimpl.h" +#include "css/css_valueimpl.h" + +namespace DOM { + +CSSStyleDeclaration::CSSStyleDeclaration() +{ + impl = 0; +} + +CSSStyleDeclaration::CSSStyleDeclaration(const CSSStyleDeclaration &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +CSSStyleDeclaration::CSSStyleDeclaration(CSSStyleDeclarationImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +CSSStyleDeclaration &CSSStyleDeclaration::operator = (const CSSStyleDeclaration &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +CSSStyleDeclaration::~CSSStyleDeclaration() +{ + if(impl) impl->deref(); +} + +DOMString CSSStyleDeclaration::cssText() const +{ + if(!impl) return DOMString(); + return static_cast<CSSStyleDeclarationImpl *>(impl)->cssText(); +} + +void CSSStyleDeclaration::setCssText( const DOMString &value ) +{ + if(!impl) return; + impl->setCssText(value); +} + +DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName ) +{ + return const_cast<const CSSStyleDeclaration*>( this )->getPropertyValue( propertyName ); +} + +DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName ) const +{ + if(!impl) return DOMString(); + int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); + if (!id) return DOMString(); + return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyValue(id); +} + +CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) +{ + return const_cast<const CSSStyleDeclaration*>( this )->getPropertyCSSValue( propertyName ); +} + +CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const +{ + if(!impl) return 0; + int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); + if (!id) return 0; + return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(id); +} + +DOMString CSSStyleDeclaration::removeProperty( const DOMString &property ) +{ + int id = getPropertyID(property.string().ascii(), property.length()); + if(!impl || !id) return DOMString(); + return static_cast<CSSStyleDeclarationImpl *>(impl)->removeProperty( id ); +} + +DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName ) +{ + return const_cast<const CSSStyleDeclaration*>( this )->getPropertyPriority( propertyName ); +} + +DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName ) const +{ + int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); + if(!impl || !id) return DOMString(); + if (impl->getPropertyPriority(id)) + return DOMString("important"); + return DOMString(); +} + +void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority ) +{ + if(!impl) return; + int id = getPropertyID(propName.string().lower().ascii(), propName.length()); + if (!id) return; + bool important = false; + TQString str = priority.string(); + if (str.find("important", 0, false) != -1) + important = true; + + static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( id, value, important ); +} + +unsigned long CSSStyleDeclaration::length() const +{ + if(!impl) return 0; + return static_cast<CSSStyleDeclarationImpl *>(impl)->length(); +} + +DOMString CSSStyleDeclaration::item( unsigned long index ) +{ + return const_cast<const CSSStyleDeclaration*>( this )->item( index ); +} + +DOMString CSSStyleDeclaration::item( unsigned long index ) const +{ + if(!impl) return DOMString(); + return static_cast<CSSStyleDeclarationImpl *>(impl)->item( index ); +} +CSSRule CSSStyleDeclaration::parentRule() const +{ + if(!impl) return 0; + return static_cast<CSSStyleDeclarationImpl *>(impl)->parentRule(); +} + +CSSStyleDeclarationImpl *CSSStyleDeclaration::handle() const +{ + return impl; +} + +bool CSSStyleDeclaration::isNull() const +{ + return (impl == 0); +} + +// ---------------------------------------------------------- + +CSSValue::CSSValue() +{ + impl = 0; +} + +CSSValue::CSSValue(const CSSValue &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +CSSValue::CSSValue(CSSValueImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +CSSValue &CSSValue::operator = (const CSSValue &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +CSSValue::~CSSValue() +{ + if(impl) impl->deref(); +} + +DOMString CSSValue::cssText() const +{ + if(!impl) return DOMString(); + return ((CSSValueImpl *)impl)->cssText(); +} + +void CSSValue::setCssText( const DOMString &/*value*/ ) +{ + if(!impl) return; + ((CSSValueImpl *)impl)->cssText(); +} + +unsigned short CSSValue::cssValueType() const +{ + if(!impl) return 0; + return ((CSSValueImpl *)impl)->cssValueType(); +} + +bool CSSValue::isCSSValueList() const +{ + if(!impl) return false; + return ((CSSValueImpl *)impl)->isValueList(); +} + +bool CSSValue::isCSSPrimitiveValue() const +{ + if(!impl) return false; + return ((CSSValueImpl *)impl)->isPrimitiveValue(); +} + +CSSValueImpl *CSSValue::handle() const +{ + return impl; +} + +bool CSSValue::isNull() const +{ + return (impl == 0); +} + +// ---------------------------------------------------------- + +CSSValueList::CSSValueList() : CSSValue() +{ +} + +CSSValueList::CSSValueList(const CSSValueList &other) : CSSValue(other) +{ +} + +CSSValueList::CSSValueList(const CSSValue &other) +{ + impl = 0; + operator=(other); +} + +CSSValueList::CSSValueList(CSSValueListImpl *impl) : CSSValue(impl) +{ +} + +CSSValueList &CSSValueList::operator = (const CSSValueList &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.handle(); + if (impl) impl->ref(); + } + return *this; +} + +CSSValueList &CSSValueList::operator = (const CSSValue &other) +{ + CSSValueImpl *ohandle = other.handle() ; + if ( impl != ohandle ) { + if (impl) impl->deref(); + if (!other.isNull() && !other.isCSSValueList()) { + impl = 0; + } else { + impl = ohandle; + if (impl) impl->ref(); + } + } + return *this; +} + +CSSValueList::~CSSValueList() +{ +} + +unsigned long CSSValueList::length() const +{ + if(!impl) return 0; + return ((CSSValueListImpl *)impl)->length(); +} + +CSSValue CSSValueList::item( unsigned long index ) +{ + if(!impl) return 0; + return ((CSSValueListImpl *)impl)->item( index ); +} + +// ---------------------------------------------------------- + +CSSPrimitiveValue::CSSPrimitiveValue() : CSSValue() +{ +} + +CSSPrimitiveValue::CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other) +{ +} + +CSSPrimitiveValue::CSSPrimitiveValue(const CSSValue &other) : CSSValue(other) +{ + impl = 0; + operator=(other); +} + +CSSPrimitiveValue::CSSPrimitiveValue(CSSPrimitiveValueImpl *impl) : CSSValue(impl) +{ +} + +CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSPrimitiveValue &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.handle(); + if (impl) impl->ref(); + } + return *this; +} + +CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSValue &other) +{ + CSSValueImpl *ohandle = other.handle(); + if ( impl != ohandle ) { + if (impl) impl->deref(); + if (!other.isNull() && !other.isCSSPrimitiveValue()) { + impl = 0; + } else { + impl = ohandle; + if (impl) impl->ref(); + } + } + return *this; +} + +CSSPrimitiveValue::~CSSPrimitiveValue() +{ +} + +unsigned short CSSPrimitiveValue::primitiveType() const +{ + if(!impl) return 0; + return ((CSSPrimitiveValueImpl *)impl)->primitiveType(); +} + +void CSSPrimitiveValue::setFloatValue( unsigned short unitType, float floatValue ) +{ + if(!impl) return; + int exceptioncode = 0; + ((CSSPrimitiveValueImpl *)impl)->setFloatValue( unitType, floatValue, exceptioncode ); + if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET ) + throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +float CSSPrimitiveValue::getFloatValue( unsigned short unitType ) +{ + if(!impl) return 0; + // ### add unit conversion + if(primitiveType() != unitType) + throw CSSException(CSSException::SYNTAX_ERR); + return ((CSSPrimitiveValueImpl *)impl)->floatValue( unitType ); +} + +void CSSPrimitiveValue::setStringValue( unsigned short stringType, const DOMString &stringValue ) +{ + int exceptioncode = 0; + if(impl) + ((CSSPrimitiveValueImpl *)impl)->setStringValue( stringType, stringValue, exceptioncode ); + if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET ) + throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + +} + +DOMString CSSPrimitiveValue::getStringValue( ) +{ + if(!impl) return DOMString(); + return ((CSSPrimitiveValueImpl *)impl)->getStringValue( ); +} + +Counter CSSPrimitiveValue::getCounterValue( ) +{ + if(!impl) return Counter(); + return ((CSSPrimitiveValueImpl *)impl)->getCounterValue( ); +} + +Rect CSSPrimitiveValue::getRectValue( ) +{ + if(!impl) return Rect(); + return ((CSSPrimitiveValueImpl *)impl)->getRectValue( ); +} + +RGBColor CSSPrimitiveValue::getRGBColorValue( ) +{ + // ### + return RGBColor(); + //if(!impl) return RGBColor(); + //return ((CSSPrimitiveValueImpl *)impl)->getRGBColorValue( ); +} + +// ------------------------------------------------------------------- + +Counter::Counter() +{ +} + +Counter::Counter(const Counter &/*other*/) +{ + impl = 0; +} + +Counter &Counter::operator = (const Counter &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + return *this; +} + +Counter::Counter(CounterImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +Counter::~Counter() +{ + if (impl) impl->deref(); +} + +DOMString Counter::identifier() const +{ + if (!impl) return DOMString(); + return impl->identifier(); +} + +DOMString Counter::listStyle() const +{ + if (!impl) return DOMString(); + return tdehtml::stringForListStyleType((tdehtml::EListStyleType)impl->listStyle()); +} + +DOMString Counter::separator() const +{ + if (!impl) return DOMString(); + return impl->separator(); +} + +CounterImpl *Counter::handle() const +{ + return impl; +} + +bool Counter::isNull() const +{ + return (impl == 0); +} + +// -------------------------------------------------------------------- + +RGBColor::RGBColor() +{ +} + +RGBColor::RGBColor(const RGBColor &other) +{ + m_color = other.m_color; +} + +RGBColor::RGBColor(QRgb color) +{ + m_color = color; +} + +RGBColor &RGBColor::operator = (const RGBColor &other) +{ + m_color = other.m_color; + return *this; +} + +RGBColor::~RGBColor() +{ +} + +CSSPrimitiveValue RGBColor::red() const +{ + return new CSSPrimitiveValueImpl(float(tqAlpha(m_color) ? tqRed(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION); +} + +CSSPrimitiveValue RGBColor::green() const +{ + return new CSSPrimitiveValueImpl(float(tqAlpha(m_color) ? tqGreen(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION); +} + +CSSPrimitiveValue RGBColor::blue() const +{ + return new CSSPrimitiveValueImpl(float(tqAlpha(m_color) ? tqBlue(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION); +} + + +// --------------------------------------------------------------------- + +Rect::Rect() +{ + impl = 0; +} + +Rect::Rect(const Rect &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +Rect::Rect(RectImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +Rect &Rect::operator = (const Rect &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + return *this; +} + +Rect::~Rect() +{ + if (impl) impl->deref(); +} + +CSSPrimitiveValue Rect::top() const +{ + if (!impl) return 0; + return impl->top(); +} + +CSSPrimitiveValue Rect::right() const +{ + if (!impl) return 0; + return impl->right(); +} + +CSSPrimitiveValue Rect::bottom() const +{ + if (!impl) return 0; + return impl->bottom(); +} + +CSSPrimitiveValue Rect::left() const +{ + if (!impl) return 0; + return impl->left(); +} + +RectImpl *Rect::handle() const +{ + return impl; +} + +bool Rect::isNull() const +{ + return (impl == 0); +} + +} // namespace + + diff --git a/tdehtml/dom/css_value.h b/tdehtml/dom/css_value.h new file mode 100644 index 000000000..5d4a043c7 --- /dev/null +++ b/tdehtml/dom/css_value.h @@ -0,0 +1,745 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 2 Specification (Style) + * http://www.w3.org/TR/DOM-Level-2-Style/ + * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. + * + */ +#ifndef _CSS_css_value_h_ +#define _CSS_css_value_h_ + +#include <dom/dom_string.h> + +#include <tqcolor.h> + +#include <kdemacros.h> + +namespace DOM { + +class CSSStyleDeclarationImpl; +class CSSRule; +class CSSValue; + +/** + * The \c CSSStyleDeclaration interface represents a + * single <a href="http://www.w3.org/TR/REC-CSS2/syndata.html#block"> + * CSS declaration block </a> . This interface may be used to + * determine the style properties currently set in a block or to set + * style properties explicitly within the block. + * + * While an implementation may not recognize all CSS properties + * within a CSS declaration block, it is expected to provide access to + * all specified properties through the \c CSSStyleDeclaration + * interface. Furthermore, implementations that support a + * specific level of CSS should correctly handle <a + * href="http://www.w3.org/TR/REC-CSS2/about.html#shorthand"> CSS + * shorthand </a> properties for that level. For a further discussion + * of shorthand properties, see the \c CSS2Properties + * interface. + * + */ +class KHTML_EXPORT CSSStyleDeclaration +{ +public: + CSSStyleDeclaration(); + CSSStyleDeclaration(const CSSStyleDeclaration &other); + CSSStyleDeclaration(CSSStyleDeclarationImpl *impl); +public: + + CSSStyleDeclaration & operator = (const CSSStyleDeclaration &other); + + ~CSSStyleDeclaration(); + + /** + * The parsable textual representation of the declaration block + * (including the surrounding curly braces). Setting this + * attribute will result in the parsing of the new value and + * resetting of the properties in the declaration block. + * + */ + DOM::DOMString cssText() const; + + /** + * see cssText + * @exception CSSException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setCssText( const DOM::DOMString & ); + + /** + * The number of properties that have been explicitly set in this + * declaration block. + * + */ + unsigned long length() const; + + /** + * The CSS rule that contains this declaration block. + * + */ + CSSRule parentRule() const; + + /** + * Used to retrieve the value of a CSS property if it has been + * explicitly set within this declaration block. + * + * @param propertyName The name of the CSS property. See the <a + * href="http://www.w3.org/TR/REC-CSS2/propidx.html"> CSS property + * index </a> . + * + * @return Returns the value of the property if it has been + * explicitly set for this declaration block. Returns the empty + * string if the property has not been set. + * + */ + DOM::DOMString getPropertyValue ( const DOM::DOMString &propertyName ) const; + DOM::DOMString getPropertyValue ( const DOM::DOMString &propertyName ); + + /** + * Used to retrieve the object representation of the value of a + * CSS property if it has been explicitly set within this + * declaration block. This method returns null if the property is + * a <a href="http://www.w3.org/TR/REC-CSS2/about.html#shorthand"> + * shorthand </a> property. Shorthand property values can only be + * accessed and modified as strings, using the + * \c getPropertyValue and \c setProperty + * methods. + * + * @param propertyName The name of the CSS property. See the <a + * href="http://www.w3.org/TR/REC-CSS2/propidx.html"> CSS property + * index </a> . + * + * @return Returns the value of the property if it has been + * explicitly set for this declaration block. Returns the + * \c null if the property has not been set. + * + */ + CSSValue getPropertyCSSValue ( const DOM::DOMString &propertyName ) const; + CSSValue getPropertyCSSValue ( const DOM::DOMString &propertyName ); + + /** + * Used to remove a CSS property if it has been explicitly set + * within this declaration block. + * + * @param propertyName The name of the CSS property. See the <a + * href="http://www.w3.org/TR/REC-CSS2/propidx.html"> CSS property + * index </a> . + * + * @return Returns the value of the property if it has been + * explicitly set for this declaration block. Returns the empty + * string if the property has not been set or the property name + * does not correspond to a valid CSS2 property. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + DOM::DOMString removeProperty ( const DOM::DOMString &propertyName ); + + /** + * Used to retrieve the priority of a CSS property (e.g. the + * \c "important" qualifier) if the property has been + * explicitly set in this declaration block. + * + * @param propertyName The name of the CSS property. See the <a + * href="http://www.w3.org/TR/REC-CSS2/propidx.html"> CSS property + * index </a> . + * + * @return A string representing the priority (e.g. + * \c "important" ) if one exists. The empty string if none + * exists. + * + */ + DOM::DOMString getPropertyPriority ( const DOM::DOMString &propertyName ) const; + DOM::DOMString getPropertyPriority ( const DOM::DOMString &propertyName ); + + /** + * Used to set a property value and priority within this + * declaration block. + * + * @param propertyName The name of the CSS property. See the <a + * href="http://www.w3.org/TR/REC-CSS2/propidx.html"> CSS property + * index </a> . + * + * @param value The new value of the property. + * + * @param priority The new priority of the property (e.g. + * \c "important" ). + * + * @return + * + * @exception CSSException + * SYNTAX_ERR: Raised if the specified value has a syntax error + * and is unparsable. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setProperty ( const DOM::DOMString &propertyName, const DOM::DOMString &value, const DOM::DOMString &priority ); + + /** + * Used to retrieve the properties that have been explicitly set + * in this declaration block. The order of the properties + * retrieved using this method does not have to be the order in + * which they were set. This method can be used to iterate over + * all properties in this declaration block. + * + * @param index Index of the property name to retrieve. + * + * @return The name of the property at this ordinal position. The + * empty string if no property exists at this position. + * + */ + DOM::DOMString item ( unsigned long index ) const; + DOM::DOMString item ( unsigned long index ); + + /** + * @internal + * not part of the DOM + */ + CSSStyleDeclarationImpl *handle() const; + bool isNull() const; + +protected: + CSSStyleDeclarationImpl *impl; +}; + + +class CSSValueImpl; + +/** + * The \c CSSValue interface represents a simple or a + * complexe value. + * + */ +class KHTML_EXPORT CSSValue +{ +public: + CSSValue(); + CSSValue(const CSSValue &other); + CSSValue(CSSValueImpl *impl); +public: + + CSSValue & operator = (const CSSValue &other); + + ~CSSValue(); + /** + * An integer indicating which type of unit applies to the value. + * + * All CSS2 constants are not supposed to be required by the + * implementation since all CSS2 interfaces are optionals. + * + */ + enum UnitTypes { + CSS_INHERIT = 0, + CSS_PRIMITIVE_VALUE = 1, + CSS_VALUE_LIST = 2, + CSS_CUSTOM = 3, + CSS_INITIAL = 4 + }; + + /** + * A string representation of the current value. + * + */ + DOM::DOMString cssText() const; + + /** + * see cssText + * @exception CSSException + * SYNTAX_ERR: Raised if the specified CSS string value has a + * syntax error and is unparsable. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is + * readonly. + * + */ + void setCssText( const DOM::DOMString & ); + + /** + * A code defining the type of the value as defined above. + * + */ + unsigned short cssValueType() const; + + /** + * @internal + * not part of the DOM + */ + bool isCSSValueList() const; + bool isCSSPrimitiveValue() const; + CSSValueImpl *handle() const; + bool isNull() const; + +protected: + CSSValueImpl *impl; +}; + + +class CSSValueListImpl; +class CSSValue; + +/** + * The \c CSSValueList interface provides the absraction + * of an ordered collection of CSS values. + * + */ +class KHTML_EXPORT CSSValueList : public CSSValue +{ +public: + CSSValueList(); + CSSValueList(const CSSValueList &other); + CSSValueList(const CSSValue &other); + CSSValueList(CSSValueListImpl *impl); +public: + + CSSValueList & operator = (const CSSValueList &other); + CSSValueList & operator = (const CSSValue &other); + + ~CSSValueList(); + + /** + * The number of \c CSSValue s in the list. The range + * of valid values indices is \c 0 to \c length-1 + * inclusive. + * + */ + unsigned long length() const; + + /** + * Used to retrieve a CSS rule by ordinal index. The order in this + * collection represents the order of the values in the CSS style + * property. + * + * @param index Index into the collection. + * + * @return The style rule at the \c index position in + * the \c CSSValueList , or \c null if + * that is not valid index. + * + */ + CSSValue item ( unsigned long index ); + +protected: + CSSValueListImpl *vimpl; +}; + + +class CSSPrimitiveValueImpl; +class Counter; +class RGBColor; +class Rect; + +/** + * The \c CSSPrimitiveValue interface represents a single + * <a href="http://www.w3.org/TR/REC-CSS2/syndata.html#values"> CSS + * value </a> . This interface may be used to determine the value of a + * specific style property currently set in a block or to set a + * specific style properties explicitly within the block. An instance + * of this interface can be obtained from the + * \c getPropertyCSSValue method of the + * \c CSSStyleDeclaration interface. + * + */ +class KHTML_EXPORT CSSPrimitiveValue : public CSSValue +{ +public: + CSSPrimitiveValue(); + CSSPrimitiveValue(const CSSPrimitiveValue &other); + CSSPrimitiveValue(const CSSValue &other); + CSSPrimitiveValue(CSSPrimitiveValueImpl *impl); +public: + + CSSPrimitiveValue & operator = (const CSSPrimitiveValue &other); + CSSPrimitiveValue & operator = (const CSSValue &other); + + ~CSSPrimitiveValue(); + /** + * An integer indicating which type of unit applies to the value. + * + */ + enum UnitTypes { + CSS_UNKNOWN = 0, + CSS_NUMBER = 1, + CSS_PERCENTAGE = 2, + CSS_EMS = 3, + CSS_EXS = 4, + CSS_PX = 5, + CSS_CM = 6, + CSS_MM = 7, + CSS_IN = 8, + CSS_PT = 9, + CSS_PC = 10, + CSS_DEG = 11, + CSS_RAD = 12, + CSS_GRAD = 13, + CSS_MS = 14, + CSS_S = 15, + CSS_HZ = 16, + CSS_KHZ = 17, + CSS_DIMENSION = 18, + CSS_STRING = 19, + CSS_URI = 20, + CSS_IDENT = 21, + CSS_ATTR = 22, + CSS_COUNTER = 23, + CSS_RECT = 24, + CSS_RGBCOLOR = 25, + CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs + CSS_HTML_RELATIVE = 255 + }; + + /** + * The type of the value as defined by the constants specified + * above. + * + */ + unsigned short primitiveType() const; + + /** + * A method to set the float value with a specified unit. If the + * property attached with this value can not accept the specified + * unit or the float value, the value will be unchanged and a + * \c DOMException will be raised. + * + * @param unitType A unit code as defined above. The unit code can + * only be a float unit type (e.g. \c NUMBER , + * \c PERCENTAGE , \c CSS_EMS , \c CSS_EXS + * , \c CSS_PX , \c CSS_PX , + * \c CSS_CM , \c CSS_MM , \c CSS_IN + * , \c CSS_PT , \c CSS_PC , + * \c CSS_DEG , \c CSS_RAD , + * \c CSS_GRAD , \c CSS_MS , \c CSS_S + * , \c CSS_HZ , \c CSS_KHZ , + * \c CSS_DIMENSION ). + * + * @param floatValue The new float value. + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the attached property doesn't + * support the float value or the unit type. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is + * readonly. + * + */ + void setFloatValue ( unsigned short unitType, float floatValue ); + + /** + * This method is used to get a float value in a specified unit. + * If this CSS value doesn't contain a float value or can't be + * converted into the specified unit, a \c DOMException + * is raised. + * + * @param unitType A unit code to get the float value. The unit + * code can only be a float unit type (e.g. \c CSS_NUMBER + * , \c CSS_PERCENTAGE , \c CSS_EMS + * , \c CSS_EXS , \c CSS_PX , + * \c CSS_PX , \c CSS_CM , \c CSS_MM + * , \c CSS_IN , \c CSS_PT , + * \c CSS_PC , \c CSS_DEG , \c CSS_RAD + * , \c CSS_GRAD , \c CSS_MS , + * \c CSS_S , \c CSS_HZ , \c CSS_KHZ + * , \c CSS_DIMENSION ). + * + * @return The float value in the specified unit. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a + * float value or if the float value can't be converted into the + * specified unit. + * + */ + // ### KDE 4: make this const! + float getFloatValue ( unsigned short unitType ); + + /** + * A method to set the string value with a specified unit. If the + * property attached to this value can't accept the specified unit + * or the string value, the value will be unchanged and a + * \c DOMException will be raised. + * + * @param stringType A string code as defined above. The string + * code can only be a string unit type (e.g. \c CSS_URI + * , \c CSS_IDENT , \c CSS_INHERIT + * and \c CSS_ATTR ). + * + * @param stringValue The new string value. If the + * \c stringType is equal to \c CSS_INHERIT , the + * \c stringValue should be \c inherit . + * + * @return + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a + * string value or if the string value can't be converted into the + * specified unit. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is + * readonly. + * + */ + void setStringValue ( unsigned short stringType, const DOM::DOMString &stringValue ); + + /** + * This method is used to get the string value in a specified + * unit. If the CSS value doesn't contain a string value, a + * \c DOMException is raised. + * + * @return The string value in the current unit. The current + * \c valueType can only be a string unit type (e.g. + * \c CSS_URI , \c CSS_IDENT and + * \c CSS_ATTR ). + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a + * string value. + * + */ + // ### KDE4: make this const! + DOM::DOMString getStringValue ( ); + + /** + * This method is used to get the Counter value. If this CSS value + * doesn't contain a counter value, a \c DOMException + * is raised. Modification to the corresponding style property can + * be achieved using the \c Counter interface. + * + * @return The Counter value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a + * Counter value. + * + */ + // ### KDE4: make this const! + Counter getCounterValue ( ); + + /** + * This method is used to get the Rect value. If this CSS value + * doesn't contain a rect value, a \c DOMException is + * raised. Modification to the corresponding style property can be + * achieved using the \c Rect interface. + * + * @return The Rect value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the CSS value doesn't contain a + * Rect value. + * + */ + // ### KDE4: make this const! + Rect getRectValue ( ); + + /** + * This method is used to get the RGB color. If this CSS value + * doesn't contain a RGB color value, a \c DOMException + * is raised. Modification to the corresponding style + * property can be achieved using the \c RGBColor + * interface. + * + * @return the RGB color value. + * + * @exception DOMException + * INVALID_ACCESS_ERR: Raises if the attached property can't + * return a RGB color value. + * + */ + // ### KDE4: make this const! + RGBColor getRGBColorValue ( ); +}; + + + +/** + * The \c RGBColor interface is used to represent any <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-color"> + * RGB color </a> value. This interface reflects the values in the + * underlying style property. Hence, modifications made through this + * interface modify the style property. + * + */ +class KHTML_EXPORT RGBColor +{ +public: + RGBColor(); + /** + * @deprecated + */ + RGBColor(const TQColor& c) { m_color = c.rgb(); } + RGBColor(QRgb color); + + RGBColor(const RGBColor &other); + RGBColor & operator = (const RGBColor &other); + + ~RGBColor(); + + /** + * This attribute is used for the red value of the RGB color. + * + */ + CSSPrimitiveValue red() const; + + /** + * This attribute is used for the green value of the RGB color. + * + */ + CSSPrimitiveValue green() const; + + /** + * This attribute is used for the blue value of the RGB color. + * + */ + CSSPrimitiveValue blue() const; + + /** + * @internal + */ + QRgb color() const { return m_color; } +protected: + QRgb m_color; +}; + +class RectImpl; + +/** + * The \c Rect interface is used to represent any <a + * href="http://www.w3.org/TR/REC-CSS2/visufx.html#value-def-shape"> + * rect </a> value. This interface reflects the values in the + * underlying style property. Hence, modifications made through this + * interface modify the style property. + * + */ +class KHTML_EXPORT Rect +{ + friend class CSSPrimitiveValue; +public: + Rect(); + Rect(const Rect &other); + + Rect & operator = (const Rect &other); + + ~Rect(); + + /** + * This attribute is used for the top of the rect. + * + */ + CSSPrimitiveValue top() const; + + /** + * This attribute is used for the right of the rect. + * + */ + CSSPrimitiveValue right() const; + + /** + * This attribute is used for the bottom of the rect. + * + */ + CSSPrimitiveValue bottom() const; + + /** + * This attribute is used for the left of the rect. + * + */ + CSSPrimitiveValue left() const; + + /** + * @internal + * not part of the DOM + */ + RectImpl *handle() const; + bool isNull() const; + +protected: + RectImpl *impl; + Rect(RectImpl *i); +}; + +class CounterImpl; + +/** + * The \c Counter interface is used to represent any <a + * href="http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-counter"> + * counter or counters function </a> value. This interface reflects + * the values in the underlying style property. Hence, modifications + * made through this interface modify the style property. + * + */ +class KHTML_EXPORT Counter +{ + friend class CSSPrimitiveValue; +public: + Counter(); + Counter(const Counter &other); +public: + + Counter & operator = (const Counter &other); + + ~Counter(); + + /** + * This attribute is used for the identifier of the counter. + * + */ + DOM::DOMString identifier() const; + + /** + * This attribute is used for the style of the list. + * + */ + DOM::DOMString listStyle() const; + + /** + * This attribute is used for the separator of nested counters. + * + */ + DOM::DOMString separator() const; + + /** + * @internal + * not part of the DOM + */ + CounterImpl *handle() const; + bool isNull() const; + +protected: + CounterImpl *impl; + Counter(CounterImpl *i); +}; + + +} // namespace + + +#endif diff --git a/tdehtml/dom/dom2_events.cpp b/tdehtml/dom/dom2_events.cpp new file mode 100644 index 000000000..898a73bc3 --- /dev/null +++ b/tdehtml/dom/dom2_events.cpp @@ -0,0 +1,725 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom2_views.h" +#include "dom/dom_exception.h" +#include "xml/dom2_eventsimpl.h" + +using namespace DOM; + +EventListener::EventListener() +{ +} + +EventListener::~EventListener() +{ +} + +void EventListener::handleEvent(Event &/*evt*/) +{ +} + +DOMString EventListener::eventListenerType() +{ + return ""; +} + +// ----------------------------------------------------------------------------- + +Event::Event() +{ + impl = 0; +} + + +Event::Event(const Event &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +Event::Event(EventImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +Event::~Event() +{ + if (impl) impl->deref(); +} + +Event &Event::operator = (const Event &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +DOMString Event::type() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->type(); +} + +Node Event::target() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->target(); +} + +Node Event::currentTarget() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->currentTarget(); +} + +unsigned short Event::eventPhase() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->eventPhase(); +} + +bool Event::bubbles() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->bubbles(); +} + +bool Event::cancelable() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->cancelable(); +} + +DOMTimeStamp Event::timeStamp() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->timeStamp(); +} + +void Event::stopPropagation() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + impl->stopPropagation(true); +} + +void Event::preventDefault() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + impl->preventDefault(true); +} + +void Event::initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + impl->initEvent(eventTypeArg,canBubbleArg,cancelableArg); +} + +EventImpl *Event::handle() const +{ + return impl; +} + +bool Event::isNull() const +{ + return (impl == 0); +} + +// ----------------------------------------------------------------------------- + +#ifndef SAVE_SPACE + +EventException::EventException(unsigned short _code) +{ + code = _code; +} + +EventException::EventException(const EventException &other) +{ + code = other.code; +} + +EventException & EventException::operator = (const EventException &other) +{ + code = other.code; + return *this; +} + +#endif + +// ----------------------------------------------------------------------------- + +UIEvent::UIEvent() : Event() +{ +} + +UIEvent::UIEvent(const UIEvent &other) : Event(other) +{ +} + +UIEvent::UIEvent(const Event &other) : Event() +{ + (*this)=other; +} + +UIEvent::UIEvent(UIEventImpl *impl) : Event(impl) +{ +} + +UIEvent &UIEvent::operator = (const UIEvent &other) +{ + Event::operator = (other); + return *this; +} + +UIEvent &UIEvent::operator = (const Event &other) +{ + Event e; + e = other; + if (!e.isNull() && !e.handle()->isUIEvent()) { + if ( impl ) impl->deref(); + impl = 0; + } else + Event::operator = (other); + return *this; +} + +UIEvent::~UIEvent() +{ +} + +AbstractView UIEvent::view() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<UIEventImpl*>(impl)->view(); +} + +long UIEvent::detail() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<UIEventImpl*>(impl)->detail(); +} + +int UIEvent::keyCode() const +{ + if ( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR ); + + if( impl->isTextInputEvent() || impl->isKeyboardEvent() ) + return static_cast<KeyEventBaseImpl*>( impl )->keyCode(); + + return 0; +} + +int UIEvent::charCode() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + if( impl->isTextInputEvent() || impl->isKeyboardEvent() ) + return static_cast<KeyEventBaseImpl*>( impl )->charCode(); + + return 0; +} + +int UIEvent::pageX() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + if (impl->isMouseEvent() ) + return static_cast<MouseEventImpl*>( impl )->pageX(); + else + return 0; +} + +int UIEvent::pageY() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + if ( impl->isMouseEvent() ) + return static_cast<MouseEventImpl*>( impl )->pageY(); + else + return 0; +} + +int UIEvent::layerX() const +{ + if( !impl ) + throw DOMException( DOMException::INVALID_STATE_ERR ); + + if( impl->isMouseEvent() ) + return static_cast<MouseEventImpl*>( impl )->layerX(); + return 0; +} + +int UIEvent::layerY() const +{ + if( !impl ) + throw DOMException( DOMException::INVALID_STATE_ERR ); + + if( impl->isMouseEvent() ) + return static_cast<MouseEventImpl*>( impl )->layerY(); + return 0; +} + +int UIEvent::which() const +{ + if( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR ); + + if( impl->isMouseEvent() ) + return static_cast<MouseEventImpl*>( impl )->button() + 1; + else if( impl->isTextInputEvent() || impl->isKeyboardEvent() ) + { + // return 0 unless the key has an ascii value + if ( static_cast<KeyEventBaseImpl*>( impl )->keyVal() ) + return static_cast<KeyEventBaseImpl*>( impl )->keyCode(); + } + + return 0; +} + +void UIEvent::initUIEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const AbstractView &viewArg, + long detailArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<UIEventImpl*>(impl)->initUIEvent(typeArg,canBubbleArg,cancelableArg, + viewArg,detailArg); +} + +// ----------------------------------------------------------------------------- + +MouseEvent::MouseEvent() : UIEvent() +{ +} + +MouseEvent::MouseEvent(const MouseEvent &other) : UIEvent(other) +{ +} + +MouseEvent::MouseEvent(const Event &other) : UIEvent() +{ + (*this)=other; +} + +MouseEvent::MouseEvent(MouseEventImpl *impl) : UIEvent(impl) +{ +} + +MouseEvent &MouseEvent::operator = (const MouseEvent &other) +{ + UIEvent::operator = (other); + return *this; +} + +MouseEvent &MouseEvent::operator = (const Event &other) +{ + Event e; + e = other; + if (!e.isNull() && !e.handle()->isMouseEvent()) { + if ( impl ) impl->deref(); + impl = 0; + } else + UIEvent::operator = (other); + return *this; +} + +MouseEvent::~MouseEvent() +{ +} + +long MouseEvent::screenX() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->screenX(); +} + +long MouseEvent::screenY() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->screenY(); +} + +long MouseEvent::clientX() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->clientX(); +} + +long MouseEvent::clientY() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->clientY(); +} + +bool MouseEvent::ctrlKey() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->ctrlKey(); +} + +bool MouseEvent::shiftKey() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->shiftKey(); +} + +bool MouseEvent::altKey() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->altKey(); +} + +bool MouseEvent::metaKey() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->metaKey(); +} + +unsigned short MouseEvent::button() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->button(); +} + +Node MouseEvent::relatedTarget() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MouseEventImpl*>(impl)->relatedTarget(); +} + +void MouseEvent::initMouseEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const AbstractView &viewArg, + long detailArg, + long screenXArg, + long screenYArg, + long clientXArg, + long clientYArg, + bool ctrlKeyArg, + bool altKeyArg, + bool shiftKeyArg, + bool metaKeyArg, + unsigned short buttonArg, + const Node &relatedTargetArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<MouseEventImpl*>(impl)->initMouseEvent(typeArg,canBubbleArg, + cancelableArg,viewArg,detailArg,screenXArg,screenYArg,clientXArg, + clientYArg,ctrlKeyArg,altKeyArg,shiftKeyArg,metaKeyArg,buttonArg, + relatedTargetArg); +} + +// ----------------------------------------------------------------------------- + +TextEvent::TextEvent() : UIEvent() +{ +} + +TextEvent::TextEvent(const TextEvent &other) : UIEvent(other) +{ +} + +TextEvent::TextEvent(const Event &other) : UIEvent() +{ + (*this)=other; +} + +TextEvent::TextEvent(KeyEventBaseImpl *impl) : UIEvent(impl) +{ +} + +TextEvent &TextEvent::operator = (const TextEvent &other) +{ + UIEvent::operator = (other); + return *this; +} + +TextEvent &TextEvent::operator = (const Event &other) +{ + Event e; + e = other; + if (!e.isNull() && !(e.handle()->isTextInputEvent() || e.handle()->isKeyboardEvent())) { + if ( impl ) impl->deref(); + impl = 0; + } else + UIEvent::operator = (other); + return *this; +} + +TextEvent::~TextEvent() +{ +} + +void TextEvent::initTextEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const AbstractView &viewArg, + long /*detailArg*/, + const DOMString &outputStringArg, + unsigned long keyValArg, + unsigned long virtKeyValArg, + bool /*inputGeneratedArg*/, + bool numPadArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + if (impl->isTextInputEvent()) { + //Initialize based on the outputStringArg or virtKeyValArg. + TQString text = outputStringArg.string(); + if (outputStringArg.length() == 0 && virtKeyValArg) { + text += TQChar((unsigned short)virtKeyValArg); + } + + TextEventImpl* tImpl = static_cast<TextEventImpl*>(impl); + tImpl->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg, text); + } else { + KeyboardEventImpl* kbImpl = static_cast<KeyboardEventImpl*>(impl); + kbImpl->initKeyboardEvent(typeArg, canBubbleArg, cancelableArg, viewArg, + keyValArg, virtKeyValArg, 0, numPadArg ? + KeyboardEventImpl::DOM_KEY_LOCATION_NUMPAD : KeyboardEventImpl::DOM_KEY_LOCATION_STANDARD); + } +} + +unsigned long TextEvent::keyVal() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<KeyEventBaseImpl*>(impl)->keyVal(); +} + +DOMString TextEvent::outputString() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + KeyEventBaseImpl* ke = static_cast<KeyEventBaseImpl*>(impl); + if (ke->isTextInputEvent()) + return static_cast<TextEventImpl*>(ke)->data(); + else { + if (ke->keyVal()) + return TQString(TQChar((ushort)ke->keyVal())); + else + return DOMString(); + } +} + +unsigned long TextEvent::virtKeyVal() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<KeyEventBaseImpl*>(impl)->virtKeyVal(); +} + +void TextEvent::initModifier(unsigned long modifierArg, bool valueArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<KeyEventBaseImpl*>(impl)->initModifier(modifierArg,valueArg); +} + +bool TextEvent::checkModifier(unsigned long modifierArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<KeyEventBaseImpl*>(impl)->checkModifier(modifierArg); +} + +bool TextEvent::inputGenerated() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<KeyEventBaseImpl*>(impl)->inputGenerated(); +} + +bool TextEvent::numPad() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + KeyEventBaseImpl* ke = static_cast<KeyEventBaseImpl*>(impl); + if (ke->isKeyboardEvent()) + return static_cast<KeyboardEventImpl*>(ke)->keyLocation() == + KeyboardEventImpl::DOM_KEY_LOCATION_NUMPAD; + else return false; +} +// ----------------------------------------------------------------------------- + +MutationEvent::MutationEvent() : Event() +{ +} + +MutationEvent::MutationEvent(const MutationEvent &other) : Event(other) +{ +} + +MutationEvent::MutationEvent(const Event &other) : Event() +{ + (*this)=other; +} + +MutationEvent::MutationEvent(MutationEventImpl *impl) : Event(impl) +{ +} + +MutationEvent &MutationEvent::operator = (const MutationEvent &other) +{ + Event::operator = (other); + return *this; +} + +MutationEvent &MutationEvent::operator = (const Event &other) +{ + Event e; + e = other; + if (!e.isNull() && !e.handle()->isMutationEvent()) { + if ( impl ) impl->deref(); + impl = 0; + } else + Event::operator = (other); + return *this; +} + +MutationEvent::~MutationEvent() +{ +} + +Node MutationEvent::relatedNode() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MutationEventImpl*>(impl)->relatedNode(); +} + +DOMString MutationEvent::prevValue() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MutationEventImpl*>(impl)->prevValue(); +} + +DOMString MutationEvent::newValue() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MutationEventImpl*>(impl)->newValue(); +} + +DOMString MutationEvent::attrName() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MutationEventImpl*>(impl)->attrName(); +} + +unsigned short MutationEvent::attrChange() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<MutationEventImpl*>(impl)->attrChange(); +} + +void MutationEvent::initMutationEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const Node &relatedNodeArg, + const DOMString &prevValueArg, + const DOMString &newValueArg, + const DOMString &attrNameArg, + unsigned short attrChangeArg) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<MutationEventImpl*>(impl)->initMutationEvent(typeArg, + canBubbleArg,cancelableArg,relatedNodeArg,prevValueArg, + newValueArg,attrNameArg,attrChangeArg); +} + + diff --git a/tdehtml/dom/dom2_events.h b/tdehtml/dom/dom2_events.h new file mode 100644 index 000000000..285a0c10e --- /dev/null +++ b/tdehtml/dom/dom2_events.h @@ -0,0 +1,846 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * (C) 2003 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef _DOM_Events_h_ +#define _DOM_Events_h_ + +#include <dom/dom_node.h> +#include <dom/dom_misc.h> + +namespace DOM { + +class Event; +class EventException; +class UIEvent; +class MouseEvent; +class TextEvent; +class MutationEvent; +class AbstractView; + +class EventListenerImpl; +class EventImpl; +class UIEventImpl; +class MouseEventImpl; +class KeyEventBaseImpl; +class MutationEventImpl; + + + +/** + * Introduced in DOM Level 2 + * + * The EventListener interface is the primary method for handling events. + * Users implement the EventListener interface and register their listener on + * an EventTarget using the AddEventListener method. The users should also + * remove their EventListener from its EventTarget after they have completed + * using the listener. + * + * When a Node is copied using the cloneNode method the EventListeners attached + * to the source Node are not attached to the copied Node. If the user wishes + * the same EventListeners to be added to the newly created copy the user must + * add them manually. + * + */ +class KHTML_EXPORT EventListener : public DomShared { +public: + EventListener(); + virtual ~EventListener(); + + /** + * This method is called whenever an event occurs of the type for which the + * EventListener interface was registered. Parameters + * + * @param evt The Event contains contextual information about the event. It + * also contains the stopPropagation and preventDefault methods which are + * used in determining the event's flow and default action. + * + */ + virtual void handleEvent(Event &evt); + + /** + * @internal + * not part of the DOM + * + * Returns a name specifying the type of listener. Useful for checking + * if an event is of a particular sublass. + * + */ + virtual DOMString eventListenerType(); + +protected: + /** + * @internal + * Reserved. Do not use in your subclasses. + */ + EventListenerImpl *impl; +}; + + +/** + * Introduced in DOM Level 2 + * + * The Event interface is used to provide contextual information about an event + * to the handler processing the event. An object which implements the Event + * interface is generally passed as the first parameter to an event handler. + * More specific context information is passed to event handlers by deriving + * additional interfaces from Event which contain information directly relating + * to the type of event they accompany. These derived interfaces are also + * implemented by the object passed to the event listener. + * + */ +class KHTML_EXPORT Event { + friend class Document; + friend class NodeImpl; + friend class DocumentImpl; +public: + Event(); + Event(const Event &other); + virtual ~Event(); + + Event & operator = (const Event &other); + + /** + * An integer indicating which phase of event flow is being processed. + * + * AT_TARGET: The event is currently being evaluated at the target + * EventTarget. + * + * BUBBLING_PHASE: The current event phase is the bubbling phase. + * + * CAPTURING_PHASE: The current event phase is the capturing phase. + * + */ + enum PhaseType { + CAPTURING_PHASE = 1, + AT_TARGET = 2, + BUBBLING_PHASE = 3 + }; + + /** + * The name of the event (case-insensitive). The name must be an XML name. + * + */ + DOMString type() const; + + /** + * Used to indicate the EventTarget to which the event was originally + * dispatched. + * + */ + Node target() const; + + /** + * Used to indicate the EventTarget whose EventListeners are currently + * being processed. This is particularly useful during capturing and + * bubbling. + * + */ + Node currentTarget() const; + + /** + * Used to indicate which phase of event flow is currently being evaluated. + * + */ + unsigned short eventPhase() const; + + /** + * Used to indicate whether or not an event is a bubbling event. If the + * event can bubble the value is true, else the value is false. + * + */ + bool bubbles() const; + + /** + * Used to indicate whether or not an event can have its default action + * prevented. If the default action can be prevented the value is true, + * else the value is false. + * + */ + bool cancelable() const; + + /** + * Used to specify the time (in milliseconds relative to the epoch) at + * which the event was created. Due to the fact that some systems may not + * provide this information the value of timeStamp may be not available for + * all events. When not available, a value of 0 will be returned. Examples + * of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970. + * + */ + DOMTimeStamp timeStamp() const; + + /** + * The stopPropagation method is used prevent further propagation of an + * event during event flow. If this method is called by any EventListener + * the event will cease propagating through the tree. The event will + * complete dispatch to all listeners on the current EventTarget before + * event flow stops. This method may be used during any stage of event flow. + * + */ + void stopPropagation(); + + /** + * If an event is cancelable, the preventDefault method is used to signify + * that the event is to be canceled, meaning any default action normally + * taken by the implementation as a result of the event will not occur. If, + * during any stage of event flow, the preventDefault method is called the + * event is canceled. Any default action associated with the event will not + * occur. Calling this method for a non-cancelable event has no effect. + * Once preventDefault has been called it will remain in effect throughout + * the remainder of the event's propagation. This method may be used during + * any stage of event flow. + * + */ + void preventDefault(); + + /** + * The initEvent method is used to initialize the value of an Event created + * through the DocumentEvent interface. This method may only be called + * before the Event has been dispatched via the dispatchEvent method, + * though it may be called multiple times during that phase if necessary. + * If called multiple times the final invocation takes precedence. If + * called from a subclass of Event interface only the values specified in + * the initEvent method are modified, all other attributes are left + * unchanged. + * + * @param eventTypeArg Specifies the event type. This type may be any event + * type currently defined in this specification or a new event type.. The + * string must be an XML name. + * + * Any new event type must not begin with any upper, lower, or mixed case + * version of the string "DOM". This prefix is reserved for future DOM + * event sets. It is also strongly recommended that third parties adding + * their own events use their own prefix to avoid confusion and lessen the + * probability of conflicts with other new events. + * + * @param canBubbleArg Specifies whether or not the event can bubble. + * + * @param cancelableArg Specifies whether or not the event's default action can be prevented. + * + */ + void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg); + + /** + * @internal + * not part of the DOM + */ + EventImpl *handle() const; + bool isNull() const; + +protected: + Event(EventImpl *i); + EventImpl *impl; +}; + + +/** + * Introduced in DOM Level 2: + * + * Event operations may throw an EventException as specified in their method + * descriptions. + * + */ +class KHTML_EXPORT EventException +{ +public: + EventException(unsigned short _code); + EventException(const EventException &other); + EventException & operator = (const EventException &other); + virtual ~EventException() {} + + /** + * An integer indicating the type of error generated. + * + * UNSPECIFIED_EVENT_TYPE_ERR: If the Event's type was not specified by + * initializing the event before the method was called. Specification of + * the Event's type as null or an empty string will also trigger this + * exception. + * + */ + enum EventExceptionCode { + UNSPECIFIED_EVENT_TYPE_ERR = 0 + }; + + unsigned short code; +}; + + +/** + * Introduced in DOM Level 2 + * + * The UIEvent interface provides specific contextual information associated + * with User Interface events. + * + */ +class KHTML_EXPORT UIEvent : public Event { +public: + UIEvent(); + UIEvent(const UIEvent &other); + UIEvent(const Event &other); + UIEvent & operator = (const UIEvent &other); + UIEvent & operator = (const Event &other); + virtual ~UIEvent(); + + /** + * The view attribute identifies the AbstractView from which the event was + * generated. + * + */ + AbstractView view() const; + + /** + * Specifies some detail information about the Event, depending on the type + * of event. + * + */ + long detail() const; + + /** + * Non-standard extension to support IE-style keyCode event property. + * + */ + int keyCode() const; + + /** + * Non-standard extension to support IE-style charCode event property. + * + */ + int charCode() const; + + /** + * Non-standard extensions to support Netscape-style pageX and pageY event properties. + * + */ + int pageX() const; + int pageY() const; + + /** + * Non-standard extensions to support Netscape-style layerX and layerY event properties. + * + */ + int layerX() const; + int layerY() const; + + /** + * Non-standard extension to support Netscape-style "which" event property. + * + */ + int which() const; + + /** + * The initUIEvent method is used to initialize the value of a UIEvent + * created through the DocumentEvent interface. This method may only be + * called before the UIEvent has been dispatched via the dispatchEvent + * method, though it may be called multiple times during that phase if + * necessary. If called multiple times, the final invocation takes + * precedence. + * + * @param typeArg Specifies the event type. + * + * @param canBubbleArg Specifies whether or not the event can bubble. + * + * @param cancelableArg Specifies whether or not the event's default action + * can be prevented. + * + * @param viewArg Specifies the Event's AbstractView. + * + * @param detailArg Specifies the Event's detail. + * + */ + void initUIEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const AbstractView &viewArg, + long detailArg); +protected: + UIEvent(UIEventImpl *impl); +}; + + + + +/** + * Introduced in DOM Level 2 + * + * The MouseEvent interface provides specific contextual information associated + * with Mouse events. + * + * The detail attribute inherited from UIEvent indicates the number of times a + * mouse button has been pressed and released over the same screen location + * during a user action. The attribute value is 1 when the user begins this + * action and increments by 1 for each full sequence of pressing and releasing. + * If the user moves the mouse between the mousedown and mouseup the value will + * be set to 0, indicating that no click is occurring. + * + * In the case of nested elements mouse events are always targeted at the most + * deeply nested element. Ancestors of the targeted element may use bubbling to + * obtain notification of mouse events which occur within its descendent elements. + * + */ +class KHTML_EXPORT MouseEvent : public UIEvent { +public: + MouseEvent(); + MouseEvent(const MouseEvent &other); + MouseEvent(const Event &other); + MouseEvent & operator = (const MouseEvent &other); + MouseEvent & operator = (const Event &other); + virtual ~MouseEvent(); + + /** + * The horizontal coordinate at which the event occurred relative to the + * origin of the screen coordinate system. + * + */ + long screenX() const; + + /** + * The vertical coordinate at which the event occurred relative to the + * origin of the screen coordinate system. + * + */ + long screenY() const; + + /** + * The horizontal coordinate at which the event occurred relative to the + * DOM implementation's client area. + * + */ + long clientX() const; + + /** + * The vertical coordinate at which the event occurred relative to the DOM + * implementation's client area. + * + */ + long clientY() const; + + /** + * Used to indicate whether the 'ctrl' key was depressed during the firing + * of the event. + */ + bool ctrlKey() const; + + /** + * Used to indicate whether the 'shift' key was depressed during the firing + * of the event. + * + */ + bool shiftKey() const; + + /** + * Used to indicate whether the 'alt' key was depressed during the firing + * of the event. On some platforms this key may map to an alternative key + * name. + * + */ + bool altKey() const; + + /** + * Used to indicate whether the 'meta' key was depressed during the firing + * of the event. On some platforms this key may map to an alternative key + * name. + * + */ + bool metaKey() const; + + /** + * During mouse events caused by the depression or release of a mouse + * button, button is used to indicate which mouse button changed state. The + * values for button range from zero to indicate the left button of the + * mouse, one to indicate the middle button if present, and two to indicate + * the right button. For mice configured for left handed use in which the + * button actions are reversed the values are instead read from right to + * left. + * + */ + unsigned short button() const; + + /** + * Used to identify a secondary EventTarget related to a UI event. + * Currently this attribute is used with the mouseover event to indicate + * the EventTarget which the pointing device exited and with the mouseout + * event to indicate the EventTarget which the pointing device entered. + * + */ + Node relatedTarget() const; + + /** + * The initMouseEvent method is used to initialize the value of a + * MouseEvent created through the DocumentEvent interface. This method may + * only be called before the MouseEvent has been dispatched via the + * dispatchEvent method, though it may be called multiple times during that + * phase if necessary. If called multiple times, the final invocation takes + * precedence. Parameters + * + * @param typeArg Specifies the event type. + * + * @param canBubbleArg Specifies whether or not the event can bubble. + * + * @param cancelableArg Specifies whether or not the event's default action can be prevented. + * + * @param viewArg Specifies the Event's AbstractView. + * + * @param detailArg Specifies the Event's mouse click count. + * + * @param screenXArg Specifies the Event's screen x coordinate + * + * @param screenYArg Specifies the Event's screen y coordinate + * + * @param clientXArg Specifies the Event's client x coordinate + * + * @param clientYArg Specifies the Event's client y coordinate + * + * @param ctrlKeyArg Specifies whether or not control key was depressed during the Event. + * + * @param altKeyArg Specifies whether or not alt key was depressed during the Event. + * + * @param shiftKeyArg Specifies whether or not shift key was depressed during the Event. + * + * @param metaKeyArg Specifies whether or not meta key was depressed during the Event. + * + * @param buttonArg Specifies the Event's mouse button. + * + * @param relatedTargetArg Specifies the Event's related EventTarget. + * + */ + void initMouseEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const AbstractView &viewArg, + long detailArg, + long screenXArg, + long screenYArg, + long clientXArg, + long clientYArg, + bool ctrlKeyArg, + bool altKeyArg, + bool shiftKeyArg, + bool metaKeyArg, + unsigned short buttonArg, + const Node &relatedTargetArg); +protected: + MouseEvent(MouseEventImpl *impl); +}; + +// Introduced in DOM Level 3: +/** + * DOM::TextEvent + * The detail attribute inherited from UIEvent is used to indicate + * the number of keypresses which have occurred during key repetition. + * If this information is not available this value should be 0. + * + * ### KDE4: split this up into proper KeyboardEvent and TextEvent classes + * as specified in current DOM3 Events revision. This is doing heavy emulation + * at the moment + */ +class KHTML_EXPORT TextEvent : public UIEvent { +public: + TextEvent(); + TextEvent(const TextEvent &other); + TextEvent(const Event &other); + TextEvent & operator = (const TextEvent &other); + TextEvent & operator = (const Event &other); + virtual ~TextEvent(); + + /** + * initTextEvent + * + * The initTextEvent method is used to initialize the value of a + * MouseEvent created through the DocumentEvent interface. This + * method may only be called before the TextEvent has been dispatched + * via the dispatchEvent method, though it may be called multiple + * times during that phase if necessary. If called multiple times, + * the final invocation takes precedence. This method has no effect + * if called after the event has been dispatched. + * + * Parameters: + * + * typeArg of type DOMString + * Specifies the event type. + * canBubbleArg of type boolean + * Specifies whether or not the event can bubble. + * cancelableArg of type boolean + * Specifies whether or not the event's default action can be prevent. + * viewArg of type views::AbstractView + * Specifies the TextEvent's AbstractView. + * detailArg of type unsigned short + * Specifies the number of repeated keypresses, if available. + * outputStringArg of type DOMString + * Specifies the TextEvent's outputString attribute + * keyValArg of type unsigned long + * Specifies the TextEvent's keyValattribute + * virtKeyValArg of type unsigned long + * Specifies the TextEvent's virtKeyValattribute + * inputGeneratedArg of type boolean + * Specifies the TextEvent's inputGeneratedattribute + * numPadArg of type boolean + * Specifies the TextEvent's numPadattribute + * + * No Return Value. + * No Exceptions. + */ + void initTextEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const AbstractView &viewArg, + long detailArg, + const DOMString &outputStringArg, + unsigned long keyValArg, + unsigned long virtKeyValArg, + bool inputGeneratedArg, + bool numPadArg); + + /** + * initModifier + * + * The initModifier method is used to initialize the values of any + * modifiers associated with a TextEvent created through the + * DocumentEvent interface. This method may only be called before the + * TextEvent has been dispatched via the dispatchEvent method, though + * it may be called multiple times during that phase if necessary. If + * called multiple times with the same modifier property the final + * invocation takes precedence. Unless explicitly give a value of + * true, all modifiers have a value of false. This method has no + * effect if called after the event has been dispatched. The list of + * keys below represents the allowable modifier parameters for this + * method (note: this was not documented properly in earlier versions): + * + * Qt::ShiftButton, Qt::AltButton, Qt::ControlButton, Qt::MetaButton + * + * Parameters: + * + * modifier of type unsigned long + * The modifier which the user wishes to initialize + * value of type boolean + * The new value of the modifier. + * + * No Return Value + * No Exceptions + */ + void initModifier(unsigned long modifierArg, bool valueArg); + + /** + * inputGenerated of type boolean + * + * The inputGenerated attribute indicates whether the key event will + * normally cause visible output. If the key event does not + * generate any visible output, such as the use of a function key + * or the combination of certain modifier keys used in conjunction + * with another key, then the value will be false. If visible + * output is normally generated by the key event then the value + * will be true. The value of inputGenerated does not guarantee + * the creation of a character. If a key event causing visible + * output is cancelable it may be prevented from causing + * output. This attribute is intended primarily to differentiate + * between keys events which may or may not produce visible output + * depending on the system state. + */ + bool inputGenerated() const; + + /** keyVal of type unsigned long + * + * The value of keyVal holds the value of the Unicode character + * associated with the depressed key. If the key has no Unicode + * representation or no Unicode character is available the value is + * 0. + */ + unsigned long keyVal() const; + + /** numPad of type boolean + * + * The numPad attribute indicates whether or not the key event was + * generated on the number pad section of the keyboard. If the number + * pad was used to generate the key event the value is true, + * otherwise the value is false. + */ + bool numPad() const; + + /** + *outputString of type DOMString + * + * outputString holds the value of the output generated by the key + * event. This may be a single Unicode character or it may be a + * string. It may also be null in the case where no output was + * generated by the key event. + */ + + DOMString outputString() const; + /** virtKeyVal of type unsigned long + * + * When the key associated with a key event is not representable via + * a Unicode character virtKeyVale holds the virtual key code + * associated with the depressed key. If the key has a Unicode + * representation or no virtual code is available the value is + * DOM_VK_UNDEFINED. + */ + unsigned long virtKeyVal() const; + + /** + * checkModifier + * + * Note: the below description does not match the actual behavior. + * it's extended in a way that you can query multiple modifiers + * at once by logically OR`ing them. + * also, we use the Qt modifier enum instead of the DOM one. + * + * The CheckModifier method is used to check the status of a single + * modifier key associated with a TextEvent. The identifier of the + * modifier in question is passed into the CheckModifier function. If + * the modifier is triggered it will return true. If not, it will + * return false. The list of keys below represents the allowable + * modifier parameters for this method (warning: this was not documented + * properly in earlier versions): + * Qt::ShiftButton, Qt::AltButton, Qt::ControlButton, Qt::MetaButton + * + * Parameters: + * + * modifier of type unsigned long + * The modifier which the user wishes to query. + * + * Return Value: boolean + * The status of the modifier represented as a boolean. + * + * No Exceptions + */ + bool checkModifier(unsigned long modifierArg); // ### KDE 4: const! + +protected: + TextEvent(KeyEventBaseImpl *impl); +}; + + +/** + * Introduced in DOM Level 2 + * + * The MutationEvent interface provides specific contextual information + * associated with Mutation events. + * + */ +class KHTML_EXPORT MutationEvent : public Event { +public: + MutationEvent(); + MutationEvent(const MutationEvent &other); + MutationEvent(const Event &other); + MutationEvent & operator = (const MutationEvent &other); + MutationEvent & operator = (const Event &other); + virtual ~MutationEvent(); + + /** + * An integer indicating in which way the Attr was changed. + * + * ADDITION: The Attr was just added. + * + * MODIFICATION: The Attr was modified in place. + * + * REMOVAL: The Attr was just removed. + * + */ + enum attrChangeType { + MODIFICATION = 1, + ADDITION = 2, + REMOVAL = 3 + }; + + + /** + * relatedNode is used to identify a secondary node related to a mutation + * event. For example, if a mutation event is dispatched to a node + * indicating that its parent has changed, the relatedNode is the changed + * parent. If an event is instead dispatched to a subtree indicating a node + * was changed within it, the relatedNode is the changed node. In the case + * of the DOMAttrModified event it indicates the Attr node which was + * modified, added, or removed. + * + */ + Node relatedNode() const; + + /** + * prevValue indicates the previous value of the Attr node in + * DOMAttrModified events, and of the CharacterData node in + * DOMCharDataModified events. + * + */ + DOMString prevValue() const; + + /** + * newValue indicates the new value of the Attr node in DOMAttrModified + * events, and of the CharacterData node in DOMCharDataModified events. + * + */ + DOMString newValue() const; + + /** + * attrName indicates the name of the changed Attr node in a + * DOMAttrModified event. + * + */ + DOMString attrName() const; + + /** + * attrChange indicates the type of change which triggered the + * DOMAttrModified event. The values can be MODIFICATION, ADDITION, or + * REMOVAL. + * + */ + unsigned short attrChange() const; + + /** + * The initMutationEvent method is used to initialize the value of a + * MutationEvent created through the DocumentEvent interface. This method + * may only be called before the MutationEvent has been dispatched via the + * dispatchEvent method, though it may be called multiple times during that + * phase if necessary. If called multiple times, the final invocation takes + * precedence. + * + * @param typeArg Specifies the event type. + * + * @param canBubbleArg Specifies whether or not the event can bubble. + * + * @param cancelableArg Specifies whether or not the event's default action can be prevented. + * + * @param relatedNodeArg Specifies the Event's related Node. + * + * @param prevValueArg Specifies the Event's prevValue attribute. This value may be null. + * + * @param newValueArg Specifies the Event's newValue attribute. This value may be null. + * + * @param attrNameArg Specifies the Event's attrName attribute. This value may be null. + * + * @param attrChangeArg Specifies the Event's attrChange attribute + * + */ + void initMutationEvent(const DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const Node &relatedNodeArg, + const DOMString &prevValueArg, + const DOMString &newValueArg, + const DOMString &attrNameArg, + unsigned short attrChangeArg); +protected: + MutationEvent(MutationEventImpl *impl); +}; + + + +} //namespace +#endif diff --git a/tdehtml/dom/dom2_range.cpp b/tdehtml/dom/dom2_range.cpp new file mode 100644 index 000000000..87bdab145 --- /dev/null +++ b/tdehtml/dom/dom2_range.cpp @@ -0,0 +1,406 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) + * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) + * (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "dom/dom_exception.h" +#include "xml/dom_docimpl.h" +#include "xml/dom2_rangeimpl.h" + +using namespace DOM; + +Range::Range() +{ + // a range can't exist by itself - it must be associated with a document + impl = 0; +} + +Range::Range(const Document rootContainer) +{ + if(rootContainer.handle()) + { + impl = new RangeImpl(rootContainer.handle()->docPtr()); + impl->ref(); + } + else + impl = 0; +} + +Range::Range(const Range &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +Range::Range(const Node startContainer, const long startOffset, const Node endContainer, const long endOffset) +{ + if (startContainer.isNull() || endContainer.isNull()) { + throw DOMException(DOMException::NOT_FOUND_ERR); + } + + if (!startContainer.handle()->getDocument() || + startContainer.handle()->getDocument() != endContainer.handle()->getDocument()) { + throw DOMException(DOMException::WRONG_DOCUMENT_ERR); + } + + impl = new RangeImpl(startContainer.handle()->docPtr(),startContainer.handle(),startOffset,endContainer.handle(),endOffset); + impl->ref(); +} + +Range::Range(RangeImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +Range &Range::operator = (const Range &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + return *this; +} + +Range::~Range() +{ + if (impl) impl->deref(); +} + +Node Range::startContainer() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeImpl *r = impl->startContainer(exceptioncode); + throwException(exceptioncode); + return r; +} + +long Range::startOffset() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + long r = impl->startOffset(exceptioncode); + throwException(exceptioncode); + return r; + +} + +Node Range::endContainer() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeImpl *r = impl->endContainer(exceptioncode); + throwException(exceptioncode); + return r; +} + +long Range::endOffset() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + long r = impl->endOffset(exceptioncode); + throwException(exceptioncode); + return r; +} + +bool Range::collapsed() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + bool r = impl->collapsed(exceptioncode); + throwException(exceptioncode); + return r; +} + +Node Range::commonAncestorContainer() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeImpl *r = impl->commonAncestorContainer(exceptioncode); + throwException(exceptioncode); + return r; +} + +void Range::setStart( const Node &refNode, long offset ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->setStart(refNode.handle(),offset,exceptioncode); + throwException(exceptioncode); +} + +void Range::setEnd( const Node &refNode, long offset ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->setEnd(refNode.handle(),offset,exceptioncode); + throwException(exceptioncode); +} + +void Range::setStartBefore( const Node &refNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + + int exceptioncode = 0; + impl->setStartBefore(refNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +void Range::setStartAfter( const Node &refNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->setStartAfter(refNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +void Range::setEndBefore( const Node &refNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->setEndBefore(refNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +void Range::setEndAfter( const Node &refNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->setEndAfter(refNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +void Range::collapse( bool toStart ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->collapse(toStart,exceptioncode); + throwException(exceptioncode); +} + +void Range::selectNode( const Node &refNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->selectNode(refNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +void Range::selectNodeContents( const Node &refNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->selectNodeContents(refNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +short Range::compareBoundaryPoints( CompareHow how, const Range &sourceRange ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + short r = impl->compareBoundaryPoints(how,sourceRange.handle(),exceptioncode); + throwException(exceptioncode); + return r; +} + +bool Range::boundaryPointsValid( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->boundaryPointsValid(); +} + +void Range::deleteContents( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->deleteContents(exceptioncode); + throwException(exceptioncode); +} + +DocumentFragment Range::extractContents( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + DocumentFragmentImpl *r = impl->extractContents(exceptioncode); + throwException(exceptioncode); + return r; +} + +DocumentFragment Range::cloneContents( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + DocumentFragmentImpl *r = impl->cloneContents(exceptioncode); + throwException(exceptioncode); + return r; +} + +void Range::insertNode( const Node &newNode ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->insertNode(newNode.handle(),exceptioncode); + throwException(exceptioncode); +} + +void Range::surroundContents( const Node &newParent ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->surroundContents(newParent.handle(),exceptioncode); + throwException(exceptioncode); +} + +Range Range::cloneRange( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + RangeImpl *r = impl->cloneRange(exceptioncode); + throwException(exceptioncode); + return r; +} + +DOMString Range::toString( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + DOMString r = impl->toString(exceptioncode); + throwException(exceptioncode); + return r; + +} + +DOMString Range::toHTML( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + int exceptioncode = 0; + DOMString r = impl->toHTML(exceptioncode); + throwException(exceptioncode); + return r; +} + +DocumentFragment Range::createContextualFragment( const DOMString &html ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + DocumentFragment r = impl->createContextualFragment(html, exceptioncode); + throwException(exceptioncode); + return r; +} + + +void Range::detach( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->detach(exceptioncode); + throwException(exceptioncode); +} + +bool Range::isDetached() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->isDetached(); +} + +RangeImpl *Range::handle() const +{ + return impl; +} + +bool Range::isNull() const +{ + return (impl == 0); +} + +void Range::throwException(int exceptioncode) const +{ + if (!exceptioncode) + return; + + // ### also check for CSS & other exceptions? + if (exceptioncode >= RangeException::_EXCEPTION_OFFSET && exceptioncode <= RangeException::_EXCEPTION_MAX) + throw RangeException(static_cast<RangeException::RangeExceptionCode>(exceptioncode-RangeException::_EXCEPTION_OFFSET)); + else + throw DOMException(exceptioncode); +} + + + diff --git a/tdehtml/dom/dom2_range.h b/tdehtml/dom/dom2_range.h new file mode 100644 index 000000000..290f4f48c --- /dev/null +++ b/tdehtml/dom/dom2_range.h @@ -0,0 +1,475 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) + * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) + * (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 2 Specification (Candidate Recommendation) + * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/ + * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. + * + */ +#ifndef _dom2_range_h_ +#define _dom2_range_h_ + +#include <dom/dom_doc.h> +#include <dom/dom_misc.h> + +namespace DOM { + +class DocumentFragment; +class Node; +class DOMString; +class DocumentImpl; +class RangeImpl; + +class DOMException; + +// Introduced in DOM Level 2: +class KHTML_EXPORT RangeException { +public: + RangeException(unsigned short _code) { code = _code; } + RangeException(const RangeException &other) { code = other.code; } + + RangeException & operator = (const RangeException &other) + { code = other.code; return *this; } + + virtual ~RangeException() {} + /** + * An integer indicating the type of error generated. + * + */ + enum RangeExceptionCode { + BAD_BOUNDARYPOINTS_ERR = 1, + INVALID_NODE_TYPE_ERR = 2, + _EXCEPTION_OFFSET = 2000, + _EXCEPTION_MAX = 2999 + }; + unsigned short code; +}; + + +class KHTML_EXPORT Range +{ + friend class DocumentImpl; + friend class Document; + friend class RangeImpl; +public: + Range(); + Range(const Document rootContainer); + Range(const Range &other); + Range(const Node startContainer, const long startOffset, const Node endContainer, const long endOffset); + + Range & operator = (const Range &other); + + ~Range(); + + /** + * Node within which the range begins + * + */ + Node startContainer() const; + + /** + * Offset within the starting node of the range. + * + */ + long startOffset() const; + + /** + * Node within which the range ends + * + */ + Node endContainer() const; + + /** + * Offset within the ending node of the range. + * + */ + long endOffset() const; + + /** + * true if the range is collapsed + * + */ + bool collapsed() const; + + /** + * Gets the common ancestor container of the range's two end-points. + * Also sets it. + * + */ + // ### BIC make const in the next release + Node commonAncestorContainer(); + + /** + * Sets the attributes describing the start of the range. + * + * @param refNode The \c refNode value. This parameter + * must be different from \c null . + * + * @param offset The \c startOffset value. + * + * @return + * + * @exception RangeException + * NULL_NODE_ERR: Raised if \c refNode is \c null . + * + * INVALID_NODE_TYPE_ERR: Raised if \c refNode or an + * ancestor of \c refNode is an Attr, Entity, + * Notation, or DocumentType node. + * + * If an offset is out-of-bounds, should it just be fixed up or + * should an exception be raised. + * + */ + void setStart ( const Node &refNode, long offset ); + + /** + * Sets the attributes describing the end of a range. + * + * @param refNode The \c refNode value. This parameter + * must be different from \c null . + * + * @param offset The \c endOffset value. + * + * @return + * + * @exception RangeException + * NULL_NODE_ERR: Raised if \c refNode is \c null . + * + * INVALID_NODE_TYPE_ERR: Raised if \c refNode or an + * ancestor of \c refNode is an Attr, Entity, + * Notation, or DocumentType node. + * + */ + void setEnd ( const Node &refNode, long offset ); + + /** + * Sets the start position to be before a node + * + * @param refNode Range starts before \c refNode + * + * @return + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode + * is an Attr, Entity, Notation, or DocumentType node or + * if \c refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * + */ + void setStartBefore ( const Node &refNode ); + + /** + * Sets the start position to be after a node + * + * @param refNode Range starts after \c refNode + * + * @return + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode + * is an Attr, Entity, Notation, or DocumentType node or + * if \c refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * + */ + void setStartAfter ( const Node &refNode ); + + /** + * Sets the end position to be before a node. + * + * @param refNode Range ends before \c refNode + * + * @return + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode + * is an Attr, Entity, Notation, or DocumentType node or + * if \c refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * + */ + void setEndBefore ( const Node &refNode ); + + /** + * Sets the end of a range to be after a node + * + * @param refNode Range ends after \c refNode . + * + * @return + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode + * is an Attr, Entity, Notation or DocumentType node or if + * \c refNode is a Document, DocumentFragment, Attr, + * Entity, or Notation node. + * + */ + void setEndAfter ( const Node &refNode ); + + /** + * Collapse a range onto one of its end-points + * + * @param toStart If true, collapses the Range onto its start; if + * false, collapses it onto its end. + * + * @return + * + */ + void collapse ( bool toStart ); + + /** + * Select a node and its contents + * + * @param refNode The node to select. + * + * @return + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode + * is an Attr, Entity, Notation or DocumentType node or if + * \c refNode is a Document, DocumentFragment, Attr, + * Entity, or Notation node. + * + */ + void selectNode ( const Node &refNode ); + + /** + * Select the contents within a node + * + * @param refNode Node to select from + * + * @return + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if \c refNode or an + * ancestor of \c refNode is an Attr, Entity, Notation + * or DocumentType node. + * + */ + void selectNodeContents ( const Node &refNode ); + + enum CompareHow { + START_TO_START = 0, + START_TO_END = 1, + END_TO_END = 2, + END_TO_START = 3 + }; + + /** + * Compare the end-points of two ranges in a document. + * + * @param how + * + * @param sourceRange + * + * @return -1, 0 or 1 depending on whether the corresponding + * end-point of the Range is before, equal to, or after the + * corresponding end-point of \c sourceRange . + * + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the + * same document or document fragment. + * + */ + short compareBoundaryPoints ( CompareHow how, const Range &sourceRange ); + + /** + * @internal + * not part of the DOM + * + * Compare the boundary-points of a range. + * + * Return true if the startContainer is before the endContainer, + * or if they are equal. + * Return false if the startContainer is after the endContainer. + * + */ + bool boundaryPointsValid ( ); + + /** + * Removes the contents of a range from the containing document or + * document fragment without returning a reference to the removed + * content. + * + * @return + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the + * content of the range is read-only or any of the nodes that + * contain any of the content of the range are read-only. + * + */ + void deleteContents ( ); + + /** + * Moves the contents of a range from the containing document or + * document fragment to a new DocumentFragment. + * + * @return A DocumentFragment containing the extracted contents. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the + * content of the range is read-only or any of the nodes which + * contain any of the content of the range are read-only. + * + * HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be + * extracted into the new DocumentFragment. + * + */ + DocumentFragment extractContents ( ); + + /** + * Duplicates the contents of a range + * + * @return A DocumentFragment containing contents equivalent to + * those of this range. + * + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be + * extracted into the new DocumentFragment. + * + */ + DocumentFragment cloneContents ( ); + + /** + * Inserts a node into the document or document fragment at the + * start of the range. + * + * @param newNode The node to insert at the start of the range + * + * @return + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of + * the start of the range is read-only. + * + * WRONG_DOCUMENT_ERR: Raised if \c newNode and the + * container of the start of the Range were not created from the + * same document. + * + * HIERARCHY_REQUEST_ERR: Raised if the container of the start of + * the Range is of a type that does not allow children of the type + * of \c newNode or if \c newNode is an + * ancestor of the container . + * + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if \c node is an + * Attr, Entity, Notation, DocumentFragment, or Document node. + * + */ + void insertNode ( const Node &newNode ); + + /** + * Reparents the contents of the range to the given node and + * inserts the node at the position of the start of the range. + * + * @param newParent The node to surround the contents with. + * + * @return + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of + * either end-point of the range is read-only. + * + * WRONG_DOCUMENT_ERR: Raised if \c newParent and the + * container of the start of the Range were not created from the + * same document. + * + * HIERARCHY_REQUEST_ERR: Raised if the container of the start of + * the Range is of a type that does not allow children of the type + * of \c newParent or if \c newParent is + * an ancestor of the container or if \c node would + * end up with a child node of a type not allowed by the type of + * \c node . + * + * @exception RangeException + * BAD_ENDPOINTS_ERR: Raised if the range partially selects a + * non-text node. + * + * INVALID_NODE_TYPE_ERR: Raised if \c node is an + * Attr, Entity, DocumentType, Notation, Document, or + * DocumentFragment node. + * + */ + void surroundContents ( const Node &newParent ); + + /** + * Produces a new range whose end-points are equal to the + * end-points of the range. + * + * @return The duplicated range. + * + */ + Range cloneRange ( ); + + /** + * Returns the contents of a range as a string. + * + * @return The contents of the range. + * + */ + DOMString toString ( ); + + /** + * @internal Not part of DOM + */ + DOMString toHTML ( ); + + /* Mozilla extension - only works for HTML documents. */ + DocumentFragment createContextualFragment (const DOMString &html); + + /** + * Called to indicate that the range is no longer in use and that + * the implementation may relinquish any resources associated with + * this range. Subsequent calls to any methods or attribute getters + * on this range will result in a DOMException being thrown with an + * error code of INVALID_STATE_ERR. + * + */ + void detach ( ); + + /** + * not part of the DOM + * true if the range is detached + * + */ + bool isDetached() const; + + /** + * @internal + * not part of the DOM + */ + RangeImpl *handle() const; + bool isNull() const; + +protected: + RangeImpl *impl; + Range(RangeImpl *i); +private: + void throwException(int exceptioncode) const; +}; + +} // namespace + +#endif diff --git a/tdehtml/dom/dom2_traversal.cpp b/tdehtml/dom/dom2_traversal.cpp new file mode 100644 index 000000000..c0a09435b --- /dev/null +++ b/tdehtml/dom/dom2_traversal.cpp @@ -0,0 +1,381 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom_exception.h" +#include "dom/dom_string.h" +#include "xml/dom2_traversalimpl.h" + +using namespace DOM; + + +NodeIterator::NodeIterator() +{ + impl = 0; +} + +NodeIterator::NodeIterator(const NodeIterator &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +NodeIterator::NodeIterator(NodeIteratorImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +NodeIterator &NodeIterator::operator = (const NodeIterator &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + return *this; +} + +NodeIterator::~NodeIterator() +{ + if (impl) impl->deref(); +} + +Node NodeIterator::root() +{ + if (impl) return impl->root(); + return 0; +} + +unsigned long NodeIterator::whatToShow() +{ + if (impl) return impl->whatToShow(); + return 0; +} + +NodeFilter NodeIterator::filter() +{ + if (impl) return impl->filter(); + return 0; +} + +bool NodeIterator::expandEntityReferences() +{ + if (impl) return impl->expandEntityReferences(); + return 0; +} + +Node NodeIterator::nextNode( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeImpl *r = impl->nextNode(exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +Node NodeIterator::previousNode( ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeImpl *r = impl->previousNode(exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +void NodeIterator::detach() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + impl->detach(exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +NodeIteratorImpl *NodeIterator::handle() const +{ + return impl; +} + +bool NodeIterator::isNull() const +{ + return (impl == 0); +} + +// ----------------------------------------------------------- + +NodeFilter::NodeFilter() +{ + impl = 0; +} + +NodeFilter::NodeFilter(const NodeFilter &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +NodeFilter::NodeFilter(NodeFilterImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +NodeFilter &NodeFilter::operator = (const NodeFilter &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + return *this; +} + +NodeFilter::~NodeFilter() +{ + if (impl) impl->deref(); +} + +short NodeFilter::acceptNode(const Node &n) +{ + if (impl) return impl->acceptNode(n); + return 0; +} + +void NodeFilter::setCustomNodeFilter(CustomNodeFilter *custom) +{ + if (impl) impl->setCustomNodeFilter(custom); +} + +CustomNodeFilter *NodeFilter::customNodeFilter() +{ + if (impl) return impl->customNodeFilter(); + return 0; +} + +NodeFilterImpl *NodeFilter::handle() const +{ + return impl; +} + +bool NodeFilter::isNull() const +{ + return (impl == 0); +} + +NodeFilter NodeFilter::createCustom(CustomNodeFilter *custom) +{ + NodeFilterImpl *i = new NodeFilterImpl(); + i->setCustomNodeFilter(custom); + return i; +} + +// -------------------------------------------------------------- +CustomNodeFilter::CustomNodeFilter() +{ + impl = 0; +} + +CustomNodeFilter::~CustomNodeFilter() +{ +} + +short CustomNodeFilter::acceptNode (const Node &/*n*/) +{ + return NodeFilter::FILTER_ACCEPT; +} + +bool CustomNodeFilter::isNull() +{ + return false; +} + +DOMString CustomNodeFilter::customNodeFilterType() +{ + return ""; +} + +// -------------------------------------------------------------- + +TreeWalker::TreeWalker() +{ + impl = 0; +} + +TreeWalker::TreeWalker(const TreeWalker &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +TreeWalker::TreeWalker(TreeWalkerImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +TreeWalker & TreeWalker::operator = (const TreeWalker &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + + return *this; +} + +TreeWalker::~TreeWalker() +{ + if (impl) impl->deref(); +} + +Node TreeWalker::root() +{ + if (impl) return impl->getRoot(); + return 0; +} + +unsigned long TreeWalker::whatToShow() +{ + if (impl) return impl->getWhatToShow(); + return 0; +} + +NodeFilter TreeWalker::filter() +{ + if (impl) return impl->getFilter(); + return 0; +} + +bool TreeWalker::expandEntityReferences() +{ + if (impl) return impl->getExpandEntityReferences(); + return false; +} + +Node TreeWalker::currentNode() +{ + if (impl) return impl->getCurrentNode(); + return 0; +} + +void TreeWalker::setCurrentNode(const Node& _currentNode) +{ + if (impl) impl->setCurrentNode(_currentNode.handle()); +} + +Node TreeWalker::parentNode() +{ + if (impl) return impl->parentNode(); + return 0; +} + +Node TreeWalker::firstChild() +{ + if (impl) return impl->firstChild(); + return 0; +} + +Node TreeWalker::lastChild() +{ + if (impl) return impl->lastChild(); + return 0; +} + +Node TreeWalker::previousSibling() +{ + if (impl) return impl->previousSibling(); + return 0; +} + +Node TreeWalker::nextSibling() +{ + if (impl) return impl->nextSibling(); + return 0; +} + +Node TreeWalker::previousNode() +{ + if (impl) return impl->previousNode(); + return 0; +} + +Node TreeWalker::nextNode() +{ + if (impl) return impl->nextNode(); + return 0; +} + +TreeWalkerImpl *TreeWalker::handle() const +{ + return impl; +} + +bool TreeWalker::isNull() const +{ + return (impl == 0); +} + +// ----------------------------------------------------------------------- + +/*DocumentTraversal::DocumentTraversal() +{ +} + +DocumentTraversal::DocumentTraversal(const DocumentTraversal &other) +{ +} + +DocumentTraversal &DocumentTraversal::operator = (const DocumentTraversal &other) +{ + DocumentTraversal::operator = (other); + return *this; +} + +DocumentTraversal::~DocumentTraversal() +{ +} + +NodeIterator DocumentTraversal::createNodeIterator( const Node &root, long whatToShow, + const NodeFilter &filter, + bool entityReferenceExpansion ) +{ + return NodeIterator(); +} + +TreeWalker DocumentTraversal::createTreeWalker( const Node &root, long whatToShow, + const NodeFilter &filter, + bool entityReferenceExpansion ) +{ + return TreeWalker(); +} + +*/ + diff --git a/tdehtml/dom/dom2_traversal.h b/tdehtml/dom/dom2_traversal.h new file mode 100644 index 000000000..ea3d3521b --- /dev/null +++ b/tdehtml/dom/dom2_traversal.h @@ -0,0 +1,617 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 2 Specification (Candidate Recommendation) + * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/ + * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. + * + */ +#ifndef _dom2_traversal_h_ +#define _dom2_traversal_h_ +#include <dom/dom_node.h> +#include <dom/dom_misc.h> + +#include <tdelibs_export.h> + +namespace DOM { +class Node; +class NodeFilter; +class NodeImpl; +class NodeIteratorImpl; +class NodeFilterImpl; +class TreeWalkerImpl; +class CustomNodeFilter; +class CustomNodeFilterImpl; + +/** + * NodeIterators are used to step through a set of nodes, e.g. the set + * of nodes in a NodeList, the document subtree governed by a + * particular node, the results of a query, or any other set of nodes. + * The set of nodes to be iterated is determined by the implementation + * of the NodeIterator. DOM Level 2 specifies a single NodeIterator + * implementation for document-order traversal of a document subtree. + * Instances of these iterators are created by calling + * DocumentTraversal.createNodeIterator(). + * + * Any Iterator that returns nodes may implement the + * \c NodeIterator interface. Users and vendor libraries may also + * choose to create Iterators that implement the \c NodeIterator + * interface. + * + */ +class KHTML_EXPORT NodeIterator +{ + friend class NodeIteratorImpl; + friend class Document; +public: + NodeIterator(); + NodeIterator(const NodeIterator &other); + + NodeIterator & operator = (const NodeIterator &other); + + ~NodeIterator(); + + /** + * The root node of the NodeIterator, as specified when it was created. + */ + Node root(); + + /** + * This attribute determines which node types are presented via the + * iterator. The available set of constants is defined in the NodeFilter + * interface. Nodes not accepted by whatToShow will be skipped, but their + * children may still be considered. Note that this skip takes precedence + * over the filter, if any. + */ + unsigned long whatToShow(); + + /** + * The NodeFilter used to screen nodes. + */ + NodeFilter filter(); + + /** + * The value of this flag determines whether the children of entity + * reference nodes are visible to the iterator. If false, they and + * their descendents will be rejected. Note that this rejection takes + * precedence over whatToShow and the filter. Also note that this is + * currently the only situation where NodeIterators may reject a complete + * subtree rather than skipping individual nodes. + * + * To produce a view of the document that has entity references expanded + * and does not expose the entity reference node itself, use the whatToShow + * flags to hide the entity reference node and set expandEntityReferences to + * true when creating the iterator. To produce a view of the document that + * has entity reference nodes but no entity expansion, use the whatToShow + * flags to show the entity reference node and set expandEntityReferences to + * false. + */ + bool expandEntityReferences(); + + /** + * Returns the next node in the set and advances the position of + * the Iterator in the set. After a NodeIterator is created, the + * first call to nextNode() returns the first node in the set. + * + * @return The next \c Node in the set being iterated + * over, or \c null if there are no more members in + * that set. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node nextNode(); + + /** + * Returns the previous node in the set and moves the position of + * the Iterator backwards in the set. + * + * @return The previous \c Node in the set being + * iterated over, or \c null if there are no more + * members in that set. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node previousNode(); + + /** + * Detaches the NodeIterator from the set which it iterated over, + * releasing any computational resources and placing the iterator in the + * INVALID state. After detach has been invoked, calls to nextNode or + * previousNode will raise the exception INVALID_STATE_ERR. + */ + void detach(); + + /** + * @internal + * not part of the DOM + */ + NodeIteratorImpl *handle() const; + bool isNull() const; + +protected: + NodeIteratorImpl *impl; + NodeIterator(NodeIteratorImpl *i); +}; + + +/** + * Filters are objects that know how to "filter out" nodes. If an + * Iterator or \c TreeWalker is given a filter, before it + * returns the next node, it applies the filter. If the filter says to + * accept the node, the Iterator returns it; otherwise, the Iterator + * looks for the next node and pretends that the node that was + * rejected was not there. + * + * The DOM does not provide any filters. Filter is just an interface + * that users can implement to provide their own filters. + * + * Filters do not need to know how to iterate, nor do they need to + * know anything about the data structure that is being iterated. This + * makes it very easy to write filters, since the only thing they have + * to know how to do is evaluate a single node. One filter may be used + * with a number of different kinds of Iterators, encouraging code + * reuse. + * + * To create your own custom NodeFilter, define a subclass of + * CustomNodeFilter which overrides the acceptNode() method and assign + * an instance of it to the NodeFilter. For more details see the + * CustomNodeFilter class + */ +class KHTML_EXPORT NodeFilter +{ + friend class NodeIterator; + friend class NodeIteratorImpl; + friend class TreeWalker; + friend class TreeWalkerImpl; + friend class NodeFilterImpl; +public: + NodeFilter(); + NodeFilter(const NodeFilter &other); + NodeFilter(NodeFilterImpl *i); + + virtual NodeFilter & operator = (const NodeFilter &other); + + virtual ~NodeFilter(); + /** + * The following constants are returned by the acceptNode() + * method: + * + */ + enum AcceptCode { + FILTER_ACCEPT = 1, + FILTER_REJECT = 2, + FILTER_SKIP = 3 + }; + + /** + * These are the available values for the whatToShow parameter. + * They are the same as the set of possible types for Node, and + * their values are derived by using a bit position corresponding + * to the value of NodeType for the equivalent node type. + * + */ + enum ShowCode { + SHOW_ALL = 0xFFFFFFFF, + SHOW_ELEMENT = 0x00000001, + SHOW_ATTRIBUTE = 0x00000002, + SHOW_TEXT = 0x00000004, + SHOW_CDATA_SECTION = 0x00000008, + SHOW_ENTITY_REFERENCE = 0x00000010, + SHOW_ENTITY = 0x00000020, + SHOW_PROCESSING_INSTRUCTION = 0x00000040, + SHOW_COMMENT = 0x00000080, + SHOW_DOCUMENT = 0x00000100, + SHOW_DOCUMENT_TYPE = 0x00000200, + SHOW_DOCUMENT_FRAGMENT = 0x00000400, + SHOW_NOTATION = 0x00000800 + }; + + /** + * Test whether a specified node is visible in the logical view of + * a TreeWalker or NodeIterator. This function will be called by + * the implementation of TreeWalker and NodeIterator; it is not + * intended to be called directly from user code. + * + * @param n The node to check to see if it passes the filter or + * not. + * + * @return a constant to determine whether the node is accepted, + * rejected, or skipped, as defined <a + * href="#Traversal-NodeFilter-acceptNode-constants"> above </a> . + * + */ + virtual short acceptNode (const Node &n); + + /** + * @internal + * not part of the DOM + */ + virtual NodeFilterImpl *handle() const; + virtual bool isNull() const; + + void setCustomNodeFilter(CustomNodeFilter *custom); + CustomNodeFilter *customNodeFilter(); + static NodeFilter createCustom(CustomNodeFilter *custom); + +protected: + NodeFilterImpl *impl; +}; + +/** + * CustomNodeFilter can be used to define your own NodeFilter for use + * with NodeIterators and TreeWalkers. You can create a custom filter + * by doing the following: + * + * class MyCustomNodeFilter { + * ..... + * virtual short acceptNode (const Node &n); + * ..... + * } + * + * Then in your program: + * + * short MyCustomNodeFilter::acceptNode (const Node &n) + * { + * if (condition) + * return NodeFilter::FILTER_ACCEPT; + * else + * .... + * } + * + * + * MyCustomFilter *filter = new MyCustomFilter(); + * NodeFilter nf = NodeFilter::createCustom(filter); + * NodeIterator ni = document.createNodeIterator(document,NodeFilter.SHOW_ALL,nf,false); + * + * The default implementation of acceptNode() returns NodeFilter::FILTER_ACCEPT + * for all nodes. + * + */ + +class KHTML_EXPORT CustomNodeFilter : public DomShared { +public: + CustomNodeFilter(); + virtual ~CustomNodeFilter(); + virtual short acceptNode (const Node &n); + virtual bool isNull(); + + /** + * @internal + * not part of the DOM + * + * Returns a name specifying the type of custom node filter. Useful for checking + * if an custom node filter is of a particular sublass. + * + */ + virtual DOMString customNodeFilterType(); + +protected: + /** + * @internal + * Reserved. Do not use in your subclasses. + */ + CustomNodeFilterImpl *impl; +}; + +/** + * \c TreeWalker objects are used to navigate a document + * tree or subtree using the view of the document defined by its + * \c whatToShow flags and any filters that are defined + * for the \c TreeWalker . Any function which performs + * navigation using a \c TreeWalker will automatically + * support any view defined by a \c TreeWalker . + * + * Omitting nodes from the logical view of a subtree can result in a + * structure that is substantially different from the same subtree in + * the complete, unfiltered document. Nodes that are siblings in the + * TreeWalker view may be children of different, widely separated + * nodes in the original view. For instance, consider a Filter that + * skips all nodes except for Text nodes and the root node of a + * document. In the logical view that results, all text nodes will be + * siblings and appear as direct children of the root node, no matter + * how deeply nested the structure of the original document. + * + */ +class KHTML_EXPORT TreeWalker +{ + friend class Document; + friend class TreeWalkerImpl; +public: + TreeWalker(); + TreeWalker(const TreeWalker &other); + + TreeWalker & operator = (const TreeWalker &other); + + ~TreeWalker(); + + + /** + * The root node of the TreeWalker, as specified when it was created. + */ + Node root(); + + /** + * This attribute determines which node types are presented via the + * TreeWalker. The available set of constants is defined in the NodeFilter + * interface. Nodes not accepted by whatToShow will be skipped, but their + * children may still be considered. Note that this skip takes precedence + * over the filter, if any. + */ + unsigned long whatToShow(); + + /** + * The filter used to screen nodes. + */ + NodeFilter filter(); + + /** + * The value of this flag determines whether the children of entity + * reference nodes are visible to the TreeWalker. If false, they and their + * descendents will be rejected. Note that this rejection takes precedence + * over whatToShow and the filter, if any. + * + * To produce a view of the document that has entity references expanded + * and does not expose the entity reference node itself, use the whatToShow + * flags to hide the entity reference node and set expandEntityReferences + * to true when creating the TreeWalker. To produce a view of the document + * that has entity reference nodes but no entity expansion, use the + * whatToShow flags to show the entity reference node and set + * expandEntityReferences to false. + */ + bool expandEntityReferences(); + + /** + * The node at which the TreeWalker is currently positioned. + * Alterations to the DOM tree may cause the current node to no longer be + * accepted by the TreeWalker's associated filter. currentNode may also be + * explicitly set to any node, whether or not it is within the subtree + * specified by the root node or would be accepted by the filter and + * whatToShow flags. Further traversal occurs relative to currentNode even + * if it is not part of the current view, by applying the filters in the + * requested direction; if no traversal is possible, currentNode is not changed. + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if an attempt is made to set currentNode to null. + */ + Node currentNode(); + + /** + * see currentNode + */ + void setCurrentNode(const Node &_currentNode); + + /** + * Moves to and returns the parent node of the current node. If + * there is no parent node, or if the current node is the root + * node from which this TreeWalker was created, retains the + * current position and returns null. + * + * @return The new parent node, or null if the current node has no + * parent in the TreeWalker's logical view. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node parentNode(); + + /** + * Moves the \c TreeWalker to the first child of the + * current node, and returns the new node. If the current node has + * no children, returns \c null , and retains the + * current node. + * + * @return The new node, or \c null if the current + * node has no children. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node firstChild(); + + /** + * Moves the \c TreeWalker to the last child of the + * current node, and returns the new node. If the current node has + * no children, returns \c null , and retains the + * current node. + * + * @return The new node, or \c null if the current + * node has no children. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node lastChild(); + + /** + * Moves the \c TreeWalker to the previous sibling of + * the current node, and returns the new node. If the current node + * has no previous sibling, returns \c null , and + * retains the current node. + * + * @return The new node, or \c null if the current + * node has no previous sibling. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node previousSibling(); + + /** + * Moves the \c TreeWalker to the next sibling of the + * current node, and returns the new node. If the current node has + * no next sibling, returns \c null , and retains the + * current node. + * + * @return The new node, or \c null if the current + * node has no next sibling. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node nextSibling(); + + /** + * Moves the \c TreeWalker to the previous node in + * document order relative to the current node, and returns the + * new node. If the current node has no previous node, returns + * \c null , and retains the current node. + * + * @return The new node, or \c null if the current + * node has no previous node. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node previousNode(); + + /** + * Moves the \c TreeWalker to the next node in + * document order relative to the current node, and returns the + * new node. If the current node has no next node, returns + * \c null , and retains the current node. + * + * @return The new node, or \c null if the current + * node has no next node. + * + * @exception Exceptions from user code + * Any exceptions raised by a user-written Filter will propagate + * through. + * + */ + Node nextNode(); + + /** + * @internal + * not part of the DOM + */ + TreeWalkerImpl *handle() const; + bool isNull() const; + +protected: + TreeWalker(TreeWalkerImpl *i); + TreeWalkerImpl *impl; +}; + + +// ### not sure if this this class is really needed - both methods are in +// Document + +/** + * \c DocumentTraversal contains methods that creates + * Iterators to traverse a node and its children in document order + * (depth first, pre-order traversal, which is equivalent to the order + * in which the start tags occur in the text representation of the + * document). + * + * +class DocumentTraversal // : public Document ? +{ +public: + DocumentTraversal(); + DocumentTraversal(const DocumentTraversal &other); + + DocumentTraversal & operator = (const DocumentTraversal &other); + + ~DocumentTraversal(); + + ** + * + * + * @param root The node which will be iterated together with its + * children. The iterator is initially positioned just before this + * node. The whatToShow flags and the filter, if any, are not + * considered when setting this position. + * + * @param whatToShow This flag specifies which node types may + * appear in the logical view of the tree presented by the + * Iterator. See the description of Iterator for the set of + * possible values. These flags can be combined using OR. + * + * These flags can be combined using \c OR . + * + * @param filter The Filter to be used with this TreeWalker, or + * null to indicate no filter. + * + * @param entityReferenceExpansion The value of this flag + * determines whether entity reference nodes are expanded. + * + * @return The newly created \c NodeIterator . + * + * + NodeIterator createNodeIterator ( const Node &root, long whatToShow, + const NodeFilter &filter, bool entityReferenceExpansion ); + + ** + * Create a new TreeWalker over the subtree rooted by the + * specified node. + * + * @param root The node which will serve as the root for the + * \c TreeWalker . The currentNode of the TreeWalker + * is set to this node. The whatToShow flags and the NodeFilter + * are not considered when setting this value; any node type will + * be accepted as the root. The root must not be null. + * + * @param whatToShow This flag specifies which node types may + * appear in the logical view of the tree presented by the + * Iterator. See the description of TreeWalker for the set of + * possible values. These flags can be combined using OR. + * + * These flags can be combined using \c OR . + * + * @param filter The Filter to be used with this TreeWalker, or + * null to indicate no filter. + * + * @param entityReferenceExpansion The value of this flag + * determines whether entity reference nodes are expanded. + * + * @return The newly created \c TreeWalker . + * + * @exception DOMException + * Raises the exception NOT_SUPPORTED_ERR if the specified root + * node is null. + * + * + TreeWalker createTreeWalker ( const Node &root, long whatToShow, + const NodeFilter &filter, bool entityReferenceExpansion ); +}; +*/ + +} // namespace + +#endif diff --git a/tdehtml/dom/dom2_views.cpp b/tdehtml/dom/dom2_views.cpp new file mode 100644 index 000000000..11b07fbb0 --- /dev/null +++ b/tdehtml/dom/dom2_views.cpp @@ -0,0 +1,95 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom2_views.h" +#include "dom/dom_exception.h" +#include "dom/dom_doc.h" +#include "xml/dom_elementimpl.h" +#include "xml/dom2_viewsimpl.h" + +using namespace DOM; + + +AbstractView::AbstractView() +{ + impl = 0; +} + + +AbstractView::AbstractView(const AbstractView &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + + +AbstractView::AbstractView(AbstractViewImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +AbstractView::~AbstractView() +{ + if (impl) + impl->deref(); +} + +AbstractView &AbstractView::operator = (const AbstractView &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +Document AbstractView::document() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->document(); +} + +CSSStyleDeclaration AbstractView::getComputedStyle(const Element &elt, const DOMString &pseudoElt) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return impl->getComputedStyle(static_cast<ElementImpl*>(elt.handle()),pseudoElt.implementation()); +} + + +AbstractViewImpl *AbstractView::handle() const +{ + return impl; +} + +bool AbstractView::isNull() const +{ + return (impl == 0); +} + + + diff --git a/tdehtml/dom/dom2_views.h b/tdehtml/dom/dom2_views.h new file mode 100644 index 000000000..6f326aaa3 --- /dev/null +++ b/tdehtml/dom/dom2_views.h @@ -0,0 +1,90 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef _DOM_Views_h_ +#define _DOM_Views_h_ + +#include <tdelibs_export.h> +namespace DOM { + +class Document; +class AbstractViewImpl; +class CSSStyleDeclaration; +class Element; +class DOMString; + +/** + * Introduced in DOM Level 2 + * + * A base interface that all views shall derive from. + * + */ +class KHTML_EXPORT AbstractView { + friend class Event; + friend class UIEvent; + friend class MouseEvent; + friend class MutationEvent; + friend class Document; +public: + AbstractView(); + AbstractView(const AbstractView &other); + virtual ~AbstractView(); + + AbstractView & operator = (const AbstractView &other); + + /** + * The source DocumentView of which this is an AbstractView. + */ + Document document() const; + + /** + * Introduced in DOM Level 2 + * This method is from the ViewCSS interface + * + * This method is used to get the computed style as it is defined in + * [CSS2]. + * + * @param elt The element whose style is to be computed. This parameter + * cannot be null. + * + * @param pseudoElt The pseudo-element or null if none. + * + * @return The computed style. The CSSStyleDeclaration is read-only and + * contains only absolute values. + */ + CSSStyleDeclaration getComputedStyle(const Element &elt, const DOMString &pseudoElt); + + /** + * @internal + * not part of the DOM + */ + AbstractViewImpl *handle() const; + bool isNull() const; + +protected: + AbstractView(AbstractViewImpl *i); + AbstractViewImpl *impl; +}; + + +} //namespace +#endif diff --git a/tdehtml/dom/dom_core.h b/tdehtml/dom/dom_core.h new file mode 100644 index 000000000..c3c8f2893 --- /dev/null +++ b/tdehtml/dom/dom_core.h @@ -0,0 +1,34 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef _DOM_CORE_H_ +#define _DOM_CORE_H_ + +#include <dom/dom_doc.h> +#include <dom/dom_element.h> +#include <dom/dom_misc.h> +#include <dom/dom_exception.h> +#include <dom/dom_node.h> +#include <dom/dom_string.h> +#include <dom/dom_text.h> +#include <dom/dom_xml.h> + +#endif diff --git a/tdehtml/dom/dom_doc.cpp b/tdehtml/dom/dom_doc.cpp new file mode 100644 index 000000000..0ff123444 --- /dev/null +++ b/tdehtml/dom/dom_doc.cpp @@ -0,0 +1,684 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom_exception.h" +#include "dom/dom_xml.h" +#include "dom/dom2_range.h" +#include "dom/dom2_events.h" +#include "dom/dom2_views.h" +#include "dom/dom2_traversal.h" +#include "dom/html_document.h" +#include "html/html_documentimpl.h" + +#include "xml/dom_docimpl.h" +#include "xml/dom_elementimpl.h" + +#include <kdebug.h> + +namespace DOM { + +DOMImplementation::DOMImplementation() +{ + impl = 0; +} + +DOMImplementation::DOMImplementation(const DOMImplementation &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +DOMImplementation::DOMImplementation(DOMImplementationImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +DOMImplementation &DOMImplementation::operator = (const DOMImplementation &other) +{ + if ( impl != other.impl ) { + if (impl) impl->deref(); + impl = other.impl; + if (impl) impl->ref(); + } + return *this; +} + +DOMImplementation::~DOMImplementation() +{ + if (impl) impl->deref(); +} + +bool DOMImplementation::hasFeature( const DOMString &feature, const DOMString &version ) +{ + if (!impl) + return false; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return impl->hasFeature(feature,version); +} + +DocumentType DOMImplementation::createDocumentType ( const DOMString &qualifiedName, + const DOMString &publicId, + const DOMString &systemId ) +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + DocumentTypeImpl *r = impl->createDocumentType(qualifiedName, publicId, systemId, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return r; +} + +Document DOMImplementation::createDocument ( const DOMString &namespaceURI, + const DOMString &qualifiedName, + const DocumentType &doctype ) +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + DocumentImpl *r = impl->createDocument(namespaceURI, qualifiedName, doctype, exceptioncode ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return r; +} + +HTMLDocument DOMImplementation::createHTMLDocument( const DOMString& title ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + + HTMLDocumentImpl* r = impl->createHTMLDocument( 0 /* ### create a view otherwise it doesn't work */); + + r->open(); + + r->write(TQString::fromLatin1("<HTML><HEAD><TITLE>") + title.string() + + TQString::fromLatin1("</TITLE></HEAD>")); + + return r; +} + +DOMImplementation DOMImplementation::getInterface(const DOMString &feature) const +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + return impl->getInterface(feature); +} + +CSSStyleSheet DOMImplementation::createCSSStyleSheet(const DOMString &title, const DOMString &media) +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + CSSStyleSheetImpl *r = impl->createCSSStyleSheet(title.implementation(), media.implementation(), + exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return r; +} + +DOMImplementationImpl *DOMImplementation::handle() const +{ + return impl; +} + +bool DOMImplementation::isNull() const +{ + return (impl == 0); +} + +// ---------------------------------------------------------------------------- + +Document::Document() + : Node() +{ + // we always want an implementation + impl = DOMImplementationImpl::instance()->createDocument(); + impl->ref(); +} + +Document::Document(bool create) + : Node() +{ + if(create) + { + impl = DOMImplementationImpl::instance()->createDocument(); + impl->ref(); + } + else + impl = 0; +// kdDebug(6090) << "Document::Document(bool)" << endl; +} + +Document::Document(const Document &other) : Node(other) +{ +// kdDebug(6090) << "Document::Document(Document &)" << endl; +} + +Document::Document(DocumentImpl *i) : Node(i) +{ +// kdDebug(6090) << "Document::Document(DocumentImpl)" << endl; +} + +Document &Document::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != DOCUMENT_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Document &Document::operator = (const Document &other) +{ + Node::operator =(other); + return *this; +} + +Document::~Document() +{ +// kdDebug(6090) << "Document::~Document\n" << endl; +} + +DocumentType Document::doctype() const +{ + if (impl) return ((DocumentImpl *)impl)->doctype(); + return 0; +} + +DOMImplementation Document::implementation() const +{ + if (impl) return ((DocumentImpl *)impl)->implementation(); + return 0; +} + +Element Document::documentElement() const +{ + if (impl) return ((DocumentImpl *)impl)->documentElement(); + return 0; +} + +Element Document::createElement( const DOMString &tagName ) +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ElementImpl* r = ((DocumentImpl *)impl)->createElement(tagName, &exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return r; +} + +Element Document::createElementNS( const DOMString &namespaceURI, const DOMString &qualifiedName ) +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ElementImpl* r = ((DocumentImpl *)impl)->createElementNS(namespaceURI,qualifiedName, &exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return r; +} + +DocumentFragment Document::createDocumentFragment( ) +{ + if (impl) return ((DocumentImpl *)impl)->createDocumentFragment(); + return 0; +} + +Text Document::createTextNode( const DOMString &data ) +{ + if (impl) return ((DocumentImpl *)impl)->createTextNode( data.implementation() ); + return 0; +} + +Comment Document::createComment( const DOMString &data ) +{ + if (impl) return ((DocumentImpl *)impl)->createComment( data.implementation() ); + return 0; +} + +CDATASection Document::createCDATASection( const DOMString &data ) +{ + // ### DOM1 spec says raise exception if html documents - what about XHTML documents? + if (impl) return ((DocumentImpl *)impl)->createCDATASection( data.implementation() ); + return 0; +} + +ProcessingInstruction Document::createProcessingInstruction( const DOMString &target, const DOMString &data ) +{ + if (impl) return ((DocumentImpl *)impl)->createProcessingInstruction( target, data.implementation() ); + return 0; +} + +Attr Document::createAttribute( const DOMString &name ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (name.isNull()) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + AttrImpl* a = impl->getDocument()->createAttribute(name, &exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return a; +} + +Attr Document::createAttributeNS( const DOMString &namespaceURI, const DOMString &qualifiedName ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (qualifiedName.isNull()) throw DOMException(DOMException::NAMESPACE_ERR); + int exceptioncode = 0; + AttrImpl* a = impl->getDocument()->createAttributeNS(namespaceURI, qualifiedName, &exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return a; +} + +EntityReference Document::createEntityReference( const DOMString &name ) +{ + if (impl) return ((DocumentImpl *)impl)->createEntityReference( name ); + return 0; +} + +Element Document::getElementById( const DOMString &elementId ) const +{ + if(impl) return ((DocumentImpl *)impl)->getElementById( elementId ); + return 0; +} + +NodeList Document::getElementsByTagName( const DOMString &tagName ) +{ + if (!impl) return 0; + NodeImpl::Id id; + if ( tagName == "*" ) + id = 0; + else + id = impl->getDocument()->getId(NodeImpl::ElementId, tagName.implementation(), false, true); + return new TagNodeListImpl( impl, id ); +} + +NodeList Document::getElementsByTagNameNS( const DOMString &namespaceURI, const DOMString &localName ) +{ + if (!impl) return 0; + return new TagNodeListImpl( impl, namespaceURI, localName ); +} + +Node Document::importNode( const Node & importedNode, bool deep ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeImpl *r = static_cast<DocumentImpl*>(impl)->importNode(importedNode.handle(), deep, exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +bool Document::isHTMLDocument() const +{ + if (impl) return ((DocumentImpl *)impl)->isHTMLDocument(); + return 0; +} + +Range Document::createRange() +{ + if (impl) return ((DocumentImpl *)impl)->createRange(); + return 0; +} + +NodeIterator Document::createNodeIterator(Node root, unsigned long whatToShow, + NodeFilter filter, bool entityReferenceExpansion) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + NodeIteratorImpl *r = static_cast<DocumentImpl*>(impl)->createNodeIterator(root.handle(), + whatToShow,filter,entityReferenceExpansion,exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +TreeWalker Document::createTreeWalker(Node root, unsigned long whatToShow, NodeFilter filter, + bool entityReferenceExpansion) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + + TreeWalkerImpl *tw = static_cast<DocumentImpl *>(impl)->createTreeWalker( + root.handle(), whatToShow, filter.handle(), entityReferenceExpansion, exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + + return tw; +} + +Event Document::createEvent(const DOMString &eventType) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + EventImpl *r = ((DocumentImpl *)impl)->createEvent(eventType,exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +AbstractView Document::defaultView() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<DocumentImpl*>(impl)->defaultView(); +} + +StyleSheetList Document::styleSheets() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<DocumentImpl*>(impl)->styleSheets(); +} + +DOMString Document::preferredStylesheetSet() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<DocumentImpl*>(impl)->preferredStylesheetSet(); +} + +DOMString Document::selectedStylesheetSet() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<DocumentImpl*>(impl)->selectedStylesheetSet(); +} + +void Document::setSelectedStylesheetSet(const DOMString& s) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<DocumentImpl*>(impl)->setSelectedStylesheetSet(s); +} + + +KHTMLView *Document::view() const +{ + if (!impl) return 0; + + return static_cast<DocumentImpl*>(impl)->view(); +} + +CSSStyleDeclaration Document::getOverrideStyle(const Element &elt, const DOMString &pseudoElt) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode = 0; + CSSStyleDeclarationImpl *r = ((DocumentImpl *)impl)->getOverrideStyle(static_cast<ElementImpl*>(elt.handle()),pseudoElt.implementation()); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +bool Document::async() const +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<DocumentImpl*>( impl )->async( ); +} + +void Document::setAsync( bool b ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<DocumentImpl*>( impl )->setAsync( b ); +} + +void Document::abort() +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + + static_cast<DocumentImpl*>( impl )->abort( ); +} + +void Document::load( const DOMString &uri ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<DocumentImpl*>( impl )->load( uri ); +} + +void Document::loadXML( const DOMString &source ) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + + static_cast<DocumentImpl*>( impl )->loadXML( source ); +} + +bool Document::designMode() const { + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + return static_cast<DocumentImpl*>( impl )->designMode(); +} + +void Document::setDesignMode(bool enable) { + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<DocumentImpl*>( impl )->setDesignMode( enable ); +} + +DOMString Document::completeURL(const DOMString& url) +{ + if ( !impl ) return url; + return static_cast<DocumentImpl*>( impl )->completeURL( url.string() ); +} + +DOMString Document::toString() const +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentImpl*>(impl)->toString(); +} + +void Document::updateRendering() +{ + if ( !impl ) return; + static_cast<DocumentImpl*>( impl )->updateRendering( ); +} + +void Document::addStyleSheet(const StyleSheet &sheet) +{ + if (!impl || sheet.isNull()) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode; + static_cast<DocumentImpl*>( impl )->addStyleSheet( sheet.handle(), &exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +void Document::removeStyleSheet(const StyleSheet &sheet) +{ + if (!impl || sheet.isNull()) + throw DOMException(DOMException::INVALID_STATE_ERR); + + int exceptioncode; + static_cast<DocumentImpl*>( impl )->removeStyleSheet( sheet.handle(), &exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +// ---------------------------------------------------------------------------- + +DocumentFragment::DocumentFragment() : Node() +{ +} + +DocumentFragment::DocumentFragment(const DocumentFragment &other) : Node(other) +{ +} + +DocumentFragment &DocumentFragment::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != DOCUMENT_FRAGMENT_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +DocumentFragment &DocumentFragment::operator = (const DocumentFragment &other) +{ + Node::operator =(other); + return *this; +} + +DocumentFragment::~DocumentFragment() +{ +} + +DocumentFragment::DocumentFragment(DocumentFragmentImpl *i) : Node(i) +{ +} + +// ---------------------------------------------------------------------------- + +DocumentType::DocumentType() + : Node() +{ +} + +DocumentType::DocumentType(const DocumentType &other) + : Node(other) +{ +} + +DocumentType::DocumentType(DocumentTypeImpl *impl) : Node(impl) +{ +} + +DocumentType &DocumentType::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != DOCUMENT_TYPE_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +DocumentType &DocumentType::operator = (const DocumentType &other) +{ + Node::operator =(other); + return *this; +} + +DocumentType::~DocumentType() +{ +} + +DOMString DocumentType::name() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentTypeImpl*>(impl)->name(); +} + +NamedNodeMap DocumentType::entities() const +{ + if (!impl) + return 0; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentTypeImpl*>(impl)->entities(); +} + +NamedNodeMap DocumentType::notations() const +{ + if (!impl) + return 0; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentTypeImpl*>(impl)->notations(); +} + +DOMString DocumentType::publicId() const +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentTypeImpl*>(impl)->publicId(); +} + +DOMString DocumentType::systemId() const +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentTypeImpl*>(impl)->systemId(); +} + +DOMString DocumentType::internalSubset() const +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + return static_cast<DocumentTypeImpl*>(impl)->internalSubset(); +} + +} // namespace diff --git a/tdehtml/dom/dom_doc.h b/tdehtml/dom/dom_doc.h new file mode 100644 index 000000000..9a5331295 --- /dev/null +++ b/tdehtml/dom/dom_doc.h @@ -0,0 +1,1107 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + */ + +#ifndef _DOM_Document_h_ +#define _DOM_Document_h_ + +#include <dom/dom_node.h> +#include <dom/css_stylesheet.h> + +class KHTMLView; +class KHTMLPart; + +namespace DOM { + +class DOMString; +class DocumentType; +class NodeList; +class CDATASection; +class Comment; +class DocumentFragment; +class Text; +class DOMImplementation; +class Element; +class Attr; +class EntityReference; +class ProcessingInstruction; +class DocumentImpl; +class Range; +class NodeIterator; +class TreeWalker; +class NodeFilter; +class DOMImplementationImpl; +class DocumentTypeImpl; +class Event; +class AbstractView; +class CSSStyleDeclaration; +class HTMLElementImpl; +class HTMLFrameElement; +class HTMLElementImpl; +class HTMLIFrameElement; +class HTMLObjectElement; +class HTMLDocument; + +/** + * The \c DOMImplementation interface provides a number of + * methods for performing operations that are independent of any + * particular instance of the document object model. + * + * DOM Level 2 and newer provide means for creating documents directly, + * which was not possible with DOM Level 1. + */ +class KHTML_EXPORT DOMImplementation +{ + friend class Document; +public: + DOMImplementation(); + DOMImplementation(const DOMImplementation &other); + + DOMImplementation & operator = (const DOMImplementation &other); + ~DOMImplementation(); + + /** + * Test if the DOM implementation implements a specific feature. + * + * @param feature The package name of the feature to test. In + * Level 1, the legal values are "HTML" and "XML" + * (case-insensitive). + * + * @param version This is the version number of the package name + * to test. In Level 1, this is the string "1.0". If the version + * is not specified, supporting any version of the feature will + * cause the method to return \c true . + * + * @return \c true if the feature is implemented in + * the specified version, \c false otherwise. + * + */ + bool hasFeature ( const DOMString &feature, const DOMString &version ); + + /** + * Introduced in DOM Level 2 + * + * Creates an empty DocumentType node. Entity declarations and notations + * are not made available. Entity reference expansions and default + * attribute additions do not occur. It is expected that a future version + * of the DOM will provide a way for populating a DocumentType. + * + * HTML-only DOM implementations do not need to implement this method. + * + * @param qualifiedName The qualified name of the document type to be + * created. + * + * @param publicId The external subset public identifier. + * + * @param systemId The external subset system identifier. + * + * @return A new DocumentType node with Node.ownerDocument set to null. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains + * an illegal character. + * + * NAMESPACE_ERR: Raised if the qualifiedName is malformed. + */ + DocumentType createDocumentType ( const DOMString &qualifiedName, + const DOMString &publicId, + const DOMString &systemId ); + + /** + * Introduced in DOM Level 2 + * + * Creates an XML Document object of the specified type with its document + * element. HTML-only DOM implementations do not need to implement this + * method. + * + * @param namespaceURI The namespace URI of the document element to create. + * + * @param qualifiedName The qualified name of the document element to be + * created. + * + * @param doctype The type of document to be created or null. When doctype + * is not null, its Node.ownerDocument attribute is set to the document + * being created. + * + * @return A new Document object. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains + * an illegal character. + * + * NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the + * qualifiedName has a prefix and the namespaceURI is null, or if the + * qualifiedName has a prefix that is "xml" and the namespaceURI is + * different from "http://www.w3.org/XML/1998/namespace" [Namespaces]. + * + * WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a + * different document or was created from a different implementation. + */ + Document createDocument ( const DOMString &namespaceURI, + const DOMString &qualifiedName, + const DocumentType &doctype ); + + /** + * Introduced in DOM Level 3 + * This method makes available a DOMImplementation's specialized + * interface. + * + * @param feature The name of the feature requested (case-insensitive) + * + * @return Returns an alternate DOMImplementation which implements + * the specialized APIs of the specified feature, if any, or null + * if there is no alternate DOMImplementation object which implements + * interfaces associated with that feature. Any alternate DOMImplementation + * returned by this method must delegate to the primary core DOMImplementation + * and not return results inconsistent with the primary DOMImplementation. + */ + DOMImplementation getInterface(const DOMString &feature) const; + + /** + * Introduced in DOM Level 2 + * This method is from the DOMImplementationCSS interface + * + * Creates a new CSSStyleSheet. + * + * @param title The advisory title. See also the Style Sheet Interfaces + * section. + * + * @param media The comma-separated list of media associated with the + * new style sheet. See also the Style Sheet Interfaces section. + * + * @return A new CSS style sheet. + * + * @exception SYNTAX_ERR: Raised if the specified media string value has a syntax error and is unparsable. + */ + CSSStyleSheet createCSSStyleSheet(const DOMString &title, const DOMString &media); + + /** + * Introduced in DOM Level 2 + * This method is from the HTMLDOMImplementation interface + * + * Creates an HTMLDocument with the minimal tree made of these + * elements: HTML,HEAD,TITLE and BODY. + * It extends the core interface which can be used to create an + * XHTML document by passing the XHTML namespace as the namespace + * for the root element. + * + * @param title The title of the document to be set as the content + * of the TITLE element, through a child Text node. + * + * @return the HTMLdocument + */ + HTMLDocument createHTMLDocument(const DOMString& title); + + /** + * @internal + * not part of the DOM + */ + DOMImplementationImpl *handle() const; + bool isNull() const; + +protected: + DOMImplementation(DOMImplementationImpl *i); + DOMImplementationImpl *impl; +}; + +/** + * The \c Document interface represents the entire HTML or + * XML document. Conceptually, it is the root of the document tree, + * and provides the primary access to the document's data. + * + * Since elements, text nodes, comments, processing instructions, + * etc. cannot exist outside the context of a \c Document + * , the \c Document interface also contains the factory + * methods needed to create these objects. The \c Node + * objects created have a \c ownerDocument attribute which + * associates them with the \c Document within whose + * context they were created. + * + */ +class KHTML_EXPORT Document : public Node +{ + friend class ::KHTMLView; + friend class ::KHTMLPart; + friend class AbstractView; + friend class DOMImplementation; + friend class HTMLFrameElement; + friend class HTMLIFrameElement; + friend class HTMLObjectElement; + +public: + Document(); + /** + * don't create an implementation if false + * use at own risk + */ + Document(bool); + Document(const Document &other); + Document(const Node &other) : Node() + {(*this)=other;} + + Document & operator = (const Node &other); + Document & operator = (const Document &other); + + ~Document(); + + /** + * The Document Type Declaration (see \c DocumentType + * ) associated with this document. For HTML documents as well as + * XML documents without a document type declaration this returns + * \c null . The DOM Level 1 does not support editing + * the Document Type Declaration, therefore \c docType + * cannot be altered in any way. + * + */ + DocumentType doctype() const; + + /** + * The \c DOMImplementation object that handles this + * document. A DOM application may use objects from multiple + * implementations. + * + */ + DOMImplementation implementation() const; + + /** + * This is a convenience attribute that allows direct access to + * the child node that is the root element of the document. For + * HTML documents, this is the element with the tagName "HTML". + * + */ + Element documentElement() const; + + /** + * Creates an element of the type specified. Note that the + * instance returned implements the Element interface, so + * attributes can be specified directly on the returned object. + * + * @param tagName The name of the element type to instantiate. For + * XML, this is case-sensitive. For HTML, the \c tagName + * parameter may be provided in any case, but it must be + * mapped to the canonical uppercase form by the DOM + * implementation. + * + * @return A new \c Element object. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * invalid character. + * + */ + Element createElement ( const DOMString &tagName ); + + /** + * Introduced in DOM Level 2 + * Creates an element of the given qualified name and namespace URI. + * + * @param namespaceURI The namespace URI of the element to create. + * + * @param qualifiedName The qualified name of the element type to instantiate. + * + * @return A new Element object with the following attributes: + * + * @exception INVALID_CHARACTER_ERR Raised if the specified qualified name + * contains an illegal character. + * + * @exception NAMESPACE_ERR Raised if the qualifiedName is malformed, if + * the qualifiedName has a prefix and the namespaceURI is null, or if the + * qualifiedName has a prefix that is "xml" and the namespaceURI is + * different from "http://www.w3.org/XML/1998/namespace" + */ + Element createElementNS( const DOMString &namespaceURI, + const DOMString &qualifiedName ); + + /** + * Creates an empty \c DocumentFragment object. + * + * @return A new \c DocumentFragment . + * + */ + DocumentFragment createDocumentFragment ( ); + + /** + * Creates a \c Text node given the specified string. + * + * @param data The data for the node. + * + * @return The new \c Text object. + * + */ + Text createTextNode ( const DOMString &data ); + + /** + * Creates a \c Comment node given the specified + * string. + * + * @param data The data for the node. + * + * @return The new \c Comment object. + * + */ + Comment createComment ( const DOMString &data ); + + /** + * Creates a \c CDATASection node whose value is the + * specified string. + * + * @param data The data for the \c CDATASection + * contents. + * + * @return The new \c CDATASection object. + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if this document is an HTML document. + * + */ + CDATASection createCDATASection ( const DOMString &data ); + + /** + * Creates a \c ProcessingInstruction node given the + * specified name and data strings. + * + * @param target The target part of the processing instruction. + * + * @param data The data for the node. + * + * @return The new \c ProcessingInstruction object. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if an invalid character is + * specified. + * + * NOT_SUPPORTED_ERR: Raised if this document is an HTML + * document. + * + */ + ProcessingInstruction createProcessingInstruction ( const DOMString &target, + const DOMString &data ); + + /** + * Creates an \c Attr of the given name. Note that the + * \c Attr instance can then be set on an \c Element + * using the \c setAttribute method. + * + * @param name The name of the attribute. + * + * @return A new \c Attr object. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * invalid character. + * + */ + Attr createAttribute ( const DOMString &name ); + + /** + * Introduced in DOM Level 2 + * Creates an attribute of the given qualified name and namespace URI. + * HTML-only DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the attribute to create. + * + * @param qualifiedName The qualified name of the attribute to instantiate. + * + * @return A new Attr object with the following attributes: + * Node.nodeName - qualifiedName + * Node.namespaceURI - namespaceURI + * Node.prefix - prefix, extracted from qualifiedName, or null if there is + * no prefix + * Node.localName - local name, extracted from qualifiedName + * Attr.name - qualifiedName + * Node.nodeValue - the empty string + * + * @exception INVALID_CHARACTER_ERR Raised if the specified qualified name + * contains an illegal character. + * + * @exception NAMESPACE_ERR Raised if the qualifiedName is malformed, if + * the qualifiedName has a prefix and the namespaceURI is null, if the + * qualifiedName has a prefix that is "xml" and the namespaceURI is + * different from "http://www.w3.org/XML/1998/namespace", or if the + * qualifiedName is "xmlns" and the namespaceURI is different from + * "http://www.w3.org/2000/xmlns/". + */ + Attr createAttributeNS( const DOMString &namespaceURI, + const DOMString &qualifiedName ); + + /** + * Creates an EntityReference object. + * + * @param name The name of the entity to reference. + * + * @return The new \c EntityReference object. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * invalid character. + * + * NOT_SUPPORTED_ERR: Raised if this document is an HTML + * document. + * + */ + EntityReference createEntityReference ( const DOMString &name ); + + /** + * Moved from HTMLDocument in DOM Level 2 + * Returns the Element whose \c id is given by + * elementId. If no such element exists, returns \c null + * . Behavior is not defined if more than one element has + * this \c id . + * + * @param elementId The unique \c id value for an + * element. + * + * @return The matching element. + * + */ + Element getElementById ( const DOMString &elementId ) const; + + /** + * No Exceptions. + * + * Returns a \c NodeList of all the \c Element 's + * with a given tag name in the order in which they + * would be encountered in a preorder traversal of the + * \c Document tree. + * + * @param tagname The name of the tag to match on. The special + * value "*" matches all tags. + * + * @return A new \c NodeList object containing all the + * matched \c Element s. + * + */ + NodeList getElementsByTagName ( const DOMString &tagname ); + + /** + * Introduced in DOM Level 2 + * No Exceptions + * + * Returns a NodeList of all the Elements with a given local name and + * namespace URI in the order in which they are encountered in a preorder + * traversal of the Document tree. + * + * @param namespaceURI The namespace URI of the elements to match on. The + * special value "*" matches all namespaces. + * + * @param localName The local name of the elements to match on. The special + * value "*" matches all local names. + * + * @return A new NodeList object containing all the matched Elements. + */ + NodeList getElementsByTagNameNS( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * Introduced in DOM Level 2 + * + * Imports a node from another document to this document. The returned node + * has no parent; (parentNode is null). The source node is not altered or + * removed from the original document; this method creates a new copy of + * the source node. + * + * For all nodes, importing a node creates a node object owned by the + * importing document, with attribute values identical to the source node's + * nodeName and nodeType, plus the attributes related to namespaces + * (prefix, localName, and namespaceURI). + * + * As in the cloneNode operation on a Node, the source node is not altered. + * Additional information is copied as appropriate to the nodeType, + * attempting to mirror the behavior expected if a fragment of XML or HTML + * source was copied from one document to another, recognizing that the two + * documents may have different DTDs in the XML case. The following list + * describes the specifics for each type of node. + * + * ATTRIBUTE_NODE + * The ownerElement attribute is set to null and the specified flag is set + * to true on the generated Attr. The descendants of the source Attr are + * recursively imported and the resulting nodes reassembled to form the + * corresponding subtree. Note that the deep parameter has no effect on + * Attr nodes; they always carry their children with them when imported. + * + * DOCUMENT_FRAGMENT_NODE + * If the deep option was set to true, the descendants of the source + * element are recursively imported and the resulting nodes reassembled to + * form the corresponding subtree. Otherwise, this simply generates an + * empty DocumentFragment. + * + * DOCUMENT_NODE + * Document nodes cannot be imported. + * + * DOCUMENT_TYPE_NODE + * DocumentType nodes cannot be imported. + * + * ELEMENT_NODE + * Specified attribute nodes of the source element are imported, and the + * generated Attr nodes are attached to the generated Element. Default + * attributes are not copied, though if the document being imported into + * defines default attributes for this element name, those are assigned. If + * the importNode deep parameter was set to true, the descendants of the + * source element are recursively imported and the resulting nodes + * reassembled to form the corresponding subtree. + * + * ENTITY_NODE + * Entity nodes can be imported, however in the current release of the DOM + * the DocumentType is readonly. Ability to add these imported nodes to a + * DocumentType will be considered for addition to a future release of the + * DOM. + * On import, the publicId, systemId, and notationName attributes are + * copied. If a deep import is requested, the descendants of the the source + * Entity are recursively imported and the resulting nodes reassembled to + * form the corresponding subtree. + * + * ENTITY_REFERENCE_NODE Only the EntityReference itself is copied, even if + * a deep import is requested, since the source and destination documents + * might have defined the entity differently. If the document being + * imported into provides a definition for this entity name, its value is + * assigned. + * + * NOTATION_NODE + * Notation nodes can be imported, however in the current release of the + * DOM the DocumentType is readonly. Ability to add these imported nodes to + * a DocumentType will be considered for addition to a future release of + * the DOM. + * On import, the publicId and systemId attributes are copied. + * Note that the deep parameter has no effect on Notation nodes since they + * never have any children. + * + * PROCESSING_INSTRUCTION_NODE + * The imported node copies its target and data values from those of the + * source node. + * + * TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE + * These three types of nodes inheriting from CharacterData copy their data + * and length attributes from those of the source node. + * + * @param importedNode The node to import. + * + * @param deep If true, recursively import the subtree under the specified + * node; if false, import only the node itself, as explained above. This + * has no effect on Attr, EntityReference, and Notation nodes. + * + * @return The imported node that belongs to this Document. + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not + * supported. + */ + Node importNode( const Node & importedNode, bool deep ); + + /** + * @internal + * not part of the DOM + */ + bool isHTMLDocument() const; + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentRange interface + * + * @return Range + * The initial state of the Range returned from this method is such that + * both of its boundary-points are positioned at the beginning of the + * corresponding Document, before any content. The Range returned can only + * be used to select content associated with this Document, or with + * DocumentFragments and Attrs for which this Document is the ownerDocument. + */ + Range createRange(); + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentTraversal interface + * + * Create a new NodeIterator over the subtree rooted at the specified node. + * + * @param root The node which will be iterated together with its children. + * The iterator is initially positioned just before this node. The + * whatToShow flags and the filter, if any, are not considered when setting + * this position. The root must not be null. + * + * @param whatToShow This flag specifies which node types may appear in the + * logical view of the tree presented by the iterator. See the description + * of NodeFilter for the set of possible SHOW_ values. These flags can be + * combined using OR. + * + * @param filter The NodeFilter to be used with this NodeIterator, or null to + * indicate no filter. + * + * @param entityReferenceExpansion The value of this flag determines + * whether entity reference nodes are expanded. + * + * @return NodeIterator The newly created NodeIterator. + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the specified root is null. + */ + NodeIterator createNodeIterator(Node root, unsigned long whatToShow, + NodeFilter filter, + bool entityReferenceExpansion); + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentTraversal interface + * + * Create a new TreeWalker over the subtree rooted at the specified node. + * + * @param root The node which will serve as the root for the TreeWalker. + * The whatToShow flags and the NodeFilter are not considered when setting + * this value; any node type will be accepted as the root. The currentNode + * of the TreeWalker is initialized to this node, whether or not it is + * visible. The root functions as a stopping point for traversal methods + * that look upward in the document structure, such as parentNode and + * nextNode. The root must not be null. + * + * @param whatToShow This flag specifies which node types may appear in the + * logical view of the tree presented by the tree-walker. See the + * description of NodeFilter for the set of possible SHOW_ values. These + * flags can be combined using OR. + * + * @param filter The NodeFilter to be used with this TreeWalker, or null to + * indicate no filter. + * + * @param entityReferenceExpansion If this flag is false, the contents of + * EntityReference nodes are not presented in the logical view. + * + * @return The newly created TreeWalker. + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the specified root is null. + */ + TreeWalker createTreeWalker(Node root, unsigned long whatToShow, + NodeFilter filter, + bool entityReferenceExpansion); + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentEvent interface + * + * The createEvent method is used in creating Events when it is either + * inconvenient or unnecessary for the user to create an Event themselves. + * In cases where the implementation provided Event is insufficient, users + * may supply their own Event implementations for use with the + * dispatchEvent method. + * + * @param eventType The eventType parameter specifies the type of Event + * interface to be created. If the Event interface specified is supported + * by the implementation this method will return a new Event of the + * interface type requested. If the Event is to be dispatched via the + * dispatchEvent method the appropriate event init method must be called + * after creation in order to initialize the Event's values. As an example, + * a user wishing to synthesize some kind of UIEvent would call createEvent + * with the parameter "UIEvents". The initUIEvent method could then be + * called on the newly created UIEvent to set the specific type of UIEvent + * to be dispatched and set its context information. + * + * @return The newly created EventExceptions + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the implementation does not support the + * type of Event interface requested + */ + Event createEvent(const DOMString &eventType); + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentView interface + * + * The default AbstractView for this Document, or null if none available. + */ + AbstractView defaultView() const; + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentStyle interface + * + * A list containing all the style sheets explicitly linked into or + * embedded in a document. For HTML documents, this includes external style + * sheets, included via the HTML LINK element, and inline STYLE elements. + * In XML, this includes external style sheets, included via style sheet + * processing instructions (see [XML-StyleSheet]). + */ + StyleSheetList styleSheets() const; + + /** + * CSS3 mechanism for selecting alternate stylesheets using the DOM. + * Might change without further notice. + */ + + DOMString preferredStylesheetSet(); + DOMString selectedStylesheetSet(); + void setSelectedStylesheetSet(const DOMString& aString); + + /** + * Adds a new style sheet to the list of style sheets. + * + * The new style sheet will be applied after all author and implicit + * style sheets, but before the user style sheet. + * + * Create new style sheets with e. g. + * \c DOMImplementation::createCSSStyleSheet + * + * This is not part of the official DOM. + * + * @param sheet style sheet + * @exception DOMException + * @since 3.4 + */ + void addStyleSheet(const StyleSheet &sheet); + + /** + * Removes a style sheet to the list of style sheets. + * + * Only sheets added by \c addStyleSheet may be removed. + * + * This is not part of the official DOM. + * + * @param sheet style sheet to remove + * @exception DOMException + * NOT_FOUND_ERR \c sheet is not contained in the list of style sheets or + * it has not been added by \c addStyleSheet + * @since 3.4 + */ + void removeStyleSheet(const StyleSheet &sheet); + + /** + * @return The KHTML view widget of this document. + */ + KHTMLView *view() const; + + /** + * Introduced in DOM Level 2 + * This method is from the DocumentCSS interface + * + * This method is used to retrieve the override style declaration for a + * specified element and a specified pseudo-element. + * + * @param elt The element whose style is to be modified. This parameter + * cannot be null. + * + * @param pseudoElt The pseudo-element or null if none. + * + * @return The override style declaration. + */ + CSSStyleDeclaration getOverrideStyle(const Element &elt, + const DOMString &pseudoElt); + + /** + * Introduced in DOM Level 3 + * This method is from the DocumentLS interface + * + * Indicates whether the method DocumentLS.load() should be synchronous or + * asynchronous. When the async attribute is set to true the load method + * returns control to the caller before the document has completed loading. + * The default value of this attribute is true. + */ + bool async() const; + + /** + * Introduced in DOM Level 3 + * This method is from the DocumentLS interface + * + * see async + * + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the implementation doesn't support the mode + * the attribute is being set to. + */ + void setAsync( bool ); + + + /** + * Introduced in DOM Level 3 + * This method is from the DocumentLS interface + * + * If the document is currently being loaded as a result of the method load + * being invoked the loading and parsing is immediately aborted. The + * possibly partial result of parsing the document is discarded and the + * document is cleared. + */ + void abort(); + + /** + * Introduced in DOM Level 3 + * This method is from the DocumentLS interface + * + * Replaces the content of the document with the result of parsing the + * given URI. Invoking this method will either block the caller or return + * to the caller immediately depending on the value of the async attribute. + * Once the document is fully loaded a "load" event (as defined in + * [DOM Level 3 Events], except that the Event.targetNode will be the + * document, not an element) will be dispatched on the document. If an + * error occurs, an implementation dependent "error" event will be + * dispatched on the document. If this method is called on a document that + * is currently loading, the current load is interrupted and the new URI + * load is initiated. + * + * When invoking this method the parameters used in the DOMParser interface + * are assumed to have their default values with the exception that the + * parameters "entities", "normalize-characters", + * "check-character-normalization" are set to "false". + * + * The result of a call to this method is the same the result of a call to + * DOMParser.parseWithContext with an input stream referencing the URI that + * was passed to this call, the document as the context node, and the + * action ACTION_REPLACE_CHILDREN. + * + * @param uri of type DOMString + * The URI reference for the XML file to be loaded. If this is a relative + * URI, the base URI used by the implementation is implementation dependent. + * + * @return If async is set to true load returns true if the document load + * was successfully initiated. If an error occurred when initiating the + * document load, load returns false. + * If async is set to false load returns true if the document was + * successfully loaded and parsed. If an error occurred when either loading + * or parsing the URI, load returns false. + */ + void load( const DOMString &uri ); + + /** + * Introduced in DOM Level 3 + * This method is from the DocumentLS interface + * + * Replace the content of the document with the result of parsing the input + * string, this method is always synchronous. This method always parses + * from a DOMString, which means the data is always UTF-16. All other + * encoding information is ignored. + * + * The parameters used in the DOMParser interface are assumed to have their + * default values when invoking this method. + * + * The result of a call to this method is the same as the result of a call + * to DOMParser.parseWithContext with an input stream containing the string + * passed to this call, the document as the context node, and the action + * ACTION_REPLACE_CHILDREN. + * + * @param source A string containing an XML document. + */ + void loadXML( const DOMString &source ); + + /** + * not part of the official DOM + * + * Documents are read-only by default, but they can be made editable by + * entering "design mode". + * + * @return whether this document is in design mode. + * @since 3.2 + */ + bool designMode() const; + + /** + * not part of the official DOM + * + * @param enable @p true to enable design mode, @p false to disable. + * @see designMode + * @since 3.2 + */ + void setDesignMode(bool enable); + + /** + * not part of the DOM + * + * completes a given URL + */ + DOMString completeURL(const DOMString& url); + + DOMString toString() const; + + /** + * not part of the DOM + * + * Updates the rendered display after one or more changes to + * the DOM structure + */ + void updateRendering(); + + Document( DocumentImpl *i); +protected: + + friend class Node; +}; + +class DocumentFragmentImpl; + +/** + * \c DocumentFragment is a "lightweight" or "minimal" + * \c Document object. It is very common to want to be + * able to extract a portion of a document's tree or to create a new + * fragment of a document. Imagine implementing a user command like + * cut or rearranging a document by moving fragments around. It is + * desirable to have an object which can hold such fragments and it is + * quite natural to use a Node for this purpose. While it is true that + * a \c Document object could fulfil this role, a + * \c Document object can potentially be a heavyweight object, + * depending on the underlying implementation. What is really needed + * for this is a very lightweight object. \c DocumentFragment + * is such an object. + * + * Furthermore, various operations -- such as inserting nodes as + * children of another \c Node -- may take + * \c DocumentFragment objects as arguments; this results in all + * the child nodes of the \c DocumentFragment being moved + * to the child list of this node. + * + * The children of a \c DocumentFragment node are zero or + * more nodes representing the tops of any sub-trees defining the + * structure of the document. \c DocumentFragment nodes do + * not need to be well-formed XML documents (although they do need to + * follow the rules imposed upon well-formed XML parsed entities, + * which can have multiple top nodes). For example, a + * \c DocumentFragment might have only one child and that child + * node could be a \c Text node. Such a structure model + * represents neither an HTML document nor a well-formed XML document. + * + * When a \c DocumentFragment is inserted into a + * \c Document (or indeed any other \c Node that may + * take children) the children of the \c DocumentFragment + * and not the \c DocumentFragment itself are inserted + * into the \c Node . This makes the + * \c DocumentFragment very useful when the user wishes to create + * nodes that are siblings; the \c DocumentFragment acts + * as the parent of these nodes so that the user can use the standard + * methods from the \c Node interface, such as + * \c insertBefore() and \c appendChild() . + * + */ +class KHTML_EXPORT DocumentFragment : public Node +{ + friend class Document; + friend class HTMLElementImpl; + friend class Range; + +public: + DocumentFragment(); + DocumentFragment(const DocumentFragment &other); + DocumentFragment(const Node &other) : Node() + {(*this)=other;} + + DocumentFragment & operator = (const Node &other); + DocumentFragment & operator = (const DocumentFragment &other); + + ~DocumentFragment(); + +protected: + DocumentFragment(DocumentFragmentImpl *i); +}; + +class NamedNodeMap; +class DOMString; + +/** + * Each \c Document has a \c doctype attribute + * whose value is either \c null or a \c DocumentType + * object. The \c DocumentType interface in the + * DOM Level 1 Core provides an interface to the list of entities that + * are defined for the document, and little else because the effect of + * namespaces and the various XML scheme efforts on DTD representation + * are not clearly understood as of this writing. + * + * The DOM Level 1 doesn't support editing \c DocumentType + * nodes. + * + */ +class KHTML_EXPORT DocumentType : public Node +{ + friend class Document; + friend class DOMImplementation; +public: + DocumentType(); + DocumentType(const DocumentType &other); + + DocumentType(const Node &other) : Node() + {(*this)=other;} + DocumentType & operator = (const Node &other); + DocumentType & operator = (const DocumentType &other); + + ~DocumentType(); + + /** + * The name of DTD; i.e., the name immediately following the + * \c DOCTYPE keyword. + * + */ + DOMString name() const; + + /** + * A \c NamedNodeMap containing the general entities, + * both external and internal, declared in the DTD. Duplicates are + * discarded. For example in: <!DOCTYPE ex SYSTEM "ex.dtd" [ + * <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY % baz + * "baz"> ]> <ex/> the interface provides access to \c foo + * and \c bar but not \c baz . + * Every node in this map also implements the \c Entity + * interface. + * + * The DOM Level 1 does not support editing entities, therefore + * \c entities cannot be altered in any way. + * + */ + NamedNodeMap entities() const; + + /** + * A \c NamedNodeMap containing the notations declared + * in the DTD. Duplicates are discarded. Every node in this map + * also implements the \c Notation interface. + * + * The DOM Level 1 does not support editing notations, therefore + * \c notations cannot be altered in any way. + * + */ + NamedNodeMap notations() const; + + /** + * Introduced in DOM Level 2 + * + * The public identifier of the external subset. + */ + DOMString publicId() const; + + /** + * Introduced in DOM Level 2 + * + * The system identifier of the external subset. + */ + DOMString systemId() const; + + /** + * Introduced in DOM Level 2 + * + * The internal subset as a string. + * + * Note: The actual content returned depends on how much information is + * available to the implementation. This may vary depending on various + * parameters, including the XML processor used to build the document. + */ + DOMString internalSubset() const; + +protected: + DocumentType(DocumentTypeImpl *impl); +}; + +} //namespace +#endif diff --git a/tdehtml/dom/dom_element.cpp b/tdehtml/dom/dom_element.cpp new file mode 100644 index 000000000..d9872e37c --- /dev/null +++ b/tdehtml/dom/dom_element.cpp @@ -0,0 +1,409 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom_exception.h" +#include "xml/dom_docimpl.h" +#include "xml/dom_elementimpl.h" +#include "html/html_formimpl.h" + +using namespace DOM; + +Attr::Attr() : Node() +{ +} + +Attr::Attr(const Attr &other) : Node(other) +{ +} + +Attr::Attr( AttrImpl *_impl ) +{ + impl= _impl; + if (impl) impl->ref(); +} + +Attr &Attr::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || !ohandle->isAttributeNode()) { + if (impl) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Attr &Attr::operator = (const Attr &other) +{ + Node::operator =(other); + return *this; +} + +Attr::~Attr() +{ +} + +DOMString Attr::name() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return ((AttrImpl *)impl)->name(); +} + +bool Attr::specified() const +{ + if (impl) return ((AttrImpl *)impl)->specified(); + return 0; +} + +Element Attr::ownerElement() const +{ + if (!impl) return 0; + return static_cast<AttrImpl*>(impl)->ownerElement(); +} + +DOMString Attr::value() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->nodeValue(); +} + +void Attr::setValue( const DOMString &newValue ) +{ + if (!impl) + return; + + int exceptioncode = 0; + ((AttrImpl *)impl)->setValue(newValue,exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +// --------------------------------------------------------------------------- + +Element::Element() : Node() +{ +} + +Element::Element(const Element &other) : Node(other) +{ +} + +Element::Element(ElementImpl *impl) : Node(impl) +{ +} + +Element &Element::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || !ohandle->isElementNode()) { + if (impl) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Element &Element::operator = (const Element &other) +{ + Node::operator =(other); + return *this; +} + +Element::~Element() +{ +} + +DOMString Element::tagName() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return static_cast<ElementImpl*>(impl)->tagName(); +} + +DOMString Element::getAttribute( const DOMString &name ) +{ + // ### getAttribute() and getAttributeNS() are supposed to return the empty string if the attribute + // does not exist. However, there are a number of places around tdehtml that expect a null string + // for nonexistent attributes. These need to be changed to use hasAttribute() instead. + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (!name.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR); + + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId,name.implementation(),true,true); + if (!id) return DOMString(); + + ElementImpl* e = static_cast<ElementImpl*>(impl); + return e->getAttribute(id, false, name); +} + +void Element::setAttribute( const DOMString &name, const DOMString &value ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), false /* allocate */, + true, &exceptioncode); + + static_cast<ElementImpl*>(impl)->setAttribute(id, value, name, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +void Element::removeAttribute( const DOMString &name ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), true, true); + if (!id) return; + + int exceptioncode = 0; + NamedNodeMapImpl *attributes = static_cast<ElementImpl*>(impl)->attributes(false); + attributes->removeNamedItem(id, false, name.implementation(), exceptioncode); + // it's allowed to remove attributes that don't exist. + if ( exceptioncode && exceptioncode != DOMException::NOT_FOUND_ERR ) + throw DOMException( exceptioncode ); +} + +Attr Element::getAttributeNode( const DOMString &name ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (!name.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR); + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), true, true); + if (!id) return 0; + + ElementImpl* e = static_cast<ElementImpl*>(impl); + if (!e->attributes()) return 0; + + return static_cast<AttrImpl*>(e->attributes()->getNamedItem(id, false, name.implementation())); +} + +Attr Element::setAttributeNode( const Attr &newAttr ) +{ + if (!impl || newAttr.isNull()) + throw DOMException(DOMException::NOT_FOUND_ERR); + // WRONG_DOCUMENT_ERR and INUSE_ATTRIBUTE_ERR are already tested & thrown by setNamedItem + + int exceptioncode = 0; + Attr r = static_cast<ElementImpl*>(impl)->attributes(false)->setNamedItem(newAttr.handle(), false, + newAttr.handle()->nodeName().implementation(), exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + static_cast<AttrImpl *>(newAttr.handle())->setOwnerElement( static_cast<ElementImpl*>(impl) ); + return r; +} + +Attr Element::removeAttributeNode( const Attr &oldAttr ) +{ + if (!impl || oldAttr.isNull() || oldAttr.ownerElement().handle() != impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + if (impl->isReadOnly()) + throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); + + if (!static_cast<ElementImpl*>(impl)->attributes(true)) + throw DOMException(DOMException::NOT_FOUND_ERR); + + NamedAttrMapImpl *attributes = static_cast<ElementImpl*>(impl)->attributes(false); + return attributes->removeAttr(static_cast<AttrImpl*>(static_cast<AttrImpl*>(oldAttr.handle()))); +} + +NodeList Element::getElementsByTagName( const DOMString &tagName ) +{ + if (!impl) return 0; + NodeImpl::Id id; + if ( tagName == "*" ) + id = 0; + else + id = impl->getDocument()->getId(NodeImpl::ElementId, tagName.implementation(), false, true); + return new TagNodeListImpl( impl, id ); +} + +NodeList Element::getElementsByTagNameNS( const DOMString &namespaceURI, + const DOMString &localName ) +{ + if (!impl) return 0; + return new TagNodeListImpl( impl, namespaceURI, localName ); +} + +DOMString Element::getAttributeNS( const DOMString &namespaceURI, + const DOMString &localName) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (!localName.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR); + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, namespaceURI.implementation(), 0/*prefix*/, localName.implementation(), true, true); + ElementImpl* e = static_cast<ElementImpl*>(impl); + return e->getAttribute(id, true); +} + +void Element::setAttributeNS( const DOMString &namespaceURI, + const DOMString &qualifiedName, + const DOMString &value) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + static_cast<ElementImpl*>(impl)->setAttributeNS(namespaceURI, qualifiedName, value, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +void Element::removeAttributeNS( const DOMString &namespaceURI, + const DOMString &localName ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + NamedNodeMapImpl *attributes = static_cast<ElementImpl*>(impl)->attributes(false); + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, namespaceURI.implementation(), 0/*prefix*/, localName.implementation(), false, true); + attributes->removeNamedItem(id, true, 0, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +Attr Element::getAttributeNodeNS( const DOMString &namespaceURI, + const DOMString &localName ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (!localName.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR); + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, namespaceURI.implementation(), + 0/*prefix*/, localName.implementation(), true, true); + ElementImpl* e = static_cast<ElementImpl*>(impl); + if (!e->attributes()) return 0; + + return static_cast<AttrImpl*>(e->attributes()->getNamedItem(id, true)); +} + +Attr Element::setAttributeNodeNS( const Attr &newAttr ) +{ + if (!impl || newAttr.isNull()) + throw DOMException(DOMException::NOT_FOUND_ERR); + // WRONG_DOCUMENT_ERR and INUSE_ATTRIBUTE_ERR are already tested & thrown by setNamedItem + + int exceptioncode = 0; + Attr r = static_cast<ElementImpl*>(impl)->attributes(false)->setNamedItem(newAttr.handle(), true, 0, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + static_cast<AttrImpl *>(newAttr.handle())->setOwnerElement( static_cast<ElementImpl*>(impl) ); + return r; +} + + +bool Element::hasAttribute( const DOMString& name ) +{ + if (!impl || !static_cast<ElementImpl*>(impl)->attributes()) return false; // ### throw ? + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), true, true); + if (!id) return false; + + if (!static_cast<ElementImpl*>(impl)->attributes(true /*readonly*/)) return false; + return static_cast<ElementImpl*>(impl)->attributes(true)->getValue(id, false, name.implementation()) != 0; +} + +bool Element::hasAttributeNS( const DOMString &namespaceURI, + const DOMString &localName ) +{ + if (!impl || !static_cast<ElementImpl*>(impl)->attributes()) return false; // ### throw ? + if (!static_cast<ElementImpl*>(impl)->attributes(true /*readonly*/)) return false; + NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId,namespaceURI.implementation(), + 0/*prefix*/, localName.implementation(), true, true); + return static_cast<ElementImpl*>(impl)->attributes(true)->getValue(id, true) != 0; +} + +bool Element::isHTMLElement() const +{ + if(!impl) return false; + return ((ElementImpl *)impl)->isHTMLElement(); +} + +Element Element::form() const +{ + if (!impl || !impl->isGenericFormElement()) return 0; + return static_cast<HTMLGenericFormElementImpl*>(impl)->form(); + ElementImpl* f = static_cast<HTMLGenericFormElementImpl*>( impl )->form(); + + if( f && f->implicitNode() ) + return 0; + return f; +} + +CSSStyleDeclaration Element::style() +{ + if (impl) return ((ElementImpl *)impl)->styleRules(); + return 0; +} + +bool Element::contentEditable() const { + if(!impl) return false; + return static_cast<ElementImpl *>(impl)->contentEditable(); +} + +void Element::setContentEditable(bool enabled) { + if(!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + static_cast<ElementImpl *>(impl)->setContentEditable(enabled); +} + +bool Element::tdehtmlValidAttrName(const DOMString &name) +{ + // Check if name is valid + // http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name + DOMStringImpl* _name = name.implementation(); + TQChar ch = _name->s[0]; + if ( !ch.isLetter() && ch != '_' && ch != ':' ) + return false; // first char isn't valid + for ( uint i = 0; i < _name->l; ++i ) + { + ch = _name->s[i]; + if ( !ch.isLetter() && !ch.isDigit() && ch != '.' + && ch != '-' && ch != '_' && ch != ':' + && ch.category() != TQChar::Mark_SpacingCombining + /* no idea what "extender is" */ ) + return false; + } + return true; +} + +bool Element::tdehtmlValidPrefix(const DOMString &name) +{ + // Null prefix is ok. If not null, reuse code from tdehtmlValidAttrName + return !name.implementation() || tdehtmlValidAttrName(name); +} + +bool Element::tdehtmlValidQualifiedName(const DOMString &name) +{ + return tdehtmlValidAttrName(name); +} + +bool Element::tdehtmlMalformedQualifiedName(const DOMString &name) +{ + // #### Not clearly defined in the DOM spec... + // But we know for sure that a null qualified name is malformed + return name.isNull(); +} + +bool Element::tdehtmlMalformedPrefix(const DOMString &/*name*/) +{ + // #### + return false; +} diff --git a/tdehtml/dom/dom_element.h b/tdehtml/dom/dom_element.h new file mode 100644 index 000000000..d3313628e --- /dev/null +++ b/tdehtml/dom/dom_element.h @@ -0,0 +1,600 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef _DOM_ELEMENT_h_ +#define _DOM_ELEMENT_h_ + +#include <dom/dom_node.h> +#include <dom/css_value.h> + +#include <tdelibs_export.h> + +namespace DOM { + +class DOMString; +class AttrImpl; +class Element; +class ElementImpl; +class NamedAttrMapImpl; +class DocumentImpl; + +/** + * The \c Attr interface represents an attribute in an + * \c Element object. Typically the allowable values for + * the attribute are defined in a document type definition. + * + * \c Attr objects inherit the \c Node + * interface, but since they are not actually child nodes of the + * element they describe, the DOM does not consider them part of the + * document tree. Thus, the \c Node attributes + * \c parentNode , \c previousSibling , and + * \c nextSibling have a null value for \c Attr + * objects. The DOM takes the view that attributes are properties of + * elements rather than having a separate identity from the elements + * they are associated with; this should make it more efficient to + * implement such features as default attributes associated with all + * elements of a given type. Furthermore, \c Attr nodes + * may not be immediate children of a \c DocumentFragment + * . However, they can be associated with \c Element nodes + * contained within a \c DocumentFragment . In short, + * users and implementors of the DOM need to be aware that \c Attr + * nodes have some things in common with other objects + * inheriting the \c Node interface, but they also are + * quite distinct. + * + * The attribute's effective value is determined as follows: if this + * attribute has been explicitly assigned any value, that value is the + * attribute's effective value; otherwise, if there is a declaration + * for this attribute, and that declaration includes a default value, + * then that default value is the attribute's effective value; + * otherwise, the attribute does not exist on this element in the + * structure model until it has been explicitly added. Note that the + * \c nodeValue attribute on the \c Attr + * instance can also be used to retrieve the string version of the + * attribute's value(s). + * + * In XML, where the value of an attribute can contain entity + * references, the child nodes of the \c Attr node provide + * a representation in which entity references are not expanded. These + * child nodes may be either \c Text or + * \c EntityReference nodes. Because the attribute type may be + * unknown, there are no tokenized attribute values. + * + */ +class KHTML_EXPORT Attr : public Node +{ + friend class Element; + friend class Document; + friend class DocumentImpl; + friend class HTMLDocument; + friend class ElementImpl; + friend class NamedAttrMapImpl; + friend class AttrImpl; + +public: + Attr(); + Attr(const Node &other) : Node() + {(*this)=other;} + Attr(const Attr &other); + + Attr & operator = (const Node &other); + Attr & operator = (const Attr &other); + + ~Attr(); + + /** + * Returns the name of this attribute. + * + */ + DOMString name() const; + + /** + * If this attribute was explicitly given a value in the original + * document, this is \c true ; otherwise, it is + * \c false . Note that the implementation is in charge of + * this attribute, not the user. If the user changes the value of + * the attribute (even if it ends up having the same value as the + * default value) then the \c specified flag is + * automatically flipped to \c true . To re-specify + * the attribute as the default value from the DTD, the user must + * delete the attribute. The implementation will then make a new + * attribute available with \c specified set to + * \c false and the default value (if one exists). + * + * In summary: + * \li If the attribute has an assigned + * value in the document then \c specified is + * \c true , and the value is the assigned value. + * + * \li If the attribute has no assigned value in the + * document and has a default value in the DTD, then + * \c specified is \c false , and the value is + * the default value in the DTD. + * + * \li If the attribute has no assigned value in the + * document and has a value of #IMPLIED in the DTD, then the + * attribute does not appear in the structure model of the + * document. + * + * + * + */ + bool specified() const; + + /** + * On retrieval, the value of the attribute is returned as a + * string. Character and general entity references are replaced + * with their values. + * + * On setting, this creates a \c Text node with the + * unparsed contents of the string. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * + * The Element node this attribute is attached to or null if this attribute + * is not in use. + */ + Element ownerElement() const; + +protected: + + Attr( AttrImpl *_impl ); +}; + +class NodeList; +class Attr; +class DOMString; + +/** + * By far the vast majority of objects (apart from text) that authors + * encounter when traversing a document are \c Element + * nodes. Assume the following XML document: <elementExample + * id="demo"> <subelement1/> + * <subelement2><subsubelement/></subelement2> + * </elementExample> + * + * When represented using DOM, the top node is an \c Element + * node for "elementExample", which contains two + * child \c Element nodes, one for "subelement1" + * and one for "subelement2". "subelement1" + * contains no child nodes. + * + * Elements may have attributes associated with them; since the + * \c Element interface inherits from \c Node + * , the generic \c Node interface method + * \c getAttributes may be used to retrieve the set of all + * attributes for an element. There are methods on the \c Element + * interface to retrieve either an \c Attr object + * by name or an attribute value by name. In XML, where an attribute + * value may contain entity references, an \c Attr object + * should be retrieved to examine the possibly fairly complex sub-tree + * representing the attribute value. On the other hand, in HTML, where + * all attributes have simple string values, methods to directly + * access an attribute value can safely be used as a convenience. + * + */ +class KHTML_EXPORT Element : public Node +{ + friend class Document; + friend class HTMLDocument; +// friend class AttrImpl; + friend class Attr; + +public: + Element(); + Element(const Node &other) : Node() + {(*this)=other;} + Element(const Element &other); + + Element & operator = (const Node &other); + Element & operator = (const Element &other); + + ~Element(); + + /** + * The name of the element. For example, in: <elementExample + * id="demo"> ... </elementExample> , + * \c tagName has the value \c "elementExample" + * . Note that this is case-preserving in XML, as are all + * of the operations of the DOM. The HTML DOM returns the + * \c tagName of an HTML element in the canonical uppercase + * form, regardless of the case in the source HTML document. + * + */ + DOMString tagName() const; + + /** + * Retrieves an attribute value by name. + * + * @param name The name of the attribute to retrieve. + * + * @return The \c Attr value as a string, or the empty + * string if that attribute does not have a specified or default + * value. + * + */ + DOMString getAttribute ( const DOMString &name ); + + /** + * Adds a new attribute. If an attribute with that name is already + * present in the element, its value is changed to be that of the + * value parameter. This value is a simple string, it is not + * parsed as it is being set. So any markup (such as syntax to be + * recognized as an entity reference) is treated as literal text, + * and needs to be appropriately escaped by the implementation + * when it is written out. In order to assign an attribute value + * that contains entity references, the user must create an + * \c Attr node plus any \c Text and + * \c EntityReference nodes, build the appropriate subtree, + * and use \c setAttributeNode to assign it as the + * value of an attribute. + * + * @param name The name of the attribute to create or alter. + * + * @param value Value to set in string form. + * + * @return + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * invalid character. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + void setAttribute ( const DOMString &name, const DOMString &value ); + + /** + * Removes an attribute by name. If the removed attribute has a + * default value it is immediately replaced. + * + * @param name The name of the attribute to remove. + * + * @return + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + void removeAttribute ( const DOMString &name ); + + /** + * Retrieves an \c Attr node by name. + * + * @param name The name of the attribute to retrieve. + * + * @return The \c Attr node with the specified + * attribute name or \c null if there is no such + * attribute. + * + */ + Attr getAttributeNode ( const DOMString &name ); + + /** + * Adds a new attribute. If an attribute with that name is already + * present in the element, it is replaced by the new one. + * + * @param newAttr The \c Attr node to add to the + * attribute list. + * + * @return If the \c newAttr attribute replaces an + * existing attribute with the same name, the previously existing + * \c Attr node is returned, otherwise \c null + * is returned. + * + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if \c newAttr was + * created from a different document than the one that created the + * element. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * INUSE_ATTRIBUTE_ERR: Raised if \c newAttr is + * already an attribute of another \c Element object. + * The DOM user must explicitly clone \c Attr nodes to + * re-use them in other elements. + * + */ + Attr setAttributeNode ( const Attr &newAttr ); + + /** + * Removes the specified attribute. + * + * @param oldAttr The \c Attr node to remove from the + * attribute list. If the removed \c Attr has a + * default value it is immediately replaced. + * + * @return The \c Attr node that was removed. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * NOT_FOUND_ERR: Raised if \c oldAttr is not an + * attribute of the element. + * + */ + Attr removeAttributeNode ( const Attr &oldAttr ); + + /** + * Returns a \c NodeList of all descendant elements + * with a given tag name, in the order in which they would be + * encountered in a preorder traversal of the \c Element + * tree. + * + * @param name The name of the tag to match on. The special value + * "*" matches all tags. + * + * @return A list of matching \c Element nodes. + * + */ + NodeList getElementsByTagName ( const DOMString &name ); + + /** + * Introduced in DOM Level 2 + * Returns a NodeList of all the descendant Elements with a given local + * name and namespace URI in the order in which they are encountered in a + * preorder traversal of this Element tree. + * + * @param namespaceURI The namespace URI of the elements to match on. The + * special value "*" matches all namespaces. + * + * @param localName The local name of the elements to match on. The special + * value "*" matches all local names. + * + * @return A new NodeList object containing all the matched Elements. + */ + NodeList getElementsByTagNameNS ( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * Introduced in DOM Level 2. + * + * No Exceptions. + * + * Retrieves an attribute value by local name and namespace URI. HTML-only + * DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the attribute to retrieve. + * + * @param localName The local name of the attribute to retrieve. + * + * @return The Attr value as a string, or the empty string if that + * attribute does not have a specified or default value. + */ + DOMString getAttributeNS ( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * Introduced in DOM Level 2 + * + * Adds a new attribute. If an attribute with the same local name and + * namespace URI is already present on the element, its prefix is changed + * to be the prefix part of the qualifiedName, and its value is changed to + * be the value parameter. This value is a simple string; it is not parsed + * as it is being set. So any markup (such as syntax to be recognized as an + * entity reference) is treated as literal text, and needs to be + * appropriately escaped by the implementation when it is written out. In + * order to assign an attribute value that contains entity references, the + * user must create an Attr node plus any Text and EntityReference nodes, + * build the appropriate subtree, and use setAttributeNodeNS or + * setAttributeNode to assign it as the value of an attribute. + * + * HTML-only DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the attribute to create or + * alter. + * + * @param qualifiedName The qualified name of the attribute to create or + * alter. + * + * @param value The value to set in string form. + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains + * an illegal character. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the + * qualifiedName has a prefix and the namespaceURI is null, if the + * qualifiedName has a prefix that is "xml" and the namespaceURI is + * different from "http://www.w3.org/XML/1998/namespace", or if the + * qualifiedName is "xmlns" and the namespaceURI is different from + * "http://www.w3.org/2000/xmlns/". + */ + void setAttributeNS ( const DOMString &namespaceURI, + const DOMString &qualifiedName, + const DOMString &value ); + + /** + * Introduced in DOM Level 2 + * + * Removes an attribute by local name and namespace URI. If the removed + * attribute has a default value it is immediately replaced. The replacing + * attribute has the same namespace URI and local name, as well as the + * original prefix. + * + * HTML-only DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the attribute to remove. + * + * @param localName The local name of the attribute to remove. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + void removeAttributeNS ( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * Introduced in DOM Level 2 + * + * Retrieves an Attr node by local name and namespace URI. HTML-only DOM + * implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the attribute to retrieve. + * + * @param localName The local name of the attribute to retrieve. + * + * @return The Attr node with the specified attribute local name and + * namespace URI or null if there is no such attribute. + */ + Attr getAttributeNodeNS ( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * Introduced in DOM Level 2 + * + * Adds a new attribute. If an attribute with that local name and that + * namespace URI is already present in the element, it is replaced by the + * new one. + * + * HTML-only DOM implementations do not need to implement this method. + * + * @param newAttr The Attr node to add to the attribute list. + * + * @return If the newAttr attribute replaces an existing attribute with the + * same local name and namespace URI, the replaced Attr node is returned, + * otherwise null is returned. + * + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different + * document than the one that created the element. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of + * another Element object. The DOM user must explicitly clone Attr nodes to + * re-use them in other elements. + */ + Attr setAttributeNodeNS ( const Attr &newAttr ); + + /** + * Returns true when an attribute with a given name is specified on this + * element or has a default value, false otherwise. + * Introduced in DOM Level 2. + * + * @param name The name of the attribute to look for. + * + * @return true if an attribute with the given name is specified on this + * element or has a default value, false otherwise. + */ + bool hasAttribute( const DOMString& name ); + + /** + * Introduced in DOM Level 2 + * + * Returns true when an attribute with a given local name and namespace URI + * is specified on this element or has a default value, false otherwise. + * HTML-only DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the attribute to look for. + * + * @param localName The local name of the attribute to look for. + * + * @return true if an attribute with the given local name and namespace URI + * is specified or has a default value on this element, false otherwise. + */ + bool hasAttributeNS ( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * Introduced in DOM Level 2 + * This method is from the CSSStyleDeclaration interface + * + * The style attribute + */ + CSSStyleDeclaration style ( ); + + /** + * not part of the official DOM + * + * This method will always reflect the editability setting of this + * element as specified by a direct or indirect (that means, inherited) + * assignment to contentEditable or the respective CSS rule, even if + * design mode is active. + * + * @return whether this element is editable. + * @since 3.2 + * @see setContentEditable + */ + bool contentEditable() const; + + /** + * not part of the official DOM + * + * This element can be made editable by setting its contentEditable + * property to @p true. The setting will be inherited to its children + * as well. + * + * Setting or clearing contentEditable when design mode is active will + * take no effect. However, its status will still be propagated to all + * child elements. + * + * @param enabled @p true to make this element editable, @p false + * otherwise. + * @see DOM::Document::designMode + * @since 3.2 + */ + void setContentEditable(bool enabled); + + /** + * @internal + * not part of the DOM + */ + bool isHTMLElement() const; + + /** + * KHTML extension to DOM + * This method returns the associated form element. + * returns null if this element is not a form-like element + * or if this elment is not in the scope of a form element. + */ + Element form() const; + + static bool tdehtmlValidAttrName(const DOMString &name); + static bool tdehtmlValidPrefix(const DOMString &name); + static bool tdehtmlValidQualifiedName(const DOMString &name); + + static bool tdehtmlMalformedQualifiedName(const DOMString &name); + static bool tdehtmlMalformedPrefix(const DOMString &name); +protected: + Element(ElementImpl *_impl); +}; + +} //namespace +#endif diff --git a/tdehtml/dom/dom_exception.h b/tdehtml/dom/dom_exception.h new file mode 100644 index 000000000..cef032206 --- /dev/null +++ b/tdehtml/dom/dom_exception.h @@ -0,0 +1,92 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef _DOM_DOMException_h_ +#define _DOM_DOMException_h_ + +#include <dom/dom_misc.h> + +namespace DOM { + + +/** + * DOM operations only raise exceptions in "exceptional" + * circumstances, i.e., when an operation is impossible to perform + * (either for logical reasons, because data is lost, or because the + * implementation has become unstable). In general, DOM methods return + * specific error values in ordinary processing situation, such as + * out-of-bound errors when using \c NodeList . + * + * Implementations may raise other exceptions under other + * circumstances. For example, implementations may raise an + * implementation-dependent exception if a \c null + * argument is passed. + * + * Some languages and object systems do not support the concept of + * exceptions. For such systems, error conditions may be indicated + * using native error reporting mechanisms. For some bindings, for + * example, methods may return error codes similar to those listed in + * the corresponding method descriptions. + * + */ +class KHTML_EXPORT DOMException +{ +public: + DOMException(unsigned short _code) { code = _code; } + DOMException(const DOMException &other) { code = other.code; } + + DOMException & operator = (const DOMException &other) + { code = other.code; return *this; } + + virtual ~DOMException() {} + /** + * An integer indicating the type of error generated. + * + */ + enum ExceptionCode { + INDEX_SIZE_ERR = 1, + DOMSTRING_SIZE_ERR = 2, + HIERARCHY_REQUEST_ERR = 3, + WRONG_DOCUMENT_ERR = 4, + INVALID_CHARACTER_ERR = 5, + NO_DATA_ALLOWED_ERR = 6, + NO_MODIFICATION_ALLOWED_ERR = 7, + NOT_FOUND_ERR = 8, + NOT_SUPPORTED_ERR = 9, + INUSE_ATTRIBUTE_ERR = 10, + INVALID_STATE_ERR = 11, + SYNTAX_ERR = 12, + INVALID_MODIFICATION_ERR = 13, + NAMESPACE_ERR = 14, + INVALID_ACCESS_ERR = 15 + }; + unsigned short code; +}; + +} //namespace +#endif diff --git a/tdehtml/dom/dom_html.h b/tdehtml/dom/dom_html.h new file mode 100644 index 000000000..f8aa02e99 --- /dev/null +++ b/tdehtml/dom/dom_html.h @@ -0,0 +1,40 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef DOM_HTML_H +#define DOM_HTML_H + +#include <dom/dom_core.h> + +#include <dom/html_base.h> +#include <dom/html_block.h> +#include <dom/html_document.h> +#include <dom/html_element.h> +#include <dom/html_form.h> +#include <dom/html_head.h> +#include <dom/html_image.h> +#include <dom/html_inline.h> +#include <dom/html_list.h> +#include <dom/html_misc.h> +#include <dom/html_object.h> +#include <dom/html_table.h> + +#endif diff --git a/tdehtml/dom/dom_misc.cpp b/tdehtml/dom/dom_misc.cpp new file mode 100644 index 000000000..d296b954a --- /dev/null +++ b/tdehtml/dom/dom_misc.cpp @@ -0,0 +1,37 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom_misc.h" +using namespace DOM; + +DomShared::~DomShared() +{ + // deliberately left blank +} + + +bool DomShared::deleteMe() +{ + return !_ref; +} + + diff --git a/tdehtml/dom/dom_misc.h b/tdehtml/dom/dom_misc.h new file mode 100644 index 000000000..4cded0f00 --- /dev/null +++ b/tdehtml/dom/dom_misc.h @@ -0,0 +1,60 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef _DOM_RefCountImpl_h_ +#define _DOM_RefCountImpl_h_ + +#include <tdelibs_export.h> + +namespace DOM { + +/* + * This implements the reference counting scheme used for all internal + * DOM objects. + * + * Other objects should overload deleteMe() to fit their needs. The default + * implementation deletes the object if the ref count drops to 0. + */ +class KHTML_EXPORT DomShared +{ +public: + DomShared() : _ref( 0 ) {} + virtual ~DomShared(); + + /* Overload this function if you want a different deletion behavior + */ + virtual bool deleteMe(); + + void ref() { _ref++; } + void deref() { if(_ref) _ref--; if(!_ref && deleteMe()) delete this; } + bool hasOneRef() const { return _ref == 1; } + unsigned int refCount() const { return _ref; } + +protected: + // the number of DOMObjects referencing this Node + // An implementation object will delete itself, if it has + // no DOMObject referencing it, and deleteMe() returns true. + unsigned int _ref; +}; + +} // namespace + +#endif diff --git a/tdehtml/dom/dom_node.cpp b/tdehtml/dom/dom_node.cpp new file mode 100644 index 000000000..9971bdb00 --- /dev/null +++ b/tdehtml/dom/dom_node.cpp @@ -0,0 +1,495 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom_doc.h" +#include "dom/dom_exception.h" +#include "dom/dom2_events.h" +#include "xml/dom_docimpl.h" +#include "xml/dom_elementimpl.h" +#include "xml/dom2_eventsimpl.h" + +#include <tqrect.h> + +using namespace DOM; + +NamedNodeMap::NamedNodeMap() +{ + impl = 0; +} + +NamedNodeMap::NamedNodeMap(const NamedNodeMap &other) +{ + impl = other.impl; + if (impl) impl->ref(); +} + +NamedNodeMap::NamedNodeMap(NamedNodeMapImpl *i) +{ + impl = i; + if (impl) impl->ref(); +} + +NamedNodeMap &NamedNodeMap::operator = (const NamedNodeMap &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +NamedNodeMap::~NamedNodeMap() +{ + if(impl) impl->deref(); +} + +Node NamedNodeMap::getNamedItem( const DOMString &name ) const +{ + if (!impl) return 0; + NodeImpl::Id nid = impl->mapId(0, name.implementation(), true); + if (!nid) return 0; + return impl->getNamedItem(nid, false, name.implementation()); +} + +Node NamedNodeMap::setNamedItem( const Node &arg ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (!arg.impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + Node r = impl->setNamedItem(arg.impl, false, + arg.impl->nodeName().implementation(), exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +Node NamedNodeMap::removeNamedItem( const DOMString &name ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + Node r = impl->removeNamedItem(impl->mapId(0, name.implementation(), false), + false, name.implementation(), exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +Node NamedNodeMap::item( unsigned long index ) const +{ + if (!impl) return 0; + return impl->item(index); +} + +Node NamedNodeMap::getNamedItemNS( const DOMString &namespaceURI, const DOMString &localName ) const +{ + if (!impl) return 0; + NodeImpl::Id nid = impl->mapId( namespaceURI.implementation(), localName.implementation(), true ); + return impl->getNamedItem(nid, true); +} + +Node NamedNodeMap::setNamedItemNS( const Node &arg ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + Node r = impl->setNamedItem(arg.impl, true, 0, exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +Node NamedNodeMap::removeNamedItemNS( const DOMString &namespaceURI, const DOMString &localName ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + NodeImpl::Id nid = impl->mapId( namespaceURI.implementation(), localName.implementation(), false ); + Node r = impl->removeNamedItem(nid, true, 0, exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return r; +} + +unsigned long NamedNodeMap::length() const +{ + if (!impl) return 0; + return impl->length(); +} + +// --------------------------------------------------------------------------- + +Node::Node(const Node &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +Node::Node( NodeImpl *i ) +{ + impl = i; + if(impl) impl->ref(); +} + +Node &Node::operator = (const Node &other) +{ + if(impl != other.impl) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +bool Node::operator == (const Node &other) const +{ + return (impl == other.impl); +} + +bool Node::operator != (const Node &other) const +{ + return !(impl == other.impl); +} + +Node::~Node() +{ + if(impl) impl->deref(); +} + +DOMString Node::nodeName() const +{ + if(impl) return impl->nodeName(); + return DOMString(); +} + +DOMString Node::nodeValue() const +{ + // ### should throw exception on plain node ? + if(impl) return impl->nodeValue(); + return DOMString(); +} + +void Node::setNodeValue( const DOMString &_str ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + if(impl) impl->setNodeValue( _str,exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +unsigned short Node::nodeType() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->nodeType(); +} + +Node Node::parentNode() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->parentNode(); +} + +NodeList Node::childNodes() const +{ + if (!impl) return 0; + return impl->childNodes(); +} + +Node Node::firstChild() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->firstChild(); +} + +Node Node::lastChild() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->lastChild(); +} + +Node Node::previousSibling() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->previousSibling(); +} + +Node Node::nextSibling() const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->nextSibling(); +} + +NamedNodeMap Node::attributes() const +{ + if (!impl || !impl->isElementNode()) return 0; + return static_cast<ElementImpl*>(impl)->attributes(); +} + +Document Node::ownerDocument() const +{ + // braindead DOM spec says that ownerDocument + // should return null if called on the document node + // we don't do that in the *impl tree to avoid excessive if()'s + // so we simply hack it here in one central place. + if (!impl || impl->getDocument() == impl) return Document(false); + + return impl->getDocument(); +} + +Node Node::insertBefore( const Node &newChild, const Node &refChild ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + NodeImpl *r = impl->insertBefore( newChild.impl, refChild.impl, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + if (!newChild.impl->closed()) newChild.impl->close(); + return r; +} + +Node Node::replaceChild( const Node &newChild, const Node &oldChild ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + impl->replaceChild( newChild.impl, oldChild.impl, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + if (newChild.impl && !newChild.impl->closed()) newChild.impl->close(); + + return oldChild; +} + +Node Node::removeChild( const Node &oldChild ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + impl->removeChild( oldChild.impl, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + + return oldChild; +} + +Node Node::appendChild( const Node &newChild ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + NodeImpl *r = impl->appendChild( newChild.impl, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + if (!newChild.impl->closed()) newChild.impl->close(); + return r; +} + +bool Node::hasAttributes() +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + if (!impl->isElementNode()) return false; + ElementImpl* e = static_cast<ElementImpl*>(impl); + return e->attributes(true) && e->attributes(true)->length(); +} + +bool Node::hasChildNodes( ) +{ + if (!impl) return false; + return impl->hasChildNodes(); +} + +Node Node::cloneNode( bool deep ) +{ + if (!impl) return 0; + return impl->cloneNode( deep ); +} + +void Node::normalize ( ) +{ + if (!impl) return; + impl->normalize(); +} + +bool Node::isSupported( const DOMString &feature, + const DOMString & /*version*/ ) const +{ + DOMString upFeature = feature.upper(); + return (upFeature == "HTML" || + upFeature == "XML" || + upFeature == "CORE"); +} + +DOMString Node::namespaceURI( ) const +{ + if (!impl) return DOMString(); + return impl->namespaceURI(); +} + +DOMString Node::prefix( ) const +{ + if (!impl) return DOMString(); + return impl->prefix(); +} + +void Node::setPrefix(const DOMString &prefix ) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int exceptioncode = 0; + impl->setPrefix(prefix,exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +DOMString Node::localName( ) const +{ + if (!impl) return DOMString(); + return impl->localName(); +} + +void Node::addEventListener(const DOMString &type, + EventListener *listener, + const bool useCapture) +{ + if (!impl) return; + if (listener) + impl->addEventListener(EventImpl::typeToId(type),listener,useCapture); +} + +void Node::removeEventListener(const DOMString &type, + EventListener *listener, + bool useCapture) +{ + if (!impl) return; + impl->removeEventListener(EventImpl::typeToId(type),listener,useCapture); +} + +bool Node::dispatchEvent(const Event &evt) +{ + if (!impl) + throw DOMException(DOMException::INVALID_STATE_ERR); + + if (!evt.handle()) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + impl->dispatchEvent(evt.handle(),exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); + return !evt.handle()->defaultPrevented(); +} + + +unsigned int Node::elementId() const +{ + if (!impl) return 0; + return impl->id(); +} + +unsigned long Node::index() const +{ + if (!impl) return 0; + return impl->nodeIndex(); +} + +TQString Node::toHTML() +{ + if (!impl) return TQString::null; + return impl->toString().string(); +} + +void Node::applyChanges() +{ + if (!impl) return; + impl->recalcStyle( NodeImpl::Inherit ); +} + +void Node::getCursor(int offset, int &_x, int &_y, int &height) +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + int dummy; + impl->getCaret(offset, false, _x, _y, dummy, height); +} + +TQRect Node::getRect() +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + return impl->getRect(); +} + +DOMString Node::textContent( ) const +{ + if(impl) return impl->textContent(); + return DOMString(); +} + +void Node::setTextContent(const DOMString &content) const +{ + if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + impl->setTextContent( content, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +//----------------------------------------------------------------------------- + +NodeList::NodeList() +{ + impl = 0; +} + +NodeList::NodeList(const NodeList &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +NodeList::NodeList(const NodeListImpl *i) +{ + impl = const_cast<NodeListImpl *>(i); + if(impl) impl->ref(); +} + +NodeList &NodeList::operator = (const NodeList &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +NodeList::~NodeList() +{ + if(impl) impl->deref(); +} + +Node NodeList::item( unsigned long index ) const +{ + if (!impl) return 0; + return impl->item(index); +} + +unsigned long NodeList::length() const +{ + if (!impl) return 0; + return impl->length(); +} diff --git a/tdehtml/dom/dom_node.h b/tdehtml/dom/dom_node.h new file mode 100644 index 000000000..594aa5e3e --- /dev/null +++ b/tdehtml/dom/dom_node.h @@ -0,0 +1,991 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 3 Core Specification (Recommendation) + * http://www.w3.org/TR/DOM-Level-3-Core/ + * Copyright ©2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. + */ +#ifndef _DOM_Node_h_ +#define _DOM_Node_h_ + +#include <tqstring.h> +#include <tdelibs_export.h> + +class TQRect; + +namespace KJS { + class HTMLDocument; + class Window; +} +namespace DOM { + +class Node; +class DOMString; +class NodeImpl; +class NamedNodeMapImpl; +class EventListener; +class Event; + +/** + * Objects implementing the \c NamedNodeMap interface are + * used to represent collections of nodes that can be accessed by + * name. Note that \c NamedNodeMap does not inherit from + * \c NodeList ; \c NamedNodeMap s are not + * maintained in any particular order. Objects contained in an object + * implementing \c NamedNodeMap may also be accessed by an + * ordinal index, but this is simply to allow convenient enumeration + * of the contents of a \c NamedNodeMap , and does not + * imply that the DOM specifies an order to these Nodes. + * + */ +class KHTML_EXPORT NamedNodeMap +{ +public: + NamedNodeMap(); + NamedNodeMap(const NamedNodeMap &other); + + NamedNodeMap & operator = (const NamedNodeMap &other); + + ~NamedNodeMap(); + + /** + * The number of nodes in the map. The range of valid child node + * indices is 0 to \c length-1 inclusive. + * + */ + unsigned long length() const; + + /** + * Retrieves a node specified by name. + * + * @param name Name of a node to retrieve. + * + * @return A \c Node (of any type) with the specified + * name, or \c null if the specified name did not + * identify any node in the map. + * + */ + Node getNamedItem ( const DOMString &name ) const; + + /** + * Adds a node using its \c nodeName attribute. + * + * As the \c nodeName attribute is used to derive the + * name which the node must be stored under, multiple nodes of + * certain types (those that have a "special" string value) cannot + * be stored as the names would clash. This is seen as preferable + * to allowing nodes to be aliased. + * + * @param arg A node to store in a named node map. The node will + * later be accessible using the value of the \c nodeName + * attribute of the node. If a node with that name is + * already present in the map, it is replaced by the new one. + * + * @return If the new \c Node replaces an existing + * node with the same name the previously existing \c Node + * is returned, otherwise \c null is returned. + * + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if \c arg was created + * from a different document than the one that created the + * \c NamedNodeMap . + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this + * \c NamedNodeMap is readonly. + * + * INUSE_ATTRIBUTE_ERR: Raised if \c arg is an + * \c Attr that is already an attribute of another + * \c Element object. The DOM user must explicitly clone + * \c Attr nodes to re-use them in other elements. + * + */ + Node setNamedItem ( const Node &arg ); + + /** + * Removes a node specified by name. If the removed node is an + * \c Attr with a default value it is immediately + * replaced. + * + * @param name The name of a node to remove. + * + * @return The node removed from the map or \c null if + * no node with such a name exists. + * + * @exception DOMException + * NOT_FOUND_ERR: Raised if there is no node named \c name + * in the map. + * + */ + Node removeNamedItem ( const DOMString &name ); + + /** + * Returns the \c index th item in the map. If + * \c index is greater than or equal to the number of nodes + * in the map, this returns \c null . + * + * @param index Index into the map. + * + * @return The node at the \c index th position in the + * \c NamedNodeMap , or \c null if that is + * not a valid index. + * + */ + Node item ( unsigned long index ) const; + + /** + * Introduced in DOM Level 2 + * + * Retrieves a node specified by local name and namespace URI. HTML-only + * DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the node to retrieve. + * + * @param localName The local name of the node to retrieve. + * + * @return A Node (of any type) with the specified local name and namespace + * URI, or null if they do not identify any node in this map. + */ + Node getNamedItemNS( const DOMString &namespaceURI, + const DOMString &localName ) const; + + /** + * Introduced in DOM Level 2 + * + * Adds a node using its namespaceURI and localName. If a node with that + * namespace URI and that local name is already present in this map, it is + * replaced by the new one. + * HTML-only DOM implementations do not need to implement this method. + * + * @param arg A node to store in this map. The node will later be + * accessible using the value of its namespaceURI and localName attributes. + * + * @return If the new Node replaces an existing node the replaced Node is + * returned, otherwise null is returned. + * + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if arg was created from a different document + * than the one that created this map. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + * + * INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an + * attribute of another Element object. The DOM user must explicitly clone + * Attr nodes to re-use them in other elements. + */ + Node setNamedItemNS( const Node &arg ); + + /** + * Introduced in DOM Level 2 + * + * Removes a node specified by local name and namespace URI. A removed + * attribute may be known to have a default value when this map contains + * the attributes attached to an element, as returned by the attributes + * attribute of the Node interface. If so, an attribute immediately appears + * containing the default value as well as the corresponding namespace URI, + * local name, and prefix when applicable. + * HTML-only DOM implementations do not need to implement this method. + * + * @param namespaceURI The namespace URI of the node to remove. + * + * @param localName The local name of the node to remove. + * + * @return The node removed from this map if a node with such a local name + * and namespace URI exists. + * + * @exception DOMException + * NOT_FOUND_ERR: Raised if there is no node with the specified + * namespaceURI and localName in this map. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + */ + Node removeNamedItemNS( const DOMString &namespaceURI, + const DOMString &localName ); + + /** + * @internal + * not part of the DOM + */ + NamedNodeMapImpl *handle() const { return impl; } + bool isNull() const { return !impl; } + +protected: + NamedNodeMap( NamedNodeMapImpl *i); + NamedNodeMapImpl *impl; + + friend class Node; + friend class DocumentType; + friend class NodeImpl; +}; + +class NamedNodeMap; +class NodeList; +class Document; +class DOMString; +class StyleSheet; + +class NodeImpl; + +/** + * The \c Node interface is the primary datatype for the + * entire Document Object Model. It represents a single node in the + * document tree. While all objects implementing the \c Node + * interface expose methods for dealing with children, not all + * objects implementing the \c Node interface may have + * children. For example, \c Text nodes may not have + * children, and adding children to such nodes results in a + * \c DOMException being raised. + * + * The attributes \c nodeName , \c nodeValue + * and \c attributes are included as a mechanism to get at + * node information without casting down to the specific derived + * interface. In cases where there is no obvious mapping of these + * attributes for a specific \c nodeType (e.g., + * \c nodeValue for an Element or \c attributes for a + * Comment), this returns \c null . Note that the + * specialized interfaces may contain additional and more convenient + * mechanisms to get and set the relevant information. + * + */ +class KHTML_EXPORT Node +{ + friend class NamedNodeMap; + friend class NodeList; + friend class HTMLCollection; + friend class StyleSheet; + +public: + Node() : impl(0) {} + Node(const Node &other); + + /** + * @internal + */ + Node( NodeImpl *_impl); + + Node & operator = (const Node &other); + + bool operator == (const Node &other) const; + + bool operator != (const Node &other) const; + + virtual ~Node(); + /** + * An integer indicating which type of node this is. + * + * + * <p>The values of \c nodeName, \c nodeValue, + * and \c attributes vary according to the node type as follows: + * <table border="1"> + * <tr> + * <td></td> + * <td>nodeName</td> + * <td>nodeValue</td> + * <td>attributes</td> + * </tr> + * <tr> + * <td>Element</td> + * <td>tagName</td> + * <td>null</td> + * <td>NamedNodeMap</td> + * </tr> + * <tr> + * <td>Attr</td> + * <td>name of attribute</td> + * <td>value of attribute</td> + * <td>null</td> + * </tr> + * <tr> + * <td>Text</td> + * <td>#text</td> + * <td>content of the text node</td> + * <td>null</td> + * </tr> + * <tr> + * <td>CDATASection</td> + * <td>#cdata-section</td> + * <td>content of the CDATA Section</td> + * <td>null</td> + * </tr> + * <tr> + * <td>EntityReference</td> + * <td>name of entity referenced</td> + * <td>null</td> + * <td>null</td> + * </tr> + * <tr> + * <td>Entity</td> + * <td>entity name</td> + * <td>null</td> + * <td>null</td> + * </tr> + * <tr> + * <td>ProcessingInstruction</td> + * <td>target</td> + * <td>entire content excluding the target</td> + * <td>null</td> + * </tr> + * <tr> + * <td>Comment</td> + * <td>#comment</td> + * <td>content of the comment</td> + * <td>null</td> + * </tr> + * <tr> + * <td>Document</td> + * <td>#document</td> + * <td>null</td> + * <td>null</td> + * </tr> + * <tr> + * <td>DocumentType</td> + * <td>document type name</td> + * <td>null</td> + * <td>null</td> + * </tr> + * <tr> + * <td>DocumentFragment</td> + * <td>#document-fragment</td> + * <td>null</td> + * <td>null</td> + * </tr> + * <tr> + * <td>Notation</td> + * <td>notation name</td> + * <td>null</td> + * <td>null</td> + * </tr> + * </table> + * </p> + */ + enum NodeType { + ELEMENT_NODE = 1, + ATTRIBUTE_NODE = 2, + TEXT_NODE = 3, + CDATA_SECTION_NODE = 4, + ENTITY_REFERENCE_NODE = 5, + ENTITY_NODE = 6, + PROCESSING_INSTRUCTION_NODE = 7, + COMMENT_NODE = 8, + DOCUMENT_NODE = 9, + DOCUMENT_TYPE_NODE = 10, + DOCUMENT_FRAGMENT_NODE = 11, + NOTATION_NODE = 12 + }; + + /** + * The name of this node, depending on its type; see the table + * above. + * + */ + DOMString nodeName() const; + + /** + * The value of this node, depending on its type; see the table + * above. + * + * @exception DOMException + * DOMSTRING_SIZE_ERR: Raised when it would return more characters + * than fit in a \c DOMString variable on the + * implementation platform. + * + */ + DOMString nodeValue() const; + + /** + * see nodeValue + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * + */ + void setNodeValue( const DOMString & ); + + /** + * A code representing the type of the underlying object, as + * defined above. + * + */ + unsigned short nodeType() const; + + /** + * The parent of this node. All nodes, except \c Document + * , \c DocumentFragment , and \c Attr + * may have a parent. However, if a node has just been + * created and not yet added to the tree, or if it has been + * removed from the tree, this is \c null . + * + */ + Node parentNode() const; + + /** + * A \c NodeList that contains all children of this + * node. If there are no children, this is a \c NodeList + * containing no nodes. The content of the returned + * \c NodeList is "live" in the sense that, for + * instance, changes to the children of the node object that it + * was created from are immediately reflected in the nodes + * returned by the \c NodeList accessors; it is not a + * static snapshot of the content of the node. This is true for + * every \c NodeList , including the ones returned by + * the \c getElementsByTagName method. + * + */ + NodeList childNodes() const; + + /** + * The first child of this node. If there is no such node, this + * returns \c null . + * + */ + Node firstChild() const; + + /** + * The last child of this node. If there is no such node, this + * returns \c null . + * + */ + Node lastChild() const; + + /** + * The node immediately preceding this node. If there is no such + * node, this returns \c null . + * + */ + Node previousSibling() const; + + /** + * The node immediately following this node. If there is no such + * node, this returns \c null . + * + */ + Node nextSibling() const; + + /** + * A \c NamedNodeMap containing the attributes of this + * node (if it is an \c Element ) or \c null + * otherwise. + * + */ + NamedNodeMap attributes() const; + + /** + * The \c Document object associated with this node. + * This is also the \c Document object used to create + * new nodes. When this node is a \c Document this is + * \c null . + * + */ + Document ownerDocument() const; + + /** + * Inserts the node \c newChild before the existing + * child node \c refChild . If \c refChild + * is \c null , insert \c newChild at the + * end of the list of children. + * + * If \c newChild is a \c DocumentFragment + * object, all of its children are inserted, in the same + * order, before \c refChild . If the \c newChild + * is already in the tree, it is first removed. + * + * @param newChild The node to insert. + * + * @param refChild The reference node, i.e., the node before which + * the new node must be inserted. + * + * @return The node being inserted. + * + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that + * does not allow children of the type of the \c newChild + * node, or if the node to insert is one of this node's + * ancestors. + * + * WRONG_DOCUMENT_ERR: Raised if \c newChild was + * created from a different document than the one that created + * this node. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * NOT_FOUND_ERR: Raised if \c refChild is not a + * child of this node. + * + */ + Node insertBefore ( const Node &newChild, const Node &refChild ); + + /** + * Replaces the child node \c oldChild with + * \c newChild in the list of children, and returns the + * \c oldChild node. If the \c newChild is + * already in the tree, it is first removed. + * + * @param newChild The new node to put in the child list. + * + * @param oldChild The node being replaced in the list. + * + * @return The node replaced. + * + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that + * does not allow children of the type of the \c newChild + * node, or it the node to put in is one of this node's + * ancestors. + * + * WRONG_DOCUMENT_ERR: Raised if \c newChild was + * created from a different document than the one that created + * this node. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * NOT_FOUND_ERR: Raised if \c oldChild is not a + * child of this node. + * + */ + Node replaceChild ( const Node &newChild, const Node &oldChild ); + + /** + * Removes the child node indicated by \c oldChild + * from the list of children, and returns it. + * + * @param oldChild The node being removed. + * + * @return The node removed. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * NOT_FOUND_ERR: Raised if \c oldChild is not a + * child of this node. + * + */ + Node removeChild ( const Node &oldChild ); + + /** + * Adds the node \c newChild to the end of the list of + * children of this node. If the \c newChild is + * already in the tree, it is first removed. + * + * @param newChild The node to add. + * + * If it is a \c DocumentFragment object, the entire + * contents of the document fragment are moved into the child list + * of this node + * + * @return The node added. + * + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that + * does not allow children of the type of the \c newChild + * node, or if the node to append is one of this node's + * ancestors. + * + * WRONG_DOCUMENT_ERR: Raised if \c newChild was + * created from a different document than the one that created + * this node. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + Node appendChild ( const Node &newChild ); + + /** + * This is a convenience method to allow easy determination of + * whether a node has any children. + * + * @return \c true if the node has any children, + * \c false if the node has no children. + * + */ + bool hasChildNodes ( ); + + /** + * Returns a duplicate of this node, i.e., serves as a generic + * copy constructor for nodes. The duplicate node has no parent ( + * \c parentNode returns \c null .). + * + * Cloning an \c Element copies all attributes and + * their values, including those generated by the XML processor to + * represent defaulted attributes, but this method does not copy + * any text it contains unless it is a deep clone, since the text + * is contained in a child \c Text node. Cloning any + * other type of node simply returns a copy of this node. + * + * @param deep If \c true , recursively clone the + * subtree under the specified node; if \c false , + * clone only the node itself (and its attributes, if it is an + * \c Element ). + * + * @return The duplicate node. + * + */ + Node cloneNode ( bool deep ); + + /** + * Modified in DOM Level 2 + * + * Puts all Text nodes in the full depth of the sub-tree underneath this + * Node, including attribute nodes, into a "normal" form where only + * structure (e.g., elements, comments, processing instructions, CDATA + * sections, and entity references) separates Text nodes, i.e., there are + * neither adjacent Text nodes nor empty Text nodes. This can be used to + * ensure that the DOM view of a document is the same as if it were saved + * and re-loaded, and is useful when operations (such as XPointer + * [XPointer] lookups) that depend on a particular document tree structure + * are to be used. + * + * Note: In cases where the document contains CDATASections, the normalize + * operation alone may not be sufficient, since XPointers do not + * differentiate between Text nodes and CDATASection nodes. + */ + void normalize ( ); + + /** + * Introduced in DOM Level 2 + * + * Tests whether the DOM implementation implements a specific feature and + * that feature is supported by this node. + * + * @param feature The name of the feature to test. This is the same name + * which can be passed to the method hasFeature on DOMImplementation. + * + * @param version This is the version number of the feature to test. In + * Level 2, version 1, this is the string "2.0". If the version is not + * specified, supporting any version of the feature will cause the method + * to return true. + * + * @return Returns true if the specified feature is supported on this node, + * false otherwise. + */ + bool isSupported( const DOMString &feature, + const DOMString &version ) const; + + /** + * Introduced in DOM Level 2 + * + * The namespace URI of this node, or null if it is unspecified. + * This is not a computed value that is the result of a namespace lookup + * based on an examination of the namespace declarations in scope. It is + * merely the namespace URI given at creation time. For nodes of any type + * other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM + * Level 1 method, such as createElement from the Document interface, this + * is always null. + * + * Note: Per the Namespaces in XML Specification [Namespaces] an attribute + * does not inherit its namespace from the element it is attached to. If an + * attribute is not explicitly given a namespace, it simply has no + * namespace. + */ + DOMString namespaceURI( ) const; + + /** + * Introduced in DOM Level 2 + * + * The namespace prefix of this node, or null if it is unspecified. + * Note that setting this attribute, when permitted, changes the nodeName + * attribute, which holds the qualified name, as well as the tagName and + * name attributes of the Element and Attr interfaces, when applicable. + * Note also that changing the prefix of an attribute that is known to have + * a default value, does not make a new attribute with the default value + * and the original prefix appear, since the namespaceURI and localName do + * not change. + * For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and + * nodes created with a DOM Level 1 method, such as createElement from the + * Document interface, this is always null. + */ + DOMString prefix( ) const; + + /** + * see prefix + * + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an + * illegal character. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + * NAMESPACE_ERR: Raised if the specified prefix is malformed, if the + * namespaceURI of this node is null, if the specified prefix is "xml" and + * the namespaceURI of this node is different from + * "http://www.w3.org/XML/1998/namespace", if this node is an attribute and + * the specified prefix is "xmlns" and the namespaceURI of this node is + * different from "http://www.w3.org/2000/xmlns/", or if this node is an + * attribute and the qualifiedName of this node is "xmlns" [Namespaces]. + */ + void setPrefix(const DOMString &prefix ); + + /** + * Introduced in DOM Level 2 + * + * Returns the local part of the qualified name of this node. + * For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and + * nodes created with a DOM Level 1 method, such as createElement from the + * Document interface, this is always null. + */ + DOMString localName( ) const; + + /** + * Returns whether this node (if it is an element) has any attributes. + * @return a boolean. True if this node has any attributes, false otherwise. + * Introduced in DOM Level 2 + */ + bool hasAttributes ( ); + + /** + * Introduced in DOM Level 3 + * + * This attribute returns the text content of this node and its descendants. + * On getting, no serialization is performed, the returned string does not contain any markup. + * + * @since 3.5.7 + */ + DOMString textContent( ) const; + + /** + * Introduced in DOM Level 3 + * + * @see textContent + * + * On setting, any possible children this node may have are removed and, if the new + * string is not empty or null, replaced by a single Text node containing the string this attribute is set to. + * No parsing is performed, the input string is taken as pure textual content. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * Note: KHTML will also raise this if setContent is called on things + * that do not have child nodes. + * + * @since 3.5.7 + */ + void setTextContent(const DOMString &content) const; + + /** + * Introduced in DOM Level 2 + * This method is from the EventTarget interface + * + * This method allows the registration of event listeners on the event + * target. If an EventListener is added to an EventTarget while it is + * processing an event, it will not be triggered by the current actions but + * may be triggered during a later stage of event flow, such as the + * bubbling phase. + * + * If multiple identical EventListeners are registered on the same + * EventTarget with the same parameters the duplicate instances are + * discarded. They do not cause the EventListener to be called twice and + * since they are discarded they do not need to be removed with the + * removeEventListener method. Parameters + * + * @param type The event type for which the user is registering + * + * @param listener The listener parameter takes an interface implemented by + * the user which contains the methods to be called when the event occurs. + * + * @param useCapture If true, useCapture indicates that the user wishes to + * initiate capture. After initiating capture, all events of the specified + * type will be dispatched to the registered EventListener before being + * dispatched to any EventTargets beneath them in the tree. Events which + * are bubbling upward through the tree will not trigger an EventListener + * designated to use capture. + */ + void addEventListener(const DOMString &type, + EventListener *listener, + const bool useCapture); + + /** + * Introduced in DOM Level 2 + * This method is from the EventTarget interface + * + * This method allows the removal of event listeners from the event target. + * If an EventListener is removed from an EventTarget while it is + * processing an event, it will not be triggered by the current actions. + * + * EventListeners can never be invoked after being removed. + * + * Calling removeEventListener with arguments which do not identify any + * currently registered EventListener on the EventTarget has no effect. + * + * @param type Specifies the event type of the EventListener being removed. + * + * @param listener The EventListener parameter indicates the EventListener + * to be removed. + * + * @param useCapture Specifies whether the EventListener being removed was + * registered as a capturing listener or not. If a listener was registered + * twice, one with capture and one without, each must be removed + * separately. Removal of a capturing listener does not affect a + * non-capturing version of the same listener, and vice versa. + */ + + void removeEventListener(const DOMString &type, + EventListener *listener, + bool useCapture); + + /** + * Introduced in DOM Level 2 + * This method is from the EventTarget interface + * + * This method allows the dispatch of events into the implementations event + * model. Events dispatched in this manner will have the same capturing and + * bubbling behavior as events dispatched directly by the implementation. + * The target of the event is the EventTarget on which dispatchEvent is + * called. + * + * @param evt Specifies the event type, behavior, and contextual + * information to be used in processing the event. + * + * @return The return value of dispatchEvent indicates whether any of the + * listeners which handled the event called preventDefault. If + * preventDefault was called the value is false, else the value is true. + * + * @exception EventException + * UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type was not specified + * by initializing the event before dispatchEvent was called. Specification + * of the Event's type as null or an empty string will also trigger this + * exception. + */ + bool dispatchEvent(const Event &evt); + + + + /** + * @internal + * not part of the DOM. + * @returns the element id, in case this is an element, 0 otherwise + */ + TQ_UINT32 elementId() const; + + /** + * tests if this Node is 0. Useful especially, if casting to a derived + * class: + * + * \code + * Node n = .....; + * // try to convert into an Element: + * Element e = n; + * if( e.isNull() ) + * kdDebug(300) << "node isn't an element node" << endl; + * \endcode + */ + bool isNull() const { return !impl; } + + /** + * @internal handle to the implementation object + */ + NodeImpl *handle() const { return impl; } + + /** + * @internal returns the index of a node + */ + unsigned long index() const; + TQString toHTML() KDE_DEPRECATED; + void applyChanges(); + /** + * @deprecated without substitution since 3.2 + */ + void getCursor(int offset, int &_x, int &_y, int &height) KDE_DEPRECATED; + /** + * not part of the DOM. + * @returns the exact coordinates and size of this element. + */ + TQRect getRect(); + +protected: + NodeImpl *impl; +}; + + +class NodeListImpl; + +/** + * The \c NodeList interface provides the abstraction of + * an ordered collection of nodes, without defining or constraining + * how this collection is implemented. + * + * The items in the \c NodeList are accessible via an + * integral index, starting from 0. + * + */ +class KHTML_EXPORT NodeList +{ + friend class Element; + friend class Node; + friend class Document; + friend class HTMLDocument; + friend class KJS::HTMLDocument; + friend class KJS::Window; + +public: + NodeList(); + NodeList(const NodeList &other); + + NodeList & operator = (const NodeList &other); + + ~NodeList(); + + /** + * The number of nodes in the list. The range of valid child node + * indices is 0 to \c length-1 inclusive. + * + */ + unsigned long length() const; + + /** + * Returns the \c index th item in the collection. If + * \c index is greater than or equal to the number of + * nodes in the list, this returns \c null . + * + * @param index Index into the collection. + * + * @return The node at the \c index th position in the + * \c NodeList , or \c null if that is not + * a valid index. + * + */ + Node item ( unsigned long index ) const; + + /** + * @internal + * not part of the DOM + */ + NodeListImpl *handle() const { return impl; } + bool isNull() const { return !impl; } + +protected: + NodeList(const NodeListImpl *i); + NodeListImpl *impl; +}; + + + +/** + * A DOMTimeStamp represents a number of milliseconds. + * + */ +typedef unsigned long long DOMTimeStamp; + + +} //namespace +#endif diff --git a/tdehtml/dom/dom_string.cpp b/tdehtml/dom/dom_string.cpp new file mode 100644 index 000000000..14bdc2613 --- /dev/null +++ b/tdehtml/dom/dom_string.cpp @@ -0,0 +1,300 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "dom/dom_string.h" +#include "xml/dom_stringimpl.h" + + +using namespace DOM; + + +DOMString::DOMString(const TQChar *str, uint len) +{ + impl = new DOMStringImpl( str, len ); + impl->ref(); +} + +DOMString::DOMString(const TQString &str) +{ + if (str.isNull()) { + impl = 0; + return; + } + + impl = new DOMStringImpl( str.unicode(), str.length() ); + impl->ref(); +} + +DOMString::DOMString(const char *str) +{ + if (!str) { + impl = 0; + return; + } + + impl = new DOMStringImpl( str ); + impl->ref(); +} + +DOMString::DOMString(DOMStringImpl *i) +{ + impl = i; + if(impl) impl->ref(); +} + +DOMString::DOMString(const DOMString &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +DOMString::~DOMString() +{ + if(impl) impl->deref(); +} + +DOMString &DOMString::operator =(const DOMString &other) +{ + if ( impl != other.impl ) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +DOMString &DOMString::operator += (const DOMString &str) +{ + if(!impl) + { + // ### FIXME!!! + impl = str.impl; + if (impl) + impl->ref(); + return *this; + } + if(str.impl) + { + DOMStringImpl *i = impl->copy(); + impl->deref(); + impl = i; + impl->ref(); + impl->append(str.impl); + } + return *this; +} + +DOMString DOMString::operator + (const DOMString &str) +{ + if(!impl) return str.copy(); + if(str.impl) + { + DOMString s = copy(); + s += str; + return s; + } + + return copy(); +} + +void DOMString::insert(DOMString str, uint pos) +{ + if(!impl) + { + impl = str.impl->copy(); + impl->ref(); + } + else + impl->insert(str.impl, pos); +} + + +const TQChar &DOMString::operator [](unsigned int i) const +{ + static const TQChar nullChar = 0; + + if(!impl || i >= impl->l ) return nullChar; + + return *(impl->s+i); +} + +int DOMString::find(const TQChar c, int start) const +{ + unsigned int l = start; + if(!impl || l >= impl->l ) return -1; + while( l < impl->l ) + { + if( *(impl->s+l) == c ) return l; + l++; + } + return -1; +} + +uint DOMString::length() const +{ + if(!impl) return 0; + return impl->l; +} + +void DOMString::truncate( unsigned int len ) +{ + if(impl) impl->truncate(len); +} + +void DOMString::remove(unsigned int pos, int len) +{ + if(impl) impl->remove(pos, len); +} + +DOMString DOMString::split(unsigned int pos) +{ + if(!impl) return DOMString(); + return impl->split(pos); +} + +DOMString DOMString::lower() const +{ + if(!impl) return DOMString(); + return impl->lower(); +} + +DOMString DOMString::upper() const +{ + if(!impl) return DOMString(); + return impl->upper(); +} + +bool DOMString::percentage(int &_percentage) const +{ + if(!impl || !impl->l) return false; + + if ( *(impl->s+impl->l-1) != TQChar('%')) + return false; + + _percentage = TQConstString(impl->s, impl->l-1).string().toInt(); + return true; +} + +TQChar *DOMString::unicode() const +{ + if(!impl) return 0; + return impl->unicode(); +} + +TQString DOMString::string() const +{ + if(!impl) return TQString::null; + + return impl->string(); +} + +int DOMString::toInt() const +{ + if(!impl) return 0; + + return impl->toInt(); +} + +DOMString DOMString::copy() const +{ + if(!impl) return DOMString(); + return impl->copy(); +} + +// ------------------------------------------------------------------------ + +bool DOM::strcasecmp( const DOMString &as, const DOMString &bs ) +{ + if ( as.length() != bs.length() ) return true; + + const TQChar *a = as.unicode(); + const TQChar *b = bs.unicode(); + if ( a == b ) return false; + if ( !( a && b ) ) return true; + int l = as.length(); + while ( l-- ) { + if ( *a != *b && a->lower() != b->lower() ) return true; + a++,b++; + } + return false; +} + +bool DOM::strcasecmp( const DOMString &as, const char* bs ) +{ + const TQChar *a = as.unicode(); + int l = as.length(); + if ( !bs ) return ( l != 0 ); + while ( l-- ) { + if ( a->latin1() != *bs ) { + char cc = ( ( *bs >= 'A' ) && ( *bs <= 'Z' ) ) ? ( ( *bs ) + 'a' - 'A' ) : ( *bs ); + if ( a->lower().latin1() != cc ) return true; + } + a++, bs++; + } + return ( *bs != '\0' ); +} + +bool DOMString::isEmpty() const +{ + return (!impl || impl->l == 0); +} + +//----------------------------------------------------------------------------- + +bool DOM::operator==( const DOMString &a, const DOMString &b ) +{ + unsigned int l = a.length(); + + if( l != b.length() ) return false; + + if(!memcmp(a.unicode(), b.unicode(), l*sizeof(TQChar))) + return true; + return false; +} + +bool DOM::operator==( const DOMString &a, const TQString &b ) +{ + unsigned int l = a.length(); + + if( l != b.length() ) return false; + + if(!memcmp(a.unicode(), b.unicode(), l*sizeof(TQChar))) + return true; + return false; +} + +bool DOM::operator==( const DOMString &a, const char *b ) +{ + DOMStringImpl* aimpl = a.impl; + if ( !b ) return !aimpl; + + if ( aimpl ) { + int alen = aimpl->l; + const TQChar *aptr = aimpl->s; + while ( alen-- ) { + unsigned char c = *b++; + if ( !c || ( *aptr++ ).unicode() != c ) + return false; + } + } + + return !*b; +} diff --git a/tdehtml/dom/dom_string.h b/tdehtml/dom/dom_string.h new file mode 100644 index 000000000..3d4706b5a --- /dev/null +++ b/tdehtml/dom/dom_string.h @@ -0,0 +1,144 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#ifndef _DOM_DOMString_h_ +#define _DOM_DOMString_h_ + +#include <kdebug.h> +#include <tqstring.h> + +#include <tdelibs_export.h> + +namespace DOM { + +class DOMStringImpl; + +/** + * This class implements the basic string we use in the DOM. We do not use + * TQString for 2 reasons: Memory overhead, and the missing explicit sharing + * of strings we need for the DOM. + * + * All DOMStrings are explicitly shared (they behave like pointers), meaning + * that modifications to one instance will also modify all others. If you + * wish to get a DOMString that is independent, use copy(). + */ +class KHTML_EXPORT DOMString +{ + friend class CharacterDataImpl; + friend KHTML_EXPORT bool operator==( const DOMString &a, const char *b ); +public: + /** + * default constructor. Gives an empty DOMString + */ + DOMString() : impl(0) {} + + DOMString(const TQChar *str, uint len); + DOMString(const TQString &); + DOMString(const char *str); + DOMString(DOMStringImpl *i); + + virtual ~DOMString(); + + // assign and copy + DOMString(const DOMString &str); + DOMString &operator =(const DOMString &str); + + /** + * append str to this string + */ + DOMString &operator += (const DOMString &str); + /** + * add two DOMString's + */ + DOMString operator + (const DOMString &str); + + void insert(DOMString str, uint pos); + + /** + * The character at position i of the DOMString. If i >= length(), the + * character returned will be 0. + */ + const TQChar &operator [](unsigned int i) const; + + int find(const TQChar c, int start = 0) const; + + uint length() const; + void truncate( unsigned int len ); + void remove(unsigned int pos, int len=1); + /** + * Splits the string into two. The original string gets truncated to pos, and the rest is returned. + */ + DOMString split(unsigned int pos); + + /** + * Returns a lowercase version of the string + */ + DOMString lower() const; + /** + * Returns an uppercase version of the string + */ + DOMString upper() const; + + TQChar *unicode() const; + TQString string() const; + + int toInt() const; + bool percentage(int &_percentage) const; + + DOMString copy() const; + + bool isNull() const { return (impl == 0); } + bool isEmpty() const; + + /** + * @internal get a handle to the imlementation of the DOMString + * Use at own risk!!! + */ + DOMStringImpl *implementation() const { return impl; } + +protected: + DOMStringImpl *impl; +}; + +#ifndef NDEBUG +inline kdbgstream &operator<<(kdbgstream &stream, const DOMString &string) { + return (stream << string.string()); +} +#else +inline kndbgstream &operator<<(kndbgstream &stream, const DOMString &) { + return stream; +} +#endif + +KHTML_EXPORT bool operator==( const DOMString &a, const DOMString &b ); +KHTML_EXPORT bool operator==( const DOMString &a, const TQString &b ); +KHTML_EXPORT bool operator==( const DOMString &a, const char *b ); +inline bool operator!=( const DOMString &a, const DOMString &b ) { return !(a==b); } +inline bool operator!=( const DOMString &a, const TQString &b ) { return !(a==b); } +inline bool operator!=( const DOMString &a, const char *b ) { return !(a==b); } +inline bool strcmp( const DOMString &a, const DOMString &b ) { return a != b; } + +// returns false when equal, true otherwise (ignoring case) +KHTML_EXPORT bool strcasecmp( const DOMString &a, const DOMString &b ); +KHTML_EXPORT bool strcasecmp( const DOMString& a, const char* b ); + +} +#endif diff --git a/tdehtml/dom/dom_text.cpp b/tdehtml/dom/dom_text.cpp new file mode 100644 index 000000000..af4584410 --- /dev/null +++ b/tdehtml/dom/dom_text.cpp @@ -0,0 +1,237 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom_exception.h" +#include "dom/dom_text.h" +#include "xml/dom_textimpl.h" + +using namespace DOM; + +CharacterData::CharacterData() : Node() +{ +} + +CharacterData::CharacterData(const CharacterData &other) : Node(other) +{ +} + +CharacterData &CharacterData::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || + ( ohandle->nodeType() != CDATA_SECTION_NODE && + ohandle->nodeType() != TEXT_NODE && + ohandle->nodeType() != COMMENT_NODE )) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +CharacterData &CharacterData::operator = (const CharacterData &other) +{ + Node::operator =(other); + return *this; +} + +CharacterData::~CharacterData() +{ +} + +DOMString CharacterData::data() const +{ + if(!impl) return DOMString(); + return ((CharacterDataImpl *)impl)->data(); +} + +void CharacterData::setData( const DOMString &str ) +{ + if (!impl) + return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ((CharacterDataImpl *)impl)->setData(str, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return; +} + +unsigned long CharacterData::length() const +{ + if ( impl ) + return ((CharacterDataImpl *)impl)->length(); + return 0; +} + +DOMString CharacterData::substringData( const unsigned long offset, const unsigned long count ) +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + DOMString str = ((CharacterDataImpl *)impl)->substringData(offset, count, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return str; +} + +void CharacterData::appendData( const DOMString &arg ) +{ + if (!impl) + return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ((CharacterDataImpl *)impl)->appendData(arg, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +void CharacterData::insertData( const unsigned long offset, const DOMString &arg ) +{ + if (!impl) + return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ((CharacterDataImpl *)impl)->insertData(offset, arg, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +void CharacterData::deleteData( const unsigned long offset, const unsigned long count ) +{ + if (!impl) + return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ((CharacterDataImpl *)impl)->deleteData(offset, count, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +void CharacterData::replaceData( const unsigned long offset, const unsigned long count, const DOMString &arg ) +{ + if (!impl) + return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ((CharacterDataImpl *)impl)->replaceData(offset, count, arg, exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +CharacterData::CharacterData(CharacterDataImpl *i) : Node(i) +{ +} + +// --------------------------------------------------------------------------- + +Comment::Comment() : CharacterData() +{ +} + +Comment::Comment(const Comment &other) : CharacterData(other) +{ +} + +Comment &Comment::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != COMMENT_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Comment &Comment::operator = (const Comment &other) +{ + CharacterData::operator =(other); + return *this; +} + +Comment::~Comment() +{ +} + +Comment::Comment(CommentImpl *i) : CharacterData(i) +{ +} + +// ---------------------------------------------------------------------------- + +Text::Text() +{ +} + +Text::Text(const Text &other) : CharacterData(other) +{ +} + +Text &Text::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || + (ohandle->nodeType() != TEXT_NODE && + ohandle->nodeType() != CDATA_SECTION_NODE)) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Text &Text::operator = (const Text &other) +{ + Node::operator =(other); + return *this; +} + +Text::~Text() +{ +} + +Text Text::splitText( const unsigned long offset ) +{ + if (!impl) + return 0; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + TextImpl *newText = static_cast<TextImpl *>(impl)->splitText(offset, exceptioncode ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return newText; +} + +Text::Text(TextImpl *i) : CharacterData(i) +{ +} diff --git a/tdehtml/dom/dom_text.h b/tdehtml/dom/dom_text.h new file mode 100644 index 000000000..c6f92fb1d --- /dev/null +++ b/tdehtml/dom/dom_text.h @@ -0,0 +1,312 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef _DOM_CharacterData_h_ +#define _DOM_CharacterData_h_ + +#include <dom/dom_node.h> + +namespace DOM { + +class DOMString; +class CharacterDataImpl; + +/** + * The \c CharacterData interface extends Node with a set + * of attributes and methods for accessing character data in the DOM. + * For clarity this set is defined here rather than on each object + * that uses these attributes and methods. No DOM objects correspond + * directly to \c CharacterData , though \c Text + * and others do inherit the interface from it. All + * <code>offset</code>s in this interface start from 0. + * + */ +class KHTML_EXPORT CharacterData : public Node +{ + friend class CharacterDataImpl; + +public: + CharacterData(); + CharacterData(const CharacterData &other); + CharacterData(const Node &other) : Node() + {(*this)=other;} + + CharacterData & operator = (const Node &other); + CharacterData & operator = (const CharacterData &other); + + ~CharacterData(); + + /** + * The character data of the node that implements this interface. + * The DOM implementation may not put arbitrary limits on the + * amount of data that may be stored in a \c CharacterData + * node. However, implementation limits may mean that the + * entirety of a node's data may not fit into a single + * \c DOMString . In such cases, the user may call + * \c substringData to retrieve the data in appropriately + * sized pieces. + * + * @exception DOMException + * DOMSTRING_SIZE_ERR: Raised when it would return more characters + * than fit in a \c DOMString variable on the + * implementation platform. + * + */ + DOMString data() const; + + /** + * see data + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * + */ + void setData( const DOMString & ); + + /** + * The number of characters that are available through \c data + * and the \c substringData method below. This + * may have the value zero, i.e., \c CharacterData + * nodes may be empty. + * + */ + unsigned long length() const; + + /** + * Extracts a range of data from the node. + * + * @param offset Start offset of substring to extract. + * + * @param count The number of characters to extract. + * + * @return The specified substring. If the sum of \c offset + * and \c count exceeds the \c length + * , then all characters to the end of the data are + * returned. + * + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is negative or + * greater than the number of characters in \c data , + * or if the specified \c count is negative. + * + * DOMSTRING_SIZE_ERR: Raised if the specified range of text does + * not fit into a \c DOMString . + * + */ + DOMString substringData ( const unsigned long offset, const unsigned long count ); + + /** + * Append the string to the end of the character data of the node. + * Upon success, \c data provides access to the + * concatenation of \c data and the \c DOMString + * specified. + * + * @param arg The \c DOMString to append. + * + * @return + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + void appendData ( const DOMString &arg ); + + /** + * Insert a string at the specified character offset. + * + * @param offset The character offset at which to insert. + * + * @param arg The \c DOMString to insert. + * + * @return + * + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is negative or + * greater than the number of characters in \c data . + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + void insertData ( const unsigned long offset, const DOMString &arg ); + + /** + * Remove a range of characters from the node. Upon success, + * \c data and \c length reflect the + * change. + * + * @param offset The offset from which to remove characters. + * + * @param count The number of characters to delete. If the sum of + * \c offset and \c count exceeds + * \c length then all characters from \c offset + * to the end of the data are deleted. + * + * @return + * + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is negative or + * greater than the number of characters in \c data , + * or if the specified \c count is negative. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + void deleteData ( const unsigned long offset, const unsigned long count ); + + /** + * Replace the characters starting at the specified character + * offset with the specified string. + * + * @param offset The offset from which to start replacing. + * + * @param count The number of characters to replace. If the sum of + * \c offset and \c count exceeds + * \c length , then all characters to the end of the data are + * replaced (i.e., the effect is the same as a \c remove + * method call with the same range, followed by an + * \c append method invocation). + * + * @param arg The \c DOMString with which the range + * must be replaced. + * + * @return + * + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is negative or + * greater than the number of characters in \c data , + * or if the specified \c count is negative. + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + void replaceData ( const unsigned long offset, const unsigned long count, const DOMString &arg ); + +protected: + CharacterData(CharacterDataImpl *i); +}; + + +class CommentImpl; + +/** + * This represents the content of a comment, i.e., all the characters + * between the starting ' \c <!-- ' and ending ' + * \c --> '. Note that this is the definition of a comment in + * XML, and, in practice, HTML, although some HTML tools may implement + * the full SGML comment structure. + * + */ +class KHTML_EXPORT Comment : public CharacterData +{ + friend class Document; + friend class TextImpl; + +public: + Comment(); + Comment(const Comment &other); + Comment(const Node &other) : CharacterData() + {(*this)=other;} + + Comment & operator = (const Node &other); + Comment & operator = (const Comment &other); + + ~Comment(); + +protected: + Comment(CommentImpl *i); +}; + +class TextImpl; + +/** + * The \c Text interface represents the textual content + * (termed <a href="&xml-spec;#syntax"> character data </a> in XML) of + * an \c Element or \c Attr . If there is no + * markup inside an element's content, the text is contained in a + * single object implementing the \c Text interface that + * is the only child of the element. If there is markup, it is parsed + * into a list of elements and \c Text nodes that form the + * list of children of the element. + * + * When a document is first made available via the DOM, there is only + * one \c Text node for each block of text. Users may + * create adjacent \c Text nodes that represent the + * contents of a given element without any intervening markup, but + * should be aware that there is no way to represent the separations + * between these nodes in XML or HTML, so they will not (in general) + * persist between DOM editing sessions. The \c normalize() + * method on \c Element merges any such adjacent + * \c Text objects into a single node for each block of + * text; this is recommended before employing operations that depend + * on a particular document structure, such as navigation with + * \c XPointers. + * + */ +class KHTML_EXPORT Text : public CharacterData +{ + friend class Document; + friend class TextImpl; + +public: + Text(); + Text(const Text &other); + Text(const Node &other) : CharacterData() + {(*this)=other;} + + Text & operator = (const Node &other); + Text & operator = (const Text &other); + + ~Text(); + + /** + * Breaks this \c Text node into two Text nodes at the + * specified offset, keeping both in the tree as siblings. This + * node then only contains all the content up to the \c offset + * point. And a new \c Text node, which is + * inserted as the next sibling of this node, contains all the + * content at and after the \c offset point. + * + * @param offset The offset at which to split, starting from 0. + * + * @return The new \c Text node. + * + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is negative or + * greater than the number of characters in \c data . + * + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * + */ + Text splitText ( const unsigned long offset ); + +protected: + Text(TextImpl *i); + +}; + +} //namespace +#endif diff --git a/tdehtml/dom/dom_xml.cpp b/tdehtml/dom/dom_xml.cpp new file mode 100644 index 000000000..524bbe218 --- /dev/null +++ b/tdehtml/dom/dom_xml.cpp @@ -0,0 +1,293 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + + +#include "dom/dom_xml.h" +#include "dom/dom_exception.h" +#include "xml/dom_textimpl.h" +#include "xml/dom_xmlimpl.h" + +using namespace DOM; + +CDATASection::CDATASection() +{ +} + +CDATASection::CDATASection(const CDATASection &) : Text() +{ +} + +CDATASection &CDATASection::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != CDATA_SECTION_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +CDATASection &CDATASection::operator = (const CDATASection &other) +{ + Node::operator =(other); + return *this; +} + +CDATASection::~CDATASection() +{ +} + +CDATASection::CDATASection(CDATASectionImpl *i) : Text(i) +{ +} + +// ---------------------------------------------------------------------------- +Entity::Entity() +{ +} + +Entity::Entity(const Entity &) : Node() +{ +} + +Entity &Entity::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != ENTITY_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Entity &Entity::operator = (const Entity &other) +{ + Node::operator =(other); + return *this; +} + +Entity::~Entity() +{ +} + +DOMString Entity::publicId() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((EntityImpl*)impl)->publicId(); +} + +DOMString Entity::systemId() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((EntityImpl*)impl)->systemId(); +} + +DOMString Entity::notationName() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((EntityImpl*)impl)->notationName(); +} + +Entity::Entity(EntityImpl *i) : Node(i) +{ +} + +// ---------------------------------------------------------------------------- + +EntityReference::EntityReference() +{ +} + +EntityReference::EntityReference(const EntityReference &) : Node() +{ +} + +EntityReference &EntityReference::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != ENTITY_REFERENCE_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +EntityReference &EntityReference::operator = (const EntityReference &other) +{ + Node::operator =(other); + return *this; +} + +EntityReference::~EntityReference() +{ +} + +EntityReference::EntityReference(EntityReferenceImpl *i) : Node(i) +{ +} + +// ---------------------------------------------------------------------------- + +Notation::Notation() +{ +} + +Notation::Notation(const Notation &) : Node() +{ +} + +Notation &Notation::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != NOTATION_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +Notation &Notation::operator = (const Notation &other) +{ + Node::operator =(other); + return *this; +} + +Notation::~Notation() +{ +} + +DOMString Notation::publicId() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((NotationImpl*)impl)->publicId(); +} + +DOMString Notation::systemId() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((NotationImpl*)impl)->systemId(); +} + +Notation::Notation(NotationImpl *i) : Node(i) +{ +} + + +// ---------------------------------------------------------------------------- + +ProcessingInstruction::ProcessingInstruction() +{ +} + +ProcessingInstruction::ProcessingInstruction(const ProcessingInstruction &) + : Node() +{ +} + +ProcessingInstruction &ProcessingInstruction::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if ( impl != ohandle ) { + if (!ohandle || ohandle->nodeType() != PROCESSING_INSTRUCTION_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +ProcessingInstruction &ProcessingInstruction::operator = (const ProcessingInstruction &other) +{ + Node::operator =(other); + return *this; +} + +ProcessingInstruction::~ProcessingInstruction() +{ +} + +DOMString ProcessingInstruction::target() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((ProcessingInstructionImpl*)impl)->target(); +} + +DOMString ProcessingInstruction::data() const +{ + if (!impl) + return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + return ((ProcessingInstructionImpl*)impl)->data(); +} + +void ProcessingInstruction::setData( const DOMString &_data ) +{ + if (!impl) + return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + ((ProcessingInstructionImpl*)impl)->setData(_data, exceptioncode); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +ProcessingInstruction::ProcessingInstruction(ProcessingInstructionImpl *i) : Node(i) +{ +} + +StyleSheet ProcessingInstruction::sheet() const +{ + if (impl) return ((ProcessingInstructionImpl*)impl)->sheet(); + return 0; +} + + diff --git a/tdehtml/dom/dom_xml.h b/tdehtml/dom/dom_xml.h new file mode 100644 index 000000000..12e70d9e5 --- /dev/null +++ b/tdehtml/dom/dom_xml.h @@ -0,0 +1,310 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef _DOM_XML_h +#define _DOM_XML_h + +#include <dom/dom_text.h> +#include <dom/css_stylesheet.h> + +namespace DOM { + +class CDATASectionImpl; +class EntityImpl; +class EntityReferenceImpl; +class NotationImpl; +class ProcessingInstructionImpl; + + + +/** + * CDATA sections are used to escape blocks of text containing + * characters that would otherwise be regarded as markup. The only + * delimiter that is recognized in a CDATA section is the "]]>" + * string that ends the CDATA section. CDATA sections can not be + * nested. The primary purpose is for including material such as XML + * fragments, without needing to escape all the delimiters. + * + * The \c DOMString attribute of the \c Text + * node holds the text that is contained by the CDATA section. Note + * that this may contain characters that need to be escaped outside of + * CDATA sections and that, depending on the character encoding + * ("charset") chosen for serialization, it may be impossible to write + * out some characters as part of a CDATA section. + * + * The \c CDATASection interface inherits the + * \c CharacterData interface through the \c Text + * interface. Adjacent \c CDATASections nodes are not + * merged by use of the Element.normalize() method. + * + */ +class KHTML_EXPORT CDATASection : public Text +{ + friend class Document; +public: + CDATASection(); + CDATASection(const CDATASection &other); + CDATASection(const Node &other) : Text() + {(*this)=other;} + + CDATASection & operator = (const Node &other); + CDATASection & operator = (const CDATASection &other); + + ~CDATASection(); +protected: + CDATASection(CDATASectionImpl *i); +}; + +class DOMString; + +/** + * This interface represents an entity, either parsed or unparsed, in + * an XML document. Note that this models the entity itself not the + * entity declaration. \c Entity declaration modeling has + * been left for a later Level of the DOM specification. + * + * The \c nodeName attribute that is inherited from + * \c Node contains the name of the entity. + * + * An XML processor may choose to completely expand entities before + * the structure model is passed to the DOM; in this case there will + * be no \c EntityReference nodes in the document tree. + * + * XML does not mandate that a non-validating XML processor read and + * process entity declarations made in the external subset or declared + * in external parameter entities. This means that parsed entities + * declared in the external subset need not be expanded by some + * classes of applications, and that the replacement value of the + * entity may not be available. When the replacement value is + * available, the corresponding \c Entity node's child + * list represents the structure of that replacement text. Otherwise, + * the child list is empty. + * + * The resolution of the children of the \c Entity (the + * replacement value) may be lazily evaluated; actions by the user + * (such as calling the \c childNodes method on the + * \c Entity Node) are assumed to trigger the evaluation. + * + * The DOM Level 1 does not support editing \c Entity + * nodes; if a user wants to make changes to the contents of an + * \c Entity , every related \c EntityReference node + * has to be replaced in the structure model by a clone of the + * \c Entity 's contents, and then the desired changes must be + * made to each of those clones instead. All the descendants of an + * \c Entity node are readonly. + * + * An \c Entity node does not have any parent. + * + */ +class KHTML_EXPORT Entity : public Node +{ +public: + Entity(); + Entity(const Entity &other); + Entity(const Node &other) : Node() + {(*this)=other;} + + Entity & operator = (const Node &other); + Entity & operator = (const Entity &other); + + ~Entity(); + + /** + * The public identifier associated with the entity, if specified. + * If the public identifier was not specified, this is \c null . + * + */ + DOMString publicId() const; + + /** + * The system identifier associated with the entity, if specified. + * If the system identifier was not specified, this is \c null . + * + */ + DOMString systemId() const; + + /** + * For unparsed entities, the name of the notation for the entity. + * For parsed entities, this is \c null . + * + */ + DOMString notationName() const; +protected: + Entity(EntityImpl *i); +}; + + +/** + * \c EntityReference objects may be inserted into the + * structure model when an entity reference is in the source document, + * or when the user wishes to insert an entity reference. Note that + * character references and references to predefined entities are + * considered to be expanded by the HTML or XML processor so that + * characters are represented by their Unicode equivalent rather than + * by an entity reference. Moreover, the XML processor may completely + * expand references to entities while building the structure model, + * instead of providing \c EntityReference objects. If it + * does provide such objects, then for a given \c EntityReference + * node, it may be that there is no \c Entity node + * representing the referenced entity; but if such an \c Entity + * exists, then the child list of the \c EntityReference + * node is the same as that of the \c Entity node. + * As with the \c Entity node, all descendants of the + * \c EntityReference are readonly. + * + * The resolution of the children of the \c EntityReference + * (the replacement value of the referenced \c Entity + * ) may be lazily evaluated; actions by the user (such as + * calling the \c childNodes method on the + * \c EntityReference node) are assumed to trigger the + * evaluation. + * + */ +class KHTML_EXPORT EntityReference : public Node +{ + friend class Document; +public: + EntityReference(); + EntityReference(const EntityReference &other); + EntityReference(const Node &other) : Node() + {(*this)=other;} + + EntityReference & operator = (const Node &other); + EntityReference & operator = (const EntityReference &other); + + ~EntityReference(); +protected: + EntityReference(EntityReferenceImpl *i); +}; + +class DOMString; + +/** + * This interface represents a notation declared in the DTD. A + * notation either declares, by name, the format of an unparsed entity + * (see section 4.7 of the XML 1.0 specification), or is used for + * formal declaration of Processing Instruction targets (see section + * 2.6 of the XML 1.0 specification). The \c nodeName + * attribute inherited from \c Node is set to the declared + * name of the notation. + * + * The DOM Level 1 does not support editing \c Notation + * nodes; they are therefore readonly. + * + * A \c Notation node does not have any parent. + * + */ +class KHTML_EXPORT Notation : public Node +{ +public: + Notation(); + Notation(const Notation &other); + Notation(const Node &other) : Node() + {(*this)=other;} + + Notation & operator = (const Node &other); + Notation & operator = (const Notation &other); + + ~Notation(); + + /** + * The public identifier of this notation. If the public + * identifier was not specified, this is \c null . + * + */ + DOMString publicId() const; + + /** + * The system identifier of this notation. If the system + * identifier was not specified, this is \c null . + * + */ + DOMString systemId() const; +protected: + Notation(NotationImpl *i); +}; + + +/** + * The \c ProcessingInstruction interface represents a + * "processing instruction", used in XML as a way to keep + * processor-specific information in the text of the document. + * + */ +class KHTML_EXPORT ProcessingInstruction : public Node +{ + friend class Document; +public: + ProcessingInstruction(); + ProcessingInstruction(const ProcessingInstruction &other); + ProcessingInstruction(const Node &other) : Node() + {(*this)=other;} + + ProcessingInstruction & operator = (const Node &other); + ProcessingInstruction & operator = (const ProcessingInstruction &other); + + ~ProcessingInstruction(); + + /** + * The target of this processing instruction. XML defines this as + * being the first token following the markup that begins the + * processing instruction. + * + */ + DOMString target() const; + + /** + * The content of this processing instruction. This is from the + * first non white space character after the target to the + * character immediately preceding the \c ?> . + * + */ + DOMString data() const; + + /** + * see data + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * + */ + void setData( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * This method is from the LinkStyle interface + * + * The style sheet. + */ + StyleSheet sheet() const; + +protected: + ProcessingInstruction(ProcessingInstructionImpl *i); +}; + +} //namespace +#endif diff --git a/tdehtml/dom/html_base.cpp b/tdehtml/dom/html_base.cpp new file mode 100644 index 000000000..e35fdaa0a --- /dev/null +++ b/tdehtml/dom/html_base.cpp @@ -0,0 +1,533 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +// -------------------------------------------------------------------------- + +#include "xml/dom_docimpl.h" +#include "dom/html_base.h" +#include "dom/dom_doc.h" +#include "html/html_baseimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLBodyElement::HTMLBodyElement() : HTMLElement() +{ +} + +HTMLBodyElement::HTMLBodyElement(const HTMLBodyElement &other) : HTMLElement(other) +{ +} + +HTMLBodyElement::HTMLBodyElement(HTMLBodyElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLBodyElement &HTMLBodyElement::operator = (const Node &other) +{ + assignOther( other, ID_BODY ); + return *this; +} + +HTMLBodyElement &HTMLBodyElement::operator = (const HTMLBodyElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLBodyElement::~HTMLBodyElement() +{ +} + +DOMString HTMLBodyElement::aLink() const +{ + return impl ? ((ElementImpl *)impl)->getAttribute(ATTR_ALINK) : DOMString(); +} + +void HTMLBodyElement::setALink( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALINK, value); +} + +DOMString HTMLBodyElement::background() const +{ + return impl ? ((ElementImpl *)impl)->getAttribute(ATTR_BACKGROUND) : DOMString(); +} + +void HTMLBodyElement::setBackground( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BACKGROUND, value); +} + +DOMString HTMLBodyElement::bgColor() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BGCOLOR); +} + +void HTMLBodyElement::setBgColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BGCOLOR, value); +} + +DOMString HTMLBodyElement::link() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_LINK); +} + +void HTMLBodyElement::setLink( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LINK, value); +} + +DOMString HTMLBodyElement::text() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TEXT); +} + +void HTMLBodyElement::setText( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TEXT, value); +} + +DOMString HTMLBodyElement::vLink() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VLINK); +} + +void HTMLBodyElement::setVLink( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VLINK, value); +} + +// -------------------------------------------------------------------------- + +HTMLFrameElement::HTMLFrameElement() : HTMLElement() +{ +} + +HTMLFrameElement::HTMLFrameElement(const HTMLFrameElement &other) : HTMLElement(other) +{ +} + +HTMLFrameElement::HTMLFrameElement(HTMLFrameElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLFrameElement &HTMLFrameElement::operator = (const Node &other) +{ + assignOther( other, ID_FRAME ); + return *this; +} + +HTMLFrameElement &HTMLFrameElement::operator = (const HTMLFrameElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLFrameElement::~HTMLFrameElement() +{ +} + +DOMString HTMLFrameElement::frameBorder() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_FRAMEBORDER); +} + +void HTMLFrameElement::setFrameBorder( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_FRAMEBORDER, value); +} + +DOMString HTMLFrameElement::longDesc() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_LONGDESC); +} + +void HTMLFrameElement::setLongDesc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LONGDESC, value); +} + +DOMString HTMLFrameElement::marginHeight() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_MARGINHEIGHT); +} + +void HTMLFrameElement::setMarginHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_MARGINHEIGHT, value); +} + +DOMString HTMLFrameElement::marginWidth() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_MARGINWIDTH); +} + +void HTMLFrameElement::setMarginWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_MARGINWIDTH, value); +} + +DOMString HTMLFrameElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLFrameElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +bool HTMLFrameElement::noResize() const +{ + if(!impl) return false; + return !((ElementImpl *)impl)->getAttribute(ATTR_NORESIZE).isNull(); +} + +void HTMLFrameElement::setNoResize( bool _noResize ) +{ + if(impl) + { + DOMString str; + if( _noResize ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_NORESIZE, str); + } +} + +DOMString HTMLFrameElement::scrolling() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SCROLLING); +} + +void HTMLFrameElement::setScrolling( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SCROLLING, value); +} + +DOMString HTMLFrameElement::src() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SRC); +} + +void HTMLFrameElement::setSrc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value); +} + +Document HTMLFrameElement::contentDocument() const +{ + if (impl) return static_cast<HTMLFrameElementImpl*>(impl)->contentDocument(); + return Document(); +} + +// -------------------------------------------------------------------------- + +HTMLIFrameElement::HTMLIFrameElement() : HTMLElement() +{ +} + +HTMLIFrameElement::HTMLIFrameElement(const HTMLIFrameElement &other) : HTMLElement(other) +{ +} + +HTMLIFrameElement::HTMLIFrameElement(HTMLIFrameElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLIFrameElement &HTMLIFrameElement::operator = (const Node &other) +{ + assignOther( other, ID_IFRAME ); + return *this; +} + +HTMLIFrameElement &HTMLIFrameElement::operator = (const HTMLIFrameElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLIFrameElement::~HTMLIFrameElement() +{ +} + +DOMString HTMLIFrameElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLIFrameElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLIFrameElement::frameBorder() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_FRAMEBORDER); +} + +void HTMLIFrameElement::setFrameBorder( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_FRAMEBORDER, value); +} + +DOMString HTMLIFrameElement::height() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HEIGHT); +} + +void HTMLIFrameElement::setHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HEIGHT, value); +} + +DOMString HTMLIFrameElement::longDesc() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_LONGDESC); +} + +void HTMLIFrameElement::setLongDesc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LONGDESC, value); +} + +DOMString HTMLIFrameElement::marginHeight() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_MARGINHEIGHT); +} + +void HTMLIFrameElement::setMarginHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_MARGINHEIGHT, value); +} + +DOMString HTMLIFrameElement::marginWidth() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_MARGINWIDTH); +} + +void HTMLIFrameElement::setMarginWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_MARGINWIDTH, value); +} + +DOMString HTMLIFrameElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLIFrameElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLIFrameElement::scrolling() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SCROLLING); +} + +void HTMLIFrameElement::setScrolling( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SCROLLING, value); +} + +DOMString HTMLIFrameElement::src() const +{ + if(!impl) return DOMString(); + DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC); + return !s.isNull() ? impl->getDocument()->completeURL( s.string() ) : s; +} + +void HTMLIFrameElement::setSrc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value); +} + +DOMString HTMLIFrameElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLIFrameElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +Document HTMLIFrameElement::contentDocument() const +{ + if (impl) return static_cast<HTMLIFrameElementImpl*>(impl)->contentDocument(); + return Document(); +} + +// -------------------------------------------------------------------------- + +HTMLFrameSetElement::HTMLFrameSetElement() : HTMLElement() +{ +} + +HTMLFrameSetElement::HTMLFrameSetElement(const HTMLFrameSetElement &other) : HTMLElement(other) +{ +} + +HTMLFrameSetElement::HTMLFrameSetElement(HTMLFrameSetElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLFrameSetElement &HTMLFrameSetElement::operator = (const Node &other) +{ + assignOther( other, ID_FRAMESET ); + return *this; +} + +HTMLFrameSetElement &HTMLFrameSetElement::operator = (const HTMLFrameSetElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLFrameSetElement::~HTMLFrameSetElement() +{ +} + +DOMString HTMLFrameSetElement::cols() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_COLS); +} + +void HTMLFrameSetElement::setCols( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_COLS, value); +} + +DOMString HTMLFrameSetElement::rows() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ROWS); +} + +void HTMLFrameSetElement::setRows( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ROWS, value); +} + +// -------------------------------------------------------------------------- + +HTMLHeadElement::HTMLHeadElement() : HTMLElement() +{ +} + +HTMLHeadElement::HTMLHeadElement(const HTMLHeadElement &other) : HTMLElement(other) +{ +} + +HTMLHeadElement::HTMLHeadElement(HTMLHeadElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLHeadElement &HTMLHeadElement::operator = (const Node &other) +{ + assignOther( other, ID_HEAD ); + return *this; +} + +HTMLHeadElement &HTMLHeadElement::operator = (const HTMLHeadElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLHeadElement::~HTMLHeadElement() +{ +} + +DOMString HTMLHeadElement::profile() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_PROFILE); +} + +void HTMLHeadElement::setProfile( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_PROFILE, value); +} + +// -------------------------------------------------------------------------- + +HTMLHtmlElement::HTMLHtmlElement() : HTMLElement() +{ +} + +HTMLHtmlElement::HTMLHtmlElement(const HTMLHtmlElement &other) : HTMLElement(other) +{ +} + +HTMLHtmlElement::HTMLHtmlElement(HTMLHtmlElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLHtmlElement &HTMLHtmlElement::operator = (const Node &other) +{ + assignOther( other, ID_HTML ); + return *this; +} + +HTMLHtmlElement &HTMLHtmlElement::operator = (const HTMLHtmlElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLHtmlElement::~HTMLHtmlElement() +{ +} + +DOMString HTMLHtmlElement::version() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VERSION); +} + +void HTMLHtmlElement::setVersion( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VERSION, value); +} + diff --git a/tdehtml/dom/html_base.h b/tdehtml/dom/html_base.h new file mode 100644 index 000000000..c7ed878ce --- /dev/null +++ b/tdehtml/dom/html_base.h @@ -0,0 +1,610 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ + +#ifndef HTML_BASE_H +#define HTML_BASE_H + +#include <dom/html_element.h> + +#include <tdelibs_export.h> + +namespace DOM { + +class HTMLBodyElementImpl; +class DOMString; + +/** + * The HTML document body. This element is always present in the DOM + * API, even if the tags are not present in the source document. See + * the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-BODY"> + * BODY element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLBodyElement : public HTMLElement +{ +public: + HTMLBodyElement(); + HTMLBodyElement(const HTMLBodyElement &other); + HTMLBodyElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLBodyElement(HTMLBodyElementImpl *impl); +public: + + HTMLBodyElement & operator = (const HTMLBodyElement &other); + HTMLBodyElement & operator = (const Node &other); + + ~HTMLBodyElement(); + + /** + * Color of active links (after mouse-button down, but before + * mouse-button up). See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-alink"> + * alink attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString aLink() const; + + /** + * see aLink + */ + void setALink( const DOMString & ); + + /** + * URI of the background texture tile image. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-background"> + * background attribute definition </a> in HTML 4.0. This + * attribute is deprecated in HTML 4.0. + * + */ + DOMString background() const; + + /** + * see background + */ + void setBackground( const DOMString & ); + + /** + * Document background color. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-bgcolor"> + * bgcolor attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString bgColor() const; + + /** + * see bgColor + */ + void setBgColor( const DOMString & ); + + /** + * Color of links that are not active and unvisited. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-link"> + * link attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString link() const; + + /** + * see link + */ + void setLink( const DOMString & ); + + /** + * Document text color. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-text"> + * text attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString text() const; + + /** + * see text + */ + void setText( const DOMString & ); + + /** + * Color of links that have been visited by the user. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-vlink"> + * vlink attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString vLink() const; + + /** + * see vLink + */ + void setVLink( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLFrameElementImpl; +class DOMString; + +/** + * Create a frame. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#edef-FRAME"> + * FRAME element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLFrameElement : public HTMLElement +{ +public: + HTMLFrameElement(); + HTMLFrameElement(const HTMLFrameElement &other); + HTMLFrameElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLFrameElement(HTMLFrameElementImpl *impl); +public: + + HTMLFrameElement & operator = (const HTMLFrameElement &other); + HTMLFrameElement & operator = (const Node &other); + + ~HTMLFrameElement(); + + /** + * Request frame borders. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-frameborder"> + * frameborder attribute definition </a> in HTML 4.0. + * + */ + DOMString frameBorder() const; + + /** + * see frameBorder + */ + void setFrameBorder( const DOMString & ); + + /** + * URI designating a long description of this image or frame. See + * the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-longdesc-FRAME"> + * longdesc attribute definition </a> in HTML 4.0. + * + */ + DOMString longDesc() const; + + /** + * see longDesc + */ + void setLongDesc( const DOMString & ); + + /** + * Frame margin height, in pixels. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-marginheight"> + * marginheight attribute definition </a> in HTML 4.0. + * + */ + DOMString marginHeight() const; + + /** + * see marginHeight + */ + void setMarginHeight( const DOMString & ); + + /** + * Frame margin width, in pixels. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-marginwidth"> + * marginwidth attribute definition </a> in HTML 4.0. + * + */ + DOMString marginWidth() const; + + /** + * see marginWidth + */ + void setMarginWidth( const DOMString & ); + + /** + * The frame name (object of the \c target attribute). + * See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-name-FRAME"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * When true, forbid user from resizing frame. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-noresize"> + * noresize attribute definition </a> in HTML 4.0. + * + */ + bool noResize() const; + + /** + * see noResize + */ + void setNoResize( bool ); + + /** + * Specify whether or not the frame should have scrollbars. See + * the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-scrolling"> + * scrolling attribute definition </a> in HTML 4.0. + * + */ + DOMString scrolling() const; + + /** + * see scrolling + */ + void setScrolling( const DOMString & ); + + /** + * A URI designating the initial frame contents. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-src-FRAME"> + * src attribute definition </a> in HTML 4.0. + * + */ + DOMString src() const; + + /** + * see src + */ + void setSrc( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * + * Returns the document this frame contains, if there is any and + * it is available, a Null document otherwise. The attribute is + * read-only. + * + * @return The content Document if available. + */ + Document contentDocument() const; +}; + +// -------------------------------------------------------------------------- + +class HTMLFrameSetElementImpl; +class DOMString; + +/** + * Create a grid of frames. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#edef-FRAMESET"> + * FRAMESET element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLFrameSetElement : public HTMLElement +{ +public: + HTMLFrameSetElement(); + HTMLFrameSetElement(const HTMLFrameSetElement &other); + HTMLFrameSetElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLFrameSetElement(HTMLFrameSetElementImpl *impl); +public: + + HTMLFrameSetElement & operator = (const HTMLFrameSetElement &other); + HTMLFrameSetElement & operator = (const Node &other); + + ~HTMLFrameSetElement(); + + /** + * The number of columns of frames in the frameset. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-cols-FRAMESET"> + * cols attribute definition </a> in HTML 4.0. + * + */ + DOMString cols() const; + + /** + * see cols + */ + void setCols( const DOMString & ); + + /** + * The number of rows of frames in the frameset. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-rows-FRAMESET"> + * rows attribute definition </a> in HTML 4.0. + * + */ + DOMString rows() const; + + /** + * see rows + */ + void setRows( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLIFrameElementImpl; + +/** + * Inline subwindows. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#edef-IFRAME"> + * IFRAME element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLIFrameElement : public HTMLElement +{ +public: + HTMLIFrameElement(); + HTMLIFrameElement(const HTMLIFrameElement &other); + HTMLIFrameElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLIFrameElement(HTMLIFrameElementImpl *impl); +public: + + HTMLIFrameElement & operator = (const HTMLIFrameElement &other); + HTMLIFrameElement & operator = (const Node &other); + + ~HTMLIFrameElement(); + + /** + * Aligns this object (vertically or horizontally) with respect to + * its surrounding text. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-align-IMG"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Request frame borders. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-frameborder"> + * frameborder attribute definition </a> in HTML 4.0. + * + */ + DOMString frameBorder() const; + + /** + * see frameBorder + */ + void setFrameBorder( const DOMString & ); + + /** + * Frame height. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-height-IFRAME"> + * height attribute definition </a> in HTML 4.0. + * + */ + DOMString height() const; + + /** + * see height + */ + void setHeight( const DOMString & ); + + /** + * URI designating a long description of this image or frame. See + * the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-longdesc-IFRAME"> + * longdesc attribute definition </a> in HTML 4.0. + * + */ + DOMString longDesc() const; + + /** + * see longDesc + */ + void setLongDesc( const DOMString & ); + + /** + * Frame margin height, in pixels. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-marginheight"> + * marginheight attribute definition </a> in HTML 4.0. + * + */ + DOMString marginHeight() const; + + /** + * see marginHeight + */ + void setMarginHeight( const DOMString & ); + + /** + * Frame margin width, in pixels. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-marginwidth"> + * marginwidth attribute definition </a> in HTML 4.0. + * + */ + DOMString marginWidth() const; + + /** + * see marginWidth + */ + void setMarginWidth( const DOMString & ); + + /** + * The frame name (object of the \c target attribute). + * See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-name-IFRAME"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Specify whether or not the frame should have scrollbars. See + * the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-scrolling"> + * scrolling attribute definition </a> in HTML 4.0. + * + */ + DOMString scrolling() const; + + /** + * see scrolling + */ + void setScrolling( const DOMString & ); + + /** + * A URI designating the initial frame contents. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-src-FRAME"> + * src attribute definition </a> in HTML 4.0. + * + */ + DOMString src() const; + + /** + * see src + */ + void setSrc( const DOMString & ); + + /** + * Frame width. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-width-IFRAME"> + * width attribute definition </a> in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * + * Returns the document this iframe contains, if there is any and + * it is available, a Null document otherwise. The attribute is + * read-only. + * + * @return The content Document if available. + */ + Document contentDocument() const; +}; + +// -------------------------------------------------------------------------- + +class HTMLHeadElementImpl; +class DOMString; + +/** + * Document head information. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-HEAD"> + * HEAD element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLHeadElement : public HTMLElement +{ +public: + HTMLHeadElement(); + HTMLHeadElement(const HTMLHeadElement &other); + HTMLHeadElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLHeadElement(HTMLHeadElementImpl *impl); +public: + + HTMLHeadElement & operator = (const HTMLHeadElement &other); + HTMLHeadElement & operator = (const Node &other); + + ~HTMLHeadElement(); + + /** + * URI designating a metadata profile. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-profile"> + * profile attribute definition </a> in HTML 4.0. + * + */ + DOMString profile() const; + + /** + * see profile + */ + void setProfile( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLHtmlElementImpl; +class DOMString; + +/** + * Root of an HTML document. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-HTML"> + * HTML element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLHtmlElement : public HTMLElement +{ +public: + HTMLHtmlElement(); + HTMLHtmlElement(const HTMLHtmlElement &other); + HTMLHtmlElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLHtmlElement(HTMLHtmlElementImpl *impl); +public: + + HTMLHtmlElement & operator = (const HTMLHtmlElement &other); + HTMLHtmlElement & operator = (const Node &other); + + ~HTMLHtmlElement(); + + /** + * Version information about the document's DTD. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-version"> + * version attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString version() const; + + /** + * see version + */ + void setVersion( const DOMString & ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_block.cpp b/tdehtml/dom/html_block.cpp new file mode 100644 index 000000000..9e499adb0 --- /dev/null +++ b/tdehtml/dom/html_block.cpp @@ -0,0 +1,443 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * Copyright (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + + +#include "dom/html_block.h" +#include "dom/html_misc.h" +#include "html/html_blockimpl.h" +#include "html/html_miscimpl.h" + +using namespace DOM; + +#include "misc/htmlhashes.h" + +HTMLBlockquoteElement::HTMLBlockquoteElement() + : HTMLElement() +{ +} + +HTMLBlockquoteElement::HTMLBlockquoteElement(const HTMLBlockquoteElement &other) + : HTMLElement(other) +{ +} + +HTMLBlockquoteElement::HTMLBlockquoteElement(HTMLElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const Node &other) +{ + assignOther( other, ID_BLOCKQUOTE ); + return *this; +} + +HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const HTMLBlockquoteElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLBlockquoteElement::~HTMLBlockquoteElement() +{ +} + +DOMString HTMLBlockquoteElement::cite() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CITE); +} + +void HTMLBlockquoteElement::setCite( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value); +} + +// -------------------------------------------------------------------------- + +HTMLDivElement::HTMLDivElement() + : HTMLElement() +{ +} + +HTMLDivElement::HTMLDivElement(const HTMLDivElement &other) + : HTMLElement(other) +{ +} + +HTMLDivElement::HTMLDivElement(HTMLDivElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLDivElement &HTMLDivElement::operator = (const Node &other) +{ + assignOther( other, ID_DIV ); + return *this; +} + +HTMLDivElement &HTMLDivElement::operator = (const HTMLDivElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLDivElement::~HTMLDivElement() +{ +} + +DOMString HTMLDivElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLDivElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +// -------------------------------------------------------------------------- + +HTMLHRElement::HTMLHRElement() + : HTMLElement() +{ +} + +HTMLHRElement::HTMLHRElement(const HTMLHRElement &other) + : HTMLElement(other) +{ +} + +HTMLHRElement::HTMLHRElement(HTMLHRElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLHRElement &HTMLHRElement::operator = (const Node &other) +{ + assignOther( other, ID_HR ); + return *this; +} + +HTMLHRElement &HTMLHRElement::operator = (const HTMLHRElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLHRElement::~HTMLHRElement() +{ +} + +DOMString HTMLHRElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLHRElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +bool HTMLHRElement::noShade() const +{ + if(!impl) return false; + return !((ElementImpl *)impl)->getAttribute(ATTR_NOSHADE).isNull(); +} + +void HTMLHRElement::setNoShade( bool _noShade ) +{ + if(impl) + { + DOMString str; + if( _noShade ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_NOSHADE, str); + } +} + +DOMString HTMLHRElement::size() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE); +} + +void HTMLHRElement::setSize( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value); +} + +DOMString HTMLHRElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLHRElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +// -------------------------------------------------------------------------- + +HTMLHeadingElement::HTMLHeadingElement() + : HTMLElement() +{ +} + +HTMLHeadingElement::HTMLHeadingElement(const HTMLHeadingElement &other) + : HTMLElement(other) +{ +} + +HTMLHeadingElement::HTMLHeadingElement(HTMLElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLHeadingElement &HTMLHeadingElement::operator = (const Node &other) +{ + if(other.elementId() != ID_H1 && + other.elementId() != ID_H2 && + other.elementId() != ID_H3 && + other.elementId() != ID_H4 && + other.elementId() != ID_H5 && + other.elementId() != ID_H6 ) + { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator = (other); + } + return *this; +} + +HTMLHeadingElement &HTMLHeadingElement::operator = (const HTMLHeadingElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLHeadingElement::~HTMLHeadingElement() +{ +} + +DOMString HTMLHeadingElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLHeadingElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +// -------------------------------------------------------------------------- + +HTMLParagraphElement::HTMLParagraphElement() : HTMLElement() +{ +} + +HTMLParagraphElement::HTMLParagraphElement(const HTMLParagraphElement &other) + : HTMLElement(other) +{ +} + +HTMLParagraphElement::HTMLParagraphElement(HTMLElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLParagraphElement &HTMLParagraphElement::operator = (const Node &other) +{ + assignOther( other, ID_P ); + return *this; +} + +HTMLParagraphElement &HTMLParagraphElement::operator = (const HTMLParagraphElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLParagraphElement::~HTMLParagraphElement() +{ +} + +DOMString HTMLParagraphElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLParagraphElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +// -------------------------------------------------------------------------- + +HTMLPreElement::HTMLPreElement() : HTMLElement() +{ +} + +HTMLPreElement::HTMLPreElement(const HTMLPreElement &other) + : HTMLElement(other) +{ +} + +HTMLPreElement::HTMLPreElement(HTMLPreElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLPreElement &HTMLPreElement::operator = (const Node &other) +{ + assignOther( other, ID_PRE ); + return *this; +} + +HTMLPreElement &HTMLPreElement::operator = (const HTMLPreElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLPreElement::~HTMLPreElement() +{ +} + +long HTMLPreElement::width() const +{ + if(!impl) return 0; + DOMString w = ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); + return w.toInt(); +} + +void HTMLPreElement::setWidth( long _width ) +{ + if(!impl) return; + + TQString aStr; + aStr.sprintf("%ld", _width); + DOMString value(aStr); + ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +// -------------------------------------------------------------------------- + +HTMLLayerElement::HTMLLayerElement() : HTMLElement() +{ +} + +HTMLLayerElement::HTMLLayerElement(const HTMLLayerElement &other) + : HTMLElement(other) +{ +} + +HTMLLayerElement::HTMLLayerElement(HTMLLayerElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLLayerElement &HTMLLayerElement::operator = (const Node &other) +{ + assignOther( other, ID_LAYER ); + return *this; +} + +HTMLLayerElement &HTMLLayerElement::operator = (const HTMLLayerElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLLayerElement::~HTMLLayerElement() +{ +} + +long HTMLLayerElement::top() const +{ + if(!impl) return 0; + DOMString t = ((ElementImpl *)impl)->getAttribute(ATTR_TOP); + return t.toInt(); +} + +void HTMLLayerElement::setTop( long _top ) +{ + if(!impl) return; + + TQString aStr; + aStr.sprintf("%ld", _top); + DOMString value(aStr); + ((ElementImpl *)impl)->setAttribute(ATTR_TOP, value); +} + +long HTMLLayerElement::left() const +{ + if(!impl) return 0; + DOMString l = ((ElementImpl *)impl)->getAttribute(ATTR_LEFT); + return l.toInt(); +} + +void HTMLLayerElement::setLeft( long _left ) +{ + if(!impl) return; + + TQString aStr; + aStr.sprintf("%ld", _left); + DOMString value(aStr); + ((ElementImpl *)impl)->setAttribute(ATTR_LEFT, value); +} + +DOMString HTMLLayerElement::visibility() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VISIBILITY); +} + +void HTMLLayerElement::setVisibility( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VISIBILITY, value); +} + +DOMString HTMLLayerElement::bgColor() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BGCOLOR); +} + +void HTMLLayerElement::setBgColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BGCOLOR, value); +} + +HTMLCollection HTMLLayerElement::layers() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_LAYERS); +} diff --git a/tdehtml/dom/html_block.h b/tdehtml/dom/html_block.h new file mode 100644 index 000000000..4283bafa2 --- /dev/null +++ b/tdehtml/dom/html_block.h @@ -0,0 +1,406 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * Copyright (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +// -------------------------------------------------------------------------- + +#ifndef HTML_BLOCK_H +#define HTML_BLOCK_H + +#include <dom/html_element.h> + +#include <tdelibs_export.h> + +namespace DOM { + +class HTMLElementImpl; +class DOMString; + +/** + * ??? See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-BLOCKQUOTE"> + * BLOCKQUOTE element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLBlockquoteElement : public HTMLElement +{ +public: + HTMLBlockquoteElement(); + HTMLBlockquoteElement(const HTMLBlockquoteElement &other); + HTMLBlockquoteElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLBlockquoteElement(HTMLElementImpl *impl); +public: + + HTMLBlockquoteElement & operator = (const HTMLBlockquoteElement &other); + HTMLBlockquoteElement & operator = (const Node &other); + + ~HTMLBlockquoteElement(); + + /** + * A URI designating a document that describes the reason for the + * change. See the <a href="http://www.w3.org/TR/REC-html40/"> + * cite attribute definition </a> in HTML 4.0. + * + */ + DOMString cite() const; + + /** + * see cite + */ + void setCite( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLDivElementImpl; +class DOMString; + +/** + * Generic block container. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-DIV"> + * DIV element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLDivElement : public HTMLElement +{ +public: + HTMLDivElement(); + HTMLDivElement(const HTMLDivElement &other); + HTMLDivElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLDivElement(HTMLDivElementImpl *impl); +public: + + HTMLDivElement & operator = (const HTMLDivElement &other); + HTMLDivElement & operator = (const Node &other); + + ~HTMLDivElement(); + + /** + * Horizontal text alignment. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-align"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLHRElementImpl; +class DOMString; + +/** + * Create a horizontal rule. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#edef-HR"> + * HR element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLHRElement : public HTMLElement +{ +public: + HTMLHRElement(); + HTMLHRElement(const HTMLHRElement &other); + HTMLHRElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLHRElement(HTMLHRElementImpl *impl); +public: + + HTMLHRElement & operator = (const HTMLHRElement &other); + HTMLHRElement & operator = (const Node &other); + + ~HTMLHRElement(); + + /** + * Align the rule on the page. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-align-HR"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Indicates to the user agent that there should be no shading in + * the rendering of this element. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-noshade"> + * noshade attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + bool noShade() const; + + /** + * see noShade + */ + void setNoShade( bool ); + + /** + * The height of the rule. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-size-HR"> + * size attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString size() const; + + /** + * see size + */ + void setSize( const DOMString & ); + + /** + * The width of the rule. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-width-HR"> + * width attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class DOMString; + +/** + * For the \c H1 to \c H6 elements. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-H1"> + * H1 element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLHeadingElement : public HTMLElement +{ +public: + HTMLHeadingElement(); + HTMLHeadingElement(const HTMLHeadingElement &other); + HTMLHeadingElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLHeadingElement(HTMLElementImpl *impl); +public: + + HTMLHeadingElement & operator = (const HTMLHeadingElement &other); + HTMLHeadingElement & operator = (const Node &other); + + ~HTMLHeadingElement(); + + /** + * Horizontal text alignment. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-align"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class DOMString; + +/** + * Paragraphs. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-P"> P + * element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLParagraphElement : public HTMLElement +{ +public: + HTMLParagraphElement(); + HTMLParagraphElement(const HTMLParagraphElement &other); + HTMLParagraphElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLParagraphElement(HTMLElementImpl *impl); +public: + + HTMLParagraphElement & operator = (const HTMLParagraphElement &other); + HTMLParagraphElement & operator = (const Node &other); + + ~HTMLParagraphElement(); + + /** + * Horizontal text alignment. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-align"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLPreElementImpl; + +/** + * Preformatted text. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-PRE"> + * PRE element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLPreElement : public HTMLElement +{ +public: + HTMLPreElement(); + HTMLPreElement(const HTMLPreElement &other); + HTMLPreElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLPreElement(HTMLPreElementImpl *impl); +public: + + HTMLPreElement & operator = (const HTMLPreElement &other); + HTMLPreElement & operator = (const Node &other); + + ~HTMLPreElement(); + + /** + * Fixed width for content. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#adef-width-PRE"> + * width attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long width() const; + + /** + * see width + */ + void setWidth( long ); +}; + +class HTMLLayerElementImpl; + +/** + * Layer container for Netscape 4.x compatability. + * Behaves mostly like absolute positioned DIV-blocks. + * + */ +class KHTML_EXPORT HTMLLayerElement : public HTMLElement +{ +public: + HTMLLayerElement(); + HTMLLayerElement(const HTMLLayerElement &other); + HTMLLayerElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLLayerElement(HTMLLayerElementImpl *impl); +public: + + HTMLLayerElement & operator = (const HTMLLayerElement &other); + HTMLLayerElement & operator = (const Node &other); + + ~HTMLLayerElement(); + + /** + * The absolute position of the layer from the top. + * + */ + long top() const; + + /** + * see top + */ + void setTop( long ); + + /** + * The absolute position of the layer from the left. + * + */ + long left() const; + + /** + * see left + */ + void setLeft( long ); + + /** + * The visibility of layers is either "show" or "hide" + * + */ + DOMString visibility() const; + + /** + * see visibility + */ + void setVisibility( const DOMString & ); + + /** + * The background color of the layer. + * + */ + DOMString bgColor() const; + + /** + * see bgColor + */ + void setBgColor( const DOMString & ); + + /** + * The collection of sub-layers + * + */ + HTMLCollection layers() const; +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_document.cpp b/tdehtml/dom/html_document.cpp new file mode 100644 index 000000000..c24bf65f7 --- /dev/null +++ b/tdehtml/dom/html_document.cpp @@ -0,0 +1,233 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * Copyright (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "html_document.h" +#include "css/csshelper.h" +#include "dom/html_misc.h" +#include "dom/dom_exception.h" +#include "xml/dom_textimpl.h" +#include "html/html_documentimpl.h" +#include "html/html_miscimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLDocument::HTMLDocument() : Document(false) // create the impl here +{ + impl = DOMImplementationImpl::instance()->createHTMLDocument(); + impl->ref(); + +} + +HTMLDocument::HTMLDocument(KHTMLView *parent) + : Document(false) // create the impl here +{ + impl = DOMImplementationImpl::instance()->createHTMLDocument(parent); + impl->ref(); +} + +HTMLDocument::HTMLDocument(const HTMLDocument &other) : Document(other) +{ +} + +HTMLDocument::HTMLDocument(HTMLDocumentImpl *impl) : Document(impl) +{ +} + +HTMLDocument &HTMLDocument::operator = (const Node &other) +{ + if(other.nodeType() != DOCUMENT_NODE) { + if ( impl ) impl->deref(); + impl = 0; + } else { + DocumentImpl *d = static_cast<DocumentImpl *>(other.handle()); + if(!d->isHTMLDocument()) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator =(other); + } + } + return *this; +} + +HTMLDocument &HTMLDocument::operator = (const HTMLDocument &other) +{ + Document::operator =(other); + return *this; +} + +HTMLDocument::~HTMLDocument() +{ +} + +DOMString HTMLDocument::title() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLDocumentImpl *>(impl)->title(); +} + +void HTMLDocument::setTitle( const DOMString &value ) +{ + if (impl) + static_cast<HTMLDocumentImpl *>(impl)->setTitle(value); +} + +DOMString HTMLDocument::referrer() const +{ + if(!impl) return DOMString(); + return ((HTMLDocumentImpl *)impl)->referrer(); +} + +DOMString HTMLDocument::completeURL(const DOMString& str) const +{ + if(!impl) return str; + DOMString parsed = tdehtml::parseURL(str); + return ((HTMLDocumentImpl *)impl)->completeURL(parsed.string()); +} + +DOMString HTMLDocument::domain() const +{ + if(!impl) return DOMString(); + return ((HTMLDocumentImpl *)impl)->domain(); +} + +DOMString HTMLDocument::lastModified() const +{ + if(!impl) return DOMString(); + return ((HTMLDocumentImpl *)impl)->lastModified(); +} + +DOMString HTMLDocument::URL() const +{ + if(!impl) return DOMString(); + return ((HTMLDocumentImpl *)impl)->URL().url(); +} + +HTMLElement HTMLDocument::body() const +{ + if(!impl) return 0; + return ((HTMLDocumentImpl *)impl)->body(); +} + +void HTMLDocument::setBody(const HTMLElement &_body) +{ + if (!impl) return; + int exceptioncode = 0; + ((HTMLDocumentImpl *)impl)->setBody(static_cast<HTMLElementImpl *>(_body.handle()), exceptioncode); + if ( exceptioncode ) + throw DOMException( exceptioncode ); + return; +} + +HTMLCollection HTMLDocument::images() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_IMAGES); +} + +HTMLCollection HTMLDocument::applets() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_APPLETS); +} + +HTMLCollection HTMLDocument::scripts() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_SCRIPTS); +} + +HTMLCollection HTMLDocument::links() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_LINKS); +} + +HTMLCollection HTMLDocument::forms() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_FORMS); +} + +HTMLCollection HTMLDocument::layers() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_LAYERS); +} + +HTMLCollection HTMLDocument::anchors() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_ANCHORS); +} + +HTMLCollection HTMLDocument::all() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL); +} + +DOMString HTMLDocument::cookie() const +{ + if (!impl) return DOMString(); + return ((HTMLDocumentImpl *)impl)->cookie(); +} + +void HTMLDocument::setCookie( const DOMString & value ) +{ + if (impl) + ((HTMLDocumentImpl *)impl)->setCookie(value); + +} + +void HTMLDocument::open( ) +{ + if(impl) + ((HTMLDocumentImpl *)impl)->open( ); +} + +void HTMLDocument::close( ) +{ + if(impl) + ((HTMLDocumentImpl *)impl)->close( ); +} + +void HTMLDocument::write( const DOMString &text ) +{ + if(impl) + ((HTMLDocumentImpl *)impl)->write( text ); +} + +void HTMLDocument::writeln( const DOMString &text ) +{ + if(impl) + ((HTMLDocumentImpl *)impl)->writeln( text ); +} + +NodeList HTMLDocument::getElementsByName( const DOMString &elementName ) +{ + if(!impl) return 0; + return new NameNodeListImpl(impl, elementName); +} + diff --git a/tdehtml/dom/html_document.h b/tdehtml/dom/html_document.h new file mode 100644 index 000000000..aa53de96c --- /dev/null +++ b/tdehtml/dom/html_document.h @@ -0,0 +1,304 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ + +#ifndef HTML_DOCUMENT_H +#define HTML_DOCUMENT_H + +#include <dom/dom_doc.h> +#include <dom/dom_string.h> + +#include <tdelibs_export.h> + +class KHTMLView; +class KHTMLPart; + +namespace DOM { + +class HTMLDocumentImpl; +class DOMImplementation; +class HTMLCollection; +class NodeList; +class Element; +class HTMLElement; + +/** + * An \c HTMLDocument is the root of the HTML hierarchy + * and holds the entire content. Beside providing access to the + * hierarchy, it also provides some convenience methods for accessing + * certain sets of information from the document. + * + * The following properties have been deprecated in favor of the + * corresponding ones for the BODY element: + * + * \li \c alinkColor + * + * \li \c background + * + * \li \c bgColor + * + * \li \c fgColor + * + * \li \c linkColor + * + * \li \c vlinkColor + * + * + */ +class KHTML_EXPORT HTMLDocument : public Document +{ + friend class ::KHTMLView; + friend class ::KHTMLPart; + friend class DOMImplementation; +public: + HTMLDocument(); + /** + * The parent is the widget the document should render itself in. + * Rendering information (like sizes, etc...) is only created if + * parent != 0 + */ + HTMLDocument(KHTMLView *parent); + HTMLDocument(const HTMLDocument &other); + HTMLDocument(const Node &other) : Document(false) + {(*this)=other;} +protected: + HTMLDocument(HTMLDocumentImpl *impl); +public: + + HTMLDocument & operator = (const HTMLDocument &other); + HTMLDocument & operator = (const Node &other); + + ~HTMLDocument(); + + /** + * The title of a document as specified by the \c TITLE + * element in the head of the document. + * + */ + DOMString title() const; + + /** + * see title + */ + void setTitle( const DOMString & ); + + /** + * Returns the URI of the page that linked to this page. The value + * is an empty string if the user navigated to the page directly + * (not through a link, but, for example, via a bookmark). + */ + DOMString referrer() const; + + /** + * The domain name of the server that served the document, or a + * null string if the server cannot be identified by a domain + * name. + * + */ + DOMString domain() const; + + /** + * The absolute URI of the document. + */ + DOMString URL() const; + + /** + * The element that contains the content for the document. In + * documents with \c BODY contents, returns the + * \c BODY element, and in frameset documents, this returns + * the outermost \c FRAMESET element. + * + */ + HTMLElement body() const; + + /** + * see body + */ + void setBody(const HTMLElement &); + + /** + * A collection of all the \c IMG elements in a + * document. The behavior is limited to \c IMG + * elements for backwards compatibility. + * + */ + HTMLCollection images() const; + + /** + * A collection of all the \c OBJECT elements that + * include applets and \c APPLET ( deprecated ) + * elements in a document. + * + */ + HTMLCollection applets() const; + + /** + * A collection of all \c AREA elements and anchor ( + * \c A ) elements in a document with a value for the + * \c href attribute. + * + */ + HTMLCollection links() const; + + /** + * A collection of all the forms of a document. + * + */ + HTMLCollection forms() const; + + /** + * A collection of all the layers of a document. + * + */ + HTMLCollection layers() const; + + /** + * A collection of all the scripts in the document. + * + */ + HTMLCollection scripts() const; + + /** + * A collection of all the anchor ( \c A ) elements in + * a document with a value for the \c name attribute. + * Note. For reasons of backwards compatibility, the returned set + * of anchors only contains those anchors created with the + * \c name attribute, not those created with the \c id + * attribute. + * + */ + HTMLCollection anchors() const; + + /** + * The cookies associated with this document. If there are none, + * the value is an empty string. Otherwise, the value is a string: + * a semicolon-delimited list of "name, value" pairs for all the + * cookies associated with the page. For example, + * \c name=value;expires=date . + * + */ + DOMString cookie() const; + + /** + * see cookie + */ + void setCookie( const DOMString & ); + + /** + * Note. This method and the ones following allow a user to add to + * or replace the structure model of a document using strings of + * unparsed HTML. At the time of writing alternate methods for + * providing similar functionality for both HTML and XML documents + * were being considered. The following methods may be deprecated + * at some point in the future in favor of a more general-purpose + * mechanism. + * + * Open a document stream for writing. If a document exists in + * the target, this method clears it. + * + * @return + * + */ + void open ( ); + + /** + * Closes a document stream opened by \c open() and + * forces rendering. + * + * @return + * + */ + void close ( ); + + /** + * Write a string of text to a document stream opened by + * \c open() . The text is parsed into the document's + * structure model. + * + * @param text The string to be parsed into some structure in the + * document structure model. + * + * @return + * + */ + void write ( const DOMString &text ); + + /** + * Write a string of text followed by a newline character to a + * document stream opened by \c open() . The text is + * parsed into the document's structure model. + * + * @param text The string to be parsed into some structure in the + * document structure model. + * + * @return + * + */ + void writeln ( const DOMString &text ); + + /** + * Returns the (possibly empty) collection of elements whose + * \c name value is given by \c elementName . + * + * @param elementName The \c name attribute value for + * an element. + * + * @return The matching elements. + * + */ + NodeList getElementsByName ( const DOMString &elementName ); + + /** + * not part of the DOM + * + * converts the given (potentially relative) URL in a + * full-qualified one, using the baseURL / document URL for + * the missing parts. + */ + DOMString completeURL( const DOMString& url) const; + + /** + * Not part of the DOM + * + * The date the document was last modified. + */ + DOMString lastModified() const; + + /** + * Not part of the DOM + * + * A collection of all the \c IMG, \c OBJECT, + * \c AREA, \c A, forms and anchor elements of + * a document. + */ + HTMLCollection all() const; +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_element.cpp b/tdehtml/dom/html_element.cpp new file mode 100644 index 000000000..0063985ea --- /dev/null +++ b/tdehtml/dom/html_element.cpp @@ -0,0 +1,186 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "dom/dom_exception.h" +#include "dom/html_misc.h" +#include "css/css_base.h" +#include "html/html_miscimpl.h" // HTMLCollectionImpl + +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLElement::HTMLElement() : Element() +{ +} + +HTMLElement::HTMLElement(const HTMLElement &other) : Element(other) +{ +} + +HTMLElement::HTMLElement(HTMLElementImpl *impl) : Element(impl) +{ +} + +HTMLElement &HTMLElement::operator = (const HTMLElement &other) +{ + Element::operator = (other); + return *this; +} + +HTMLElement &HTMLElement::operator = (const Node &other) +{ + NodeImpl* ohandle = other.handle(); + if (!ohandle || !ohandle->isHTMLElement()) { + if (impl) impl->deref(); + impl = 0; + return *this; + } + Node::operator = (other); + return *this; +} + +HTMLElement::~HTMLElement() +{ +} + +DOMString HTMLElement::id() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ID); +} + +void HTMLElement::setId( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ID, value); +} + +DOMString HTMLElement::title() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TITLE); +} + +void HTMLElement::setTitle( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TITLE, value); +} + +DOMString HTMLElement::lang() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_LANG); +} + +void HTMLElement::setLang( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LANG, value); +} + +DOMString HTMLElement::dir() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_DIR); +} + +void HTMLElement::setDir( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DIR, value); +} + +DOMString HTMLElement::className() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CLASS); +} + +void HTMLElement::setClassName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLASS, value); +} + +void HTMLElement::removeCSSProperty( const DOMString &property ) +{ + int id = getPropertyID(property.string().lower().ascii(), property.length()); + if(id && impl) + static_cast<HTMLElementImpl*>(impl)->removeCSSProperty(id); +} + +void HTMLElement::addCSSProperty( const DOMString &property, const DOMString &value ) +{ + int id = getPropertyID(property.string().lower().ascii(), property.length()); + if(id && impl) + static_cast<HTMLElementImpl*>(impl)->addCSSProperty(id, value); +} + +DOMString HTMLElement::innerHTML() const +{ + if ( !impl ) return DOMString(); + return ((HTMLElementImpl *)impl)->innerHTML(); +} + +void HTMLElement::setInnerHTML( const DOMString &html ) +{ + if( !impl ) + return; + int exceptioncode = 0; + ((HTMLElementImpl *)impl)->setInnerHTML( html, exceptioncode ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +DOMString HTMLElement::innerText() const +{ + if ( !impl ) return DOMString(); + return ((HTMLElementImpl *)impl)->innerText(); +} + +void HTMLElement::setInnerText( const DOMString &text ) +{ + if( !impl ) + return; + int exceptioncode = 0; + ((HTMLElementImpl *)impl)->setInnerText( text, exceptioncode ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +HTMLCollection HTMLElement::children() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::NODE_CHILDREN); +} + +HTMLCollection HTMLElement::all() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL /*it's called "doc" but it works from any node */); +} + +void HTMLElement::assignOther( const Node &other, int elementId ) +{ + if (other.elementId() != static_cast<TQ_UINT32>(elementId)) { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator = (other); + } +} diff --git a/tdehtml/dom/html_element.h b/tdehtml/dom/html_element.h new file mode 100644 index 000000000..1329793b2 --- /dev/null +++ b/tdehtml/dom/html_element.h @@ -0,0 +1,221 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_ELEMENT_H +#define HTML_ELEMENT_H + +#include <dom/dom_element.h> +#include <tdelibs_export.h> + +class KHTMLView; + +namespace DOM { + +class HTMLElementImpl; +class DOMString; +class Element; +class HTMLCollection; + +/** + * All HTML element interfaces derive from this class. Elements that + * only expose the HTML core attributes are represented by the base + * \c HTMLElement interface. These elements are as + * follows: + * + * \li \c HEAD + * + * \li special: <tt> SUB, SUP, SPAN, BDO </tt> + * + * \li font: <tt> TT, I, B, U, S, STRIKE, BIG, SMALL </tt> + * + * \li phrase: <tt> EM, STRONG, DFN, CODE, SAMP, KBD, VAR, + * CITE, ACRONYM, ABBR</tt> + * + * \li list: <tt> DD, DT </tt> + * + * \li <tt> NOFRAMES, NOSCRIPT </tt> + * + * \li <tt> ADDRESS, CENTER </tt> + * + * Note: The \c style attribute for this + * interface is reserved for future usage. + * + */ +class KHTML_EXPORT HTMLElement : public Element +{ + friend class HTMLDocument; + friend class ::KHTMLView; + friend class HTMLTableElement; + friend class HTMLTableRowElement; + friend class HTMLTableSectionElement; + +public: + HTMLElement(); + HTMLElement(const HTMLElement &other); + HTMLElement(const Node &other) : Element() + {(*this)=other;} + +protected: + HTMLElement(HTMLElementImpl *impl); +public: + + HTMLElement & operator = (const HTMLElement &other); + HTMLElement & operator = (const Node &other); + + ~HTMLElement(); + + /** + * The element's identifier. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-id"> + * id attribute definition </a> in HTML 4.0. + * + */ + DOMString id() const; + + /** + * see id + */ + void setId( const DOMString & ); + + /** + * The element's advisory title. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-title"> + * title attribute definition </a> in HTML 4.0. + * + */ + DOMString title() const; + + /** + * see title + */ + void setTitle( const DOMString & ); + + /** + * Language code defined in RFC 1766. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/dirlang.html#adef-lang"> + * lang attribute definition </a> in HTML 4.0. + * + */ + DOMString lang() const; + + /** + * see lang + */ + void setLang( const DOMString & ); + + /** + * Specifies the base direction of directionally neutral text and + * the directionality of tables. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/dirlang.html#adef-dir"> + * dir attribute definition </a> in HTML 4.0. + * + */ + DOMString dir() const; + + /** + * see dir + */ + void setDir( const DOMString & ); + + /** + * The class attribute of the element. This attribute has been + * renamed due to conflicts with the "class" keyword exposed by + * many languages. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-class"> + * class attribute definition </a> in HTML 4.0. + * + */ + DOMString className() const; + + /** + * see className + */ + void setClassName( const DOMString & ); + + /** + * The HTML code contained in this element. + * This function is not part of the DOM specifications as defined by the w3c. + */ + DOMString innerHTML() const; + + /** + * Set the HTML content of this node. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if there is the element does not allow + * children. + */ + void setInnerHTML( const DOMString &html ); + + /** + * The text contained in this element. + * This function is not part of the DOM specifications as defined by the w3c. + */ + DOMString innerText() const; + + /** + * Set the text content of this node. + * + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if there is the element does not allow + * children. + */ + void setInnerText( const DOMString &text ); + + /** + * Retrieves a collection of nodes that are direct descendants of this node. + * IE-specific extension. + */ + HTMLCollection children() const; + + /** + * Retrieves a collection of all nodes that descend from this node. + * IE-specific extension. + */ + HTMLCollection all() const; + + /* + * @internal + */ + void removeCSSProperty( const DOMString& property ); + + /* + * @internal + */ + void addCSSProperty( const DOMString &property, const DOMString &value ); + +protected: + /* + * @internal + */ + void assignOther( const Node &other, int elementId ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_form.cpp b/tdehtml/dom/html_form.cpp new file mode 100644 index 000000000..5d9aec633 --- /dev/null +++ b/tdehtml/dom/html_form.cpp @@ -0,0 +1,1302 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/html_form.h" +#include "dom/dom_exception.h" +#include "dom/dom_doc.h" + +#include "html/html_formimpl.h" +#include "html/html_miscimpl.h" + +#include "xml/dom_docimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLButtonElement::HTMLButtonElement() : HTMLElement() +{ +} + +HTMLButtonElement::HTMLButtonElement(const HTMLButtonElement &other) : HTMLElement(other) +{ +} + +HTMLButtonElement::HTMLButtonElement(HTMLButtonElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLButtonElement &HTMLButtonElement::operator = (const Node &other) +{ + assignOther( other, ID_BUTTON ); + return *this; +} + +HTMLButtonElement &HTMLButtonElement::operator = (const HTMLButtonElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLButtonElement::~HTMLButtonElement() +{ +} + +HTMLFormElement HTMLButtonElement::form() const +{ + return Element::form(); +} + +DOMString HTMLButtonElement::accessKey() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLButtonElement::setAccessKey( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +bool HTMLButtonElement::disabled() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLButtonElement::setDisabled( bool _disabled ) +{ + if (impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); +} + +DOMString HTMLButtonElement::name() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_NAME); +} + +void HTMLButtonElement::setName( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_NAME, value); +} + +void HTMLButtonElement::focus( ) +{ + if(impl) + static_cast<HTMLButtonElementImpl*>(impl)->focus(); +} + +void HTMLButtonElement::blur( ) +{ + if(impl) + static_cast<HTMLButtonElementImpl*>(impl)->blur(); +} + +long HTMLButtonElement::tabIndex() const +{ + if(!impl) return 0; + return static_cast<ElementImpl*>(impl)->tabIndex(); +} + +void HTMLButtonElement::setTabIndex( long _tabIndex ) +{ + if (!impl) return; + static_cast<ElementImpl*>(impl)->setTabIndex(_tabIndex); +} + +DOMString HTMLButtonElement::type() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLButtonElementImpl*>(impl)->type(); +} + +DOMString HTMLButtonElement::value() const +{ + if(!impl) return DOMString(); + DOMString s = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_VALUE); + if (s.isNull()) return DOMString(""); + return s; +} + +void HTMLButtonElement::setValue( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_VALUE, value); +} + +// -------------------------------------------------------------------------- + +HTMLFieldSetElement::HTMLFieldSetElement() : HTMLElement() +{ +} + +HTMLFieldSetElement::HTMLFieldSetElement(const HTMLFieldSetElement &other) : HTMLElement(other) +{ +} + +HTMLFieldSetElement::HTMLFieldSetElement(HTMLFieldSetElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLFieldSetElement &HTMLFieldSetElement::operator = (const Node &other) +{ + assignOther( other, ID_FIELDSET ); + return *this; +} + +HTMLFieldSetElement &HTMLFieldSetElement::operator = (const HTMLFieldSetElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLFieldSetElement::~HTMLFieldSetElement() +{ +} + +HTMLFormElement HTMLFieldSetElement::form() const +{ + return Element::form(); +} + +// -------------------------------------------------------------------------- + +HTMLFormElement::HTMLFormElement() : HTMLElement() +{ +} + +HTMLFormElement::HTMLFormElement(const HTMLFormElement &other) : HTMLElement(other) +{ +} + +HTMLFormElement::HTMLFormElement(HTMLFormElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLFormElement &HTMLFormElement::operator = (const Node &other) +{ + assignOther( other, ID_FORM ); + return *this; +} + +HTMLFormElement &HTMLFormElement::operator = (const HTMLFormElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLFormElement::~HTMLFormElement() +{ +} + +HTMLCollection HTMLFormElement::elements() const +{ + if(!impl) return HTMLCollection(); + return HTMLFormCollection(impl); +} + +long HTMLFormElement::length() const +{ + if(!impl) return 0; + return static_cast<HTMLFormElementImpl*>(impl)->length(); +} + +DOMString HTMLFormElement::name() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_NAME); +} + +void HTMLFormElement::setName( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLFormElement::acceptCharset() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ACCEPT_CHARSET); +} + +void HTMLFormElement::setAcceptCharset( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ACCEPT_CHARSET, value); +} + +DOMString HTMLFormElement::action() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ACTION); +} + +void HTMLFormElement::setAction( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ACTION, value); +} + +DOMString HTMLFormElement::enctype() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ENCTYPE); +} + +void HTMLFormElement::setEnctype( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ENCTYPE, value); +} + +DOMString HTMLFormElement::method() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_METHOD); +} + +void HTMLFormElement::setMethod( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_METHOD, value); +} + +DOMString HTMLFormElement::target() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_TARGET); +} + +void HTMLFormElement::setTarget( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_TARGET, value); +} + +void HTMLFormElement::submit( ) +{ + if(impl) static_cast<HTMLFormElementImpl*>(impl)->submit( ); +} + +void HTMLFormElement::reset( ) +{ + if(impl) static_cast<HTMLFormElementImpl*>(impl)->reset( ); +} + +// -------------------------------------------------------------------------- + +HTMLInputElement::HTMLInputElement() : HTMLElement() +{ +} + +HTMLInputElement::HTMLInputElement(const HTMLInputElement &other) : HTMLElement(other) +{ +} + +HTMLInputElement::HTMLInputElement(HTMLInputElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLInputElement &HTMLInputElement::operator = (const Node &other) +{ + assignOther( other, ID_INPUT ); + return *this; +} + +HTMLInputElement &HTMLInputElement::operator = (const HTMLInputElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLInputElement::~HTMLInputElement() +{ +} + +DOMString HTMLInputElement::defaultValue() const +{ + if(!impl) return DOMString(); + DOMString s = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_VALUE); + if (s.isNull()) return DOMString(""); + return s; + +} + +void HTMLInputElement::setDefaultValue( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALUE, value); +} + +bool HTMLInputElement::defaultChecked() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_CHECKED).isNull(); +} + +void HTMLInputElement::setDefaultChecked( bool _defaultChecked ) +{ + if(impl) + ((ElementImpl *)impl)->setAttribute(ATTR_CHECKED, _defaultChecked ? "" : 0); +} + +HTMLFormElement HTMLInputElement::form() const +{ + return Element::form(); +} + +DOMString HTMLInputElement::accept() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ACCEPT); +} + +void HTMLInputElement::setAccept( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ACCEPT, value); +} + +DOMString HTMLInputElement::accessKey() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLInputElement::setAccessKey( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +DOMString HTMLInputElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLInputElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLInputElement::alt() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); +} + +void HTMLInputElement::setAlt( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); +} + +bool HTMLInputElement::checked() const +{ + if(!impl) return 0; + return ((HTMLInputElementImpl*)impl)->checked(); +} + +void HTMLInputElement::setChecked( bool _checked ) +{ + if(impl) + ((HTMLInputElementImpl*)impl)->setChecked(_checked); +} + +bool HTMLInputElement::indeterminate() const +{ + if(!impl) return 0; + return ((HTMLInputElementImpl*)impl)->indeterminate(); +} + +void HTMLInputElement::setIndeterminate( bool _indeterminate ) +{ + if(impl) + ((HTMLInputElementImpl*)impl)->setIndeterminate(_indeterminate); +} + +bool HTMLInputElement::disabled() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLInputElement::setDisabled( bool _disabled ) +{ + if(impl) + { + ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); + } +} + +long HTMLInputElement::maxLength() const +{ + if(!impl) return 0; + return ((HTMLInputElementImpl *)impl)->getAttribute(ATTR_MAXLENGTH).toInt(); +} + +void HTMLInputElement::setMaxLength( long _maxLength ) +{ + if(impl) { + DOMString value(TQString::number(_maxLength)); + ((ElementImpl *)impl)->setAttribute(ATTR_MAXLENGTH,value); + } +} + +DOMString HTMLInputElement::name() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLInputElementImpl* const>(impl)->name(); +} + +void HTMLInputElement::setName( const DOMString &value ) +{ + if(impl) static_cast<HTMLInputElementImpl*>(impl)->setName(value); +} + +bool HTMLInputElement::readOnly() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_READONLY).isNull(); +} + +void HTMLInputElement::setReadOnly( bool _readOnly ) +{ + if(impl) + static_cast<ElementImpl*>(impl)->setAttribute(ATTR_READONLY, _readOnly ? "" : 0); +} + +/* The next two are provided for backwards compatibility. */ +DOMString HTMLInputElement::size() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_SIZE); +} + +void HTMLInputElement::setSize( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_SIZE, value); +} + +long HTMLInputElement::getSize() const +{ + if(!impl) return 0; + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_SIZE).toInt(); +} + +void HTMLInputElement::setSize( long value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_SIZE, TQString::number(value)); +} + +DOMString HTMLInputElement::src() const +{ + if(!impl) return DOMString(); + DOMString s = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_SRC); + return !s.isNull() ? impl->getDocument()->completeURL( s.string() ) : s; +} + +void HTMLInputElement::setSrc( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_SRC, value); +} + +long HTMLInputElement::tabIndex() const +{ + if(!impl) return 0; + return static_cast<ElementImpl*>(impl)->tabIndex(); +} + +void HTMLInputElement::setTabIndex( long _tabIndex ) +{ + if (!impl) return; + static_cast<ElementImpl*>(impl)->setTabIndex(_tabIndex); +} + +DOMString HTMLInputElement::type() const +{ + if(!impl) return DOMString(); + return ((HTMLInputElementImpl *)impl)->type(); +} + +void HTMLInputElement::setType(const DOMString& _type) +{ + if (!impl) return; + static_cast<HTMLInputElementImpl*>(impl)->setType(_type); +} + +DOMString HTMLInputElement::useMap() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_USEMAP); +} + +void HTMLInputElement::setUseMap( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_USEMAP, value); +} + +DOMString HTMLInputElement::value() const +{ + if(!impl) return DOMString(); + return ((HTMLInputElementImpl*)impl)->value(); +} + +void HTMLInputElement::setValue( const DOMString &value ) +{ + if (impl) + ((HTMLInputElementImpl*)impl)->setValue(value); + +} + +void HTMLInputElement::blur( ) +{ + if(impl) + ((HTMLInputElementImpl*)impl)->blur(); +} + +void HTMLInputElement::focus( ) +{ + if(impl) + ((HTMLInputElementImpl*)impl)->focus(); +} + +void HTMLInputElement::select( ) +{ + if(impl) + ((HTMLInputElementImpl *)impl)->select( ); +} + +void HTMLInputElement::click( ) +{ + if(impl) + ((HTMLInputElementImpl *)impl)->click( ); +} + +long HTMLInputElement::selectionStart() +{ + if (impl) + return ((HTMLInputElementImpl *)impl)->selectionStart( ); + return -1; +} + +long HTMLInputElement::selectionEnd() +{ + if (impl) + return ((HTMLInputElementImpl *)impl)->selectionEnd( ); + return -1; +} + +void HTMLInputElement::setSelectionStart(long pos) +{ + if (impl) + ((HTMLInputElementImpl *)impl)->setSelectionStart( pos ); +} + +void HTMLInputElement::setSelectionEnd(long pos) +{ + if (impl) + ((HTMLInputElementImpl *)impl)->setSelectionEnd( pos ); +} + +void HTMLInputElement::setSelectionRange(long start, long end) +{ + if (impl) + ((HTMLInputElementImpl *)impl)->setSelectionRange( start, end ); +} + +// -------------------------------------------------------------------------- + +HTMLLabelElement::HTMLLabelElement() : HTMLElement() +{ +} + +HTMLLabelElement::HTMLLabelElement(const HTMLLabelElement &other) : HTMLElement(other) +{ +} + +HTMLLabelElement::HTMLLabelElement(HTMLLabelElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLLabelElement &HTMLLabelElement::operator = (const Node &other) +{ + assignOther( other, ID_LABEL ); + return *this; +} + +HTMLLabelElement &HTMLLabelElement::operator = (const HTMLLabelElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLLabelElement::~HTMLLabelElement() +{ +} + +DOMString HTMLLabelElement::accessKey() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLLabelElement::setAccessKey( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +DOMString HTMLLabelElement::htmlFor() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_FOR); +} + +void HTMLLabelElement::setHtmlFor( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_FOR, value); +} + +// -------------------------------------------------------------------------- + +HTMLLegendElement::HTMLLegendElement() : HTMLElement() +{ +} + +HTMLLegendElement::HTMLLegendElement(const HTMLLegendElement &other) : HTMLElement(other) +{ +} + +HTMLLegendElement::HTMLLegendElement(HTMLLegendElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLLegendElement &HTMLLegendElement::operator = (const Node &other) +{ + assignOther( other, ID_LEGEND ); + return *this; +} + +HTMLLegendElement &HTMLLegendElement::operator = (const HTMLLegendElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLLegendElement::~HTMLLegendElement() +{ +} + +HTMLFormElement HTMLLegendElement::form() const +{ + return Element::form(); +} + +DOMString HTMLLegendElement::accessKey() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLLegendElement::setAccessKey( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +DOMString HTMLLegendElement::align() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLLegendElement::setAlign( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ALIGN, value); +} + +// -------------------------------------------------------------------------- + +HTMLOptGroupElement::HTMLOptGroupElement() : HTMLElement() +{ +} + +HTMLOptGroupElement::HTMLOptGroupElement(const HTMLOptGroupElement &other) : HTMLElement(other) +{ +} + +HTMLOptGroupElement::HTMLOptGroupElement(HTMLOptGroupElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLOptGroupElement &HTMLOptGroupElement::operator = (const Node &other) +{ + assignOther( other, ID_OPTGROUP ); + return *this; +} + +HTMLOptGroupElement &HTMLOptGroupElement::operator = (const HTMLOptGroupElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLOptGroupElement::~HTMLOptGroupElement() +{ +} + +bool HTMLOptGroupElement::disabled() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLOptGroupElement::setDisabled( bool _disabled ) +{ + if(impl) + static_cast<ElementImpl*>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); +} + +DOMString HTMLOptGroupElement::label() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_LABEL); +} + +void HTMLOptGroupElement::setLabel( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_LABEL, value); +} + +// -------------------------------------------------------------------------- + +HTMLSelectElement::HTMLSelectElement() : HTMLElement() +{ +} + +HTMLSelectElement::HTMLSelectElement(const HTMLSelectElement &other) : HTMLElement(other) +{ +} + +HTMLSelectElement::HTMLSelectElement(HTMLSelectElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLSelectElement &HTMLSelectElement::operator = (const Node &other) +{ + assignOther( other, ID_SELECT ); + return *this; +} + +HTMLSelectElement &HTMLSelectElement::operator = (const HTMLSelectElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLSelectElement::~HTMLSelectElement() +{ +} + +DOMString HTMLSelectElement::type() const +{ + if(!impl) return DOMString(); + return ((HTMLSelectElementImpl *)impl)->type(); +} + +long HTMLSelectElement::selectedIndex() const +{ + if(!impl) return 0; + return ((HTMLSelectElementImpl *)impl)->selectedIndex(); +} + +void HTMLSelectElement::setSelectedIndex( long _selectedIndex ) +{ + if(impl) + ((HTMLSelectElementImpl *)impl)->setSelectedIndex(_selectedIndex); +} + +DOMString HTMLSelectElement::value() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLSelectElementImpl*>(impl)->value(); +} + +void HTMLSelectElement::setValue( const DOMString &value ) +{ + if(!impl || value.isNull()) return; + static_cast<HTMLSelectElementImpl*>(impl)->setValue(value.implementation()); +} + +long HTMLSelectElement::length() const +{ + if(!impl) return 0; + return ((HTMLSelectElementImpl *)impl)->length(); +} + +HTMLFormElement HTMLSelectElement::form() const +{ + return Element::form(); +} + +HTMLCollection HTMLSelectElement::options() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::SELECT_OPTIONS); +} + +bool HTMLSelectElement::disabled() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLSelectElement::setDisabled( bool _disabled ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); +} + + +bool HTMLSelectElement::multiple() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_MULTIPLE).isNull(); +} + +void HTMLSelectElement::setMultiple( bool _multiple ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_MULTIPLE, _multiple ? "" : 0); +} + +DOMString HTMLSelectElement::name() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLSelectElementImpl* const>(impl)->name(); +} + +void HTMLSelectElement::setName( const DOMString &value ) +{ + if(impl) static_cast<HTMLSelectElementImpl*>(impl)->setName(value); +} + +long HTMLSelectElement::size() const +{ + if(!impl) return 0; + return ((HTMLSelectElementImpl *)impl)->getAttribute(ATTR_SIZE).toInt(); +} + +void HTMLSelectElement::setSize( long _size ) +{ + + if(impl) { + DOMString value(TQString::number(_size)); + static_cast<ElementImpl*>(impl)->setAttribute(ATTR_SIZE,value); + } +} + +long HTMLSelectElement::tabIndex() const +{ + if(!impl) return 0; + return static_cast<ElementImpl*>(impl)->tabIndex(); +} + +void HTMLSelectElement::setTabIndex( long _tabIndex ) +{ + if (!impl) return; + static_cast<ElementImpl*>(impl)->setTabIndex(_tabIndex); +} + +void HTMLSelectElement::add( const HTMLElement &element, const HTMLElement &before ) +{ + if (!impl) + throw DOMException(DOMException::NOT_FOUND_ERR); + + int exceptioncode = 0; + static_cast<HTMLSelectElementImpl*>(impl)->add( element, before, exceptioncode ); + if ( exceptioncode ) + throw DOMException( exceptioncode ); +} + +void HTMLSelectElement::remove( long index ) +{ + if(impl) static_cast<HTMLSelectElementImpl*>(impl)->remove( index ); +} + +void HTMLSelectElement::blur( ) +{ + if(impl) + ((HTMLSelectElementImpl*)impl)->blur(); +} + +void HTMLSelectElement::focus( ) +{ + if(impl) + ((HTMLSelectElementImpl*)impl)->focus(); +} + +// -------------------------------------------------------------------------- + +HTMLTextAreaElement::HTMLTextAreaElement() : HTMLElement() +{ +} + +HTMLTextAreaElement::HTMLTextAreaElement(const HTMLTextAreaElement &other) : HTMLElement(other) +{ +} + +HTMLTextAreaElement::HTMLTextAreaElement(HTMLTextAreaElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTextAreaElement &HTMLTextAreaElement::operator = (const Node &other) +{ + assignOther( other, ID_TEXTAREA ); + return *this; +} + +HTMLTextAreaElement &HTMLTextAreaElement::operator = (const HTMLTextAreaElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTextAreaElement::~HTMLTextAreaElement() +{ +} + +DOMString HTMLTextAreaElement::defaultValue() const +{ + if(!impl) return DOMString(); + return ((HTMLTextAreaElementImpl *)impl)->defaultValue(); +} + +void HTMLTextAreaElement::setDefaultValue( const DOMString &value ) +{ + if (impl) ((HTMLTextAreaElementImpl *)impl)->setDefaultValue(value); +} + +HTMLFormElement HTMLTextAreaElement::form() const +{ + return Element::form(); +} + +DOMString HTMLTextAreaElement::accessKey() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLTextAreaElement::setAccessKey( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +long HTMLTextAreaElement::cols() const +{ + if(!impl) return 0; + return ((HTMLTextAreaElementImpl *)impl)->getAttribute(ATTR_COLS).toInt(); +} + +void HTMLTextAreaElement::setCols( long _cols ) +{ + + if(impl) { + DOMString value(TQString::number(_cols)); + static_cast<ElementImpl*>(impl)->setAttribute(ATTR_COLS,value); + } +} + +bool HTMLTextAreaElement::disabled() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLTextAreaElement::setDisabled( bool _disabled ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); +} + +DOMString HTMLTextAreaElement::name() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLTextAreaElementImpl* const>(impl)->name(); +} + +void HTMLTextAreaElement::setName( const DOMString &value ) +{ + if(impl) static_cast<HTMLTextAreaElementImpl*>(impl)->setName(value); +} + +bool HTMLTextAreaElement::readOnly() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_READONLY).isNull(); +} + +void HTMLTextAreaElement::setReadOnly( bool _readOnly ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_READONLY, _readOnly ? "" : 0); +} + +long HTMLTextAreaElement::rows() const +{ + if(!impl) return 0; + return ((HTMLTextAreaElementImpl *)impl)->getAttribute(ATTR_ROWS).toInt(); +} + +void HTMLTextAreaElement::setRows( long _rows ) +{ + + if(impl) { + DOMString value(TQString::number(_rows)); + static_cast<ElementImpl*>(impl)->setAttribute(ATTR_ROWS,value); + } +} + +long HTMLTextAreaElement::tabIndex() const +{ + if(!impl) return 0; + return static_cast<ElementImpl*>(impl)->tabIndex(); +} + +void HTMLTextAreaElement::setTabIndex( long _tabIndex ) +{ + if (!impl) return; + static_cast<ElementImpl*>(impl)->setTabIndex(_tabIndex); +} + +DOMString HTMLTextAreaElement::type() const +{ + if(!impl) return DOMString(); + return ((HTMLTextAreaElementImpl *)impl)->type(); +} + +DOMString HTMLTextAreaElement::value() const +{ + if(!impl) return DOMString(); + return ((HTMLTextAreaElementImpl *)impl)->value(); +} + +void HTMLTextAreaElement::setValue( const DOMString &value ) +{ + if(impl) ((HTMLTextAreaElementImpl *)impl)->setValue(value); +} + +void HTMLTextAreaElement::blur( ) +{ + if(impl) + ((HTMLTextAreaElementImpl*)impl)->blur(); +} + +void HTMLTextAreaElement::focus( ) +{ + if(impl) + ((HTMLTextAreaElementImpl*)impl)->focus(); +} + +void HTMLTextAreaElement::select( ) +{ + if(impl) + ((HTMLTextAreaElementImpl *)impl)->select( ); +} + +long HTMLTextAreaElement::selectionStart() +{ + if (impl) + return ((HTMLTextAreaElementImpl *)impl)->selectionStart( ); + return 0; +} + +long HTMLTextAreaElement::selectionEnd() +{ + if (impl) + return ((HTMLTextAreaElementImpl *)impl)->selectionEnd( ); + return 0; +} + +long HTMLTextAreaElement::textLength() +{ + if (impl) + return ((HTMLTextAreaElementImpl *)impl)->textLength( ); + return 0; +} + +void HTMLTextAreaElement::setSelectionStart(long pos) +{ + if (impl) + ((HTMLTextAreaElementImpl *)impl)->setSelectionStart( pos ); +} + +void HTMLTextAreaElement::setSelectionEnd(long pos) +{ + if (impl) + ((HTMLTextAreaElementImpl *)impl)->setSelectionEnd( pos ); +} + +void HTMLTextAreaElement::setSelectionRange(long start, long end) +{ + if (impl) + ((HTMLTextAreaElementImpl *)impl)->setSelectionRange( start, end ); +} + +// -------------------------------------------------------------------------- + +HTMLOptionElement::HTMLOptionElement() : HTMLElement() +{ +} + +HTMLOptionElement::HTMLOptionElement(const HTMLOptionElement &other) : HTMLElement(other) +{ +} + +HTMLOptionElement::HTMLOptionElement(HTMLOptionElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLOptionElement &HTMLOptionElement::operator = (const Node &other) +{ + assignOther( other, ID_OPTION ); + return *this; +} + +HTMLOptionElement &HTMLOptionElement::operator = (const HTMLOptionElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLOptionElement::~HTMLOptionElement() +{ +} + +HTMLFormElement HTMLOptionElement::form() const +{ + return Element::form(); +} + +bool HTMLOptionElement::defaultSelected() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_SELECTED).isNull(); +} + +void HTMLOptionElement::setDefaultSelected( bool _defaultSelected ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_SELECTED, _defaultSelected ? "" : 0); +} + +DOMString HTMLOptionElement::text() const +{ + if(!impl) return DOMString(); + return ((HTMLOptionElementImpl *)impl)->text(); +} + +long HTMLOptionElement::index() const +{ + if(!impl) return 0; + return ((HTMLOptionElementImpl *)impl)->index(); +} + +void HTMLOptionElement::setIndex( long /*_index*/ ) +{ + throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); +} + +bool HTMLOptionElement::disabled() const +{ + if(!impl) return 0; + return !static_cast<ElementImpl*>(impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLOptionElement::setDisabled( bool _disabled ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); +} + +DOMString HTMLOptionElement::label() const +{ + if(!impl) return DOMString(); + return static_cast<ElementImpl*>(impl)->getAttribute(ATTR_LABEL); +} + +void HTMLOptionElement::setLabel( const DOMString &value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_LABEL, value); +} + +bool HTMLOptionElement::selected() const +{ + if(!impl) return 0; + return ((HTMLOptionElementImpl *)impl)->selected(); +} + +void HTMLOptionElement::setSelected(bool _selected) { + if(!impl) return; + ((HTMLOptionElementImpl *)impl)->setSelected(_selected); +} + +DOMString HTMLOptionElement::value() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLOptionElementImpl*>(impl)->value(); +} + +void HTMLOptionElement::setValue( const DOMString &value ) +{ + if(impl) static_cast<HTMLOptionElementImpl*>(impl)->setValue(value.implementation()); +} + +// ----------------------------------------------------------------------------- + +HTMLIsIndexElement::HTMLIsIndexElement() : HTMLElement() +{ +} + +HTMLIsIndexElement::HTMLIsIndexElement(const HTMLIsIndexElement &other) : HTMLElement(other) +{ +} + +HTMLIsIndexElement::HTMLIsIndexElement(HTMLIsIndexElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLIsIndexElement &HTMLIsIndexElement::operator = (const Node &other) +{ + assignOther( other, ID_ISINDEX ); + return *this; +} + +HTMLIsIndexElement &HTMLIsIndexElement::operator = (const HTMLIsIndexElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLIsIndexElement::~HTMLIsIndexElement() +{ +} + +HTMLFormElement HTMLIsIndexElement::form() const +{ + return Element::form(); +} + +DOMString HTMLIsIndexElement::prompt() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLIsIndexElementImpl*>(impl)->prompt(); +} + +void HTMLIsIndexElement::setPrompt( const DOMString &value ) +{ + if(impl) static_cast<HTMLIsIndexElementImpl*>(impl)->setPrompt(value); +} diff --git a/tdehtml/dom/html_form.h b/tdehtml/dom/html_form.h new file mode 100644 index 000000000..0623e421b --- /dev/null +++ b/tdehtml/dom/html_form.h @@ -0,0 +1,1427 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_FORM_H +#define HTML_FORM_H + +// -------------------------------------------------------------------------- +#include <dom/html_element.h> +#include <dom/html_misc.h> + +#include <kdemacros.h> + +namespace DOM { + +class HTMLButtonElementImpl; +class HTMLFormElement; +class DOMString; + +/** + * Push button. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-BUTTON"> + * BUTTON element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLButtonElement : public HTMLElement +{ +public: + HTMLButtonElement(); + HTMLButtonElement(const HTMLButtonElement &other); + HTMLButtonElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLButtonElement(HTMLButtonElementImpl *impl); +public: + + HTMLButtonElement & operator = (const HTMLButtonElement &other); + HTMLButtonElement & operator = (const Node &other); + + ~HTMLButtonElement(); + + /** + * Returns the \c FORM element containing this + * control. Returns null if this control is not within the context + * of a form. + * + */ + HTMLFormElement form() const; + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * The control is unavailable in this context. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled"> + * disabled attribute definition </a> in HTML 4.0. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * Form control or object name when submitted with a form. See the + * <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-BUTTON"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * The type of button. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-type-BUTTON"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * The current form control value. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-value-BUTTON"> + * value attribute definition </a> in HTML 4.0. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); + + /** + * Removes keyboard focus from this element. + * + */ + void blur ( ); + + /** + * Gives keyboard focus to this element. + * + */ + void focus ( ); +}; + +// -------------------------------------------------------------------------- + +class HTMLFieldSetElementImpl; +/** + * Organizes form controls into logical groups. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-FIELDSET"> + * FIELDSET element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLFieldSetElement : public HTMLElement +{ +public: + HTMLFieldSetElement(); + HTMLFieldSetElement(const HTMLFieldSetElement &other); + HTMLFieldSetElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLFieldSetElement(HTMLFieldSetElementImpl *impl); +public: + + HTMLFieldSetElement & operator = (const HTMLFieldSetElement &other); + HTMLFieldSetElement & operator = (const Node &other); + + ~HTMLFieldSetElement(); + + /** + * ### KDE 4.0: remove. + */ + HTMLFormElement form() const; +}; + +// -------------------------------------------------------------------------- + +class HTMLFormElementImpl; +/** + * The \c FORM element encompasses behavior similar to a + * collection and an element. It provides direct access to the + * contained input elements as well as the attributes of the form + * element. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-FORM"> + * FORM element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLFormElement : public HTMLElement +{ + friend class HTMLButtonElement; + friend class HTMLFieldSetElement; + friend class HTMLInputElement; + friend class HTMLLabelElement; + friend class HTMLLegendElement; + friend class HTMLSelectElement; + friend class HTMLTextAreaElement; + friend class HTMLOptionElement; + friend class HTMLIsIndexElement; + friend class HTMLObjectElement; + +public: + HTMLFormElement(); + HTMLFormElement(const HTMLFormElement &other); + HTMLFormElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLFormElement(HTMLFormElementImpl *impl); +public: + + HTMLFormElement & operator = (const HTMLFormElement &other); + HTMLFormElement & operator = (const Node &other); + + ~HTMLFormElement(); + + /** + * Returns a collection of all control elements in the form. + * + */ + HTMLCollection elements() const; + + /** + * The number of form controls in the form. + * + */ + long length() const; + + /** + * Names the form. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * List of character sets supported by the server. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accept-charset"> + * accept-charset attribute definition </a> in HTML 4.0. + * + */ + DOMString acceptCharset() const; + + /** + * see acceptCharset + */ + void setAcceptCharset( const DOMString & ); + + /** + * Server-side form handler. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-action"> + * action attribute definition </a> in HTML 4.0. + * + */ + DOMString action() const; + + /** + * see action + */ + void setAction( const DOMString & ); + + /** + * The content type of the submitted form, generally + * "application/x-www-form-urlencoded". See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-enctype"> + * enctype attribute definition </a> in HTML 4.0. + * + */ + DOMString enctype() const; + + /** + * see enctype + */ + void setEnctype( const DOMString & ); + + /** + * HTTP method used to submit form. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-method"> + * method attribute definition </a> in HTML 4.0. + * + */ + DOMString method() const; + + /** + * see method + */ + void setMethod( const DOMString & ); + + /** + * Frame to render the resource in. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target"> + * target attribute definition </a> in HTML 4.0. + * + */ + DOMString target() const; + + /** + * see target + */ + void setTarget( const DOMString & ); + + /** + * Submits the form. It performs the same action as a submit + * button. + * + */ + void submit ( ); + + /** + * Restores a form element's default values. It performs the same + * action as a reset button. + * + */ + void reset ( ); +}; + +// -------------------------------------------------------------------------- + +class HTMLInputElementImpl; +/** + * Form control. Note. Depending upon the environment the page is + * being viewed, the value property may be read-only for the file + * upload input type. For the "password" input type, the actual value + * returned may be masked to prevent unauthorized use. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-INPUT"> + * INPUT element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLInputElement : public HTMLElement +{ +public: + HTMLInputElement(); + HTMLInputElement(const HTMLInputElement &other); + HTMLInputElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLInputElement(HTMLInputElementImpl *impl); +public: + + HTMLInputElement & operator = (const HTMLInputElement &other); + HTMLInputElement & operator = (const Node &other); + + ~HTMLInputElement(); + + /** + * Stores the initial control value (i.e., the initial value of + * \c value ). + * + */ + DOMString defaultValue() const; + + /** + * see defaultValue + */ + void setDefaultValue( const DOMString & ); + + /** + * When \c type has the value "Radio" or "Checkbox", + * stores the initial value of the \c checked + * attribute. + * + */ + bool defaultChecked() const; + + /** + * see defaultChecked + */ + void setDefaultChecked( bool ); + + /** + * ### KDE 4.0: remove. + */ + HTMLFormElement form() const; + + /** + * A comma-separated list of content types that a server + * processing this form will handle correctly. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accept"> + * accept attribute definition </a> in HTML 4.0. + * + */ + DOMString accept() const; + + /** + * see accept + */ + void setAccept( const DOMString & ); + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * Aligns this object (vertically or horizontally) with respect to + * its surrounding text. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-align-IMG"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Alternate text for user agents not rendering the normal content + * of this element. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-alt"> + * alt attribute definition </a> in HTML 4.0. + * + */ + DOMString alt() const; + + /** + * see alt + */ + void setAlt( const DOMString & ); + + /** + * Describes whether a radio or check box is checked, when + * \c type has the value "Radio" or "Checkbox". The value is + * true if explicitly set. Represents the current state of the + * checkbox or radio button. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-checked"> + * checked attribute definition </a> in HTML 4.0. + * + */ + bool checked() const; + + /** + * see checked + */ + void setChecked( bool ); + + /** + * Describes whether a radio box is indeterminate + */ + bool indeterminate() const; + + /** + * see indeterminate + */ + void setIndeterminate( bool ); + + /** + * The control is unavailable in this context. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled"> + * disabled attribute definition </a> in HTML 4.0. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * Maximum number of characters for text fields, when \c type + * has the value "Text" or "Password". See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-maxlength"> + * maxlength attribute definition </a> in HTML 4.0. + * + */ + long maxLength() const; + + /** + * see maxLength + */ + void setMaxLength( long ); + + /** + * Form control or object name when submitted with a form. See the + * <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-INPUT"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * This control is read-only. When \c type has the + * value "text" or "password" only. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-readonly"> + * readonly attribute definition </a> in HTML 4.0. + * + */ + bool readOnly() const; + + // ### remove in 4.0 + /** + * see readOnly + */ + void setReadOnly( bool ); + + /** + * @deprecated + */ + DOMString size() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setSize( const DOMString & ) KDE_DEPRECATED; + + /** + * Size information. The precise meaning is specific to each type + * of field. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-size-INPUT"> + * size attribute definition </a> in HTML 4.0. + * + */ + long getSize() const; + + /** + * see getSize + */ + void setSize( long ); + + /** + * When the \c type attribute has the value "Image", + * this attribute specifies the location of the image to be used + * to decorate the graphical submit button. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-src"> + * src attribute definition </a> in HTML 4.0. + * + */ + DOMString src() const; + + /** + * see src + */ + void setSrc( const DOMString & ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * The type of control created. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-type-INPUT"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType(const DOMString&); + + /** + * Use client-side image map. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-usemap"> + * usemap attribute definition </a> in HTML 4.0. + * + */ + DOMString useMap() const; + + /** + * see useMap + */ + void setUseMap( const DOMString & ); + + /** + * The current form control value. Used for radio buttons and + * check boxes. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-value-INPUT"> + * value attribute definition </a> in HTML 4.0. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); + + /** + * Removes keyboard focus from this element. + * + */ + void blur ( ); + + /** + * Gives keyboard focus to this element. + * + */ + void focus ( ); + + /** + * Select the contents of the text area. For \c INPUT + * elements whose \c type attribute has one of the + * following values: "Text", "File", or "Password". + * + */ + void select ( ); + + /** + * Simulate a mouse-click. For \c INPUT elements whose + * \c type attribute has one of the following values: + * "Button", "Checkbox", "Radio", "Reset", or "Submit". + */ + void click ( ); + + + /** + * Returns the character offset of beginning of selection, or if none, + * the cursor position. + * This operation is only supported if the type of this element is text; + * otherwise -1 is returned. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + long selectionStart(); + + /** + * Move the beginning of the selection to the given offset in text + * This call has no effect if the type of this input element isn't text + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + void setSelectionStart(long offset); + + /** + * Returns the character offset of end of selection, or if none, + * the cursor position. + * This operation is only supported if the type of this element is text; + * otherwise -1 is returned. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + long selectionEnd(); + + /** + * Move the end of the selection (and the cursor) to the given offset in text + * This call has no effect if the type of this input element isn't text + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + void setSelectionEnd(long offset); + + /** + * Makes the position span from start to end, and positions the cursor after the selection. + * This call has no effect if the type of this input element isn't text or if it is not rendered. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + void setSelectionRange(long start, long end); + +}; + +// -------------------------------------------------------------------------- + +class HTMLLabelElementImpl; +/** + * Form field label text. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL"> + * LABEL element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLLabelElement : public HTMLElement +{ +public: + HTMLLabelElement(); + HTMLLabelElement(const HTMLLabelElement &other); + HTMLLabelElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLLabelElement(HTMLLabelElementImpl *impl); +public: + + HTMLLabelElement & operator = (const HTMLLabelElement &other); + HTMLLabelElement & operator = (const Node &other); + + ~HTMLLabelElement(); + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * This attribute links this label with another form control by + * \c id attribute. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-for"> + * for attribute definition </a> in HTML 4.0. + * + */ + DOMString htmlFor() const; + + /** + * see htmlFor + */ + void setHtmlFor( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLLegendElementImpl; +/** + * Provides a caption for a \c FIELDSET grouping. See the + * <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LEGEND"> + * LEGEND element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLLegendElement : public HTMLElement +{ +public: + HTMLLegendElement(); + HTMLLegendElement(const HTMLLegendElement &other); + HTMLLegendElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLLegendElement(HTMLLegendElementImpl *impl); +public: + + HTMLLegendElement & operator = (const HTMLLegendElement &other); + HTMLLegendElement & operator = (const Node &other); + + ~HTMLLegendElement(); + + /** + * ### KDE 4.0: remove + */ + HTMLFormElement form() const; + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * Text alignment relative to \c FIELDSET . See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-align-LEGEND"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLOptGroupElementImpl; +/** + * Group options together in logical subdivisions. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-OPTGROUP"> + * OPTGROUP element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLOptGroupElement : public HTMLElement +{ +public: + HTMLOptGroupElement(); + HTMLOptGroupElement(const HTMLOptGroupElement &other); + HTMLOptGroupElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLOptGroupElement(HTMLOptGroupElementImpl *impl); +public: + + HTMLOptGroupElement & operator = (const HTMLOptGroupElement &other); + HTMLOptGroupElement & operator = (const Node &other); + + ~HTMLOptGroupElement(); + + /** + * The control is unavailable in this context. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled"> + * disabled attribute definition </a> in HTML 4.0. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * Assigns a label to this option group. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-label-OPTGROUP"> + * label attribute definition </a> in HTML 4.0. + * + */ + DOMString label() const; + + /** + * see label + */ + void setLabel( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLSelectElementImpl; +/** + * The select element allows the selection of an option. The contained + * options can be directly accessed through the select element as a + * collection. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-SELECT"> + * SELECT element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLSelectElement : public HTMLElement +{ +public: + HTMLSelectElement(); + HTMLSelectElement(const HTMLSelectElement &other); + HTMLSelectElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLSelectElement(HTMLSelectElementImpl *impl); +public: + + HTMLSelectElement & operator = (const HTMLSelectElement &other); + HTMLSelectElement & operator = (const Node &other); + + ~HTMLSelectElement(); + + /** + * The type of control created. + * + */ + DOMString type() const; + + /** + * The ordinal index of the selected option. The value -1 is + * returned if no element is selected. If multiple options are + * selected, the index of the first selected option is returned. + * + */ + long selectedIndex() const; + + /** + * see selectedIndex + */ + void setSelectedIndex( long ); + + /** + * The current form control value. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); + + /** + * The number of options in this \c SELECT . + * + */ + long length() const; + + /** + * ### KDE 4.0: remove. + */ + HTMLFormElement form() const; + + /** + * The collection of \c OPTION elements contained by + * this element. + * + */ + HTMLCollection options() const; + + /** + * The control is unavailable in this context. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled"> + * disabled attribute definition </a> in HTML 4.0. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * If true, multiple \c OPTION elements may be + * selected in this \c SELECT . See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-multiple"> + * multiple attribute definition </a> in HTML 4.0. + * + */ + bool multiple() const; + + /** + * see multiple + */ + void setMultiple( bool ); + + /** + * Form control or object name when submitted with a form. See the + * <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-SELECT"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Number of visible rows. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-size-SELECT"> + * size attribute definition </a> in HTML 4.0. + * + */ + long size() const; + + /** + * see size + */ + void setSize( long ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * Add a new element to the collection of \c OPTION + * elements for this \c SELECT . + * + * @param element The element to add. + * + * @param before The element to insert before, or 0 for the + * tail of the list. + * + */ + void add ( const HTMLElement &element, const HTMLElement &before ); + + /** + * Remove an element from the collection of \c OPTION + * elements for this \c SELECT . Does nothing if no + * element has the given index. + * + * @param index The index of the item to remove. + * + */ + void remove ( long index ); + + /** + * Removes keyboard focus from this element. + * + */ + void blur ( ); + + /** + * Gives keyboard focus to this element. + * + */ + void focus ( ); +}; + +// -------------------------------------------------------------------------- + +class HTMLTextAreaElementImpl; +/** + * Multi-line text field. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-TEXTAREA"> + * TEXTAREA element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTextAreaElement : public HTMLElement +{ +public: + HTMLTextAreaElement(); + HTMLTextAreaElement(const HTMLTextAreaElement &other); + HTMLTextAreaElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLTextAreaElement(HTMLTextAreaElementImpl *impl); +public: + + HTMLTextAreaElement & operator = (const HTMLTextAreaElement &other); + HTMLTextAreaElement & operator = (const Node &other); + + ~HTMLTextAreaElement(); + + /** + * Stores the initial control value (i.e., the initial value of + * \c value ). + * + */ + DOMString defaultValue() const; + + /** + * see defaultValue + */ + void setDefaultValue( const DOMString & ); + + /** + * ### KDE 4.0: remove. + */ + HTMLFormElement form() const; + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * Width of control (in characters). See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-cols-TEXTAREA"> + * cols attribute definition </a> in HTML 4.0. + * + */ + long cols() const; + + /** + * see cols + */ + void setCols( long ); + + /** + * The control is unavailable in this context. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled"> + * disabled attribute definition </a> in HTML 4.0. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * Form control or object name when submitted with a form. See the + * <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-TEXTAREA"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * This control is read-only. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-readonly"> + * readonly attribute definition </a> in HTML 4.0. + * + */ + bool readOnly() const; + + /** + * see readOnly + */ + void setReadOnly( bool ); + + /** + * Number of text rows. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-rows-TEXTAREA"> + * rows attribute definition </a> in HTML 4.0. + * + */ + long rows() const; + + /** + * see rows + */ + void setRows( long ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * The type of this form control. + * + */ + DOMString type() const; + + /** + * The current textual content of the multi-line text field. If + * the entirety of the data can not fit into a single wstring, the + * implementation may truncate the data. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); + + /** + * Removes keyboard focus from this element. + */ + void blur ( ); + + /** + * Gives keyboard focus to this element. + */ + void focus ( ); + + /** + * Select the contents of the \c TEXTAREA . + */ + void select ( ); + + /** + * Returns the character offset of beginning of selection, or if none, + * the cursor position. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + long selectionStart(); + + /** + * Move the beginning of the selection to the given offset in text + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + void setSelectionStart(long offset); + + /** + * Returns the character offset of end of selection, or if none, + * the cursor position. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + long selectionEnd(); + + /** + * Move the end of the selection (and the cursor) to the given offset in text + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + void setSelectionEnd(long offset); + + /** + * Selects the text from start to end, and positions the cursor after the selection. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + void setSelectionRange(long start, long end); + + /** + * Returns the length of the text. + * NOTE: this method is not part of the DOM, but a Mozilla extension + * @since 3.5.2 + */ + long textLength(); +}; + +// -------------------------------------------------------------------------- + +class HTMLOptionElementImpl; +/** + * A selectable choice. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-OPTION"> + * OPTION element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLOptionElement : public HTMLElement +{ +public: + HTMLOptionElement(); + HTMLOptionElement(const HTMLOptionElement &other); + HTMLOptionElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLOptionElement(HTMLOptionElementImpl *impl); +public: + + HTMLOptionElement & operator = (const HTMLOptionElement &other); + HTMLOptionElement & operator = (const Node &other); + + ~HTMLOptionElement(); + + /** + * ### KDE 4.0: remove + */ + HTMLFormElement form() const; + + /** + * Stores the initial value of the \c selected + * attribute. + * + */ + bool defaultSelected() const; + + /** + * see defaultSelected + */ + void setDefaultSelected( bool ); + + /** + * The text contained within the option element. + * + */ + DOMString text() const; + + /** + * The index of this \c OPTION in its parent + * \c SELECT . + * + */ + long index() const; + + /** + * see index + * + * This function is obsolete - the index property is actually supposed to be read-only + * (http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html) + */ + void setIndex( long ); + + /** + * The control is unavailable in this context. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled"> + * disabled attribute definition </a> in HTML 4.0. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * Option label for use in hierarchical menus. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-label-OPTION"> + * label attribute definition </a> in HTML 4.0. + * + */ + DOMString label() const; + + /** + * see label + */ + void setLabel( const DOMString & ); + + /** + * Means that this option is initially selected. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-selected"> + * selected attribute definition </a> in HTML 4.0. + * + */ + bool selected() const; + + /** + * see selected + */ + void setSelected( bool ); + + /** + * The current form control value. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-value-OPTION"> + * value attribute definition </a> in HTML 4.0. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); +}; + + +// -------------------------------------------------------------------------- + +class HTMLIsIndexElementImpl; +class HTMLFormElement; + +/** + * This element is used for single-line text input. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#edef-ISINDEX"> + * ISINDEX element definition </a> in HTML 4.0. This element is + * deprecated in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLIsIndexElement : public HTMLElement +{ +public: + HTMLIsIndexElement(); + HTMLIsIndexElement(const HTMLIsIndexElement &other); + HTMLIsIndexElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLIsIndexElement(HTMLIsIndexElementImpl *impl); +public: + + HTMLIsIndexElement & operator = (const HTMLIsIndexElement &other); + HTMLIsIndexElement & operator = (const Node &other); + + ~HTMLIsIndexElement(); + + /** + * ### KDE 4.0: remove + */ + HTMLFormElement form() const; + + /** + * The prompt message. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-prompt"> + * prompt attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString prompt() const; + + /** + * see prompt + */ + void setPrompt( const DOMString & ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_head.cpp b/tdehtml/dom/html_head.cpp new file mode 100644 index 000000000..e5e72e73b --- /dev/null +++ b/tdehtml/dom/html_head.cpp @@ -0,0 +1,515 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/html_head.h" +#include "html/html_headimpl.h" +#include "misc/htmlhashes.h" +#include "xml/dom_docimpl.h" + +using namespace DOM; + +HTMLBaseElement::HTMLBaseElement() : HTMLElement() +{ +} + +HTMLBaseElement::HTMLBaseElement(const HTMLBaseElement &other) : HTMLElement(other) +{ +} + +HTMLBaseElement::HTMLBaseElement(HTMLBaseElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLBaseElement &HTMLBaseElement::operator = (const Node &other) +{ + assignOther( other, ID_BASE ); + return *this; +} + +HTMLBaseElement &HTMLBaseElement::operator = (const HTMLBaseElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLBaseElement::~HTMLBaseElement() +{ +} + +DOMString HTMLBaseElement::href() const +{ + if(!impl) return DOMString(); + DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF); + return !href.isNull() ? impl->getDocument()->completeURL(href.string()) : href; +} + +void HTMLBaseElement::setHref( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value); +} + +DOMString HTMLBaseElement::target() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET); +} + +void HTMLBaseElement::setTarget( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value); +} + +// -------------------------------------------------------------------------- + +HTMLLinkElement::HTMLLinkElement() : HTMLElement() +{ +} + +HTMLLinkElement::HTMLLinkElement(const HTMLLinkElement &other) : HTMLElement(other) +{ +} + +HTMLLinkElement::HTMLLinkElement(HTMLLinkElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLLinkElement &HTMLLinkElement::operator = (const Node &other) +{ + assignOther( other, ID_LINK ); + return *this; +} + +HTMLLinkElement &HTMLLinkElement::operator = (const HTMLLinkElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLLinkElement::~HTMLLinkElement() +{ +} + +bool HTMLLinkElement::disabled() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLLinkElement::setDisabled( bool _disabled ) +{ + if(impl) + ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0); +} + +DOMString HTMLLinkElement::charset() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET); +} + +void HTMLLinkElement::setCharset( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value); +} + +DOMString HTMLLinkElement::href() const +{ + if(!impl) return DOMString(); + DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF); + return !href.isNull() ? impl->getDocument()->completeURL(href.string()) : href; +} + +void HTMLLinkElement::setHref( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value); +} + +DOMString HTMLLinkElement::hreflang() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HREFLANG); +} + +void HTMLLinkElement::setHreflang( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HREFLANG, value); +} + +DOMString HTMLLinkElement::media() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_MEDIA); +} + +void HTMLLinkElement::setMedia( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_MEDIA, value); +} + +DOMString HTMLLinkElement::rel() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_REL); +} + +void HTMLLinkElement::setRel( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_REL, value); +} + +DOMString HTMLLinkElement::rev() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_REV); +} + +void HTMLLinkElement::setRev( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_REV, value); +} + +DOMString HTMLLinkElement::target() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET); +} + +void HTMLLinkElement::setTarget( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value); +} + +DOMString HTMLLinkElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLLinkElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +StyleSheet HTMLLinkElement::sheet() const +{ + if(!impl) return 0; + return ((HTMLLinkElementImpl *)impl)->sheet(); +} + +// -------------------------------------------------------------------------- + +HTMLMetaElement::HTMLMetaElement() : HTMLElement() +{ +} + +HTMLMetaElement::HTMLMetaElement(const HTMLMetaElement &other) : HTMLElement(other) +{ +} + +HTMLMetaElement::HTMLMetaElement(HTMLMetaElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLMetaElement &HTMLMetaElement::operator = (const Node &other) +{ + assignOther( other, ID_META ); + return *this; +} + +HTMLMetaElement &HTMLMetaElement::operator = (const HTMLMetaElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLMetaElement::~HTMLMetaElement() +{ +} + +DOMString HTMLMetaElement::content() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CONTENT); +} + +void HTMLMetaElement::setContent( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CONTENT, value); +} + +DOMString HTMLMetaElement::httpEquiv() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HTTP_EQUIV); +} + +void HTMLMetaElement::setHttpEquiv( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HTTP_EQUIV, value); +} + +DOMString HTMLMetaElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLMetaElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLMetaElement::scheme() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SCHEME); +} + +void HTMLMetaElement::setScheme( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SCHEME, value); +} + +// -------------------------------------------------------------------------- + +HTMLScriptElement::HTMLScriptElement() : HTMLElement() +{ +} + +HTMLScriptElement::HTMLScriptElement(const HTMLScriptElement &other) : HTMLElement(other) +{ +} + +HTMLScriptElement::HTMLScriptElement(HTMLScriptElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLScriptElement &HTMLScriptElement::operator = (const Node &other) +{ + assignOther( other, ID_SCRIPT ); + return *this; +} + +HTMLScriptElement &HTMLScriptElement::operator = (const HTMLScriptElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLScriptElement::~HTMLScriptElement() +{ +} + +DOMString HTMLScriptElement::text() const +{ + if(!impl) return DOMString(); + return ((HTMLScriptElementImpl *)impl)->text(); +} + +void HTMLScriptElement::setText( const DOMString &value ) +{ + if(impl) ((HTMLScriptElementImpl *)impl)->setText(value); +} + +DOMString HTMLScriptElement::htmlFor() const +{ + // DOM Level 1 says: reserved for future use... + return DOMString(); +} + +void HTMLScriptElement::setHtmlFor( const DOMString &/*value*/ ) +{ + // DOM Level 1 says: reserved for future use... +} + +DOMString HTMLScriptElement::event() const +{ + // DOM Level 1 says: reserved for future use... + return DOMString(); +} + +void HTMLScriptElement::setEvent( const DOMString &/*value*/ ) +{ + // DOM Level 1 says: reserved for future use... +} + +DOMString HTMLScriptElement::charset() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET); +} + +void HTMLScriptElement::setCharset( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value); +} + +bool HTMLScriptElement::defer() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_DEFER).isNull(); +} + +void HTMLScriptElement::setDefer( bool _defer ) +{ + + if(impl) + ((ElementImpl *)impl)->setAttribute(ATTR_DEFER,_defer ? "" : 0); +} + +DOMString HTMLScriptElement::src() const +{ + if(!impl) return DOMString(); + DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC); + return !s.isNull() ? impl->getDocument()->completeURL(s.string()) : s; +} + +void HTMLScriptElement::setSrc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value); +} + +DOMString HTMLScriptElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLScriptElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +// -------------------------------------------------------------------------- + +HTMLStyleElement::HTMLStyleElement() : HTMLElement() +{ +} + +HTMLStyleElement::HTMLStyleElement(const HTMLStyleElement &other) : HTMLElement(other) +{ +} + +HTMLStyleElement::HTMLStyleElement(HTMLStyleElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLStyleElement &HTMLStyleElement::operator = (const Node &other) +{ + assignOther( other, ID_STYLE ); + return *this; +} + +HTMLStyleElement &HTMLStyleElement::operator = (const HTMLStyleElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLStyleElement::~HTMLStyleElement() +{ +} + +bool HTMLStyleElement::disabled() const +{ + if(!impl) return 0; + return !((HTMLStyleElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLStyleElement::setDisabled( bool _disabled ) +{ + + if(impl) + ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED,_disabled ? "" : 0); +} + +DOMString HTMLStyleElement::media() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_MEDIA); +} + +void HTMLStyleElement::setMedia( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_MEDIA, value); +} + +DOMString HTMLStyleElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLStyleElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +StyleSheet HTMLStyleElement::sheet() const +{ + if(!impl) return 0; + return ((HTMLStyleElementImpl *)impl)->sheet(); +} + + +// -------------------------------------------------------------------------- + +HTMLTitleElement::HTMLTitleElement() : HTMLElement() +{ +} + +HTMLTitleElement::HTMLTitleElement(const HTMLTitleElement &other) : HTMLElement(other) +{ +} + +HTMLTitleElement::HTMLTitleElement(HTMLTitleElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTitleElement &HTMLTitleElement::operator = (const Node &other) +{ + assignOther( other, ID_TITLE ); + return *this; +} + +HTMLTitleElement &HTMLTitleElement::operator = (const HTMLTitleElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTitleElement::~HTMLTitleElement() +{ +} + +DOMString HTMLTitleElement::text() const +{ + if(!impl) return DOMString(); + return ((HTMLTitleElementImpl *)impl)->text(); +} + +void HTMLTitleElement::setText( const DOMString &value ) +{ + if(impl) ((HTMLTitleElementImpl *)impl)->setText(value); +} + diff --git a/tdehtml/dom/html_head.h b/tdehtml/dom/html_head.h new file mode 100644 index 000000000..e8dc52d21 --- /dev/null +++ b/tdehtml/dom/html_head.h @@ -0,0 +1,552 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_HEAD_H +#define HTML_HEAD_H + +#include <dom/html_element.h> +#include <dom/css_stylesheet.h> + +namespace DOM { + +class HTMLBaseElementImpl; +class DOMString; + +/** + * Document base URI. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#edef-BASE"> + * BASE element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLBaseElement : public HTMLElement +{ +public: + HTMLBaseElement(); + HTMLBaseElement(const HTMLBaseElement &other); + HTMLBaseElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLBaseElement(HTMLBaseElementImpl *impl); +public: + + HTMLBaseElement & operator = (const HTMLBaseElement &other); + HTMLBaseElement & operator = (const Node &other); + + ~HTMLBaseElement(); + + /** + * The base URI See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-href-BASE"> + * href attribute definition </a> in HTML 4.0. + * + */ + DOMString href() const; + + /** + * see href + */ + void setHref( const DOMString & ); + + /** + * The default target frame. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target"> + * target attribute definition </a> in HTML 4.0. + * + */ + DOMString target() const; + + /** + * see target + */ + void setTarget( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLLinkElementImpl; + +/** + * The \c LINK element specifies a link to an external + * resource, and defines this document's relationship to that resource + * (or vice versa). See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#edef-LINK"> + * LINK element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLLinkElement : public HTMLElement +{ +public: + HTMLLinkElement(); + HTMLLinkElement(const HTMLLinkElement &other); + HTMLLinkElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLLinkElement(HTMLLinkElementImpl *impl); +public: + + HTMLLinkElement & operator = (const HTMLLinkElement &other); + HTMLLinkElement & operator = (const Node &other); + + ~HTMLLinkElement(); + + /** + * Enables/disables the link. This is currently only used for + * style sheet links, and may be used to activate or deactivate + * style sheets. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * The character encoding of the resource being linked to. See the + * <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-charset"> + * charset attribute definition </a> in HTML 4.0. + * + */ + DOMString charset() const; + + /** + * see charset + */ + void setCharset( const DOMString & ); + + /** + * The URI of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-href"> + * href attribute definition </a> in HTML 4.0. + * + */ + DOMString href() const; + + /** + * see href + */ + void setHref( const DOMString & ); + + /** + * Language code of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-hreflang"> + * hreflang attribute definition </a> in HTML 4.0. + * + */ + DOMString hreflang() const; + + /** + * see hreflang + */ + void setHreflang( const DOMString & ); + + /** + * Designed for use with one or more target media. See the <a + * href="http://www.w3.org/TR/REC-html40/present/styles.html#adef-media"> + * media attribute definition </a> in HTML 4.0. + * + */ + DOMString media() const; + + /** + * see media + */ + void setMedia( const DOMString & ); + + /** + * Forward link type. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-rel"> + * rel attribute definition </a> in HTML 4.0. + * + */ + DOMString rel() const; + + /** + * see rel + */ + void setRel( const DOMString & ); + + /** + * Reverse link type. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-rev"> + * rev attribute definition </a> in HTML 4.0. + * + */ + DOMString rev() const; + + /** + * see rev + */ + void setRev( const DOMString & ); + + /** + * Frame to render the resource in. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target"> + * target attribute definition </a> in HTML 4.0. + * + */ + DOMString target() const; + + /** + * see target + */ + void setTarget( const DOMString & ); + + /** + * Advisory content type. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-type-A"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * This method is from the LinkStyle interface + * + * The style sheet. + */ + StyleSheet sheet() const; + +}; + +// -------------------------------------------------------------------------- + +class HTMLMetaElementImpl; + +/** + * This contains generic meta-information about the document. See the + * <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-META"> + * META element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLMetaElement : public HTMLElement +{ +public: + HTMLMetaElement(); + HTMLMetaElement(const HTMLMetaElement &other); + HTMLMetaElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLMetaElement(HTMLMetaElementImpl *impl); +public: + + HTMLMetaElement & operator = (const HTMLMetaElement &other); + HTMLMetaElement & operator = (const Node &other); + + ~HTMLMetaElement(); + + /** + * Associated information. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-content"> + * content attribute definition </a> in HTML 4.0. + * + */ + DOMString content() const; + + /** + * see content + */ + void setContent( const DOMString & ); + + /** + * HTTP response header name. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-http-equiv"> + * http-equiv attribute definition </a> in HTML 4.0. + * + */ + DOMString httpEquiv() const; + + /** + * see httpEquiv + */ + void setHttpEquiv( const DOMString & ); + + /** + * Meta information name. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-name-META"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Select form of content. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#adef-scheme"> + * scheme attribute definition </a> in HTML 4.0. + * + */ + DOMString scheme() const; + + /** + * see scheme + */ + void setScheme( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLScriptElementImpl; + +/** + * Script statements. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/scripts.html#edef-SCRIPT"> + * SCRIPT element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLScriptElement : public HTMLElement +{ +public: + HTMLScriptElement(); + HTMLScriptElement(const HTMLScriptElement &other); + HTMLScriptElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLScriptElement(HTMLScriptElementImpl *impl); +public: + + HTMLScriptElement & operator = (const HTMLScriptElement &other); + HTMLScriptElement & operator = (const Node &other); + + ~HTMLScriptElement(); + + /** + * The script content of the element. + * + */ + DOMString text() const; + + /** + * see text + */ + void setText( const DOMString & ); + + /** + * Reserved for future use. + * + */ + DOMString htmlFor() const; + + /** + * see htmlFor + */ + void setHtmlFor( const DOMString & ); + + /** + * Reserved for future use. + * + */ + DOMString event() const; + + /** + * see event + */ + void setEvent( const DOMString & ); + + /** + * The character encoding of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-charset"> + * charset attribute definition </a> in HTML 4.0. + * + */ + DOMString charset() const; + + /** + * see charset + */ + void setCharset( const DOMString & ); + + /** + * Indicates that the user agent can defer processing of the + * script. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/scripts.html#adef-defer"> + * defer attribute definition </a> in HTML 4.0. + * + */ + bool defer() const; + + /** + * see defer + */ + void setDefer( bool ); + + /** + * URI designating an external script. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/scripts.html#adef-src-SCRIPT"> + * src attribute definition </a> in HTML 4.0. + * + */ + DOMString src() const; + + /** + * see src + */ + void setSrc( const DOMString & ); + + /** + * The content type of the script language. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/scripts.html#adef-type-SCRIPT"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLStyleElementImpl; + +/** + * Style information. A more detailed style sheet object model is + * planned to be defined in a separate document. See the <a + * href="http://www.w3.org/TR/REC-html40/present/styles.html#edef-STYLE"> + * STYLE element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLStyleElement : public HTMLElement +{ +public: + HTMLStyleElement(); + HTMLStyleElement(const HTMLStyleElement &other); + HTMLStyleElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLStyleElement(HTMLStyleElementImpl *impl); +public: + + HTMLStyleElement & operator = (const HTMLStyleElement &other); + HTMLStyleElement & operator = (const Node &other); + + ~HTMLStyleElement(); + + /** + * Enables/disables the style sheet. + * + */ + bool disabled() const; + + /** + * see disabled + */ + void setDisabled( bool ); + + /** + * Designed for use with one or more target media. See the <a + * href="http://www.w3.org/TR/REC-html40/present/styles.html#adef-media"> + * media attribute definition </a> in HTML 4.0. + * + */ + DOMString media() const; + + /** + * see media + */ + void setMedia( const DOMString & ); + + /** + * The style sheet language (Internet media type). See the <a + * href="http://www.w3.org/TR/REC-html40/present/styles.html#adef-type-STYLE"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * This method is from the LinkStyle interface + * + * The style sheet. + */ + StyleSheet sheet() const; + +}; + +// -------------------------------------------------------------------------- + +class HTMLTitleElementImpl; + +/** + * The document title. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/global.html#edef-TITLE"> + * TITLE element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTitleElement : public HTMLElement +{ +public: + HTMLTitleElement(); + HTMLTitleElement(const HTMLTitleElement &other); + HTMLTitleElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLTitleElement(HTMLTitleElementImpl *impl); +public: + + HTMLTitleElement & operator = (const HTMLTitleElement &other); + HTMLTitleElement & operator = (const Node &other); + + ~HTMLTitleElement(); + + /** + * The specified title as a string. + * + */ + DOMString text() const; + + /** + * see text + */ + void setText( const DOMString & ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_image.cpp b/tdehtml/dom/html_image.cpp new file mode 100644 index 000000000..f7c9dac26 --- /dev/null +++ b/tdehtml/dom/html_image.cpp @@ -0,0 +1,413 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/dom_doc.h" +#include "dom/html_image.h" +#include "dom/html_misc.h" + +#include "html/html_imageimpl.h" +#include "html/html_miscimpl.h" +#include "misc/htmlhashes.h" +#include "xml/dom_docimpl.h" + +using namespace DOM; + +HTMLAreaElement::HTMLAreaElement() : HTMLElement() +{ +} + +HTMLAreaElement::HTMLAreaElement(const HTMLAreaElement &other) : HTMLElement(other) +{ +} + +HTMLAreaElement::HTMLAreaElement(HTMLAreaElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLAreaElement &HTMLAreaElement::operator = (const Node &other) +{ + assignOther( other, ID_AREA ); + return *this; +} + +HTMLAreaElement &HTMLAreaElement::operator = (const HTMLAreaElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLAreaElement::~HTMLAreaElement() +{ +} + +DOMString HTMLAreaElement::accessKey() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLAreaElement::setAccessKey( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +DOMString HTMLAreaElement::alt() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); +} + +void HTMLAreaElement::setAlt( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); +} + +DOMString HTMLAreaElement::coords() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_COORDS); +} + +void HTMLAreaElement::setCoords( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_COORDS, value); +} + +DOMString HTMLAreaElement::href() const +{ + if(!impl) return DOMString(); + DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF); + return !href.isNull() ? impl->getDocument()->completeURL(href.string()) : href; +} + +void HTMLAreaElement::setHref( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value); +} + +bool HTMLAreaElement::noHref() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_NOHREF).isNull(); +} + +void HTMLAreaElement::setNoHref( bool _noHref ) +{ + if(impl) + { + DOMString str; + if( _noHref ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_NOHREF, str); + } +} + +DOMString HTMLAreaElement::shape() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SHAPE); +} + +void HTMLAreaElement::setShape( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SHAPE, value); +} + +long HTMLAreaElement::tabIndex() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt(); +} + +void HTMLAreaElement::setTabIndex( long _tabIndex ) +{ + if(impl) { + DOMString value(TQString::number(_tabIndex)); + ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX,value); + } +} + +DOMString HTMLAreaElement::target() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET); +} + +void HTMLAreaElement::setTarget( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value); +} + +// -------------------------------------------------------------------------- + +HTMLImageElement::HTMLImageElement() : HTMLElement() +{ +} + +HTMLImageElement::HTMLImageElement(const HTMLImageElement &other) : HTMLElement(other) +{ +} + +HTMLImageElement::HTMLImageElement(HTMLImageElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLImageElement &HTMLImageElement::operator = (const Node &other) +{ + assignOther( other, ID_IMG ); + return *this; +} + +HTMLImageElement &HTMLImageElement::operator = (const HTMLImageElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLImageElement::~HTMLImageElement() +{ +} + +DOMString HTMLImageElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLImageElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLImageElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLImageElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLImageElement::alt() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); +} + +void HTMLImageElement::setAlt( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); +} + +long HTMLImageElement::border() const +{ + if(!impl) return 0; + // ### return value in pixels + return static_cast<HTMLImageElementImpl*>(impl)->getAttribute(ATTR_BORDER).toInt(); +} + +void HTMLImageElement::setBorder( long value ) +{ + if (impl) static_cast<HTMLImageElementImpl*>(impl)->setAttribute(ATTR_BORDER, TQString::number(value)); +} + +DOMString HTMLImageElement::getBorder() const +{ + if(!impl) return DOMString(); + return static_cast<HTMLImageElementImpl*>(impl)->getAttribute(ATTR_BORDER); +} + +void HTMLImageElement::setBorder( const DOMString& value ) +{ + if (impl) static_cast<HTMLImageElementImpl*>(impl)->setAttribute(ATTR_BORDER, value); +} + + +long HTMLImageElement::height() const +{ + if(!impl) return 0; + return static_cast<HTMLImageElementImpl*>(impl)->height(); +} + +void HTMLImageElement::setHeight( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HEIGHT, TQString::number(value)); +} + +long HTMLImageElement::hspace() const +{ + if(!impl) return 0; + // ### return actual value + return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE).toInt(); +} + +void HTMLImageElement::setHspace( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, TQString::number(value)); +} + +bool HTMLImageElement::isMap() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull(); +} + +void HTMLImageElement::setIsMap( bool _isMap ) +{ + if(impl) + { + DOMString str; + if( _isMap ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_ISMAP, str); + } +} + +DOMString HTMLImageElement::longDesc() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_LONGDESC); +} + +void HTMLImageElement::setLongDesc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LONGDESC, value); +} + +DOMString HTMLImageElement::src() const +{ + if(!impl) return DOMString(); + DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC); + return !s.isNull() ? impl->getDocument()->completeURL( s.string() ) : s; +} + +void HTMLImageElement::setSrc( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value); +} + +DOMString HTMLImageElement::useMap() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_USEMAP); +} + +void HTMLImageElement::setUseMap( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_USEMAP, value); +} + +long HTMLImageElement::vspace() const +{ + if(!impl) return 0; + // ### return actual vspace + return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE).toInt(); +} + +void HTMLImageElement::setVspace( long value ) +{ + if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_VSPACE, TQString::number(value)); +} + +long HTMLImageElement::width() const +{ + if(!impl) return 0; + return static_cast<HTMLImageElementImpl*>(impl)->width(); +} + +void HTMLImageElement::setWidth( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, TQString::number(value)); +} + +long HTMLImageElement::x() const +{ + if (impl && impl->renderer()) { + int x = 0; + int y = 0; + impl->renderer()->absolutePosition(x,y); + return x; + } + return 0; +} + +long HTMLImageElement::y() const +{ + if (impl && impl->renderer()) { + int x = 0; + int y = 0; + impl->renderer()->absolutePosition(x,y); + return y; + } + return 0; +} + +// -------------------------------------------------------------------------- + +HTMLMapElement::HTMLMapElement() : HTMLElement() +{ +} + +HTMLMapElement::HTMLMapElement(const HTMLMapElement &other) : HTMLElement(other) +{ +} + +HTMLMapElement::HTMLMapElement(HTMLMapElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLMapElement &HTMLMapElement::operator = (const Node &other) +{ + assignOther( other, ID_MAP ); + return *this; +} + +HTMLMapElement &HTMLMapElement::operator = (const HTMLMapElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLMapElement::~HTMLMapElement() +{ +} + +HTMLCollection HTMLMapElement::areas() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::MAP_AREAS); +} + +DOMString HTMLMapElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLMapElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + diff --git a/tdehtml/dom/html_image.h b/tdehtml/dom/html_image.h new file mode 100644 index 000000000..9f30aaa14 --- /dev/null +++ b/tdehtml/dom/html_image.h @@ -0,0 +1,431 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_IMAGE_H +#define HTML_IMAGE_H + +#include <dom/html_element.h> + +#include <kdemacros.h> + +namespace DOM { + +class HTMLAreaElementImpl; +class DOMString; + +/** + * Client-side image map area definition. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#edef-AREA"> + * AREA element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLAreaElement : public HTMLElement +{ +public: + HTMLAreaElement(); + HTMLAreaElement(const HTMLAreaElement &other); + HTMLAreaElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLAreaElement(HTMLAreaElementImpl *impl); +public: + + HTMLAreaElement & operator = (const HTMLAreaElement &other); + HTMLAreaElement & operator = (const Node &other); + + ~HTMLAreaElement(); + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * Alternate text for user agents not rendering the normal content + * of this element. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-alt"> + * alt attribute definition </a> in HTML 4.0. + * + */ + DOMString alt() const; + + /** + * see alt + */ + void setAlt( const DOMString & ); + + /** + * Comma-separated list of lengths, defining an active region + * geometry. See also \c shape for the shape of the + * region. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-coords"> + * coords attribute definition </a> in HTML 4.0. + * + */ + DOMString coords() const; + + /** + * see coords + */ + void setCoords( const DOMString & ); + + /** + * The URI of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-href"> + * href attribute definition </a> in HTML 4.0. + * + */ + DOMString href() const; + + /** + * see href + */ + void setHref( const DOMString & ); + + /** + * Specifies that this area is inactive, i.e., has no associated + * action. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-nohref"> + * nohref attribute definition </a> in HTML 4.0. + * + */ + bool noHref() const; + + /** + * see noHref + */ + void setNoHref( bool ); + + /** + * The shape of the active area. The coordinates are given by + * \c coords . See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-shape"> + * shape attribute definition </a> in HTML 4.0. + * + */ + DOMString shape() const; + + /** + * see shape + */ + void setShape( const DOMString & ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * Frame to render the resource in. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target"> + * target attribute definition </a> in HTML 4.0. + * + */ + DOMString target() const; + + /** + * see target + */ + void setTarget( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLImageElementImpl; + +/** + * Embedded image. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#edef-IMG"> + * IMG element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLImageElement : public HTMLElement +{ +public: + HTMLImageElement(); + HTMLImageElement(const HTMLImageElement &other); + HTMLImageElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLImageElement(HTMLImageElementImpl *impl); +public: + + HTMLImageElement & operator = (const HTMLImageElement &other); + HTMLImageElement & operator = (const Node &other); + + ~HTMLImageElement(); + + /** + * The name of the element (for backwards compatibility). + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Aligns this object (vertically or horizontally) with respect to + * its surrounding text. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-align-IMG"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Alternate text for user agents not rendering the normal content + * of this element. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-alt"> + * alt attribute definition </a> in HTML 4.0. + * + */ + DOMString alt() const; + + /** + * see alt + */ + void setAlt( const DOMString & ); + + /** + * Width of border around image. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-border-IMG"> + * border attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString getBorder() const; + + /** + * see border + */ + void setBorder( const DOMString& ); + + + /** + * @deprecated + */ + long border() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setBorder( long ) KDE_DEPRECATED; + + /** + * Override height. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-height-IMG"> + * height attribute definition </a> in HTML 4.0. + * + */ + long height() const; + + /** + * see height + */ + void setHeight( long ); + + /** + * Horizontal space to the left and right of this image. See the + * <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-hspace"> + * hspace attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long hspace() const; + + /** + * see hspace + */ + void setHspace( long ); + + /** + * Use server-side image map. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-ismap"> + * ismap attribute definition </a> in HTML 4.0. + * + */ + bool isMap() const; + + /** + * see isMap + */ + void setIsMap( bool ); + + /** + * URI designating a long description of this image or frame. See + * the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-longdesc-IMG"> + * longdesc attribute definition </a> in HTML 4.0. + * + */ + DOMString longDesc() const; + + /** + * see longDesc + */ + void setLongDesc( const DOMString & ); + + /** + * URI designating the source of this image. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-src-IMG"> + * src attribute definition </a> in HTML 4.0. + * + */ + DOMString src() const; + + /** + * see src + */ + void setSrc( const DOMString & ); + + /** + * Use client-side image map. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-usemap"> + * usemap attribute definition </a> in HTML 4.0. + * + */ + DOMString useMap() const; + + /** + * see useMap + */ + void setUseMap( const DOMString & ); + + /** + * Vertical space above and below this image. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-vspace"> + * vspace attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long vspace() const; + + /** + * see vspace + */ + void setVspace( long ); + + /** + * Override width. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-width-IMG"> + * width attribute definition </a> in HTML 4.0. + * + */ + long width() const; + + /** + * see width + */ + void setWidth( long ); + + /** + * Nonstandard extension to DOM::ImgElement + */ + long x() const; + long y() const; +}; + +// -------------------------------------------------------------------------- + +class HTMLMapElementImpl; +class HTMLCollection; +class DOMString; + +/** + * Client-side image map. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#edef-MAP"> + * MAP element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLMapElement : public HTMLElement +{ +public: + HTMLMapElement(); + HTMLMapElement(const HTMLMapElement &other); + HTMLMapElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLMapElement(HTMLMapElementImpl *impl); +public: + + HTMLMapElement & operator = (const HTMLMapElement &other); + HTMLMapElement & operator = (const Node &other); + + ~HTMLMapElement(); + + /** + * The list of areas defined for the image map. + * + */ + HTMLCollection areas() const; + + /** + * Names the map (for use with \c usemap ). See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-name-MAP"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_inline.cpp b/tdehtml/dom/html_inline.cpp new file mode 100644 index 000000000..568761685 --- /dev/null +++ b/tdehtml/dom/html_inline.cpp @@ -0,0 +1,434 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2001 Dirk mueller (mueller@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/dom_doc.h" +#include "dom/html_inline.h" +#include "html/html_inlineimpl.h" +#include "html/html_baseimpl.h" +#include "xml/dom_docimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLAnchorElement::HTMLAnchorElement() : HTMLElement() +{ +} + +HTMLAnchorElement::HTMLAnchorElement(const HTMLAnchorElement &other) : HTMLElement(other) +{ +} + +HTMLAnchorElement::HTMLAnchorElement(HTMLAnchorElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLAnchorElement &HTMLAnchorElement::operator = (const Node &other) +{ + assignOther( other, ID_A ); + return *this; +} + +HTMLAnchorElement &HTMLAnchorElement::operator = (const HTMLAnchorElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLAnchorElement::~HTMLAnchorElement() +{ +} + +DOMString HTMLAnchorElement::accessKey() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY); +} + +void HTMLAnchorElement::setAccessKey( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value); +} + +DOMString HTMLAnchorElement::charset() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET); +} + +void HTMLAnchorElement::setCharset( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value); +} + +DOMString HTMLAnchorElement::coords() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_COORDS); +} + +void HTMLAnchorElement::setCoords( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_COORDS, value); +} + +DOMString HTMLAnchorElement::href() const +{ + if(!impl) return DOMString(); + DOMString href = static_cast<ElementImpl*>(impl)->getAttribute(ATTR_HREF); + return !href.isNull() ? impl->getDocument()->completeURL(href.string()) : href; +} + +void HTMLAnchorElement::setHref( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value); +} + +DOMString HTMLAnchorElement::hreflang() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HREFLANG); +} + +void HTMLAnchorElement::setHreflang( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HREFLANG, value); +} + +DOMString HTMLAnchorElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLAnchorElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLAnchorElement::rel() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_REL); +} + +void HTMLAnchorElement::setRel( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_REL, value); +} + +DOMString HTMLAnchorElement::rev() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_REV); +} + +void HTMLAnchorElement::setRev( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_REV, value); +} + +DOMString HTMLAnchorElement::shape() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SHAPE); +} + +void HTMLAnchorElement::setShape( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SHAPE, value); +} + +long HTMLAnchorElement::tabIndex() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt(); +} + +void HTMLAnchorElement::setTabIndex( long _tabIndex ) +{ + if(impl) { + DOMString value(TQString::number(_tabIndex)); + ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX,value); + } +} + +DOMString HTMLAnchorElement::target() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET); +} + +void HTMLAnchorElement::setTarget( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value); +} + +DOMString HTMLAnchorElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLAnchorElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +void HTMLAnchorElement::blur( ) +{ + if(impl && impl->getDocument()->focusNode()==impl) + impl->getDocument()->setFocusNode(0); +} + +void HTMLAnchorElement::focus( ) +{ + if(impl) + impl->getDocument()->setFocusNode(static_cast<ElementImpl*>(impl)); +} + +void HTMLAnchorElement::click( ) +{ + if(impl) ((HTMLAnchorElement *)impl)->click(); +} + + +// -------------------------------------------------------------------------- + +HTMLBRElement::HTMLBRElement() : HTMLElement() +{ +} + +HTMLBRElement::HTMLBRElement(const HTMLBRElement &other) : HTMLElement(other) +{ +} + +HTMLBRElement::HTMLBRElement(HTMLBRElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLBRElement &HTMLBRElement::operator = (const Node &other) +{ + assignOther( other, ID_BR ); + return *this; +} + +HTMLBRElement &HTMLBRElement::operator = (const HTMLBRElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLBRElement::~HTMLBRElement() +{ +} + +DOMString HTMLBRElement::clear() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CLEAR); +} + +void HTMLBRElement::setClear( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLEAR, value); +} + +// -------------------------------------------------------------------------- + +HTMLFontElement::HTMLFontElement() : HTMLElement() +{ +} + +HTMLFontElement::HTMLFontElement(const HTMLFontElement &other) : HTMLElement(other) +{ +} + +HTMLFontElement::HTMLFontElement(HTMLFontElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLFontElement &HTMLFontElement::operator = (const Node &other) +{ + assignOther( other, ID_FONT ); + return *this; +} + +HTMLFontElement &HTMLFontElement::operator = (const HTMLFontElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLFontElement::~HTMLFontElement() +{ +} + +DOMString HTMLFontElement::color() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_COLOR); +} + +void HTMLFontElement::setColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_COLOR, value); +} + +DOMString HTMLFontElement::face() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_FACE); +} + +void HTMLFontElement::setFace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_FACE, value); +} + +DOMString HTMLFontElement::size() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE); +} + +void HTMLFontElement::setSize( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value); +} + + +// -------------------------------------------------------------------------- + +HTMLModElement::HTMLModElement() : HTMLElement() +{ +} + +HTMLModElement::HTMLModElement(const HTMLModElement &other) : HTMLElement(other) +{ +} + +HTMLModElement::HTMLModElement(HTMLElementImpl *_impl) + : HTMLElement() +{ + if (_impl && (_impl->id() == ID_INS || _impl->id() == ID_DEL)) + impl = _impl; + else + impl = 0; + if ( impl ) impl->ref(); +} + +HTMLModElement &HTMLModElement::operator = (const Node &other) +{ + if (other.handle() != handle()) { + if( other.elementId() != ID_INS && + other.elementId() != ID_DEL ) + { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator = (other); + } + } + return *this; +} + +HTMLModElement &HTMLModElement::operator = (const HTMLModElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLModElement::~HTMLModElement() +{ +} + +DOMString HTMLModElement::cite() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CITE); +} + +void HTMLModElement::setCite( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value); +} + +DOMString HTMLModElement::dateTime() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_DATETIME); +} + +void HTMLModElement::setDateTime( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DATETIME, value); +} + +// -------------------------------------------------------------------------- + +HTMLQuoteElement::HTMLQuoteElement() : HTMLElement() +{ +} + +HTMLQuoteElement::HTMLQuoteElement(const HTMLQuoteElement &other) : HTMLElement(other) +{ +} + +HTMLQuoteElement::HTMLQuoteElement(HTMLGenericElementImpl *_impl) + : HTMLElement() +{ + if (_impl && _impl->id() == ID_Q) + impl = _impl; + else + impl = 0; + if ( impl ) impl->ref(); +} + +HTMLQuoteElement &HTMLQuoteElement::operator = (const Node &other) +{ + assignOther( other, ID_Q ); + return *this; +} + +HTMLQuoteElement &HTMLQuoteElement::operator = (const HTMLQuoteElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLQuoteElement::~HTMLQuoteElement() +{ +} + +DOMString HTMLQuoteElement::cite() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CITE); +} + +void HTMLQuoteElement::setCite( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value); +} + diff --git a/tdehtml/dom/html_inline.h b/tdehtml/dom/html_inline.h new file mode 100644 index 000000000..f92ed6917 --- /dev/null +++ b/tdehtml/dom/html_inline.h @@ -0,0 +1,463 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_INLINE_H +#define HTML_INLINE_H + +#include <dom/html_element.h> + +#include <tdelibs_export.h> + +namespace DOM { +class HTMLGenericElementImpl; +class HTMLAnchorElementImpl; +class DOMString; + +/** + * The anchor element. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#edef-A"> A + * element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLAnchorElement : public HTMLElement +{ +public: + HTMLAnchorElement(); + HTMLAnchorElement(const HTMLAnchorElement &other); + HTMLAnchorElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLAnchorElement(HTMLAnchorElementImpl *impl); +public: + + HTMLAnchorElement & operator = (const HTMLAnchorElement &other); + HTMLAnchorElement & operator = (const Node &other); + + ~HTMLAnchorElement(); + + /** + * A single character access key to give access to the form + * control. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey"> + * accesskey attribute definition </a> in HTML 4.0. + * + */ + DOMString accessKey() const; + + /** + * see accessKey + */ + void setAccessKey( const DOMString & ); + + /** + * The character encoding of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-charset"> + * charset attribute definition </a> in HTML 4.0. + * + */ + DOMString charset() const; + + /** + * see charset + */ + void setCharset( const DOMString & ); + + /** + * Comma-separated list of lengths, defining an active region + * geometry. See also \c shape for the shape of the + * region. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-coords"> + * coords attribute definition </a> in HTML 4.0. + * + */ + DOMString coords() const; + + /** + * see coords + */ + void setCoords( const DOMString & ); + + /** + * The URI of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-href"> + * href attribute definition </a> in HTML 4.0. + * + */ + DOMString href() const; + + /** + * see href + */ + void setHref( const DOMString & ); + + /** + * Language code of the linked resource. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-hreflang"> + * hreflang attribute definition </a> in HTML 4.0. + * + */ + DOMString hreflang() const; + + /** + * see hreflang + */ + void setHreflang( const DOMString & ); + + /** + * Anchor name. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-name-A"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Forward link type. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-rel"> + * rel attribute definition </a> in HTML 4.0. + * + */ + DOMString rel() const; + + /** + * see rel + */ + void setRel( const DOMString & ); + + /** + * Reverse link type. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-rev"> + * rev attribute definition </a> in HTML 4.0. + * + */ + DOMString rev() const; + + /** + * see rev + */ + void setRev( const DOMString & ); + + /** + * The shape of the active area. The coordinates are given by + * \c coords . See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-shape"> + * shape attribute definition </a> in HTML 4.0. + * + */ + DOMString shape() const; + + /** + * see shape + */ + void setShape( const DOMString & ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * Frame to render the resource in. See the <a + * href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target"> + * target attribute definition </a> in HTML 4.0. + * + */ + DOMString target() const; + + /** + * see target + */ + void setTarget( const DOMString & ); + + /** + * Advisory content type. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/links.html#adef-type-A"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); + + /** + * Removes keyboard focus from this element. + * + * @return + * + */ + void blur ( ); + + /** + * Gives keyboard focus to this element. + * + * @return + * + */ + void focus ( ); + + /** + * Simulate a mouse-click. + * NOTE: this method is not part of the DOM + * @since 3.5.7 + */ + void click ( ); + +}; + +// -------------------------------------------------------------------------- + +class HTMLBRElementImpl; + +/** + * Force a line break. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-BR"> BR + * element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLBRElement : public HTMLElement +{ +public: + HTMLBRElement(); + HTMLBRElement(const HTMLBRElement &other); + HTMLBRElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLBRElement(HTMLBRElementImpl *impl); +public: + + HTMLBRElement & operator = (const HTMLBRElement &other); + HTMLBRElement & operator = (const Node &other); + + ~HTMLBRElement(); + + /** + * Control flow of text around floats. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-clear"> + * clear attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString clear() const; + + /** + * see clear + */ + void setClear( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLFontElementImpl; +class DOMString; + +/** + * Local change to font. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#edef-FONT"> + * FONT element definition </a> in HTML 4.0. This element is + * deprecated in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLFontElement : public HTMLElement +{ +public: + HTMLFontElement(); + HTMLFontElement(const HTMLFontElement &other); + HTMLFontElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLFontElement(HTMLFontElementImpl *impl); +public: + + HTMLFontElement & operator = (const HTMLFontElement &other); + HTMLFontElement & operator = (const Node &other); + + ~HTMLFontElement(); + + /** + * Font color. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-color-FONT"> + * color attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString color() const; + + /** + * see color + */ + void setColor( const DOMString & ); + + /** + * Font face identifier. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-face-FONT"> + * face attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString face() const; + + /** + * see face + */ + void setFace( const DOMString & ); + + /** + * Font size. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-size-FONT"> + * size attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString size() const; + + /** + * see size + */ + void setSize( const DOMString & ); +}; + +class HTMLModElementImpl; +class DOMString; + +/** + * Notice of modification to part of a document. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-ins"> + * INS </a> and <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-del"> + * DEL </a> element definitions in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLModElement : public HTMLElement +{ +public: + HTMLModElement(); + HTMLModElement(const HTMLModElement &other); + HTMLModElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLModElement(HTMLElementImpl *impl); +public: + + HTMLModElement & operator = (const HTMLModElement &other); + HTMLModElement & operator = (const Node &other); + + ~HTMLModElement(); + + /** + * A URI designating a document that describes the reason for the + * change. See the <a href="http://www.w3.org/TR/REC-html40/"> + * cite attribute definition </a> in HTML 4.0. + * + */ + DOMString cite() const; + + /** + * see cite + */ + void setCite( const DOMString & ); + + /** + * The date and time of the change. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#adef-datetime"> + * datetime attribute definition </a> in HTML 4.0. + * + */ + DOMString dateTime() const; + + /** + * see dateTime + */ + void setDateTime( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLQuoteElementImpl; + +/** + * For the \c Q and \c BLOCKQUOTE elements. + * See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-Q"> Q + * element definition </a> in HTML 4.0. + * + * Note: The DOM is not quite consistent here. They also define the + * HTMLBlockQuoteElement interface, to represent the \c BLOCKQUOTE + * element. To resolve ambiquities, we use this one for the \c Q + * element only. + */ +class KHTML_EXPORT HTMLQuoteElement : public HTMLElement +{ +public: + HTMLQuoteElement(); + HTMLQuoteElement(const HTMLQuoteElement &other); + HTMLQuoteElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLQuoteElement(HTMLGenericElementImpl *impl); +public: + + HTMLQuoteElement & operator = (const HTMLQuoteElement &other); + HTMLQuoteElement & operator = (const Node &other); + + ~HTMLQuoteElement(); + + /** + * A URI designating a document that designates a source document + * or message. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/text.html#adef-cite-Q"> + * cite attribute definition </a> in HTML 4.0. + * + */ + DOMString cite() const; + + /** + * see cite + */ + void setCite( const DOMString & ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_list.cpp b/tdehtml/dom/html_list.cpp new file mode 100644 index 000000000..8d66fe3fc --- /dev/null +++ b/tdehtml/dom/html_list.cpp @@ -0,0 +1,354 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/html_list.h" +#include "html/html_listimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLDListElement::HTMLDListElement() : HTMLElement() +{ +} + +HTMLDListElement::HTMLDListElement(const HTMLDListElement &other) : HTMLElement(other) +{ +} + +HTMLDListElement::HTMLDListElement(HTMLDListElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLDListElement &HTMLDListElement::operator = (const Node &other) +{ + assignOther( other, ID_DL ); + return *this; +} + +HTMLDListElement &HTMLDListElement::operator = (const HTMLDListElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLDListElement::~HTMLDListElement() +{ +} + +bool HTMLDListElement::compact() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull(); +} + +void HTMLDListElement::setCompact( bool _compact ) +{ + if(impl) + { + DOMString str; + if( _compact ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str); + } +} + +// -------------------------------------------------------------------------- + +HTMLDirectoryElement::HTMLDirectoryElement() : HTMLElement() +{ +} + +HTMLDirectoryElement::HTMLDirectoryElement(const HTMLDirectoryElement &other) : HTMLElement(other) +{ +} + +HTMLDirectoryElement::HTMLDirectoryElement(HTMLDirectoryElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLDirectoryElement &HTMLDirectoryElement::operator = (const Node &other) +{ + assignOther( other, ID_DIR ); + return *this; +} + +HTMLDirectoryElement &HTMLDirectoryElement::operator = (const HTMLDirectoryElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLDirectoryElement::~HTMLDirectoryElement() +{ +} + +bool HTMLDirectoryElement::compact() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull(); +} + +void HTMLDirectoryElement::setCompact( bool _compact ) +{ + if(impl) + { + DOMString str; + if( _compact ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str); + } +} + +// -------------------------------------------------------------------------- + +HTMLLIElement::HTMLLIElement() : HTMLElement() +{ +} + +HTMLLIElement::HTMLLIElement(const HTMLLIElement &other) : HTMLElement(other) +{ +} + +HTMLLIElement::HTMLLIElement(HTMLLIElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLLIElement &HTMLLIElement::operator = (const Node &other) +{ + assignOther( other, ID_LI ); + return *this; +} + +HTMLLIElement &HTMLLIElement::operator = (const HTMLLIElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLLIElement::~HTMLLIElement() +{ +} + +DOMString HTMLLIElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLLIElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +long HTMLLIElement::value() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_VALUE).toInt(); +} + +void HTMLLIElement::setValue( long _value ) +{ + if(impl) { + DOMString value(TQString::number(_value)); + ((ElementImpl *)impl)->setAttribute(ATTR_VALUE,value); + } +} + +// -------------------------------------------------------------------------- + +HTMLMenuElement::HTMLMenuElement() : HTMLElement() +{ +} + +HTMLMenuElement::HTMLMenuElement(const HTMLMenuElement &other) : HTMLElement(other) +{ +} + +HTMLMenuElement::HTMLMenuElement(HTMLMenuElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLMenuElement &HTMLMenuElement::operator = (const Node &other) +{ + assignOther( other, ID_MENU ); + return *this; +} + +HTMLMenuElement &HTMLMenuElement::operator = (const HTMLMenuElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLMenuElement::~HTMLMenuElement() +{ +} + +bool HTMLMenuElement::compact() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull(); +} + +void HTMLMenuElement::setCompact( bool _compact ) +{ + if(impl) + { + DOMString str; + if( _compact ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str); + } +} + +// -------------------------------------------------------------------------- + +HTMLOListElement::HTMLOListElement() : HTMLElement() +{ +} + +HTMLOListElement::HTMLOListElement(const HTMLOListElement &other) : HTMLElement(other) +{ +} + +HTMLOListElement::HTMLOListElement(HTMLOListElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLOListElement &HTMLOListElement::operator = (const Node &other) +{ + assignOther( other, ID_OL ); + return *this; +} + +HTMLOListElement &HTMLOListElement::operator = (const HTMLOListElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLOListElement::~HTMLOListElement() +{ +} + +bool HTMLOListElement::compact() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull(); +} + +void HTMLOListElement::setCompact( bool _compact ) +{ + if(impl) + { + DOMString str; + if( _compact ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str); + } +} + +long HTMLOListElement::start() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_START).toInt(); +} + +void HTMLOListElement::setStart( long _start ) +{ + + if(impl) { + DOMString value(TQString::number(_start)); + ((ElementImpl *)impl)->setAttribute(ATTR_START,value); + } +} + +DOMString HTMLOListElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLOListElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +// -------------------------------------------------------------------------- + +HTMLUListElement::HTMLUListElement() : HTMLElement() +{ +} + +HTMLUListElement::HTMLUListElement(const HTMLUListElement &other) : HTMLElement(other) +{ +} + +HTMLUListElement::HTMLUListElement(HTMLUListElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLUListElement &HTMLUListElement::operator = (const Node &other) +{ + assignOther( other, ID_UL ); + return *this; +} + +HTMLUListElement &HTMLUListElement::operator = (const HTMLUListElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLUListElement::~HTMLUListElement() +{ +} + +bool HTMLUListElement::compact() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull(); +} + +void HTMLUListElement::setCompact( bool _compact ) +{ + if(impl) + { + DOMString str; + if( _compact ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str); + } +} + +DOMString HTMLUListElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLUListElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + diff --git a/tdehtml/dom/html_list.h b/tdehtml/dom/html_list.h new file mode 100644 index 000000000..34c081cb5 --- /dev/null +++ b/tdehtml/dom/html_list.h @@ -0,0 +1,341 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_LIST_H +#define HTML_LIST_H + +#include <dom/html_element.h> +#include <tdelibs_export.h> + +namespace DOM { + +class HTMLDListElementImpl; +class HTMLUListElementImpl; +class HTMLOListElementImpl; +class HTMLDirectoryElementImpl; +class HTMLMenuElementImpl; +class HTMLLIElementImpl; + +class DOMString; + +/** + * Definition list. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#edef-DL"> + * DL element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLDListElement : public HTMLElement +{ +public: + HTMLDListElement(); + HTMLDListElement(const HTMLDListElement &other); + HTMLDListElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLDListElement(HTMLDListElementImpl *impl); +public: + + HTMLDListElement & operator = (const HTMLDListElement &other); + HTMLDListElement & operator = (const Node &other); + + ~HTMLDListElement(); + + /** + * Reduce spacing between list items. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-compact"> + * compact attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + bool compact() const; + + /** + * see compact + */ + void setCompact( bool ); +}; + +// -------------------------------------------------------------------------- + +/** + * Directory list. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#edef-DIR"> + * DIR element definition </a> in HTML 4.0. This element is deprecated + * in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLDirectoryElement : public HTMLElement +{ +public: + HTMLDirectoryElement(); + HTMLDirectoryElement(const HTMLDirectoryElement &other); + HTMLDirectoryElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLDirectoryElement(HTMLDirectoryElementImpl *impl); +public: + + HTMLDirectoryElement & operator = (const HTMLDirectoryElement &other); + HTMLDirectoryElement & operator = (const Node &other); + + ~HTMLDirectoryElement(); + + /** + * Reduce spacing between list items. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-compact"> + * compact attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + bool compact() const; + + /** + * see compact + */ + void setCompact( bool ); +}; + +// -------------------------------------------------------------------------- + +/** + * List item. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#edef-LI"> + * LI element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLLIElement : public HTMLElement +{ +public: + HTMLLIElement(); + HTMLLIElement(const HTMLLIElement &other); + HTMLLIElement(const Node &other) : HTMLElement() + {(*this)=other;} + +protected: + HTMLLIElement(HTMLLIElementImpl *impl); +public: + + HTMLLIElement & operator = (const HTMLLIElement &other); + HTMLLIElement & operator = (const Node &other); + + ~HTMLLIElement(); + + /** + * List item bullet style. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-type-LI"> + * type attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); + + /** + * Reset sequence number when used in \c OL See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-value-LI"> + * value attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long value() const; + + /** + * see value + */ + void setValue( long ); +}; + +// -------------------------------------------------------------------------- + +/** + * Menu list. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#edef-MENU"> + * MENU element definition </a> in HTML 4.0. This element is + * deprecated in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLMenuElement : public HTMLElement +{ +public: + HTMLMenuElement(); + HTMLMenuElement(const HTMLMenuElement &other); + HTMLMenuElement(const Node &other) : HTMLElement() + {(*this)=other;} + +protected: + HTMLMenuElement(HTMLMenuElementImpl *impl); +public: + + HTMLMenuElement & operator = (const HTMLMenuElement &other); + HTMLMenuElement & operator = (const Node &other); + + ~HTMLMenuElement(); + + /** + * Reduce spacing between list items. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-compact"> + * compact attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + bool compact() const; + + /** + * see compact + */ + void setCompact( bool ); +}; + +// -------------------------------------------------------------------------- + +/** + * Ordered list. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#edef-OL"> + * OL element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLOListElement : public HTMLElement +{ +public: + HTMLOListElement(); + HTMLOListElement(const HTMLOListElement &other); + HTMLOListElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLOListElement(HTMLOListElementImpl *impl); +public: + + HTMLOListElement & operator = (const HTMLOListElement &other); + HTMLOListElement & operator = (const Node &other); + + ~HTMLOListElement(); + + /** + * Reduce spacing between list items. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-compact"> + * compact attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + bool compact() const; + + /** + * see compact + */ + void setCompact( bool ); + + /** + * Starting sequence number. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-start"> + * start attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long start() const; + + /** + * see start + */ + void setStart( long ); + + /** + * Numbering style. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-type-OL"> + * type attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + + +/** + * Unordered list. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#edef-UL"> + * UL element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLUListElement : public HTMLElement +{ +public: + HTMLUListElement(); + HTMLUListElement(const HTMLUListElement &other); + HTMLUListElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLUListElement(HTMLUListElementImpl *impl); +public: + + HTMLUListElement & operator = (const HTMLUListElement &other); + HTMLUListElement & operator = (const Node &other); + + ~HTMLUListElement(); + + /** + * Reduce spacing between list items. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-compact"> + * compact attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + bool compact() const; + + /** + * see compact + */ + void setCompact( bool ); + + /** + * Bullet style. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/lists.html#adef-type-UL"> + * type attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_misc.cpp b/tdehtml/dom/html_misc.cpp new file mode 100644 index 000000000..fb975b7cf --- /dev/null +++ b/tdehtml/dom/html_misc.cpp @@ -0,0 +1,214 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/html_misc.h" +#include "html/html_miscimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLBaseFontElement::HTMLBaseFontElement() : HTMLElement() +{ +} + +HTMLBaseFontElement::HTMLBaseFontElement(const HTMLBaseFontElement &other) : HTMLElement(other) +{ +} + +HTMLBaseFontElement::HTMLBaseFontElement(HTMLBaseFontElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLBaseFontElement &HTMLBaseFontElement::operator = (const Node &other) +{ + assignOther( other, ID_BASEFONT ); + return *this; +} + +HTMLBaseFontElement &HTMLBaseFontElement::operator = (const HTMLBaseFontElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLBaseFontElement::~HTMLBaseFontElement() +{ +} + +DOMString HTMLBaseFontElement::color() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_COLOR); +} + +void HTMLBaseFontElement::setColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_COLOR, value); +} + +DOMString HTMLBaseFontElement::face() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_FACE); +} + +void HTMLBaseFontElement::setFace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_FACE, value); +} + +DOMString HTMLBaseFontElement::size() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE); +} + +void HTMLBaseFontElement::setSize( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value); +} + +long HTMLBaseFontElement::getSize() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE).toInt(); +} + +void HTMLBaseFontElement::setSize( long _value ) +{ + if ( impl ) + { + DOMString value( TQString::number( _value ) ); + ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value); + } +} + + +// -------------------------------------------------------------------------- + +HTMLCollection::HTMLCollection() + : impl(0) +{ +} + +HTMLCollection::HTMLCollection(const HTMLCollection &other) +{ + impl = other.impl; + if(impl) impl->ref(); +} + +HTMLCollection::HTMLCollection(NodeImpl *base, int type) +{ + impl = new HTMLCollectionImpl(base, type); + impl->ref(); +} + +HTMLCollection &HTMLCollection::operator = (const HTMLCollection &other) +{ + if(impl != other.impl) { + if(impl) impl->deref(); + impl = other.impl; + if(impl) impl->ref(); + } + return *this; +} + +HTMLCollection::~HTMLCollection() +{ + if(impl) impl->deref(); +} + +unsigned long HTMLCollection::length() const +{ + if(!impl) return 0; + return ((HTMLCollectionImpl *)impl)->length(); +} + +Node HTMLCollection::item( unsigned long index ) const +{ + if(!impl) return 0; + return ((HTMLCollectionImpl *)impl)->item( index ); +} + +Node HTMLCollection::namedItem( const DOMString &name ) const +{ + if(!impl) return 0; + return ((HTMLCollectionImpl *)impl)->namedItem( name ); +} + +Node HTMLCollection::base() const +{ + if ( !impl ) + return 0; + + return static_cast<HTMLCollectionImpl*>( impl )->m_refNode; +} + +Node HTMLCollection::firstItem() const +{ + if ( !impl ) + return 0; + return static_cast<HTMLCollectionImpl*>( impl )->firstItem(); +} + +Node HTMLCollection::nextItem() const +{ + if ( !impl ) + return 0; + return static_cast<HTMLCollectionImpl*>( impl )->nextItem(); +} + +Node HTMLCollection::nextNamedItem( const DOMString &name ) const +{ + if ( !impl ) + return 0; + return static_cast<HTMLCollectionImpl*>( impl )->nextNamedItem( name ); +} + +HTMLCollectionImpl *HTMLCollection::handle() const +{ + return impl; +} + +bool HTMLCollection::isNull() const +{ + return (impl == 0); +} + + +// ----------------------------------------------------------------------------- + +HTMLFormCollection::HTMLFormCollection(NodeImpl *base) + : HTMLCollection() +{ + impl = new HTMLFormCollectionImpl(base); + impl->ref(); +} + + +// ----------------------------------------------------------------------------- +HTMLMappedNameCollection::HTMLMappedNameCollection(NodeImpl *base, int type, const DOMString &name ) +{ + impl = new HTMLMappedNameCollectionImpl(base, type, name); + impl->ref(); +} diff --git a/tdehtml/dom/html_misc.h b/tdehtml/dom/html_misc.h new file mode 100644 index 000000000..643e5caf6 --- /dev/null +++ b/tdehtml/dom/html_misc.h @@ -0,0 +1,222 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_MISC_H +#define HTML_MISC_H + +#include <dom/html_element.h> +#include <tdelibs_export.h> + +namespace DOM { + +class HTMLBaseFontElementImpl; +class DOMString; +class HTMLCollectionImpl; + +/** + * Base font. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#edef-BASEFONT"> + * BASEFONT element definition </a> in HTML 4.0. This element is + * deprecated in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLBaseFontElement : public HTMLElement +{ +public: + HTMLBaseFontElement(); + HTMLBaseFontElement(const HTMLBaseFontElement &other); + HTMLBaseFontElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLBaseFontElement(HTMLBaseFontElementImpl *impl); +public: + + HTMLBaseFontElement & operator = (const HTMLBaseFontElement &other); + HTMLBaseFontElement & operator = (const Node &other); + + ~HTMLBaseFontElement(); + + /** + * Font color. See the <a href="http://www.w3.org/TR/REC-html40/"> + * color attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString color() const; + + /** + * see color + */ + void setColor( const DOMString & ); + + /** + * Font face identifier. See the <a + * href="http://www.w3.org/TR/REC-html40/"> face attribute + * definition </a> in HTML 4.0. This attribute is deprecated in + * HTML 4.0. + * + */ + DOMString face() const; + + /** + * see face + */ + void setFace( const DOMString & ); + + /** + * Computed Font size. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-size-BASEFONT"> + * size attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long getSize() const; + + /** + * see size + */ + void setSize( long ); + + /** + * @deprecated + */ + DOMString size() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setSize( const DOMString & ) KDE_DEPRECATED; +}; + +// -------------------------------------------------------------------------- + +/** + * An \c HTMLCollection is a list of nodes. An individual + * node may be accessed by either ordinal index or the node's + * \c name or \c id attributes. Note: Collections in + * the HTML DOM are assumed to be live meaning that they are + * automatically updated when the underlying document is changed. + * + */ +class KHTML_EXPORT HTMLCollection +{ + friend class HTMLDocument; + friend class HTMLSelectElement; + friend class HTMLImageElement; + friend class HTMLMapElement; + friend class HTMLTableElement; + friend class HTMLTableRowElement; + friend class HTMLTableSectionElement; + friend class HTMLLayerElement; + friend class HTMLElement; + +public: + HTMLCollection(); + HTMLCollection(const HTMLCollection &other); +protected: + HTMLCollection(NodeImpl *base, int type); +public: + + HTMLCollection & operator = (const HTMLCollection &other); + + ~HTMLCollection(); + + /** + * This attribute specifies the length or size of the list. + * + */ + unsigned long length() const; + + /** + * This method retrieves a node specified by ordinal index. Nodes + * are numbered in tree order (depth-first traversal order). + * + * @param index The index of the node to be fetched. The index + * origin is 0. + * + * @return The \c Node at the corresponding position + * upon success. A value of \c null is returned if the + * index is out of range. + * + */ + Node item ( unsigned long index ) const; + + /** + * This method retrieves a \c Node using a name. It + * first searches for a \c Node with a matching + * \c id attribute. If it doesn't find one, it then searches + * for a \c Node with a matching \c name + * attribute, but only on those elements that are allowed a name + * attribute. + * + * @param name The name of the \c Node to be fetched. + * + * @return The \c Node with a \c name or + * \c id attribute whose value corresponds to the + * specified string. Upon failure (e.g., no node with this name + * exists), returns \c null . + * + */ + Node namedItem ( const DOMString &name ) const; + + /** + * @internal + * not part of the DOM + */ + Node base() const; + HTMLCollectionImpl *handle() const; + bool isNull() const; + // Fast iteration + Node firstItem() const; + Node nextItem() const; + // In case of multiple items named the same way + Node nextNamedItem( const DOMString &name ) const; + +protected: + HTMLCollectionImpl *impl; +}; + +class KHTML_EXPORT HTMLFormCollection : public HTMLCollection +{ + friend class HTMLFormElement; +protected: + HTMLFormCollection(NodeImpl *base); +}; + +/** + @internal. Not part of the public API +*/ +class KHTML_EXPORT HTMLMappedNameCollection : public HTMLCollection +{ +public: + HTMLMappedNameCollection(NodeImpl *base, int type, const DOMString &name ); +}; + +} //namespace + +#endif diff --git a/tdehtml/dom/html_object.cpp b/tdehtml/dom/html_object.cpp new file mode 100644 index 000000000..65ec2f34e --- /dev/null +++ b/tdehtml/dom/html_object.cpp @@ -0,0 +1,535 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "dom/dom_doc.h" +#include "dom/html_object.h" +#include "html/html_objectimpl.h" +#include "misc/htmlhashes.h" + +HTMLAppletElement::HTMLAppletElement() : HTMLElement() +{ +} + +HTMLAppletElement::HTMLAppletElement(const HTMLAppletElement &other) + : HTMLElement(other) +{ +} + +HTMLAppletElement::HTMLAppletElement(HTMLAppletElementImpl *impl) + : HTMLElement(impl) +{ +} + +HTMLAppletElement &HTMLAppletElement::operator = (const Node &other) +{ + assignOther( other, ID_APPLET ); + return *this; +} + +HTMLAppletElement &HTMLAppletElement::operator = (const HTMLAppletElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLAppletElement::~HTMLAppletElement() +{ +} + +DOMString HTMLAppletElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLAppletElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLAppletElement::alt() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); +} + +void HTMLAppletElement::setAlt( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); +} + +DOMString HTMLAppletElement::archive() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ARCHIVE); +} + +void HTMLAppletElement::setArchive( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ARCHIVE, value); +} + +DOMString HTMLAppletElement::code() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CODE); +} + +void HTMLAppletElement::setCode( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CODE, value); +} + +DOMString HTMLAppletElement::codeBase() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CODEBASE); +} + +void HTMLAppletElement::setCodeBase( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CODEBASE, value); +} + +DOMString HTMLAppletElement::height() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HEIGHT); +} + +void HTMLAppletElement::setHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HEIGHT, value); +} + +DOMString HTMLAppletElement::hspace() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE); +} + +void HTMLAppletElement::setHspace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, value); +} + +long HTMLAppletElement::getHspace() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE).toInt(); +} + +void HTMLAppletElement::setHspace( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, TQString::number(value)); +} + +DOMString HTMLAppletElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLAppletElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLAppletElement::object() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_OBJECT); +} + +void HTMLAppletElement::setObject( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_OBJECT, value); +} + +DOMString HTMLAppletElement::vspace() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE); +} + +void HTMLAppletElement::setVspace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VSPACE, value); +} + +long HTMLAppletElement::getVspace() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE).toInt(); +} + +void HTMLAppletElement::setVspace( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VSPACE, TQString::number(value)); +} + + +DOMString HTMLAppletElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLAppletElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +// -------------------------------------------------------------------------- + +HTMLObjectElement::HTMLObjectElement() : HTMLElement() +{ +} + +HTMLObjectElement::HTMLObjectElement(const HTMLObjectElement &other) : HTMLElement(other) +{ +} + +HTMLObjectElement::HTMLObjectElement(HTMLObjectElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLObjectElement &HTMLObjectElement::operator = (const Node &other) +{ + assignOther( other, ID_OBJECT ); + return *this; +} + +HTMLObjectElement &HTMLObjectElement::operator = (const HTMLObjectElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLObjectElement::~HTMLObjectElement() +{ +} + +HTMLFormElement HTMLObjectElement::form() const +{ + if(!impl) return 0; + return ((HTMLObjectElementImpl *)impl)->form(); +} + +DOMString HTMLObjectElement::code() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CODE); +} + +void HTMLObjectElement::setCode( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CODE, value); +} + +DOMString HTMLObjectElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLObjectElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLObjectElement::archive() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ARCHIVE); +} + +void HTMLObjectElement::setArchive( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ARCHIVE, value); +} + +DOMString HTMLObjectElement::border() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BORDER); +} + +void HTMLObjectElement::setBorder( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BORDER, value); +} + +DOMString HTMLObjectElement::codeBase() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CODEBASE); +} + +void HTMLObjectElement::setCodeBase( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CODEBASE, value); +} + +DOMString HTMLObjectElement::codeType() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CODETYPE); +} + +void HTMLObjectElement::setCodeType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CODETYPE, value); +} + +DOMString HTMLObjectElement::data() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_DATA); +} + +void HTMLObjectElement::setData( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DATA, value); +} + +bool HTMLObjectElement::declare() const +{ + if(!impl) return 0; + return !((ElementImpl *)impl)->getAttribute(ATTR_DECLARE).isNull(); +} + +void HTMLObjectElement::setDeclare( bool _declare ) +{ + if(impl) + { + DOMString str; + if( _declare ) + str = ""; + ((ElementImpl *)impl)->setAttribute(ATTR_DECLARE, str); + } +} + +DOMString HTMLObjectElement::height() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HEIGHT); +} + +void HTMLObjectElement::setHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HEIGHT, value); +} + +DOMString HTMLObjectElement::hspace() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE); +} + +void HTMLObjectElement::setHspace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, value); +} + +long HTMLObjectElement::getHspace() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE).toInt(); +} + +void HTMLObjectElement::setHspace( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, TQString::number(value)); +} + +DOMString HTMLObjectElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLObjectElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLObjectElement::standby() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_STANDBY); +} + +void HTMLObjectElement::setStandby( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_STANDBY, value); +} + +long HTMLObjectElement::tabIndex() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt(); +} + +void HTMLObjectElement::setTabIndex( long _tabIndex ) +{ + if(impl) { + DOMString value(TQString::number(_tabIndex)); + ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX,value); + } +} + +DOMString HTMLObjectElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLObjectElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +DOMString HTMLObjectElement::useMap() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_USEMAP); +} + +void HTMLObjectElement::setUseMap( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_USEMAP, value); +} + +DOMString HTMLObjectElement::vspace() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE); +} + +void HTMLObjectElement::setVspace( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VSPACE, value); +} + +long HTMLObjectElement::getVspace() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE).toInt(); +} + +void HTMLObjectElement::setVspace( long value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VSPACE, TQString::number(value)); +} + +DOMString HTMLObjectElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLObjectElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +Document HTMLObjectElement::contentDocument() const +{ + if (impl) return static_cast<HTMLObjectElementImpl*>(impl)->contentDocument(); + return Document(); +} + +// -------------------------------------------------------------------------- + +HTMLParamElement::HTMLParamElement() : HTMLElement() +{ +} + +HTMLParamElement::HTMLParamElement(const HTMLParamElement &other) : HTMLElement(other) +{ +} + +HTMLParamElement::HTMLParamElement(HTMLParamElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLParamElement &HTMLParamElement::operator = (const Node &other) +{ + assignOther( other, ID_PARAM ); + return *this; +} + +HTMLParamElement &HTMLParamElement::operator = (const HTMLParamElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLParamElement::~HTMLParamElement() +{ +} + +DOMString HTMLParamElement::name() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); +} + +void HTMLParamElement::setName( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); +} + +DOMString HTMLParamElement::type() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE); +} + +void HTMLParamElement::setType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value); +} + +DOMString HTMLParamElement::value() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VALUE); +} + +void HTMLParamElement::setValue( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALUE, value); +} + +DOMString HTMLParamElement::valueType() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VALUETYPE); +} + +void HTMLParamElement::setValueType( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALUETYPE, value); +} + diff --git a/tdehtml/dom/html_object.h b/tdehtml/dom/html_object.h new file mode 100644 index 000000000..9195a40f7 --- /dev/null +++ b/tdehtml/dom/html_object.h @@ -0,0 +1,630 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ + +// -------------------------------------------------------------------------- + +#ifndef HTML_OBJECT_H +#define HTML_OBJECT_H + +#include <dom/html_element.h> +#include <dom/html_form.h> +#include <kdemacros.h> + +namespace DOM { + +class HTMLAppletElementImpl; + +/** + * An embedded Java applet. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#edef-APPLET"> + * APPLET element definition </a> in HTML 4.0. This element is + * deprecated in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLAppletElement : public HTMLElement +{ +public: + HTMLAppletElement(); + HTMLAppletElement(const HTMLAppletElement &other); + HTMLAppletElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLAppletElement(HTMLAppletElementImpl *impl); +public: + + HTMLAppletElement & operator = (const HTMLAppletElement &other); + HTMLAppletElement & operator = (const Node &other); + + ~HTMLAppletElement(); + + /** + * Aligns this object (vertically or horizontally) with respect to + * its surrounding text. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-align-IMG"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Alternate text for user agents not rendering the normal content + * of this element. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-alt"> + * alt attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString alt() const; + + /** + * see alt + */ + void setAlt( const DOMString & ); + + /** + * Comma-separated archive list. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-archive-APPLET"> + * archive attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString archive() const; + + /** + * see archive + */ + void setArchive( const DOMString & ); + + /** + * Applet class file. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-code"> + * code attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString code() const; + + /** + * see code + */ + void setCode( const DOMString & ); + + /** + * Optional base URI for applet. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-codebase-APPLET"> + * codebase attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString codeBase() const; + + /** + * see codeBase + */ + void setCodeBase( const DOMString &value ); + + /** + * Override height. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-height-APPLET"> + * height attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString height() const; + + /** + * see height + */ + void setHeight( const DOMString & ); + + /** + * Horizontal space, in pixels, to the left and right of this image, applet, + * or object. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-hspace"> + * hspace attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long getHspace() const; + + /** + * see hspace + */ + void setHspace( long ); + + /** + * @deprecated + */ + DOMString hspace() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setHspace( const DOMString &value ) KDE_DEPRECATED; + + /** + * The name of the applet. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-name-APPLET"> + * name attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Serialized applet file. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-object"> + * object attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString object() const; + + /** + * see object + */ + void setObject( const DOMString & ); + + /** + * Vertical space, in pixels, above and below this image, applet, or object. + * See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-vspace"> + * vspace attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long getVspace() const; + + /** + * see vspace + */ + void setVspace( long ); + + /** + * @deprecated + */ + DOMString vspace() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setVspace( const DOMString & ) KDE_DEPRECATED; + + /** + * Override width. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-width-APPLET"> + * width attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLObjectElementImpl; + +/** + * Generic embedded object. Note. In principle, all properties on the + * object element are read-write but in some environments some + * properties may be read-only once the underlying object is + * instantiated. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#edef-OBJECT"> + * OBJECT element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLObjectElement : public HTMLElement +{ +public: + HTMLObjectElement(); + HTMLObjectElement(const HTMLObjectElement &other); + HTMLObjectElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLObjectElement(HTMLObjectElementImpl *impl); +public: + + HTMLObjectElement & operator = (const HTMLObjectElement &other); + HTMLObjectElement & operator = (const Node &other); + + ~HTMLObjectElement(); + + /** + * Returns the \c FORM element containing this + * control. Returns null if this control is not within the context + * of a form. + * + */ + HTMLFormElement form() const; + + /** + * Applet class file. See the \c code attribute for + * HTMLAppletElement. + * + */ + DOMString code() const; + + /** + * see code + */ + void setCode( const DOMString & ); + + /** + * Aligns this object (vertically or horizontally) with respect to + * its surrounding text. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-align-IMG"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Space-separated list of archives. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-archive-OBJECT"> + * archive attribute definition </a> in HTML 4.0. + * + */ + DOMString archive() const; + + /** + * see archive + */ + void setArchive( const DOMString & ); + + /** + * Width of border around the object. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-border"> + * border attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString border() const; + + /** + * see border + */ + void setBorder( const DOMString & ); + + /** + * Base URI for \c classid , \c data , and + * \c archive attributes. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-codebase-OBJECT"> + * codebase attribute definition </a> in HTML 4.0. + * + */ + DOMString codeBase() const; + + /** + * see codeBase + */ + void setCodeBase( const DOMString & ); + + /** + * Content type for data downloaded via \c classid + * attribute. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-codetype"> + * codetype attribute definition </a> in HTML 4.0. + * + */ + DOMString codeType() const; + + /** + * see codeType + */ + void setCodeType( const DOMString & ); + + /** + * A URI specifying the location of the object's data. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-data"> + * data attribute definition </a> in HTML 4.0. + * + */ + DOMString data() const; + + /** + * see data + */ + void setData( const DOMString & ); + + /** + * Declare (for future reference), but do not instantiate, this + * object. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-declare"> + * declare attribute definition </a> in HTML 4.0. + * + */ + bool declare() const; + + /** + * see declare + */ + void setDeclare( bool ); + + /** + * Override height. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-height-IMG"> + * height attribute definition </a> in HTML 4.0. + * + */ + DOMString height() const; + + /** + * see height + */ + void setHeight( const DOMString & ); + + /** + * Horizontal space, in pixels, to the left and right of this image, applet, + * or object. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-hspace"> + * hspace attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long getHspace() const; + + /** + * see hspace + */ + void setHspace( long ); + + /** + * @deprecated + */ + DOMString hspace() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setHspace( const DOMString & ) KDE_DEPRECATED; + + /** + * Form control or object name when submitted with a form. See the + * <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-INPUT"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Message to render while loading the object. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-standby"> + * standby attribute definition </a> in HTML 4.0. + * + */ + DOMString standby() const; + + /** + * see standby + */ + void setStandby( const DOMString & ); + + /** + * Index that represents the element's position in the tabbing + * order. See the <a + * href="http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex"> + * tabindex attribute definition </a> in HTML 4.0. + * + */ + long tabIndex() const; + + /** + * see tabIndex + */ + void setTabIndex( long ); + + /** + * Content type for data downloaded via \c data + * attribute. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-type-OBJECT"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); + + /** + * Use client-side image map. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-usemap"> + * usemap attribute definition </a> in HTML 4.0. + * + */ + DOMString useMap() const; + + /** + * see useMap + */ + void setUseMap( const DOMString & ); + + /** + * Vertical space, in pixels, above and below this image, applet, or object. + * See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-vspace"> + * vspace attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + long getVspace() const; + + /** + * see vspace + */ + void setVspace( long ); + + /** + * @deprecated + */ + DOMString vspace() const KDE_DEPRECATED; + + /** + * @deprecated + */ + void setVspace( const DOMString & ) KDE_DEPRECATED; + + /** + * Override width. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-width-IMG"> + * width attribute definition </a> in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); + + /** + * Introduced in DOM Level 2 + * + * Returns the document this iframe contains, if there is any and + * it is available, a Null document otherwise. The attribute is + * read-only. + * + * @return The content Document if available. + */ + Document contentDocument() const; +}; + +// -------------------------------------------------------------------------- + +class HTMLParamElementImpl; + +/** + * Parameters fed to the \c OBJECT element. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#edef-PARAM"> + * PARAM element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLParamElement : public HTMLElement +{ +public: + HTMLParamElement(); + HTMLParamElement(const HTMLParamElement &other); + HTMLParamElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLParamElement(HTMLParamElementImpl *impl); +public: + + HTMLParamElement & operator = (const HTMLParamElement &other); + HTMLParamElement & operator = (const Node &other); + + ~HTMLParamElement(); + + /** + * The name of a run-time parameter. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-name-PARAM"> + * name attribute definition </a> in HTML 4.0. + * + */ + DOMString name() const; + + /** + * see name + */ + void setName( const DOMString & ); + + /** + * Content type for the \c value attribute when + * \c valuetype has the value "ref". See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-type-PARAM"> + * type attribute definition </a> in HTML 4.0. + * + */ + DOMString type() const; + + /** + * see type + */ + void setType( const DOMString & ); + + /** + * The value of a run-time parameter. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-value-PARAM"> + * value attribute definition </a> in HTML 4.0. + * + */ + DOMString value() const; + + /** + * see value + */ + void setValue( const DOMString & ); + + /** + * Information about the meaning of the \c value + * attribute value. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-valuetype"> + * valuetype attribute definition </a> in HTML 4.0. + * + */ + DOMString valueType() const; + + /** + * see valueType + */ + void setValueType( const DOMString & ); +}; + +} // namespace + +#endif diff --git a/tdehtml/dom/html_table.cpp b/tdehtml/dom/html_table.cpp new file mode 100644 index 000000000..b42c4fcd1 --- /dev/null +++ b/tdehtml/dom/html_table.cpp @@ -0,0 +1,868 @@ +/** + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +// -------------------------------------------------------------------------- + +#include "dom/html_misc.h" +#include "dom/html_table.h" +#include "dom/dom_exception.h" + +#include "html/html_miscimpl.h" +#include "html/html_tableimpl.h" +#include "misc/htmlhashes.h" + +using namespace DOM; + +HTMLTableCaptionElement::HTMLTableCaptionElement() : HTMLElement() +{ +} + +HTMLTableCaptionElement::HTMLTableCaptionElement(const HTMLTableCaptionElement &other) : HTMLElement(other) +{ +} + +HTMLTableCaptionElement::HTMLTableCaptionElement(HTMLTableCaptionElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTableCaptionElement &HTMLTableCaptionElement::operator = (const Node &other) +{ + assignOther( other, ID_CAPTION ); + return *this; +} + +HTMLTableCaptionElement &HTMLTableCaptionElement::operator = (const HTMLTableCaptionElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTableCaptionElement::~HTMLTableCaptionElement() +{ +} + +DOMString HTMLTableCaptionElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLTableCaptionElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +// -------------------------------------------------------------------------- + +HTMLTableCellElement::HTMLTableCellElement() : HTMLElement() +{ +} + +HTMLTableCellElement::HTMLTableCellElement(const HTMLTableCellElement &other) : HTMLElement(other) +{ +} + +HTMLTableCellElement::HTMLTableCellElement(HTMLTableCellElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTableCellElement &HTMLTableCellElement::operator = (const Node &other) +{ + if( other.elementId() != ID_TD && + other.elementId() != ID_TH ) + { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator = (other); + } + return *this; +} + +HTMLTableCellElement &HTMLTableCellElement::operator = (const HTMLTableCellElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTableCellElement::~HTMLTableCellElement() +{ +} + +long HTMLTableCellElement::cellIndex() const +{ + if(!impl) return 0; + return ((HTMLTableCellElementImpl *)impl)->cellIndex(); +} + +void HTMLTableCellElement::setCellIndex( long /*_cellIndex*/ ) +{ + throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); +} + +DOMString HTMLTableCellElement::abbr() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ABBR); +} + +void HTMLTableCellElement::setAbbr( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ABBR, value); +} + +DOMString HTMLTableCellElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLTableCellElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLTableCellElement::axis() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_AXIS); +} + +void HTMLTableCellElement::setAxis( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_AXIS, value); +} + +DOMString HTMLTableCellElement::bgColor() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BGCOLOR); +} + +void HTMLTableCellElement::setBgColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BGCOLOR, value); +} + +DOMString HTMLTableCellElement::ch() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAR); +} + +void HTMLTableCellElement::setCh( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAR, value); +} + +DOMString HTMLTableCellElement::chOff() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAROFF); +} + +void HTMLTableCellElement::setChOff( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAROFF, value); +} + +long HTMLTableCellElement::colSpan() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_COLSPAN).toInt(); +} + +void HTMLTableCellElement::setColSpan( long _colSpan ) +{ + if(impl) { + DOMString value(TQString::number(_colSpan)); + ((ElementImpl *)impl)->setAttribute(ATTR_COLSPAN,value); + } +} + +DOMString HTMLTableCellElement::headers() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HEADERS); +} + +void HTMLTableCellElement::setHeaders( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HEADERS, value); +} + +DOMString HTMLTableCellElement::height() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_HEIGHT); +} + +void HTMLTableCellElement::setHeight( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_HEIGHT, value); +} + +bool HTMLTableCellElement::noWrap() const +{ + if(!impl) return false; + return !((ElementImpl *)impl)->getAttribute(ATTR_NOWRAP).isNull(); +} + +void HTMLTableCellElement::setNoWrap( bool _noWrap ) +{ + if(impl) + ((ElementImpl *)impl)->setAttribute(ATTR_NOWRAP, _noWrap ? "" : 0); +} + +long HTMLTableCellElement::rowSpan() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_ROWSPAN).toInt(); +} + +void HTMLTableCellElement::setRowSpan( long _rowSpan ) +{ + if(impl) { + DOMString value(TQString::number(_rowSpan)); + ((ElementImpl *)impl)->setAttribute(ATTR_ROWSPAN,value); + } +} + +DOMString HTMLTableCellElement::scope() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SCOPE); +} + +void HTMLTableCellElement::setScope( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SCOPE, value); +} + +DOMString HTMLTableCellElement::vAlign() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VALIGN); +} + +void HTMLTableCellElement::setVAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALIGN, value); +} + +DOMString HTMLTableCellElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLTableCellElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +// -------------------------------------------------------------------------- + +HTMLTableColElement::HTMLTableColElement() : HTMLElement() +{ +} + +HTMLTableColElement::HTMLTableColElement(const HTMLTableColElement &other) : HTMLElement(other) +{ +} + +HTMLTableColElement::HTMLTableColElement(HTMLTableColElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTableColElement &HTMLTableColElement::operator = (const Node &other) +{ + if( other.elementId() != ID_COL && + other.elementId() != ID_COLGROUP ) + { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator = (other); + } + return *this; +} + +HTMLTableColElement &HTMLTableColElement::operator = (const HTMLTableColElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTableColElement::~HTMLTableColElement() +{ +} + +DOMString HTMLTableColElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLTableColElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLTableColElement::ch() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAR); +} + +void HTMLTableColElement::setCh( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAR, value); +} + +DOMString HTMLTableColElement::chOff() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAROFF); +} + +void HTMLTableColElement::setChOff( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAROFF, value); +} + +long HTMLTableColElement::span() const +{ + if(!impl) return 0; + return ((ElementImpl *)impl)->getAttribute(ATTR_SPAN).toInt(); +} + +void HTMLTableColElement::setSpan( long _span ) +{ + if(impl) { + DOMString value(TQString::number(_span)); + ((ElementImpl *)impl)->setAttribute(ATTR_SPAN,value); + } +} + +DOMString HTMLTableColElement::vAlign() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VALIGN); +} + +void HTMLTableColElement::setVAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALIGN, value); +} + +DOMString HTMLTableColElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLTableColElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +// -------------------------------------------------------------------------- + +HTMLTableElement::HTMLTableElement() : HTMLElement() +{ +} + +HTMLTableElement::HTMLTableElement(const HTMLTableElement &other) : HTMLElement(other) +{ +} + +HTMLTableElement::HTMLTableElement(HTMLTableElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTableElement &HTMLTableElement::operator = (const Node &other) +{ + assignOther( other, ID_TABLE ); + return *this; +} + +HTMLTableElement &HTMLTableElement::operator = (const HTMLTableElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTableElement::~HTMLTableElement() +{ +} + +HTMLTableCaptionElement HTMLTableElement::caption() const +{ + if(!impl) return 0; + return ((HTMLTableElementImpl *)impl)->caption(); +} + +void HTMLTableElement::setCaption( const HTMLTableCaptionElement &_caption ) +{ + if(impl) + ((HTMLTableElementImpl *)impl) + ->setCaption( ((HTMLTableCaptionElementImpl *)_caption.impl) ); +} + +HTMLTableSectionElement HTMLTableElement::tHead() const +{ + if(!impl) return 0; + return ((HTMLTableElementImpl *)impl)->tHead(); +} + +void HTMLTableElement::setTHead( const HTMLTableSectionElement &_tHead ) +{ + + if(impl) + ((HTMLTableElementImpl *)impl) + ->setTHead( ((HTMLTableSectionElementImpl *)_tHead.impl) ); +} + +HTMLTableSectionElement HTMLTableElement::tFoot() const +{ + if(!impl) return 0; + return ((HTMLTableElementImpl *)impl)->tFoot(); +} + +void HTMLTableElement::setTFoot( const HTMLTableSectionElement &_tFoot ) +{ + + if(impl) + ((HTMLTableElementImpl *)impl) + ->setTFoot( ((HTMLTableSectionElementImpl *)_tFoot.impl) ); +} + +HTMLCollection HTMLTableElement::rows() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::TABLE_ROWS); +} + +HTMLCollection HTMLTableElement::tBodies() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::TABLE_TBODIES); +} + +DOMString HTMLTableElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLTableElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLTableElement::bgColor() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BGCOLOR); +} + +void HTMLTableElement::setBgColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BGCOLOR, value); +} + +DOMString HTMLTableElement::border() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BORDER); +} + +void HTMLTableElement::setBorder( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BORDER, value); +} + +DOMString HTMLTableElement::cellPadding() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CELLPADDING); +} + +void HTMLTableElement::setCellPadding( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CELLPADDING, value); +} + +DOMString HTMLTableElement::cellSpacing() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CELLSPACING); +} + +void HTMLTableElement::setCellSpacing( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CELLSPACING, value); +} + +DOMString HTMLTableElement::frame() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_FRAME); +} + +void HTMLTableElement::setFrame( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_FRAME, value); +} + +DOMString HTMLTableElement::rules() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_RULES); +} + +void HTMLTableElement::setRules( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_RULES, value); +} + +DOMString HTMLTableElement::summary() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_SUMMARY); +} + +void HTMLTableElement::setSummary( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SUMMARY, value); +} + +DOMString HTMLTableElement::width() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); +} + +void HTMLTableElement::setWidth( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); +} + +HTMLElement HTMLTableElement::createTHead( ) +{ + if(!impl) return 0; + return ((HTMLTableElementImpl *)impl)->createTHead( ); +} + +void HTMLTableElement::deleteTHead( ) +{ + if(impl) + ((HTMLTableElementImpl *)impl)->deleteTHead( ); +} + +HTMLElement HTMLTableElement::createTFoot( ) +{ + if(!impl) return 0; + return ((HTMLTableElementImpl *)impl)->createTFoot( ); +} + +void HTMLTableElement::deleteTFoot( ) +{ + if(impl) + ((HTMLTableElementImpl *)impl)->deleteTFoot( ); +} + +HTMLElement HTMLTableElement::createCaption( ) +{ + if(!impl) return 0; + return ((HTMLTableElementImpl *)impl)->createCaption( ); +} + +void HTMLTableElement::deleteCaption( ) +{ + if(impl) + ((HTMLTableElementImpl *)impl)->deleteCaption( ); +} + +HTMLElement HTMLTableElement::insertRow( long index ) +{ + if(!impl) return 0; + int exceptioncode = 0; + HTMLElementImpl* ret = ((HTMLTableElementImpl *)impl)->insertRow( index, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + return ret; +} + +void HTMLTableElement::deleteRow( long index ) +{ + int exceptioncode = 0; + if(impl) + ((HTMLTableElementImpl *)impl)->deleteRow( index, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +// -------------------------------------------------------------------------- + +HTMLTableRowElement::HTMLTableRowElement() : HTMLElement() +{ +} + +HTMLTableRowElement::HTMLTableRowElement(const HTMLTableRowElement &other) : HTMLElement(other) +{ +} + +HTMLTableRowElement::HTMLTableRowElement(HTMLTableRowElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTableRowElement &HTMLTableRowElement::operator = (const Node &other) +{ + assignOther( other, ID_TR ); + return *this; +} + +HTMLTableRowElement &HTMLTableRowElement::operator = (const HTMLTableRowElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTableRowElement::~HTMLTableRowElement() +{ +} + +long HTMLTableRowElement::rowIndex() const +{ + if(!impl) return 0; + return ((HTMLTableRowElementImpl *)impl)->rowIndex(); +} + +void HTMLTableRowElement::setRowIndex( long /*_rowIndex*/ ) +{ + throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); +} + +long HTMLTableRowElement::sectionRowIndex() const +{ + if(!impl) return 0; + return ((HTMLTableRowElementImpl *)impl)->sectionRowIndex(); +} + +void HTMLTableRowElement::setSectionRowIndex( long /*_sectionRowIndex*/ ) +{ + throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); +} + +HTMLCollection HTMLTableRowElement::cells() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::TR_CELLS); +} + +void HTMLTableRowElement::setCells( const HTMLCollection & /*_cells*/ ) +{ + throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); +} + +DOMString HTMLTableRowElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLTableRowElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLTableRowElement::bgColor() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_BGCOLOR); +} + +void HTMLTableRowElement::setBgColor( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_BGCOLOR, value); +} + +DOMString HTMLTableRowElement::ch() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAR); +} + +void HTMLTableRowElement::setCh( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAR, value); +} + +DOMString HTMLTableRowElement::chOff() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAROFF); +} + +void HTMLTableRowElement::setChOff( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAROFF, value); +} + +DOMString HTMLTableRowElement::vAlign() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VALIGN); +} + +void HTMLTableRowElement::setVAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALIGN, value); +} + +HTMLElement HTMLTableRowElement::insertCell( long index ) +{ + if(!impl) return 0; + int exceptioncode = 0; + HTMLElementImpl* ret = ((HTMLTableRowElementImpl *)impl)->insertCell( index, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + return ret; +} + +void HTMLTableRowElement::deleteCell( long index ) +{ + int exceptioncode = 0; + if(impl) + ((HTMLTableRowElementImpl *)impl)->deleteCell( index, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + +// -------------------------------------------------------------------------- + +HTMLTableSectionElement::HTMLTableSectionElement() : HTMLElement() +{ +} + +HTMLTableSectionElement::HTMLTableSectionElement(const HTMLTableSectionElement &other) : HTMLElement(other) +{ +} + +HTMLTableSectionElement::HTMLTableSectionElement(HTMLTableSectionElementImpl *impl) : HTMLElement(impl) +{ +} + +HTMLTableSectionElement &HTMLTableSectionElement::operator = (const Node &other) +{ + if(other.elementId() != ID_TBODY && + other.elementId() != ID_THEAD && + other.elementId() != ID_TFOOT ) + { + if ( impl ) impl->deref(); + impl = 0; + } else { + Node::operator = (other); + } + return *this; +} + +HTMLTableSectionElement &HTMLTableSectionElement::operator = (const HTMLTableSectionElement &other) +{ + HTMLElement::operator = (other); + return *this; +} + +HTMLTableSectionElement::~HTMLTableSectionElement() +{ +} + +DOMString HTMLTableSectionElement::align() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); +} + +void HTMLTableSectionElement::setAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); +} + +DOMString HTMLTableSectionElement::ch() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAR); +} + +void HTMLTableSectionElement::setCh( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAR, value); +} + +DOMString HTMLTableSectionElement::chOff() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_CHAROFF); +} + +void HTMLTableSectionElement::setChOff( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CHAROFF, value); +} + +DOMString HTMLTableSectionElement::vAlign() const +{ + if(!impl) return DOMString(); + return ((ElementImpl *)impl)->getAttribute(ATTR_VALIGN); +} + +void HTMLTableSectionElement::setVAlign( const DOMString &value ) +{ + if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALIGN, value); +} + +HTMLCollection HTMLTableSectionElement::rows() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::TSECTION_ROWS); +} + +HTMLElement HTMLTableSectionElement::insertRow( long index ) +{ + if(!impl) return 0; + int exceptioncode = 0; + HTMLElementImpl* ret = ((HTMLTableSectionElementImpl *)impl)->insertRow( index, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); + return ret; +} + +void HTMLTableSectionElement::deleteRow( long index ) +{ + int exceptioncode = 0; + if(impl) + ((HTMLTableSectionElementImpl *)impl)->deleteRow( index, exceptioncode ); + if (exceptioncode) + throw DOMException(exceptioncode); +} + diff --git a/tdehtml/dom/html_table.h b/tdehtml/dom/html_table.h new file mode 100644 index 000000000..6b9a2d99d --- /dev/null +++ b/tdehtml/dom/html_table.h @@ -0,0 +1,997 @@ +/* + * This file is part of the DOM implementation for KDE. + * + * (C) 1999 Lars Knoll (knoll@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * This file includes excerpts from the Document Object Model (DOM) + * Level 1 Specification (Recommendation) + * http://www.w3.org/TR/REC-DOM-Level-1/ + * Copyright © World Wide Web Consortium , (Massachusetts Institute of + * Technology , Institut National de Recherche en Informatique et en + * Automatique , Keio University ). All Rights Reserved. + * + */ +#ifndef HTML_TABLE_H +#define HTML_TABLE_H + +// -------------------------------------------------------------------------- +#include <dom/html_element.h> +#include <tdelibs_export.h> + +namespace DOM { + +class HTMLTableCaptionElementImpl; +class DOMString; + +/** + * Table caption See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#edef-CAPTION"> + * CAPTION element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTableCaptionElement : public HTMLElement +{ + friend class HTMLTableElement; + +public: + HTMLTableCaptionElement(); + HTMLTableCaptionElement(const HTMLTableCaptionElement &other); + HTMLTableCaptionElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLTableCaptionElement(HTMLTableCaptionElementImpl *impl); +public: + + HTMLTableCaptionElement & operator = (const HTMLTableCaptionElement &other); + HTMLTableCaptionElement & operator = (const Node &other); + + ~HTMLTableCaptionElement(); + + /** + * Caption alignment with respect to the table. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-align-CAPTION"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLTableCellElementImpl; + +/** + * The object used to represent the \c TH and \c TD + * elements. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#edef-TD"> + * TD element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTableCellElement : public HTMLElement +{ + friend class HTMLTableElement; + +public: + HTMLTableCellElement(); + HTMLTableCellElement(const HTMLTableCellElement &other); + HTMLTableCellElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLTableCellElement(HTMLTableCellElementImpl *impl); +public: + + HTMLTableCellElement & operator = (const HTMLTableCellElement &other); + HTMLTableCellElement & operator = (const Node &other); + + ~HTMLTableCellElement(); + + /** + * The index of this cell in the row. + * + */ + long cellIndex() const; + + /** + * see cellIndex + * + * This function is obsolete - the cellIndex property is actually supposed to be read-only + * (http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html) + */ + void setCellIndex( long ); + + /** + * Abbreviation for header cells. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-abbr"> + * abbr attribute definition </a> in HTML 4.0. + * + */ + DOMString abbr() const; + + /** + * see abbr + */ + void setAbbr( const DOMString & ); + + /** + * Horizontal alignment of data in cell. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-align-TD"> + * align attribute definition </a> in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Names group of related headers. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-axis"> + * axis attribute definition </a> in HTML 4.0. + * + */ + DOMString axis() const; + + /** + * see axis + */ + void setAxis( const DOMString & ); + + /** + * Cell background color. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-bgcolor"> + * bgcolor attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString bgColor() const; + + /** + * see bgColor + */ + void setBgColor( const DOMString & ); + + /** + * Alignment character for cells in a column. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-char"> + * char attribute definition </a> in HTML 4.0. + * + */ + DOMString ch() const; + + /** + * see ch + */ + void setCh( const DOMString & ); + + /** + * Offset of alignment character. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-charoff"> + * charoff attribute definition </a> in HTML 4.0. + * + */ + DOMString chOff() const; + + /** + * see chOff + */ + void setChOff( const DOMString & ); + + /** + * Number of columns spanned by cell. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-colspan"> + * colspan attribute definition </a> in HTML 4.0. + * + */ + long colSpan() const; + + /** + * see colSpan + */ + void setColSpan( long ); + + /** + * List of \c id attribute values for header cells. + * See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-headers"> + * headers attribute definition </a> in HTML 4.0. + * + */ + DOMString headers() const; + + /** + * see headers + */ + void setHeaders( const DOMString & ); + + /** + * Cell height. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-height-TH"> + * height attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString height() const; + + /** + * see height + */ + void setHeight( const DOMString & ); + + /** + * Suppress word wrapping. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-nowrap"> + * nowrap attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + bool noWrap() const; + + /** + * see noWrap + */ + void setNoWrap( bool ); + + /** + * Number of rows spanned by cell. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-rowspan"> + * rowspan attribute definition </a> in HTML 4.0. + * + */ + long rowSpan() const; + + /** + * see rowSpan + */ + void setRowSpan( long ); + + /** + * Scope covered by header cells. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-scope"> + * scope attribute definition </a> in HTML 4.0. + * + */ + DOMString scope() const; + + /** + * see scope + */ + void setScope( const DOMString & ); + + /** + * Vertical alignment of data in cell. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-valign"> + * valign attribute definition </a> in HTML 4.0. + * + */ + DOMString vAlign() const; + + /** + * see vAlign + */ + void setVAlign( const DOMString & ); + + /** + * Cell width. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-width-TH"> + * width attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLTableColElementImpl; + +/** + * Regroups the \c COL and \c COLGROUP + * elements. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#edef-COL"> + * COL element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTableColElement : public HTMLElement +{ + friend class HTMLTableElement; + +public: + HTMLTableColElement(); + HTMLTableColElement(const HTMLTableColElement &other); + HTMLTableColElement(const Node &other) : HTMLElement() + {(*this)=other;} +protected: + HTMLTableColElement(HTMLTableColElementImpl *impl); +public: + + HTMLTableColElement & operator = (const HTMLTableColElement &other); + HTMLTableColElement & operator = (const Node &other); + + ~HTMLTableColElement(); + + /** + * Horizontal alignment of cell data in column. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-align-TD"> + * align attribute definition </a> in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Alignment character for cells in a column. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-char"> + * char attribute definition </a> in HTML 4.0. + * + */ + DOMString ch() const; + + /** + * see ch + */ + void setCh( const DOMString & ); + + /** + * Offset of alignment character. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-charoff"> + * charoff attribute definition </a> in HTML 4.0. + * + */ + DOMString chOff() const; + + /** + * see chOff + */ + void setChOff( const DOMString & ); + + /** + * Indicates the number of columns in a group or affected by a + * grouping. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-span-COL"> + * span attribute definition </a> in HTML 4.0. + * + */ + long span() const; + + /** + * see span + */ + void setSpan( long ); + + /** + * Vertical alignment of cell data in column. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-valign"> + * valign attribute definition </a> in HTML 4.0. + * + */ + DOMString vAlign() const; + + /** + * see vAlign + */ + void setVAlign( const DOMString & ); + + /** + * Default column width. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-width-COL"> + * width attribute definition </a> in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); +}; + +// -------------------------------------------------------------------------- + +class HTMLTableElementImpl; +class HTMLCollection; +class HTMLTableSectionElement; +class HTMLTableCaptionElement; +class HTMLElement; +class DOMString; + +/** + * The create* and delete* methods on the table allow authors to + * construct and modify tables. HTML 4.0 specifies that only one of + * each of the \c CAPTION , \c THEAD , and + * \c TFOOT elements may exist in a table. Therefore, if + * one exists, and the createTHead() or createTFoot() method is + * called, the method returns the existing THead or TFoot element. See + * the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#edef-TABLE"> + * TABLE element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTableElement : public HTMLElement +{ +public: + HTMLTableElement(); + HTMLTableElement(const HTMLTableElement &other); + HTMLTableElement(const Node &other) : HTMLElement() + {(*this)=other;} + +protected: + HTMLTableElement(HTMLTableElementImpl *impl); +public: + + HTMLTableElement & operator = (const HTMLTableElement &other); + HTMLTableElement & operator = (const Node &other); + + ~HTMLTableElement(); + + /** + * Returns the table's \c CAPTION , or void if none + * exists. + * + */ + HTMLTableCaptionElement caption() const; + + /** + * see caption + */ + void setCaption( const HTMLTableCaptionElement & ); + + /** + * Returns the table's \c THEAD , or \c null + * if none exists. + * + */ + HTMLTableSectionElement tHead() const; + + /** + * see tHead + */ + void setTHead( const HTMLTableSectionElement & ); + + /** + * Returns the table's \c TFOOT , or \c null + * if none exists. + * + */ + HTMLTableSectionElement tFoot() const; + + /** + * see tFoot + */ + void setTFoot( const HTMLTableSectionElement & ); + + /** + * Returns a collection of all the rows in the table, including + * all in \c THEAD , \c TFOOT , all + * \c TBODY elements. + * + */ + HTMLCollection rows() const; + + /** + * Returns a collection of the table bodies (including implicit ones). + * + */ + HTMLCollection tBodies() const; + + /** + * Specifies the table's position with respect to the rest of the + * document. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-align-TABLE"> + * align attribute definition </a> in HTML 4.0. This attribute is + * deprecated in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Cell background color. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-bgcolor"> + * bgcolor attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString bgColor() const; + + /** + * see bgColor + */ + void setBgColor( const DOMString & ); + + /** + * The width of the border around the table. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-border-TABLE"> + * border attribute definition </a> in HTML 4.0. + * + */ + DOMString border() const; + + /** + * see border + */ + void setBorder( const DOMString & ); + + /** + * Specifies the horizontal and vertical space between cell + * content and cell borders. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-cellpadding"> + * cellpadding attribute definition </a> in HTML 4.0. + * + */ + DOMString cellPadding() const; + + /** + * see cellPadding + */ + void setCellPadding( const DOMString & ); + + /** + * Specifies the horizontal and vertical separation between cells. + * See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-cellspacing"> + * cellspacing attribute definition </a> in HTML 4.0. + * + */ + DOMString cellSpacing() const; + + /** + * see cellSpacing + */ + void setCellSpacing( const DOMString & ); + + /** + * Specifies which external table borders to render. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-frame"> + * frame attribute definition </a> in HTML 4.0. + * + */ + DOMString frame() const; + + /** + * see frame + */ + void setFrame( const DOMString & ); + + /** + * Specifies which internal table borders to render. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-rules"> + * rules attribute definition </a> in HTML 4.0. + * + */ + DOMString rules() const; + + /** + * see rules + */ + void setRules( const DOMString & ); + + /** + * Supplementary description about the purpose or structure of a + * table. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-summary"> + * summary attribute definition </a> in HTML 4.0. + * + */ + DOMString summary() const; + + /** + * see summary + */ + void setSummary( const DOMString & ); + + /** + * Specifies the desired table width. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-width-TABLE"> + * width attribute definition </a> in HTML 4.0. + * + */ + DOMString width() const; + + /** + * see width + */ + void setWidth( const DOMString & ); + + /** + * Create a table header row or return an existing one. + * + * @return A new table header element ( \c THEAD ). + * + */ + HTMLElement createTHead ( ); + + /** + * Delete the header from the table, if one exists. + * + * @return + * + */ + void deleteTHead ( ); + + /** + * Create a table footer row or return an existing one. + * + * @return A footer element ( \c TFOOT ). + * + */ + HTMLElement createTFoot ( ); + + /** + * Delete the footer from the table, if one exists. + * + * @return + * + */ + void deleteTFoot ( ); + + /** + * Create a new table caption object or return an existing one. + * + * @return A \c CAPTION element. + * + */ + HTMLElement createCaption ( ); + + /** + * Delete the table caption, if one exists. + * + * @return + * + */ + void deleteCaption ( ); + + /** + * Insert a new empty row in the table. + * The new row is inserted immediately before and in the same section + * as the current indexth row in the table. If index is -1 or equal + * to the number of rows, the new row is appended. In addition, when + * the table is empty the row is inserted into a TBODY which is created + * and inserted into the table. + * Note. A table row cannot + * be empty according to HTML 4.0 Recommendation. + * + * @param index The row number where to insert a new row. + * The index starts from 0 and is relative to the logical order + * (not document order) of all the rows contained inside the table. + * + * @return The newly created row. + * + */ + HTMLElement insertRow ( long index ); + + /** + * Delete a table row. + * + * @param index The index of the row to be deleted. + * This index starts from 0 and is relative to the logical order + * (not document order) of all the rows contained inside the table. + * If the index is -1 the last row in the table is deleted. + * + * @return + * + */ + void deleteRow ( long index ); +}; + +// -------------------------------------------------------------------------- + +class HTMLTableRowElementImpl; +class HTMLCollection; +class HTMLElement; +class DOMString; + +/** + * A row in a table. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#edef-TR"> + * TR element definition </a> in HTML 4.0. + * + */ +class KHTML_EXPORT HTMLTableRowElement : public HTMLElement +{ + friend class HTMLTableElement; + +public: + HTMLTableRowElement(); + HTMLTableRowElement(const HTMLTableRowElement &other); + HTMLTableRowElement(const Node &other) : HTMLElement() + {(*this)=other;} + +protected: + HTMLTableRowElement(HTMLTableRowElementImpl *impl); +public: + + HTMLTableRowElement & operator = (const HTMLTableRowElement &other); + HTMLTableRowElement & operator = (const Node &other); + + ~HTMLTableRowElement(); + + /** + * The index of this row, relative to the entire table. + * This is in logical order and not in document order. + * The rowIndex does take into account sections + * (THEAD, TFOOT or TBODY) within the table, + * placing THEAD rows first in the index, followed by + * TBODY rows, followed by TFOOT rows. + */ + long rowIndex() const; + + /** + * see rowIndex + * + * This function is obsolete - the rowIndex property is actually supposed to be read-only + * (http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html) + */ + void setRowIndex( long ); + + /** + * The index of this row, relative to the current section ( + * \c THEAD , \c TFOOT , or \c TBODY + * ). + * + */ + long sectionRowIndex() const; + + /** + * see sectionRowIndex + * + * This function is obsolete - the sectionRowIndex property is actually supposed to be read-only + * (http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html) + */ + void setSectionRowIndex( long ); + + /** + * The collection of cells in this row. + * + */ + HTMLCollection cells() const; + + /** + * see cells + * + * This function is obsolete - the cells property is actually supposed to be read-only + * (http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html) + */ + void setCells( const HTMLCollection & ); + + /** + * Horizontal alignment of data within cells of this row. See the + * <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-align-TD"> + * align attribute definition </a> in HTML 4.0. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Background color for rows. See the <a + * href="http://www.w3.org/TR/REC-html40/present/graphics.html#adef-bgcolor"> + * bgcolor attribute definition </a> in HTML 4.0. This attribute + * is deprecated in HTML 4.0. + * + */ + DOMString bgColor() const; + + /** + * see bgColor + */ + void setBgColor( const DOMString & ); + + /** + * Alignment character for cells in a column. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-char"> + * char attribute definition </a> in HTML 4.0. + * + */ + DOMString ch() const; + + /** + * see ch + */ + void setCh( const DOMString & ); + + /** + * Offset of alignment character. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-charoff"> + * charoff attribute definition </a> in HTML 4.0. + * + */ + DOMString chOff() const; + + /** + * see chOff + */ + void setChOff( const DOMString & ); + + /** + * Vertical alignment of data within cells of this row. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-valign"> + * valign attribute definition </a> in HTML 4.0. + * + */ + DOMString vAlign() const; + + /** + * see vAlign + */ + void setVAlign( const DOMString & ); + + /** + * Insert an empty \c TD cell into this row. + * If index is -1 or equal to the number of cells, the new + * cell is appended. + * + * @param index The place to insert the cell. + * + * @return The newly created cell. + * + */ + HTMLElement insertCell ( long index ); + + /** + * Delete a cell from the current row. + * + * @param index The index of the cell to delete, starting from 0. + * If the index is -1 the last cell in the row is deleted. + * + * @return + * + */ + void deleteCell ( long index ); +}; + +// -------------------------------------------------------------------------- + +class HTMLTableSectionElementImpl; +class HTMLCollection; +class HTMLElement; +class DOMString; + +/** + * The \c THEAD , \c TFOOT , and \c TBODY + * elements. + * + */ +class KHTML_EXPORT HTMLTableSectionElement : public HTMLElement +{ + friend class HTMLTableElement; + +public: + HTMLTableSectionElement(); + HTMLTableSectionElement(const HTMLTableSectionElement &other); + HTMLTableSectionElement(const Node &other) : HTMLElement() + {(*this)=other;} + + +protected: + HTMLTableSectionElement(HTMLTableSectionElementImpl *impl); +public: + + HTMLTableSectionElement & operator = (const HTMLTableSectionElement &other); + HTMLTableSectionElement & operator = (const Node &other); + + ~HTMLTableSectionElement(); + + /** + * Horizontal alignment of data in cells. See the \c align + * attribute for HTMLTheadElement for details. + * + */ + DOMString align() const; + + /** + * see align + */ + void setAlign( const DOMString & ); + + /** + * Alignment character for cells in a column. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-char"> + * char attribute definition </a> in HTML 4.0. + * + */ + DOMString ch() const; + + /** + * see ch + */ + void setCh( const DOMString & ); + + /** + * Offset of alignment character. See the <a + * href="http://www.w3.org/TR/REC-html40/struct/tables.html#adef-charoff"> + * charoff attribute definition </a> in HTML 4.0. + * + */ + DOMString chOff() const; + + /** + * see chOff + */ + void setChOff( const DOMString & ); + + /** + * Vertical alignment of data in cells. See the \c valign + * attribute for HTMLTheadElement for details. + * + */ + DOMString vAlign() const; + + /** + * see vAlign + */ + void setVAlign( const DOMString & ); + + /** + * The collection of rows in this table section. + * + */ + HTMLCollection rows() const; + + /** + * Insert a row into this section. + * The new row is inserted immediately before the current indexth + * row in this section. If index is -1 or equal to the number of rows + * in this sectino, the new row is appended. + * + * @param index The row number where to insert a new row. + * + * @return The newly created row. + * + */ + HTMLElement insertRow ( long index ); + + /** + * Delete a row from this section. + * + * @param index The index of the row to be deleted, + * or -1 to delete the last row. This index starts from 0 and is relative only + * to the rows contained inside this section, not all the rows in the table. + * + */ + void deleteRow ( long index ); +}; + +} //namespace + +#endif |