From f64f2824ac11e9fb885bce8754fa6327831f3d74 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 20 Feb 2014 15:12:35 -0500 Subject: Add data uri checking back into the code (bzr r13047.1.1) --- src/uri-test.h | 2 +- src/uri.cpp | 22 ++++++++++++++++++++++ src/uri.h | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/uri-test.h b/src/uri-test.h index 2a4cdab46..9cb4ad639 100644 --- a/src/uri-test.h +++ b/src/uri-test.h @@ -47,7 +47,7 @@ public: { "foo", "foo" }, { "#foo", "#foo" }, { "blah.svg#h", "blah.svg#h" }, - //{ "data:data", "data:data" }, + { "data:data", "data:data" }, }; for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { diff --git a/src/uri.cpp b/src/uri.cpp index 89f6f33e4..219bc1c96 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -26,6 +26,15 @@ URI::URI(gchar const *preformed) throw(BadURIException) { if (!preformed) { throw MalformedURIException(); } + // One day Inkscape::URI should use std::string by default + std::string path = std::string(preformed); + // Check for a data URI and parse seperately because + // libxml can't handle this; although svgs need to. + if( path.compare(0, 5, "data:") == 0 ) { + parseDataUri( path ); + // Empty the uri for libxml + preformed = ""; + } uri = xmlParseURI(preformed); if (!uri) { throw MalformedURIException(); @@ -135,6 +144,17 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) filename = tmp.toNativeFilename(); return filename; } + +/* + * Parse data:... uris so we can access their data transparently. + * otherwise data: is considered a malformed protocol like http: + * and two // as appended and the data is stored in the path of the uri. + */ +bool URI::parseDataUri(const std::string &uri) { + + return true; +} + /* * Returns the absolute path to an existing file referenced in this URI, * if the uri is data, the path is empty or the file doesn't exist, then @@ -149,6 +169,8 @@ const std::string URI::getFullPath(std::string const base) const { if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } + // Path normalisation should go here TODO + // Check the existance of the file if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS) || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) { diff --git a/src/uri.h b/src/uri.h index 74820cb29..a1450c27b 100644 --- a/src/uri.h +++ b/src/uri.h @@ -121,6 +121,8 @@ public: URI &operator=(URI const &uri); private: + bool parseDataUri(const std::string &uri); + class Impl { public: static Impl *create(xmlURIPtr uri); -- cgit v1.2.3 From 7f9907d4fa5836d20555343dfe5e13649cad1f30 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 20 Feb 2014 15:48:07 -0500 Subject: Not finished by improved data uri support (bzr r13047.1.2) --- src/uri-test.h | 19 ++++++++++++++++--- src/uri.cpp | 18 ++++++++++++++++++ src/uri.h | 5 +++++ 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/uri-test.h b/src/uri-test.h index 9cb4ad639..4a2499a77 100644 --- a/src/uri-test.h +++ b/src/uri-test.h @@ -46,15 +46,28 @@ public: char const* cases[][2] = { { "foo", "foo" }, { "#foo", "#foo" }, - { "blah.svg#h", "blah.svg#h" }, - { "data:data", "data:data" }, + { "blah.svg#h", "blah.svg#h" }, + { "data:data", "data:data" }, + { "data:head,data", "data:head,data" }, }; for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) ); } } + void testDataUri() + { + char const* cases[][2] = { + { "data:HAIL-DATUM", "HAIL-DATUM" }, + { "data:head,HAIL-DATUM", "HAIL-DATUM" }, + }; + + for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { + // XXX replace this with a getData test + toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) ); + } + } void testPath() { char const* cases[][2] = { @@ -71,7 +84,7 @@ public: void testFullPath() { std::ofstream fhl("/tmp/cxxtest-uri.svg", std::ofstream::out); stringTest( URI("cxxtest-uri.svg").getFullPath("/tmp"), std::string("/tmp/cxxtest-uri.svg") ); - stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") ); + //stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") ); } }; diff --git a/src/uri.cpp b/src/uri.cpp index 219bc1c96..33a2fd13d 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -14,6 +14,8 @@ #include #include +#include + namespace Inkscape { URI::URI(const URI &uri) { @@ -151,6 +153,22 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) * and two // as appended and the data is stored in the path of the uri. */ bool URI::parseDataUri(const std::string &uri) { + unsigned int track = 5; // Ignore start of uri 'data:' + + unsigned int head_end = uri.find(",", track); + if (head_end < uri.length()) { + std::string head = uri.substr(track, head_end); + // Head split by ';' for mime-type, charset and base64 bool + track = head_end + 1; + } else { + head = "No Head"; + } + data = uri.substr(track, uri.length()-track); + if(data_base64) { + // Parse data here + } else { + // Fill data here + } return true; } diff --git a/src/uri.h b/src/uri.h index a1450c27b..11b091928 100644 --- a/src/uri.h +++ b/src/uri.h @@ -123,6 +123,11 @@ public: private: bool parseDataUri(const std::string &uri); + std::string data_mimetype; + std::string data_charset; + bool data_base64; + std::string data; + class Impl { public: static Impl *create(xmlURIPtr uri); -- cgit v1.2.3 From 6f844ef457690c841b0be91d70b1e54b61c04812 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 26 Feb 2014 10:31:28 -0500 Subject: Remove DOM directory and reduce size of inkscape. Use Inkscape::URI and save ziptool to utils. (bzr r13047.1.5) --- src/Makefile.am | 3 - src/color-profile.cpp | 14 +- src/dom/CMakeLists.txt | 61 - src/dom/Makefile.mingw | 234 -- src/dom/Makefile_insert | 56 - src/dom/css.h | 4693 --------------------------- src/dom/cssreader.cpp | 1684 ---------- src/dom/cssreader.h | 294 -- src/dom/dom.h | 2758 ---------------- src/dom/domimpl.cpp | 3071 ------------------ src/dom/domimpl.h | 2029 ------------ src/dom/domptr.cpp | 87 - src/dom/domptr.h | 339 -- src/dom/domstring.cpp | 423 --- src/dom/domstring.h | 316 -- src/dom/events.h | 1644 ---------- src/dom/io/domstream.cpp | 1228 ------- src/dom/io/domstream.h | 684 ---- src/dom/ls.h | 947 ------ src/dom/lsimpl.cpp | 441 --- src/dom/lsimpl.h | 390 --- src/dom/makefile.in | 17 - src/dom/mingwenv.bat | 2 - src/dom/prop-css.cpp | 1161 ------- src/dom/prop-css2.cpp | 1305 -------- src/dom/prop-svg.cpp | 746 ----- src/dom/smil.h | 2508 --------------- src/dom/smilimpl.cpp | 855 ----- src/dom/smilimpl.h | 766 ----- src/dom/stylesheets.h | 597 ---- src/dom/svg.h | 4758 --------------------------- src/dom/svgimpl.cpp | 2563 --------------- src/dom/svgimpl.h | 5543 -------------------------------- src/dom/svgreader.cpp | 750 ----- src/dom/svgreader.h | 187 -- src/dom/svgtypes.h | 6900 ---------------------------------------- src/dom/traversal.h | 609 ---- src/dom/ucd.cpp | 2539 --------------- src/dom/ucd.h | 335 -- src/dom/uri.cpp | 961 ------ src/dom/uri.h | 488 --- src/dom/util/ziptool.cpp | 3031 ------------------ src/dom/util/ziptool.h | 567 ---- src/dom/views-level3.h | 1967 ------------ src/dom/views.h | 218 -- src/dom/xmlreader.cpp | 998 ------ src/dom/xmlreader.h | 126 - src/dom/xmlwriter.cpp | 200 -- src/dom/xmlwriter.h | 84 - src/dom/xpath.h | 351 -- src/dom/xpathimpl.cpp | 236 -- src/dom/xpathimpl.h | 265 -- src/dom/xpathparser.cpp | 2093 ------------ src/dom/xpathparser.h | 801 ----- src/dom/xpathtoken.cpp | 1068 ------- src/dom/xpathtoken.h | 672 ---- src/extension/internal/odf.cpp | 19 +- src/extension/internal/odf.h | 9 +- src/uri.cpp | 57 +- src/uri.h | 33 +- src/util/Makefile_insert | 2 + src/util/ziptool.cpp | 3031 ++++++++++++++++++ src/util/ziptool.h | 567 ++++ 63 files changed, 3691 insertions(+), 67690 deletions(-) delete mode 100644 src/dom/CMakeLists.txt delete mode 100644 src/dom/Makefile.mingw delete mode 100644 src/dom/Makefile_insert delete mode 100644 src/dom/css.h delete mode 100644 src/dom/cssreader.cpp delete mode 100644 src/dom/cssreader.h delete mode 100644 src/dom/dom.h delete mode 100644 src/dom/domimpl.cpp delete mode 100644 src/dom/domimpl.h delete mode 100644 src/dom/domptr.cpp delete mode 100644 src/dom/domptr.h delete mode 100644 src/dom/domstring.cpp delete mode 100644 src/dom/domstring.h delete mode 100644 src/dom/events.h delete mode 100644 src/dom/io/domstream.cpp delete mode 100644 src/dom/io/domstream.h delete mode 100644 src/dom/ls.h delete mode 100644 src/dom/lsimpl.cpp delete mode 100644 src/dom/lsimpl.h delete mode 100644 src/dom/makefile.in delete mode 100644 src/dom/mingwenv.bat delete mode 100644 src/dom/prop-css.cpp delete mode 100644 src/dom/prop-css2.cpp delete mode 100644 src/dom/prop-svg.cpp delete mode 100644 src/dom/smil.h delete mode 100644 src/dom/smilimpl.cpp delete mode 100644 src/dom/smilimpl.h delete mode 100644 src/dom/stylesheets.h delete mode 100644 src/dom/svg.h delete mode 100644 src/dom/svgimpl.cpp delete mode 100644 src/dom/svgimpl.h delete mode 100644 src/dom/svgreader.cpp delete mode 100644 src/dom/svgreader.h delete mode 100644 src/dom/svgtypes.h delete mode 100644 src/dom/traversal.h delete mode 100644 src/dom/ucd.cpp delete mode 100644 src/dom/ucd.h delete mode 100644 src/dom/uri.cpp delete mode 100644 src/dom/uri.h delete mode 100644 src/dom/util/ziptool.cpp delete mode 100644 src/dom/util/ziptool.h delete mode 100644 src/dom/views-level3.h delete mode 100644 src/dom/views.h delete mode 100644 src/dom/xmlreader.cpp delete mode 100644 src/dom/xmlreader.h delete mode 100644 src/dom/xmlwriter.cpp delete mode 100644 src/dom/xmlwriter.h delete mode 100644 src/dom/xpath.h delete mode 100644 src/dom/xpathimpl.cpp delete mode 100644 src/dom/xpathimpl.h delete mode 100644 src/dom/xpathparser.cpp delete mode 100644 src/dom/xpathparser.h delete mode 100644 src/dom/xpathtoken.cpp delete mode 100644 src/dom/xpathtoken.h create mode 100644 src/util/ziptool.cpp create mode 100644 src/util/ziptool.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7fbc135c5..d3f8794ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,6 @@ endif noinst_LIBRARIES = \ - dom/libdom.a \ libcroco/libcroco.a \ libavoid/libavoid.a \ $(internal_GDL) \ @@ -108,7 +107,6 @@ endif include Makefile_insert include dialogs/Makefile_insert include display/Makefile_insert -include dom/Makefile_insert include extension/Makefile_insert include extension/dbus/Makefile_insert include extension/implementation/Makefile_insert @@ -148,7 +146,6 @@ EXTRA_DIST += \ debug/makefile.in \ dialogs/makefile.in \ display/makefile.in \ - dom/makefile.in \ extension/implementation/makefile.in \ extension/internal/makefile.in \ extension/makefile.in \ diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 2736b9a3b..09eaa36e5 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -46,7 +46,7 @@ #include "document.h" #include "preferences.h" -#include "dom/uri.h" +#include "uri.h" #ifdef WIN32 #include @@ -331,13 +331,17 @@ void ColorProfile::set(unsigned key, gchar const *value) { gchar* escaped = g_uri_escape_string(this->href, "!*'();:@=+$,/?#[]", TRUE); //g_message("docbase:%s\n", docbase); - org::w3c::dom::URI docUri(docbase); + //org::w3c::dom::URI docUri(docbase); + Inkscape::URI docUri(docbase); + //# 2. Get href of icc file. we don't care if it's rel or abs - org::w3c::dom::URI hrefUri(escaped); + //org::w3c::dom::URI hrefUri(escaped); + Inkscape::URI hrefUri(escaped); //# 3. Resolve the href according the docBase. This follows // the w3c specs. All absolute and relative issues are considered - org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri); - gchar* fullname = g_uri_unescape_string(cprofUri.getNativePath().c_str(), ""); + std::string fullpath = docUri.getFullPath(hrefUri.getFullPath("")); + + gchar* fullname = g_uri_unescape_string(fullpath.c_str(), ""); this->impl->_clearProfile(); this->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); if ( this->impl->_profHandle ) { diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt deleted file mode 100644 index c3078a8e3..000000000 --- a/src/dom/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ - -set(dom_SRC - cssreader.cpp - domimpl.cpp - domptr.cpp - domstring.cpp - lsimpl.cpp - prop-css2.cpp - prop-css.cpp - prop-svg.cpp - smilimpl.cpp - svgimpl.cpp - svgreader.cpp - ucd.cpp - uri.cpp - xmlreader.cpp - xpathimpl.cpp - xpathparser.cpp - xpathtoken.cpp - - io/domstream.cpp - - util/ziptool.cpp - - - # ------- - # Headers - css.h - cssreader.h - dom.h - domimpl.h - domptr.h - domstring.h - events.h - ls.h - lsimpl.h - smil.h - smilimpl.h - stylesheets.h - svg.h - svgimpl.h - svgreader.h - svgtypes.h - traversal.h - ucd.h - uri.h - views-level3.h - views.h - xmlreader.h - xmlwriter.h - xpath.h - xpathimpl.h - xpathparser.h - xpathtoken.h - - io/domstream.h - - util/ziptool.h -) - -add_inkscape_lib(dom_LIB "${dom_SRC}") diff --git a/src/dom/Makefile.mingw b/src/dom/Makefile.mingw deleted file mode 100644 index 9f75b2dbb..000000000 --- a/src/dom/Makefile.mingw +++ /dev/null @@ -1,234 +0,0 @@ -########################################################################### -# -# Makefile for testing DOM code -# -########################################################################### - -####### Sense whether we are on a DOS box or cross-compiling -ifdef ComSpec -BUILD=native -DOSSHELL=CMD_EXE -else -ifdef COMSPEC -BUILD=native -DOSSHELL=COMMAND_COM -else -BUILD=cross -endif -endif - - - - -########################################################################## -# FILE SEPARATORS -# $(S) will be set to one of these -########################################################################## -BSLASH := \\# -FSLASH := / - - - -########################################################################## -# CROSS / NATIVE SWITCHES -########################################################################## -ifeq ($(BUILD),cross) - - - -########################################################################## -# CROSS COMPILER SETTINGS -########################################################################## - -CC = i686-pc-mingw32-gcc -CXX = i686-pc-mingw32-g++ -AS = i686-pc-mingw32-as -AR = i686-pc-mingw32-ar -RANLIB = i686-pc-mingw32-ranlib -WINDRES = i686-pc-mingw32-windres -LD = i686-pc-mingw32-ld -DLLWRAP = i686-pc-mingw32-dllwrap -DLLTOOL = i686-pc-mingw32-dlltool - -####### file separator -S = $(FSLASH) - -####### escape character for echo -E = / - -####### file manipulation programs -CP = cp -RMDIR = rm -rf -MKDIR = mkdir -CPDIR = cp -rf -MSGFMT = msgfmt -RMREC = find ./inkscape -type f -name -RMREC1 = |xargs $(RM) -RMDIRREC = find ./inkscape -type d -name -RMDIRREC1 = |xargs $(RMDIR) - -####### Where is your GTK directory? -GTK=/target - -####### Same thing, file system style -GTKDOS=$(GTK) - -DTG := $(shell date +%y%m%d.%H%M) - -else - -########################################################################## -# NATIVE COMPILER SETTINGS -########################################################################## - -CC = mingw32-gcc -CXX = mingw32-g++ -AS = as -AR = mingw32-ar -RANLIB = ranlib -WINDRES = windres -DLLWRAP = dllwrap -DLLTOOL = dlltool - -####### file separator -S = $(BSLASH) - -####### escape character for echo -E = - -####### file manipulation programs -CP = copy - -####### are we on WinNt and beyond? -ifeq ($(DOSSHELL),CMD_EXE) -RMDIR = rmdir /s /q -RM = del -else -RMDIR = deltree /y -RM = del -endif -MKDIR = mkdir -CPDIR = xcopy /e /i -RMREC = cd inkscape & $(RM) /s /q -RMREC1 = & cd .. -RMDIRREC = cd inkscape & $(RMDIR) /s -RMDIRREC1 = & cd .. - -####### Where is your GTK directory? -GTK=c:/devlibs - -####### Same thing, DOS style -GTKDOS=c:\devlibs - -####### Command to process .po files --> .mo -MSGFMT = $(GTKDOS)$(S)bin$(S)msgfmt - -####### change me!! -DTG := 20080515 - -endif -########################################################################## -# END CROSS / NATIVE SWITCHES -########################################################################## - - - - -INC = -I. -I.. -CFLAGS = -Wall -g -DDOM_STANDALONE -LIBS = -lws2_32 - -DOMOBJ = \ -cssreader.o \ -domimpl.o \ -domptr.o \ -domstring.o \ -lsimpl.o \ -smilimpl.o \ -uri.o \ -xmlreader.o \ -xpathimpl.o \ -xpathparser.o \ -xpathtoken.o \ -io/base64stream.o \ -io/domstream.o \ -io/bufferstream.o \ -io/gzipstream.o \ -io/httpclient.o \ -io/stringstream.o \ -io/uristream.o \ -io/socket.o \ -odf/odfdocument.o \ -svgimpl.o \ -svgreader.o \ -ucd.o \ -util/thread.o \ -util/ziptool.o - - - -TESTOBJ = \ -work/testdom.o \ -work/testodf.o \ -work/testsvg.o \ -work/testuri.o \ -work/testxpath.o \ -work/testzip.o - -OBJ = $(DOMOBJ) - -all: testsvg.exe - -tests: testdom.exe testhttp.exe \ -testsvg.exe testuri.exe testxpath.exe testzip.exe - -testdom.exe: libdom.a work/testdom.o - $(CXX) -o $@ work/testdom.o libdom.a $(LIBS) - -testhttp.exe: libdom.a work/testhttp.o - $(CXX) -o $@ work/testhttp.o libdom.a $(LIBS) - -testodf.exe: libdom.a work/testodf.o - $(CXX) -o $@ work/testodf.o libdom.a $(LIBS) - -testsvg.exe: libdom.a work/testsvg.o - $(CXX) -o $@ work/testsvg.o libdom.a $(LIBS) - -testuri.exe: libdom.a work/testuri.o - $(CXX) -o $@ work/testuri.o libdom.a $(LIBS) - -testxpath.exe: libdom.a work/testxpath.o - $(CXX) -o $@ work/testxpath.o libdom.a $(LIBS) - -testzip.exe: libdom.a work/testzip.o - $(CXX) -o $@ work/testzip.o libdom.a $(LIBS) - - -libdom.a: $(OBJ) - ar crv $@ $(OBJ) - - -.cpp.o: - $(CXX) $(CFLAGS) $(INC) -c -o $@ $< - -clean: - $(foreach a, $(OBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - $(foreach a, $(TESTOBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - -$(RM) *.a - -$(RM) *.gch - -$(RM) testdom - -$(RM) testdom.exe - -$(RM) testsvg - -$(RM) testsvg.exe - -$(RM) testuri - -$(RM) testuri.exe - -$(RM) testxpath - -$(RM) testxpath.exe - -$(RM) testzip - -$(RM) testzip.exe - -$(RM) core.* - -########################################################################### -# E N D O F F I L E -########################################################################### - diff --git a/src/dom/Makefile_insert b/src/dom/Makefile_insert deleted file mode 100644 index 6d222987e..000000000 --- a/src/dom/Makefile_insert +++ /dev/null @@ -1,56 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -dom/all: dom/libdom.a - -dom/clean: - rm -f dom/libdom.a $(dom_libdom_a_OBJECTS) - -dom_libdom_a_SOURCES = \ - dom/css.h \ - dom/cssreader.cpp \ - dom/cssreader.h \ - dom/dom.h \ - dom/domimpl.cpp \ - dom/domimpl.h \ - dom/domptr.cpp \ - dom/domptr.h \ - dom/domstring.cpp \ - dom/domstring.h \ - dom/events.h \ - dom/ls.h \ - dom/lsimpl.cpp \ - dom/lsimpl.h \ - dom/prop-css2.cpp \ - dom/prop-css.cpp \ - dom/prop-svg.cpp \ - dom/smil.h \ - dom/smilimpl.cpp \ - dom/smilimpl.h \ - dom/stylesheets.h \ - dom/svg.h \ - dom/svgimpl.cpp \ - dom/svgimpl.h \ - dom/svgreader.cpp \ - dom/svgreader.h \ - dom/svgtypes.h \ - dom/traversal.h \ - dom/ucd.cpp \ - dom/ucd.h \ - dom/uri.cpp \ - dom/uri.h \ - dom/views.h \ - dom/views-level3.h \ - dom/xmlreader.cpp \ - dom/xmlreader.h \ - dom/xpath.h \ - dom/xpathimpl.cpp \ - dom/xpathimpl.h \ - dom/xpathparser.cpp \ - dom/xpathparser.h \ - dom/xpathtoken.h \ - dom/xpathtoken.cpp \ - dom/io/domstream.cpp \ - dom/io/domstream.h \ - dom/util/ziptool.h \ - dom/util/ziptool.cpp - diff --git a/src/dom/css.h b/src/dom/css.h deleted file mode 100644 index f270b99eb..000000000 --- a/src/dom/css.h +++ /dev/null @@ -1,4693 +0,0 @@ -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================= - * NOTES - * - * Views, Stylesheets and CSS are DOM Level 2 for the purposes of supporting - * SVG. Be prepared in the future when they make Level 3 and SVG is likewise - * updated. The API here and many of the comments come from this document: - * http://www.w3.org/TR/DOM-Level-2-Style/css.html - - */ - -#ifndef SEEN_CSS_H -#define SEEN_CSS_H - -#include "dom.h" -#include "stylesheets.h" -#include "views.h" - -#include -#include - - -namespace org { -namespace w3c { -namespace dom { -namespace css { - - - - -//Make local definitions -typedef dom::DOMString DOMString; -typedef dom::Element Element; -typedef dom::DOMImplementation DOMImplementation; - -//forward declarations -class CSSRule; -class CSSStyleSheet; -class CSSStyleDeclaration; -class CSSValue; -class Counter; -class Rect; -class RGBColor; - - - - - -/*######################################################################### -## CSSRule -#########################################################################*/ - -/** - * The CSSRule interface is the abstract base interface for any type of CSS - * statement. This includes both rule sets and at-rules. An implementation is - * expected to preserve all rules specified in a CSS style sheet, even if the - * rule is not recognized by the parser. Unrecognized rules are represented using - * the CSSUnknownRule interface. - */ -class CSSRule -{ -public: - - /** - * An integer indicating which type of rule this is. - */ - typedef enum - { - UNKNOWN_RULE = 0, - STYLE_RULE = 1, - CHARSET_RULE = 2, - IMPORT_RULE = 3, - MEDIA_RULE = 4, - FONT_FACE_RULE = 5, - PAGE_RULE = 6 - } RuleType; - - - /** - * 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 CSSRule interface to the specific derived interface implied by the type. - */ - virtual unsigned short getType() - { - return type; - } - - /** - * The parsable textual representation of the rule. This reflects the current - * state of the rule and not its initial value. - */ - virtual DOMString getCssText() - { - return cssText; - } - - /** - * The parsable textual representation of the rule. This reflects the current - * state of the rule and not its initial value. - * Note that setting involves reparsing. - */ - virtual void setCssText(const DOMString &val) throw (dom::DOMException) - { - cssText = val; - } - - /** - * The style sheet that contains this rule. - */ - virtual CSSStyleSheet *getParentStyleSheet() - { - return parentStyleSheet; - } - - /** - * 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 null. - */ - virtual CSSRule *getParentRule() - { - return parentRule; - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSRule() - { - type = UNKNOWN_RULE; - cssText = ""; - parentStyleSheet = NULL; - parentRule = NULL; - } - - /** - * - */ - CSSRule(const CSSRule &other) - { - assign(other); - } - - /** - * - */ - CSSRule &operator=(const CSSRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSRule &other) - { - type = other.type; - cssText = other.cssText; - parentStyleSheet = other.parentStyleSheet; - parentRule = other.parentRule; - } - - /** - * - */ - virtual ~CSSRule() {} - -protected: - - int type; - - DOMString cssText; - - CSSStyleSheet *parentStyleSheet; - - CSSRule *parentRule; -}; - - - -/*######################################################################### -## CSSRuleList -#########################################################################*/ - -/** - * The CSSRuleList interface provides the abstraction of an ordered collection of - * CSS rules. - * - * The items in the CSSRuleList are accessible via an integral index, starting - * from 0. - */ -class CSSRuleList -{ -public: - - /** - * The number of CSSRules in the list. The range of valid child rule indices is 0 - * to length-1 inclusive. - */ - virtual unsigned long getLength() - { - return rules.size(); - } - - /** - * 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. If index is greater - * than or equal to the number of rules in the list, this returns null. - */ - virtual CSSRule item(unsigned long index) - { - if (index>=rules.size()) - { - CSSRule rule; - return rule; - } - return rules[index]; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSRuleList() {} - - - /** - * - */ - CSSRuleList(const CSSRuleList &other) - : rules (other.rules) - { - } - - /** - * - */ - CSSRuleList &operator=(const CSSRuleList &other) - { - rules = other.rules; - return *this; - } - - /** - * - */ - virtual ~CSSRuleList() {} - -protected: - -friend class CSSMediaRule; -friend class CSSStyleSheet; - - /** - * - */ - virtual void addRule(const CSSRule &rule) - { - rules.push_back(rule); - } - - - /** - * - */ - virtual void deleteRule(unsigned long index) - { - if (index>=rules.size()) - return; - std::vector::iterator iter = rules.begin() + index; - rules.erase(iter); - } - - - /** - * - */ - virtual long insertRule(const CSSRule &rule, unsigned long index) - { - if (index>=rules.size()) - return -1; - std::vector::iterator iter = rules.begin() + index; - rules.insert(iter, rule); - return index; - } - - std::vectorrules; -}; - - -/*######################################################################### -## CSSStyleSheet -#########################################################################*/ - -/** - * The 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 CSSStyleSheet : virtual public stylesheets::StyleSheet -{ -public: - - /** - * If this style sheet comes from an @import rule, the ownerRule attribute will - * contain the CSSImportRule. In that case, the ownerNode attribute in the - * StyleSheet interface will be null. If the style sheet comes from an element or - * a processing instruction, the ownerRule attribute will be null and the - * ownerNode attribute will contain the Node. - */ - virtual CSSRule *getOwnerRule() - { - return ownerRule; - } - - /** - * The list of all CSS rules contained within the style sheet. This - * includes both rule sets and at-rules. - */ - virtual CSSRuleList getCssRules() - { - return rules; - } - - /** - * Used to insert a new rule into the style sheet. The new rule now - * becomes part of the cascade. - */ - virtual unsigned long insertRule(const DOMString &/*ruleStr*/, - unsigned long index) - throw (dom::DOMException) - { - CSSRule rule; - return rules.insertRule(rule, index); - } - - /** - * Used to delete a rule from the style sheet. - */ - virtual void deleteRule(unsigned long index) - throw (dom::DOMException) - { - rules.deleteRule(index); - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSStyleSheet() : stylesheets::StyleSheet(), ownerRule(0) - { - } - - /** - * - */ - CSSStyleSheet(const CSSStyleSheet &other) : - stylesheets::StyleSheet(other) - { - assign(other); - } - - /** - * - */ - CSSStyleSheet &operator=(const CSSStyleSheet &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSStyleSheet &other) - { - ownerRule = other.ownerRule; - rules = other.rules; - } - - /** - * - */ - virtual ~CSSStyleSheet() {} - -protected: - - CSSRule *ownerRule; - - CSSRuleList rules; -}; - - -/*######################################################################### -## CSSValue -#########################################################################*/ - -/** - * The CSSValue interface represents a simple or a complex value. A CSSValue - * object only occurs in a context of a CSS property. - */ -class CSSValue -{ -public: - - /** - * An integer indicating which type of unit applies to the value. - */ - typedef enum - { - CSS_INHERIT = 0, - CSS_PRIMITIVE_VALUE = 1, - CSS_VALUE_LIST = 2, - CSS_CUSTOM = 3 - } UnitTypes; - - /** - * A code defining the type of the value as defined above. - */ - virtual unsigned short getCssValueType() - { - return valueType; - } - - /** - * A string representation of the current value. - */ - virtual DOMString getCssText() - { - return cssText; - } - - /** - * A string representation of the current value. - * Note that setting implies parsing. - */ - virtual void setCssText(const DOMString &val) - throw (dom::DOMException) - { - cssText = val; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSValue() - { - valueType = CSS_INHERIT; - } - - /** - * - */ - CSSValue(const CSSValue &other) - { - assign(other); - } - - /** - * - */ - CSSValue &operator=(const CSSValue &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSValue &other) - { - cssText = other.cssText; - valueType = other.valueType; - } - - /** - * - */ - virtual ~CSSValue() {} - -protected: - - DOMString cssText; - int valueType; -}; - - - - - -/*######################################################################### -## CSSStyleDeclaration -#########################################################################*/ - -/** - * The CSSStyleDeclaration interface represents a single CSS declaration block. - * 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 in the style sheet through the CSSStyleDeclaration interface. - * Furthermore, implementations that support a specific level of CSS should - * correctly handle CSS shorthand properties for that level. For a further - * discussion of shorthand properties, see the CSS2Properties interface. - * - * This interface is also used to provide a read-only access to the computed - * values of an element. See also the ViewCSS interface. - * - * Note: The CSS Object Model doesn't provide an access to the specified or - * actual values of the CSS cascade. - */ -class CSSStyleDeclaration -{ -private: - - class CSSStyleDeclarationEntry - { - public: - CSSStyleDeclarationEntry(const DOMString &nameArg, - const DOMString &valueArg, - const DOMString &prioArg) - { - name = nameArg; - value = valueArg; - prio = prioArg; - } - virtual ~CSSStyleDeclarationEntry(){} - DOMString name; - DOMString value; - DOMString prio; - }; - - -public: - - /** - * The parsable textual representation of the declaration block (excluding the - * surrounding curly braces). - */ - virtual DOMString getCssText() - { - return cssText; - } - - /** - * The parsable textual representation of the declaration block (excluding the - * surrounding curly braces). Setting this attribute will result in the parsing - * of the new value and resetting of all the properties in the declaration block - * including the removal or addition of properties. - */ - virtual void setCssText(const DOMString &val) - throw (dom::DOMException) - { - cssText = val; - } - - /** - * Used to retrieve the value of a CSS property if it has been explicitly - * set within this declaration block. - */ - virtual DOMString getPropertyValue(const DOMString &propertyName) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - return iter->value; - } - return ""; - } - - /** - * 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 shorthand property. Shorthand property values can - * only be accessed and modified as strings, using the getPropertyValue and - * setProperty methods. - */ - virtual CSSValue getPropertyCSSValue(const DOMString &/*propertyName*/) - { - CSSValue value; - return value; - } - - /** - * Used to remove a CSS property if it has been explicitly set within - * this declaration block. - */ - virtual DOMString removeProperty(const DOMString &propertyName) - throw (dom::DOMException) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ){ - if (iter->name == propertyName){ - iter = items.erase(iter); - } - else{ - ++iter; - } - } - return propertyName; - } - - /** - * Used to retrieve the priority of a CSS property (e.g. the "important" - * qualifier) if the property has been explicitly set in this declaration block. - */ - virtual DOMString getPropertyPriority(const DOMString &propertyName) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - return iter->prio; - } - return ""; - } - - /** - * Used to set a property value and priority within this declaration block. - */ - virtual void setProperty(const DOMString &propertyName, - const DOMString &value, - const DOMString &priority) - throw (dom::DOMException) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - { - iter->name = propertyName; - iter->value = value; - iter->prio = priority; - return; - } - } - CSSStyleDeclarationEntry entry(propertyName, value, priority); - items.push_back(entry); - } - - /** - * The number of properties that have been explicitly set in this declaration - * block. The range of valid indices is 0 to length-1 inclusive. - */ - virtual unsigned long getLength() - { - return items.size(); - } - - /** - * 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. - */ - virtual DOMString item(unsigned long index) - { - if (index>=items.size()) - return ""; - DOMString ret = items[index].name; - ret.append(":"); - ret.append(items[index].value); - return ret; - } - - /** - * The CSS rule that contains this declaration block or null if this - * CSSStyleDeclaration is not attached to a CSSRule. - */ - virtual CSSRule *getParentRule() - { - return parentRule; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSStyleDeclaration() - { - parentRule = NULL; - } - - /** - * - */ - CSSStyleDeclaration(const CSSStyleDeclaration &other) - { - assign(other); - } - - /** - * - */ - CSSStyleDeclaration &operator=(const CSSStyleDeclaration &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSStyleDeclaration &other) - { - parentRule = other.parentRule; - cssText = other.cssText; - items = other.items; - } - - /** - * - */ - virtual ~CSSStyleDeclaration() {} - -protected: - - DOMString cssText; - - CSSRule *parentRule; - - std::vector items; -}; - - - - -/*######################################################################### -## CSSStyleRule -#########################################################################*/ - -/** - * The CSSStyleRule interface represents a single rule set in a CSS style sheet. - */ -class CSSStyleRule : virtual public CSSRule -{ -public: - - /** - * The textual representation of the selector for the rule set. The - * implementation may have stripped out insignificant whitespace while parsing - * the selector. - */ - virtual DOMString getSelectorText() - { - return selectorText; - } - - /** - * The textual representation of the selector for the rule set. The - * implementation may have stripped out insignificant whitespace while parsing - * the selector. Setting implies reparsing. - */ - virtual void setSelectorText(const DOMString &val) - throw (dom::DOMException) - { - selectorText = val; - } - - - /** - * The declaration-block of this rule set. - */ - virtual CSSStyleDeclaration &getStyle() - { - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSStyleRule() : CSSRule() - { - type = STYLE_RULE; - selectorText = ""; - } - - - /** - * - */ - CSSStyleRule(const CSSStyleRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSStyleRule &operator=(const CSSStyleRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSStyleRule &other) - { - selectorText = other.selectorText; - style = other.style; - } - - /** - * - */ - virtual ~CSSStyleRule() {} - -protected: - - DOMString selectorText; - - CSSStyleDeclaration style; - -}; - -/*######################################################################### -## CSSMediaRule -#########################################################################*/ - -/** - * The CSSMediaRule interface represents a @media rule in a CSS style sheet. A - * @media rule can be used to delimit style rules for specific media types. - */ -class CSSMediaRule : virtual public CSSRule -{ -public: - - /** - * A list of media types for this rule. - */ - virtual stylesheets::MediaList getMedia() - { - return mediaList; - } - - /** - * A list of all CSS rules contained within the media block. - */ - virtual CSSRuleList getCssRules() - { - return cssRules; - } - - /** - * Used to insert a new rule into the media block. - */ - virtual unsigned long insertRule(const DOMString &/*ruleStr*/, - unsigned long index) - throw (dom::DOMException) - { - if (index>cssRules.getLength()) - return 0; - CSSRule rule; - cssRules.insertRule(rule, index); - return index; - } - - /** - * Used to delete a rule from the media block. - */ - virtual void deleteRule(unsigned long index) - throw(dom::DOMException) - { - cssRules.deleteRule(index); - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSMediaRule() : CSSRule() - { - type = MEDIA_RULE; - } - - /** - * - */ - CSSMediaRule(const CSSMediaRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSMediaRule &operator=(const CSSMediaRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSMediaRule &other) - { - mediaList = other.mediaList; - cssRules = other.cssRules; - } - - /** - * - */ - virtual ~CSSMediaRule() {} - -protected: - - stylesheets::MediaList mediaList; - - CSSRuleList cssRules; -}; - - - - -/*######################################################################### -## CSSFontFaceRule -#########################################################################*/ - -/** - * The CSSFontFaceRule interface represents a @font-face rule in a CSS style - * sheet. The @font-face rule is used to hold a set of font descriptions. - */ -class CSSFontFaceRule : virtual public CSSRule -{ -public: - - /** - * The declaration-block of this rule. - */ - virtual CSSStyleDeclaration getStyle() - { - return style; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSFontFaceRule() : CSSRule() - { - type = FONT_FACE_RULE; - } - - /** - * - */ - CSSFontFaceRule(const CSSFontFaceRule &other) - : CSSRule(other), - style (other.style) - { - } - - /** - * - */ - CSSFontFaceRule &operator=(const CSSFontFaceRule &other) - { - style = other.style; - return *this; - } - - /** - * - */ - void assign(const CSSFontFaceRule &other) - { - style = other.style; - } - - /** - * - */ - virtual ~CSSFontFaceRule() {} - -protected: - - CSSStyleDeclaration style; -}; - - - - -/*######################################################################### -## CSSPageRule -#########################################################################*/ - -/** - * The CSSPageRule interface represents a @page rule within a CSS style sheet. - * The @page rule is used to specify the dimensions, orientation, margins, etc. - * of a page box for paged media. - */ -class CSSPageRule : virtual public CSSRule -{ -public: - - /** - * The parsable textual representation of the page selector for the rule. - */ - virtual DOMString getSelectorText() - { - return selectorText; - } - - /** - * The parsable textual representation of the page selector for the rule. - * Setting implies parsing. - */ - virtual void setSelectorText(const DOMString &val) - throw(dom::DOMException) - { - selectorText = val; - } - - - /** - * The declaration-block of this rule. - */ - virtual CSSStyleDeclaration getStyle() - { - return style; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSPageRule() : CSSRule() - { - type = PAGE_RULE; - } - - /** - * - */ - CSSPageRule(const CSSPageRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSPageRule &operator=(const CSSPageRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSPageRule &other) - { - selectorText = other.selectorText; - style = other.style; - } - - /** - * - */ - virtual ~CSSPageRule() {} - -protected: - - DOMString selectorText; - - CSSStyleDeclaration style; -}; - - - - - -/*######################################################################### -## CSSImportRule -#########################################################################*/ - -/** - * The CSSImportRule interface represents a @import rule within a CSS style - * sheet. The @import rule is used to import style rules from other style sheets. - */ -class CSSImportRule : virtual public CSSRule -{ -public: - - /** - * The location of the style sheet to be imported. The attribute will not contain - * the "url(...)" specifier around the URI. - */ - virtual DOMString getHref() - { - return href; - } - - /** - * A list of media types for which this style sheet may be used. - */ - virtual stylesheets::MediaList getMedia() - { - return mediaList; - } - - /** - * 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). - */ - virtual CSSStyleSheet getStyleSheet() - { - return styleSheet; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSImportRule() : CSSRule() - { - type = IMPORT_RULE; - } - - /** - * - */ - CSSImportRule(const CSSImportRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSImportRule &operator=(const CSSImportRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSImportRule &other) - { - href = other.href; - mediaList = other.mediaList; - styleSheet = other.styleSheet; - } - - /** - * - */ - virtual ~CSSImportRule() {} - -protected: - - DOMString href; - - stylesheets::MediaList mediaList; - - CSSStyleSheet styleSheet; -}; - - - - - - -/*######################################################################### -## CSSCharsetRule -#########################################################################*/ - -/** - * The CSSCharsetRule interface represents a @charset rule in a CSS style sheet. - * The value of the encoding attribute does not affect the encoding of text data - * in the DOM objects; this encoding is always UTF-16. After a stylesheet is - * loaded, the value of the encoding attribute is the value found in the @charset - * rule. If there was no @charset in the original document, then no - * CSSCharsetRule is created. The value of the encoding attribute may also be - * used as a hint for the encoding used on serialization of the style sheet. - * - * The value of the @charset rule (and therefore of the CSSCharsetRule) may not - * correspond to the encoding the document actually came in; character encoding - * information e.g. in an HTTP header, has priority (see CSS document - * representation) but this is not reflected in the CSSCharsetRule. - */ -class CSSCharsetRule : virtual public CSSRule -{ -public: - - /** - * The encoding information used in this @charset rule. - */ - virtual DOMString getEncoding() - { - return encoding; - } - - /** - * The encoding information used in this @charset rule. - * Setting implies parsing. - */ - virtual void setEncoding(const DOMString &val) throw (dom::DOMException) - { - encoding = val; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSCharsetRule() : CSSRule() - { - type = CHARSET_RULE; - } - - /** - * - */ - CSSCharsetRule(const CSSCharsetRule &other) : CSSRule(other) - { - encoding = other.encoding; - } - - /** - * - */ - CSSCharsetRule &operator=(const CSSCharsetRule &other) - { - encoding = other.encoding; - return *this; - } - - /** - * - */ - virtual ~CSSCharsetRule() {} - -protected: - - DOMString encoding; - -}; - - - - - -/*######################################################################### -## CSSUnknownRule -#########################################################################*/ - -/** - * The CSSUnknownRule interface represents an at-rule not supported by - * this user agent. - */ -class CSSUnknownRule : virtual public CSSRule -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSUnknownRule() : CSSRule() - { - type = UNKNOWN_RULE; - } - - /** - * - */ - CSSUnknownRule(const CSSUnknownRule &other) : CSSRule(other) - { - } - - /** - * - */ - CSSUnknownRule &operator=(const CSSUnknownRule &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~CSSUnknownRule() {} -}; - - - - - - - -/*######################################################################### -## CSSValueList -#########################################################################*/ - -/** - * The CSSValueList interface provides the abstraction of an ordered collection - * of CSS values. - * - * Some properties allow an empty list into their syntax. In that case, these - * properties take the none identifier. So, an empty list means that the property - * has the value none. - * - * The items in the CSSValueList are accessible via an integral index, starting - * from 0. - */ -class CSSValueList : virtual public CSSValue -{ -public: - - /** - * The number of CSSValues in the list. The range of valid values of the indices - * is 0 to length-1 inclusive. - */ - virtual unsigned long getLength() - { - return items.size(); - } - - /** - * Used to retrieve a CSSValue by ordinal index. The order in this collection - * represents the order of the values in the CSS style property. If index is - * greater than or equal to the number of values in the list, this returns null. - */ - virtual CSSValue item(unsigned long index) - { - if (index>=items.size()) - { - CSSValue dummy; - return dummy; - } - return items[index]; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSValueList() - { - } - - /** - * - */ - CSSValueList(const CSSValueList &other) - : CSSValue(other), - items (other.items) - { - } - - /** - * - */ - CSSValueList &operator=(const CSSValueList &other) - { - items = other.items; - return *this; - } - - /** - * - */ - virtual ~CSSValueList() {} - -protected: - - std::vector items; -}; - - - - -/*######################################################################### -## CSSPrimitiveValue -#########################################################################*/ - -/** - * The CSSPrimitiveValue interface represents a single CSS value. 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 property explicitly within the block. An - * instance of this interface might be obtained from the getPropertyCSSValue - * method of the CSSStyleDeclaration interface. A CSSPrimitiveValue object only - * occurs in a context of a CSS property. - * - * Conversions are allowed between absolute values (from millimeters to - * centimeters, from degrees to radians, and so on) but not between relative - * values. (For example, a pixel value cannot be converted to a centimeter value.) - * Percentage values can't be converted since they are relative to the parent - * value (or another property value). There is one exception for color percentage - * values: since a color percentage value is relative to the range 0-255, a color - * percentage value can be converted to a number; (see also the RGBColor - * interface). - */ -class CSSPrimitiveValue : virtual public CSSValue -{ -public: - - /** - *An integer indicating which type of unit applies to the value. - */ - typedef enum - { - 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 - } UnitTypes; - - - /** - * The type of the value as defined by the constants specified above. - */ - virtual unsigned short getPrimitiveType() - { - return primitiveType; - } - - /** - * 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 DOMException will be raised. - */ - virtual void setFloatValue(unsigned short unitType, - double doubleValueArg) - throw (dom::DOMException) - { - primitiveType = unitType; - doubleValue = doubleValueArg; - } - - /** - * 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 DOMException is raised. - */ - virtual double getFloatValue(unsigned short /*unitType*/) - throw (dom::DOMException) - { - return doubleValue; - } - - /** - * A method to set the string value with the 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 DOMException will be raised. - */ - virtual void setStringValue(unsigned short /*stringType*/, - const DOMString &stringValueArg) - throw (dom::DOMException) - { - stringValue = stringValueArg; - } - - /** - * This method is used to get the string value. If the CSS value doesn't contain - * a string value, a DOMException is raised. - * - * Note: Some properties (like 'font-family' or 'voice-family') convert a - * whitespace separated list of idents to a string. - */ - virtual DOMString getStringValue() throw (dom::DOMException) - { - return stringValue; - } - - /** - * This method is used to get the Counter value. If this CSS value doesn't - * contain a counter value, a DOMException is raised. Modification to the - * corresponding style property can be achieved using the Counter interface. - */ - virtual Counter *getCounterValue() throw (dom::DOMException) - { - return NULL; - } - - /** - * This method is used to get the Rect value. If this CSS value doesn't contain a - * rect value, a DOMException is raised. Modification to the corresponding style - * property can be achieved using the Rect interface. - */ - virtual Rect *getRectValue() throw (dom::DOMException) - { - return NULL; - } - - /** - * This method is used to get the RGB color. If this CSS value doesn't contain a - * RGB color value, a DOMException is raised. Modification to the corresponding - * style property can be achieved using the RGBColor interface. - */ - virtual RGBColor *getRGBColorValue() throw (dom::DOMException) - { - return NULL; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSPrimitiveValue() : - CSSValue(), - primitiveType(0), - doubleValue(0), - stringValue() - { - } - - /** - * - */ - CSSPrimitiveValue(const CSSPrimitiveValue &other) : - CSSValue() - { - primitiveType = other.primitiveType; - doubleValue = other.doubleValue; - stringValue = other.stringValue; - } - - /** - * - */ - CSSPrimitiveValue &operator=(const CSSPrimitiveValue &other) - { - if(this == &other) - { - return *this; - } - primitiveType = other.primitiveType; - doubleValue = other.doubleValue; - stringValue = other.stringValue; - return *this; - } - - /** - * - */ - virtual ~CSSPrimitiveValue() {} - -protected: - - int primitiveType; - - double doubleValue; - - DOMString stringValue; - - -}; - - - -/*######################################################################### -## RGBColor -#########################################################################*/ - -/** - * The RGBColor interface is used to represent any RGB color value. This - * interface reflects the values in the underlying style property. Hence, - * modifications made to the CSSPrimitiveValue objects modify the style property. - * - * A specified RGB color is not clipped (even if the number is outside the range - * 0-255 or 0%-100%). A computed RGB color is clipped depending on the device. - * - * Even if a style sheet can only contain an integer for a color value, the - * internal storage of this integer is a float, and this can be used as a float - * in the specified or the computed style. - * - * A color percentage value can always be converted to a number and vice versa. - */ -class RGBColor -{ -public: - - /** - * This attribute is used for the red value of the RGB color. - */ - virtual CSSPrimitiveValue getRed() - { - return red; - } - - /** - * This attribute is used for the green value of the RGB color. - */ - virtual CSSPrimitiveValue getGreen() - { - return green; - } - - /** - * This attribute is used for the blue value of the RGB color. - */ - virtual CSSPrimitiveValue getBlue() - { - return blue; - } - - /** - * REPLACES: RGBColor CSSPrimitiveValue::getRGBColorValue() throw (dom::DOMException) - */ - static RGBColor getRGBColorValue(const CSSPrimitiveValue &/*val*/) - { - RGBColor col; - return col; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - RGBColor() {} - - /** - * - */ - RGBColor(const RGBColor &other) - { - assign(other); - } - - /** - * - */ - RGBColor &operator=(const RGBColor &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const RGBColor &other) - { - red = other.red; - green = other.green; - blue = other.blue; - } - - /** - * - */ - virtual ~RGBColor() {} - -protected: - - CSSPrimitiveValue red; - CSSPrimitiveValue green; - CSSPrimitiveValue blue; -}; - - - - -/*######################################################################### -## Rect -#########################################################################*/ - -/** - * The Rect interface is used to represent any rect value. This interface - * reflects the values in the underlying style property. Hence, modifications - * made to the CSSPrimitiveValue objects modify the style property. - */ -class Rect -{ -public: - - /** - * This attribute is used for the top of the rect. - */ - virtual CSSPrimitiveValue getTop() - { - return top; - } - - /** - * This attribute is used for the right of the rect. - */ - virtual CSSPrimitiveValue getRight() - { - return right; - } - - /** - * This attribute is used for the bottom of the rect. - */ - virtual CSSPrimitiveValue getBottom() - { - return bottom; - } - - /** - * This attribute is used for the left of the rect. - */ - virtual CSSPrimitiveValue getLeft() - { - return left; - } - - /** - * REPLACES: Rect CSSPrimitiveValue::getRectValue() throw (dom::DOMException) - */ - static Rect getRectValue(const CSSPrimitiveValue &/*val*/) - { - Rect rect; - return rect; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - Rect() {} - - /** - * - */ - Rect(const Rect &other) - { - assign(other); - } - - /** - * - */ - Rect &operator=(const Rect &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const Rect &other) - { - top = other.top; - right = other.right; - bottom = other.bottom; - left = other.left; - } - - /** - * - */ - virtual ~Rect() {} - -protected: - - CSSPrimitiveValue top; - CSSPrimitiveValue right; - CSSPrimitiveValue bottom; - CSSPrimitiveValue left; -}; - - - - - - -/*######################################################################### -## Counter -#########################################################################*/ - -/** - * The Counter interface is used to represent any counter or counters function - * value. This interface reflects the values in the underlying style property. - */ -class Counter -{ -public: - - /** - * This attribute is used for the identifier of the counter. - */ - virtual DOMString getIdentifier() - { - return identifier; - } - - /** - * This attribute is used for the style of the list. - */ - virtual DOMString getListStyle() - { - return listStyle; - } - - /** - * This attribute is used for the separator of the nested counters. - */ - virtual DOMString getSeparator() - { - return separator; - } - - /** - * REPLACES: Counter CSSPrimitiveValue::getCounterValue() throw (dom::DOMException) - */ - static Counter getCounterValue(const CSSPrimitiveValue &/*val*/) - { - Counter counter; - return counter; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - Counter() {} - - /** - * - */ - Counter(const Counter &other) - { - assign(other); - } - - /** - * - */ - Counter &operator=(const Counter &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const Counter &other) - { - identifier = other.identifier; - listStyle = other.listStyle; - separator = other.separator; - } - - /** - * - */ - virtual ~Counter() {} - -protected: - - DOMString identifier; - DOMString listStyle; - DOMString separator; - -}; - - - - -/*######################################################################### -## ElementCSSInlineStyle -#########################################################################*/ - -/** - * Inline style information attached to elements is exposed through the style - * attribute. This represents the contents of the STYLE attribute for HTML - * elements (or elements in other schemas or DTDs which use the STYLE attribute - * in the same way). The expectation is that an instance of the - * ElementCSSInlineStyle interface can be obtained by using binding-specific - * casting methods on an instance of the Element interface when the element - * supports inline CSS style informations. - */ -class ElementCSSInlineStyle -{ -public: - - /** - * The style attribute. - */ - virtual CSSStyleDeclaration getStyle() - { - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - ElementCSSInlineStyle() {} - - /** - * - */ - ElementCSSInlineStyle(const ElementCSSInlineStyle &other) - : style (other.style) - { - } - - /** - * - */ - ElementCSSInlineStyle &operator=(const ElementCSSInlineStyle &other) - { - style = other.style; - return *this; - } - - /** - * - */ - virtual ~ElementCSSInlineStyle() {} - -protected: - - CSSStyleDeclaration style; -}; - - - - - - -/*######################################################################### -## CSS2Properties -#########################################################################*/ - -/** - * The CSS2Properties interface represents a convenience mechanism for retrieving - * and setting properties within a CSSStyleDeclaration. The attributes of this - * interface correspond to all the properties specified in CSS2. Getting an - * attribute of this interface is equivalent to calling the getPropertyValue - * method of the CSSStyleDeclaration interface. Setting an attribute of this - * interface is equivalent to calling the setProperty method of the - * CSSStyleDeclaration interface. - * - * A conformant implementation of the CSS module is not required to implement the - * 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 CSSStyleDeclaration interface to the 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 margin property is set, for example, the marginTop, - * marginRight, marginBottom and 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 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 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 margin, padding, and 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 font property with a value of - * "menu", querying for the values of the component longhand properties should - * return the empty string. - * */ -class CSS2Properties -{ -public: - - - /** - * return the 'azimuth' property - */ - virtual DOMString getAzimuth() - { - return azimuth; - } - - /** - * set the 'azimuth' property - */ - virtual void setAzimuth(const DOMString &val) - throw (dom::DOMException) - { - azimuth = val; - } - - /** - * return the 'background' property - */ - virtual DOMString getBackground() - { - return background; - } - - /** - * set the 'background' property - */ - virtual void setBackground(const DOMString &val) - throw (dom::DOMException) - { - background = val; - } - - /** - * return the 'backgroundAttachment' property - */ - virtual DOMString getBackgroundAttachment() - { - return backgroundAttachment; - } - - /** - * set the 'backgroundAttachment' property - */ - virtual void setBackgroundAttachment(const DOMString &val) - throw (dom::DOMException) - { - backgroundAttachment = val; - } - - /** - * return the 'backgroundColor' property - */ - virtual DOMString getBackgroundColor() - { - return backgroundColor; - } - - /** - * set the 'backgroundColor' property - */ - virtual void setBackgroundColor(const DOMString &val) - throw (dom::DOMException) - { - backgroundColor = val; - } - - /** - * return the 'backgroundImage' property - */ - virtual DOMString getBackgroundImage() - { - return backgroundImage; - } - - /** - * set the 'backgroundImage' property - */ - virtual void setBackgroundImage(const DOMString &val) - throw (dom::DOMException) - { - backgroundImage = val; - } - - /** - * return the 'backgroundPosition' property - */ - virtual DOMString getBackgroundPosition() - { - return backgroundPosition; - } - - /** - * set the 'backgroundPosition' property - */ - virtual void setBackgroundPosition(const DOMString &val) - throw (dom::DOMException) - { - backgroundPosition = val; - } - - /** - * return the 'backgroundRepeat' property - */ - virtual DOMString getBackgroundRepeat() - { - return backgroundRepeat; - } - - /** - * set the 'backgroundRepeat' property - */ - virtual void setBackgroundRepeat(const DOMString &val) - throw (dom::DOMException) - { - backgroundRepeat = val; - } - - /** - * return the 'border' property - */ - virtual DOMString getBorder() - { - return border; - } - - /** - * set the 'border' property - */ - virtual void setBorder(const DOMString &val) - throw (dom::DOMException) - { - border = val; - } - - /** - * return the 'borderCollapse' property - */ - virtual DOMString getBorderCollapse() - { - return borderCollapse; - } - - /** - * set the 'borderCollapse' property - */ - virtual void setBorderCollapse(const DOMString &val) - throw (dom::DOMException) - { - borderCollapse = val; - } - - /** - * return the 'borderColor' property - */ - virtual DOMString getBorderColor() - { - return borderColor; - } - - /** - * set the 'borderColor' property - */ - virtual void setBorderColor(const DOMString &val) - throw (dom::DOMException) - { - borderColor = val; - } - - /** - * return the 'borderSpacing' property - */ - virtual DOMString getBorderSpacing() - { - return borderSpacing; - } - - /** - * set the 'borderSpacing' property - */ - virtual void setBorderSpacing(const DOMString &val) - throw (dom::DOMException) - { - borderSpacing = val; - } - - /** - * return the 'borderStyle' property - */ - virtual DOMString getBorderStyle() - { - return borderStyle; - } - - /** - * set the 'borderStyle' property - */ - virtual void setBorderStyle(const DOMString &val) - throw (dom::DOMException) - { - borderStyle = val; - } - - /** - * return the 'borderTop' property - */ - virtual DOMString getBorderTop() - { - return borderTop; - } - - /** - * set the 'borderTop' property - */ - virtual void setBorderTop(const DOMString &val) - throw (dom::DOMException) - { - borderTop = val; - } - - /** - * return the 'borderRight' property - */ - virtual DOMString getBorderRight() - { - return borderRight; - } - - /** - * set the 'borderRight' property - */ - virtual void setBorderRight(const DOMString &val) - throw (dom::DOMException) - { - borderRight = val; - } - - /** - * return the 'borderBottom' property - */ - virtual DOMString getBorderBottom() - { - return borderBottom; - } - - /** - * set the 'borderBottom' property - */ - virtual void setBorderBottom(const DOMString &val) - throw (dom::DOMException) - { - borderBottom = val; - } - - /** - * return the 'borderLeft' property - */ - virtual DOMString getBorderLeft() - { - return borderLeft; - } - - /** - * set the 'borderLeft' property - */ - virtual void setBorderLeft(const DOMString &val) - throw (dom::DOMException) - { - borderLeft = val; - } - - /** - * return the 'borderTopColor' property - */ - virtual DOMString getBorderTopColor() - { - return borderTopColor; - } - - /** - * set the 'borderTopColor' property - */ - virtual void setBorderTopColor(const DOMString &val) - throw (dom::DOMException) - { - borderTopColor = val; - } - - /** - * return the 'borderRightColor' property - */ - virtual DOMString getBorderRightColor() - { - return borderRightColor; - } - - /** - * set the 'borderRightColor' property - */ - virtual void setBorderRightColor(const DOMString &val) - throw (dom::DOMException) - { - borderRightColor = val; - } - - /** - * return the 'borderBottomColor' property - */ - virtual DOMString getBorderBottomColor() - { - return borderBottomColor; - } - - /** - * set the 'borderBottomColor' property - */ - virtual void setBorderBottomColor(const DOMString &val) - throw (dom::DOMException) - { - borderBottomColor = val; - } - - /** - * return the 'borderLeftColor' property - */ - virtual DOMString getBorderLeftColor() - { - return borderLeftColor; - } - - /** - * set the 'borderLeftColor' property - */ - virtual void setBorderLeftColor(const DOMString &val) - throw (dom::DOMException) - { - borderLeftColor = val; - } - - /** - * return the 'borderTopStyle' property - */ - virtual DOMString getBorderTopStyle() - { - return borderTopStyle; - } - - /** - * set the 'borderTopStyle' property - */ - virtual void setBorderTopStyle(const DOMString &val) - throw (dom::DOMException) - { - borderTopStyle = val; - } - - /** - * return the 'borderRightStyle' property - */ - virtual DOMString getBorderRightStyle() - { - return borderRightStyle; - } - - /** - * set the 'borderRightStyle' property - */ - virtual void setBorderRightStyle(const DOMString &val) - throw (dom::DOMException) - { - borderRightStyle = val; - } - - /** - * return the 'borderBottomStyle' property - */ - virtual DOMString getBorderBottomStyle() - { - return borderBottomStyle; - } - - /** - * set the 'borderBottomStyle' property - */ - virtual void setBorderBottomStyle(const DOMString &val) - throw (dom::DOMException) - { - borderBottomStyle = val; - } - - /** - * return the 'borderLeftStyle' property - */ - virtual DOMString getBorderLeftStyle() - { - return borderLeftStyle; - } - - /** - * set the 'borderLeftStyle' property - */ - virtual void setBorderLeftStyle(const DOMString &val) - throw (dom::DOMException) - { - borderLeftStyle = val; - } - - /** - * return the 'borderTopWidth' property - */ - virtual DOMString getBorderTopWidth() - { - return borderTopWidth; - } - - /** - * set the 'borderTopWidth' property - */ - virtual void setBorderTopWidth(const DOMString &val) - throw (dom::DOMException) - { - borderTopWidth = val; - } - - /** - * return the 'borderRightWidth' property - */ - virtual DOMString getBorderRightWidth() - { - return borderRightWidth; - } - - /** - * set the 'borderRightWidth' property - */ - virtual void setBorderRightWidth(const DOMString &val) - throw (dom::DOMException) - { - borderRightWidth = val; - } - - /** - * return the 'borderBottomWidth' property - */ - virtual DOMString getBorderBottomWidth() - { - return borderBottomWidth; - } - - /** - * set the 'borderBottomWidth' property - */ - virtual void setBorderBottomWidth(const DOMString &val) - throw (dom::DOMException) - { - borderBottomWidth = val; - } - - /** - * return the 'borderLeftWidth' property - */ - virtual DOMString getBorderLeftWidth() - { - return borderLeftWidth; - } - - /** - * set the 'borderLeftWidth' property - */ - virtual void setBorderLeftWidth(const DOMString &val) - throw (dom::DOMException) - { - borderLeftWidth = val; - } - - /** - * return the 'borderWidth' property - */ - virtual DOMString getBorderWidth() - { - return borderWidth; - } - - /** - * set the 'borderWidth' property - */ - virtual void setBorderWidth(const DOMString &val) - throw (dom::DOMException) - { - borderWidth = val; - } - - /** - * return the 'bottom' property - */ - virtual DOMString getBottom() - { - return bottom; - } - - /** - * set the 'bottom' property - */ - virtual void setBottom(const DOMString &val) - throw (dom::DOMException) - { - bottom = val; - } - - /** - * return the 'captionSide' property - */ - virtual DOMString getCaptionSide() - { - return captionSide; - } - - /** - * set the 'captionSide' property - */ - virtual void setCaptionSide(const DOMString &val) - throw (dom::DOMException) - { - captionSide = val; - } - - /** - * return the 'clear' property - */ - virtual DOMString getClear() - { - return clear; - } - - /** - * set the 'clear' property - */ - virtual void setClear(const DOMString &val) - throw (dom::DOMException) - { - clear = val; - } - - /** - * return the 'clip' property - */ - virtual DOMString getClip() - { - return clip; - } - - /** - * set the 'clip' property - */ - virtual void setClip(const DOMString &val) - throw (dom::DOMException) - { - clip = val; - } - - /** - * return the 'color' property - */ - virtual DOMString getColor() - { - return color; - } - - /** - * set the 'color' property - */ - virtual void setColor(const DOMString &val) - throw (dom::DOMException) - { - color = val; - } - - /** - * return the 'content' property - */ - virtual DOMString getContent() - { - return content; - } - - /** - * set the 'content' property - */ - virtual void setContent(const DOMString &val) - throw (dom::DOMException) - { - content = val; - } - - /** - * return the 'counterIncrement' property - */ - virtual DOMString getCounterIncrement() - { - return counterIncrement; - } - - /** - * set the 'counterIncrement' property - */ - virtual void setCounterIncrement(const DOMString &val) - throw (dom::DOMException) - { - counterIncrement = val; - } - - /** - * return the 'counterReset' property - */ - virtual DOMString getCounterReset() - { - return counterReset; - } - - /** - * set the 'counterReset' property - */ - virtual void setCounterReset(const DOMString &val) - throw (dom::DOMException) - { - counterReset = val; - } - - /** - * return the 'cue' property - */ - virtual DOMString getCue() - { - return cue; - } - - /** - * set the 'cue' property - */ - virtual void setCue(const DOMString &val) - throw (dom::DOMException) - { - cue = val; - } - - /** - * return the 'cueAfter' property - */ - virtual DOMString getCueAfter() - { - return cueAfter; - } - - /** - * set the 'cueAfter' property - */ - virtual void setCueAfter(const DOMString &val) - throw (dom::DOMException) - { - cueAfter = val; - } - - /** - * return the 'cueBefore' property - */ - virtual DOMString getCueBefore() - { - return cueBefore; - } - - /** - * set the 'cueBefore' property - */ - virtual void setCueBefore(const DOMString &val) - throw (dom::DOMException) - { - cueBefore = val; - } - - /** - * return the 'cursor' property - */ - virtual DOMString getCursor() - { - return cursor; - } - - /** - * set the 'cursor' property - */ - virtual void setCursor(const DOMString &val) - throw (dom::DOMException) - { - cursor = val; - } - - /** - * return the 'direction' property - */ - virtual DOMString getDirection() - { - return direction; - } - - /** - * set the 'direction' property - */ - virtual void setDirection(const DOMString &val) - throw (dom::DOMException) - { - direction = val; - } - - /** - * return the 'display' property - */ - virtual DOMString getDisplay() - { - return display; - } - - /** - * set the 'display' property - */ - virtual void setDisplay(const DOMString &val) - throw (dom::DOMException) - { - display = val; - } - - /** - * return the 'elevation' property - */ - virtual DOMString getElevation() - { - return elevation; - } - - /** - * set the 'elevation' property - */ - virtual void setElevation(const DOMString &val) - throw (dom::DOMException) - { - elevation = val; - } - - /** - * return the 'emptyCells' property - */ - virtual DOMString getEmptyCells() - { - return emptyCells; - } - - /** - * set the 'emptyCells' property - */ - virtual void setEmptyCells(const DOMString &val) - throw (dom::DOMException) - { - emptyCells = val; - } - - /** - * return the 'cssFloat' property - */ - virtual DOMString getCssFloat() - { - return cssFloat; - } - - /** - * set the 'cssFloat' property - */ - virtual void setCssFloat(const DOMString &val) - throw (dom::DOMException) - { - cssFloat = val; - } - - /** - * return the 'font' property - */ - virtual DOMString getFont() - { - return font; - } - - /** - * set the 'font' property - */ - virtual void setFont(const DOMString &val) - throw (dom::DOMException) - { - font = val; - } - - /** - * return the 'fontFamily' property - */ - virtual DOMString getFontFamily() - { - return fontFamily; - } - - /** - * set the 'fontFamily' property - */ - virtual void setFontFamily(const DOMString &val) - throw (dom::DOMException) - { - fontFamily = val; - } - - /** - * return the 'fontSize' property - */ - virtual DOMString getFontSize() - { - return fontSize; - } - - /** - * set the 'fontSize' property - */ - virtual void setFontSize(const DOMString &val) - throw (dom::DOMException) - { - fontSize = val; - } - - /** - * return the 'fontSizeAdjust' property - */ - virtual DOMString getFontSizeAdjust() - { - return fontSizeAdjust; - } - - /** - * set the 'fontSizeAdjust' property - */ - virtual void setFontSizeAdjust(const DOMString &val) - throw (dom::DOMException) - { - fontSizeAdjust = val; - } - - /** - * return the 'fontStretch' property - */ - virtual DOMString getFontStretch() - { - return fontStretch; - } - - /** - * set the 'fontStretch' property - */ - virtual void setFontStretch(const DOMString &val) - throw (dom::DOMException) - { - fontStretch = val; - } - - /** - * return the 'fontStyle' property - */ - virtual DOMString getFontStyle() - { - return fontStyle; - } - - /** - * set the 'fontStyle' property - */ - virtual void setFontStyle(const DOMString &val) - throw (dom::DOMException) - { - fontStyle = val; - } - - /** - * return the 'fontVariant' property - */ - virtual DOMString getFontVariant() - { - return fontVariant; - } - - /** - * set the 'fontVariant' property - */ - virtual void setFontVariant(const DOMString &val) - throw (dom::DOMException) - { - fontVariant = val; - } - - /** - * return the 'fontWeight' property - */ - virtual DOMString getFontWeight() - { - return fontWeight; - } - - /** - * set the 'fontWeight' property - */ - virtual void setFontWeight(const DOMString &val) - throw (dom::DOMException) - { - fontWeight = val; - } - - /** - * return the 'height' property - */ - virtual DOMString getHeight() - { - return height; - } - - /** - * set the 'height' property - */ - virtual void setHeight(const DOMString &val) - throw (dom::DOMException) - { - height = val; - } - - /** - * return the 'left' property - */ - virtual DOMString getLeft() - { - return left; - } - - /** - * set the 'left' property - */ - virtual void setLeft(const DOMString &val) - throw (dom::DOMException) - { - left = val; - } - - /** - * return the 'letterSpacing' property - */ - virtual DOMString getLetterSpacing() - { - return letterSpacing; - } - - /** - * set the 'letterSpacing' property - */ - virtual void setLetterSpacing(const DOMString &val) - throw (dom::DOMException) - { - letterSpacing = val; - } - - /** - * return the 'lineHeight' property - */ - virtual DOMString getLineHeight() - { - return lineHeight; - } - - /** - * set the 'lineHeight' property - */ - virtual void setLineHeight(const DOMString &val) - throw (dom::DOMException) - { - lineHeight = val; - } - - /** - * return the 'listStyle' property - */ - virtual DOMString getListStyle() - { - return listStyle; - } - - /** - * set the 'listStyle' property - */ - virtual void setListStyle(const DOMString &val) - throw (dom::DOMException) - { - listStyle = val; - } - - /** - * return the 'listStyleImage' property - */ - virtual DOMString getListStyleImage() - { - return listStyleImage; - } - - /** - * set the 'listStyleImage' property - */ - virtual void setListStyleImage(const DOMString &val) - throw (dom::DOMException) - { - listStyleImage = val; - } - - /** - * return the 'listStylePosition' property - */ - virtual DOMString getListStylePosition() - { - return listStylePosition; - } - - /** - * set the 'listStylePosition' property - */ - virtual void setListStylePosition(const DOMString &val) - throw (dom::DOMException) - { - listStylePosition = val; - } - - /** - * return the 'listStyleType' property - */ - virtual DOMString getListStyleType() - { - return listStyleType; - } - - /** - * set the 'listStyleType' property - */ - virtual void setListStyleType(const DOMString &val) - throw (dom::DOMException) - { - listStyleType = val; - } - - /** - * return the 'margin' property - */ - virtual DOMString getMargin() - { - return margin; - } - - /** - * set the 'margin' property - */ - virtual void setMargin(const DOMString &val) - throw (dom::DOMException) - { - margin = val; - } - - /** - * return the 'marginTop' property - */ - virtual DOMString getMarginTop() - { - return marginTop; - } - - /** - * set the 'marginTop' property - */ - virtual void setMarginTop(const DOMString &val) - throw (dom::DOMException) - { - marginTop = val; - } - - /** - * return the 'marginRight' property - */ - virtual DOMString getMarginRight() - { - return marginRight; - } - - /** - * set the 'marginRight' property - */ - virtual void setMarginRight(const DOMString &val) - throw (dom::DOMException) - { - marginRight = val; - } - - /** - * return the 'marginBottom' property - */ - virtual DOMString getMarginBottom() - { - return marginBottom; - } - - /** - * set the 'marginBottom' property - */ - virtual void setMarginBottom(const DOMString &val) - throw (dom::DOMException) - { - marginBottom = val; - } - - /** - * return the 'marginLeft' property - */ - virtual DOMString getMarginLeft() - { - return marginLeft; - } - - /** - * set the 'marginLeft' property - */ - virtual void setMarginLeft(const DOMString &val) - throw (dom::DOMException) - { - marginLeft = val; - } - - /** - * return the 'markerOffset' property - */ - virtual DOMString getMarkerOffset() - { - return markerOffset; - } - - /** - * set the 'markerOffset' property - */ - virtual void setMarkerOffset(const DOMString &val) - throw (dom::DOMException) - { - markerOffset = val; - } - - /** - * return the 'marks' property - */ - virtual DOMString getMarks() - { - return marks; - } - - /** - * set the 'marks' property - */ - virtual void setMarks(const DOMString &val) - throw (dom::DOMException) - { - marks = val; - } - - /** - * return the 'maxHeight' property - */ - virtual DOMString getMaxHeight() - { - return maxHeight; - } - - /** - * set the 'maxHeight' property - */ - virtual void setMaxHeight(const DOMString &val) - throw (dom::DOMException) - { - maxHeight = val; - } - - /** - * return the 'maxWidth' property - */ - virtual DOMString getMaxWidth() - { - return maxWidth; - } - - /** - * set the 'maxWidth' property - */ - virtual void setMaxWidth(const DOMString &val) - throw (dom::DOMException) - { - maxWidth = val; - } - - /** - * return the 'minHeight' property - */ - virtual DOMString getMinHeight() - { - return minHeight; - } - - /** - * set the 'minHeight' property - */ - virtual void setMinHeight(const DOMString &val) - throw (dom::DOMException) - { - minHeight = val; - } - - /** - * return the 'minWidth' property - */ - virtual DOMString getMinWidth() - { - return minWidth; - } - - /** - * set the 'minWidth' property - */ - virtual void setMinWidth(const DOMString &val) - throw (dom::DOMException) - { - minWidth = val; - } - - /** - * return the 'orphans' property - */ - virtual DOMString getOrphans() - { - return orphans; - } - - /** - * set the 'orphans' property - */ - virtual void setOrphans(const DOMString &val) - throw (dom::DOMException) - { - orphans = val; - } - - /** - * return the 'outline' property - */ - virtual DOMString getOutline() - { - return outline; - } - - /** - * set the 'outline' property - */ - virtual void setOutline(const DOMString &val) - throw (dom::DOMException) - { - outline = val; - } - - /** - * return the 'outlineColor' property - */ - virtual DOMString getOutlineColor() - { - return outlineColor; - } - - /** - * set the 'outlineColor' property - */ - virtual void setOutlineColor(const DOMString &val) - throw (dom::DOMException) - { - outlineColor = val; - } - - /** - * return the 'outlineStyle' property - */ - virtual DOMString getOutlineStyle() - { - return outlineStyle; - } - - /** - * set the 'outlineStyle' property - */ - virtual void setOutlineStyle(const DOMString &val) - throw (dom::DOMException) - { - outlineStyle = val; - } - - /** - * return the 'outlineWidth' property - */ - virtual DOMString getOutlineWidth() - { - return outlineWidth; - } - - /** - * set the 'outlineWidth' property - */ - virtual void setOutlineWidth(const DOMString &val) - throw (dom::DOMException) - { - outlineWidth = val; - } - - /** - * return the 'overflow' property - */ - virtual DOMString getOverflow() - { - return overflow; - } - - /** - * set the 'overflow' property - */ - virtual void setOverflow(const DOMString &val) - throw (dom::DOMException) - { - overflow = val; - } - - /** - * return the 'padding' property - */ - virtual DOMString getPadding() - { - return padding; - } - - /** - * set the 'padding' property - */ - virtual void setPadding(const DOMString &val) - throw (dom::DOMException) - { - padding = val; - } - - /** - * return the 'paddingTop' property - */ - virtual DOMString getPaddingTop() - { - return paddingTop; - } - - /** - * set the 'paddingTop' property - */ - virtual void setPaddingTop(const DOMString &val) - throw (dom::DOMException) - { - paddingTop = val; - } - - /** - * return the 'paddingRight' property - */ - virtual DOMString getPaddingRight() - { - return paddingRight; - } - - /** - * set the 'paddingRight' property - */ - virtual void setPaddingRight(const DOMString &val) - throw (dom::DOMException) - { - paddingRight = val; - } - - /** - * return the 'paddingBottom' property - */ - virtual DOMString getPaddingBottom() - { - return paddingBottom; - } - - /** - * set the 'paddingBottom' property - */ - virtual void setPaddingBottom(const DOMString &val) - throw (dom::DOMException) - { - paddingBottom = val; - } - - /** - * return the 'paddingLeft' property - */ - virtual DOMString getPaddingLeft() - { - return paddingLeft; - } - - /** - * set the 'paddingLeft' property - */ - virtual void setPaddingLeft(const DOMString &val) - throw (dom::DOMException) - { - paddingLeft = val; - } - - /** - * return the 'page' property - */ - virtual DOMString getPage() - { - return page; - } - - /** - * set the 'page' property - */ - virtual void setPage(const DOMString &val) - throw (dom::DOMException) - { - page = val; - } - - /** - * return the 'pageBreakAfter' property - */ - virtual DOMString getPageBreakAfter() - { - return pageBreakAfter; - } - - /** - * set the 'pageBreakAfter' property - */ - virtual void setPageBreakAfter(const DOMString &val) - throw (dom::DOMException) - { - pageBreakAfter = val; - } - - /** - * return the 'pageBreakBefore' property - */ - virtual DOMString getPageBreakBefore() - { - return pageBreakBefore; - } - - /** - * set the 'pageBreakBefore' property - */ - virtual void setPageBreakBefore(const DOMString &val) - throw (dom::DOMException) - { - pageBreakBefore = val; - } - - /** - * return the 'pageBreakInside' property - */ - virtual DOMString getPageBreakInside() - { - return pageBreakInside; - } - - /** - * set the 'pageBreakInside' property - */ - virtual void setPageBreakInside(const DOMString &val) - throw (dom::DOMException) - { - pageBreakInside = val; - } - - /** - * return the 'pause' property - */ - virtual DOMString getPause() - { - return pause; - } - - /** - * set the 'pause' property - */ - virtual void setPause(const DOMString &val) - throw (dom::DOMException) - { - pause = val; - } - - /** - * return the 'pauseAfter' property - */ - virtual DOMString getPauseAfter() - { - return pauseAfter; - } - - /** - * set the 'pauseAfter' property - */ - virtual void setPauseAfter(const DOMString &val) - throw (dom::DOMException) - { - pauseAfter = val; - } - - /** - * return the 'pauseBefore' property - */ - virtual DOMString getPauseBefore() - { - return pauseBefore; - } - - /** - * set the 'pauseBefore' property - */ - virtual void setPauseBefore(const DOMString &val) - throw (dom::DOMException) - { - pauseBefore = val; - } - - /** - * return the 'pitch' property - */ - virtual DOMString getPitch() - { - return pitch; - } - - /** - * set the 'pitch' property - */ - virtual void setPitch(const DOMString &val) - throw (dom::DOMException) - { - pitch = val; - } - - /** - * return the 'pitchRange' property - */ - virtual DOMString getPitchRange() - { - return pitchRange; - } - - /** - * set the 'pitchRange' property - */ - virtual void setPitchRange(const DOMString &val) - throw (dom::DOMException) - { - pitchRange = val; - } - - /** - * return the 'playDuring' property - */ - virtual DOMString getPlayDuring() - { - return playDuring; - } - - /** - * set the 'playDuring' property - */ - virtual void setPlayDuring(const DOMString &val) - throw (dom::DOMException) - { - playDuring = val; - } - - /** - * return the 'position' property - */ - virtual DOMString getPosition() - { - return position; - } - - /** - * set the 'position' property - */ - virtual void setPosition(const DOMString &val) - throw (dom::DOMException) - { - position = val; - } - - /** - * return the 'quotes' property - */ - virtual DOMString getQuotes() - { - return quotes; - } - - /** - * set the 'quotes' property - */ - virtual void setQuotes(const DOMString &val) - throw (dom::DOMException) - { - quotes = val; - } - - /** - * return the 'richness' property - */ - virtual DOMString getRichness() - { - return richness; - } - - /** - * set the 'richness' property - */ - virtual void setRichness(const DOMString &val) - throw (dom::DOMException) - { - richness = val; - } - - /** - * return the 'right' property - */ - virtual DOMString getRight() - { - return right; - } - - /** - * set the 'right' property - */ - virtual void setRight(const DOMString &val) - throw (dom::DOMException) - { - right = val; - } - - /** - * return the 'size' property - */ - virtual DOMString getSize() - { - return size; - } - - /** - * set the 'size' property - */ - virtual void setSize(const DOMString &val) - throw (dom::DOMException) - { - size = val; - } - - /** - * return the 'speak' property - */ - virtual DOMString getSpeak() - { - return speak; - } - - /** - * set the 'speak' property - */ - virtual void setSpeak(const DOMString &val) - throw (dom::DOMException) - { - speak = val; - } - - /** - * return the 'speakHeader' property - */ - virtual DOMString getSpeakHeader() - { - return speakHeader; - } - - /** - * set the 'speakHeader' property - */ - virtual void setSpeakHeader(const DOMString &val) - throw (dom::DOMException) - { - speakHeader = val; - } - - /** - * return the 'speakNumeral' property - */ - virtual DOMString getSpeakNumeral() - { - return speakNumeral; - } - - /** - * set the 'speakNumeral' property - */ - virtual void setSpeakNumeral(const DOMString &val) - throw (dom::DOMException) - { - speakNumeral = val; - } - - /** - * return the 'speakPunctuation' property - */ - virtual DOMString getSpeakPunctuation() - { - return speakPunctuation; - } - - /** - * set the 'speakPunctuation' property - */ - virtual void setSpeakPunctuation(const DOMString &val) - throw (dom::DOMException) - { - speakPunctuation = val; - } - - /** - * return the 'speechRate' property - */ - virtual DOMString getSpeechRate() - { - return speechRate; - } - - /** - * set the 'speechRate' property - */ - virtual void setSpeechRate(const DOMString &val) - throw (dom::DOMException) - { - speechRate = val; - } - - /** - * return the 'stress' property - */ - virtual DOMString getStress() - { - return stress; - } - - /** - * set the 'stress' property - */ - virtual void setStress(const DOMString &val) - throw (dom::DOMException) - { - stress = val; - } - - /** - * return the 'tableLayout' property - */ - virtual DOMString getTableLayout() - { - return tableLayout; - } - - /** - * set the 'tableLayout' property - */ - virtual void setTableLayout(const DOMString &val) - throw (dom::DOMException) - { - tableLayout = val; - } - - /** - * return the 'textAlign' property - */ - virtual DOMString getTextAlign() - { - return textAlign; - } - - /** - * set the 'textAlign' property - */ - virtual void setTextAlign(const DOMString &val) - throw (dom::DOMException) - { - textAlign = val; - } - - /** - * return the 'textDecoration' property - */ - virtual DOMString getTextDecoration() - { - return textDecoration; - } - - /** - * set the 'textDecoration' property - */ - virtual void setTextDecoration(const DOMString &val) - throw (dom::DOMException) - { - textDecoration = val; - } - - /** - * return the 'textIndent' property - */ - virtual DOMString getTextIndent() - { - return textIndent; - } - - /** - * set the 'textIndent' property - */ - virtual void setTextIndent(const DOMString &val) - throw (dom::DOMException) - { - textIndent = val; - } - - /** - * return the 'textShadow' property - */ - virtual DOMString getTextShadow() - { - return textShadow; - } - - /** - * set the 'textShadow' property - */ - virtual void setTextShadow(const DOMString &val) - throw (dom::DOMException) - { - textShadow = val; - } - - /** - * return the 'textTransform' property - */ - virtual DOMString getTextTransform() - { - return textTransform; - } - - /** - * set the 'textTransform' property - */ - virtual void setTextTransform(const DOMString &val) - throw (dom::DOMException) - { - textTransform = val; - } - - /** - * return the 'top' property - */ - virtual DOMString getTop() - { - return top; - } - - /** - * set the 'top' property - */ - virtual void setTop(const DOMString &val) - throw (dom::DOMException) - { - top = val; - } - - /** - * return the 'unicodeBidi' property - */ - virtual DOMString getUnicodeBidi() - { - return unicodeBidi; - } - - /** - * set the 'unicodeBidi' property - */ - virtual void setUnicodeBidi(const DOMString &val) - throw (dom::DOMException) - { - unicodeBidi = val; - } - - /** - * return the 'verticalAlign' property - */ - virtual DOMString getVerticalAlign() - { - return verticalAlign; - } - - /** - * set the 'verticalAlign' property - */ - virtual void setVerticalAlign(const DOMString &val) - throw (dom::DOMException) - { - verticalAlign = val; - } - - /** - * return the 'visibility' property - */ - virtual DOMString getVisibility() - { - return visibility; - } - - /** - * set the 'visibility' property - */ - virtual void setVisibility(const DOMString &val) - throw (dom::DOMException) - { - visibility = val; - } - - /** - * return the 'voiceFamily' property - */ - virtual DOMString getVoiceFamily() - { - return voiceFamily; - } - - /** - * set the 'voiceFamily' property - */ - virtual void setVoiceFamily(const DOMString &val) - throw (dom::DOMException) - { - voiceFamily = val; - } - - /** - * return the 'volume' property - */ - virtual DOMString getVolume() - { - return volume; - } - - /** - * set the 'volume' property - */ - virtual void setVolume(const DOMString &val) - throw (dom::DOMException) - { - volume = val; - } - - /** - * return the 'whiteSpace' property - */ - virtual DOMString getWhiteSpace() - { - return whiteSpace; - } - - /** - * set the 'whiteSpace' property - */ - virtual void setWhiteSpace(const DOMString &val) - throw (dom::DOMException) - { - whiteSpace = val; - } - - /** - * return the 'widows' property - */ - virtual DOMString getWidows() - { - return widows; - } - - /** - * set the 'widows' property - */ - virtual void setWidows(const DOMString &val) - throw (dom::DOMException) - { - widows = val; - } - - /** - * return the 'width' property - */ - virtual DOMString getWidth() - { - return width; - } - - /** - * set the 'width' property - */ - virtual void setWidth(const DOMString &val) - throw (dom::DOMException) - { - width = val; - } - - /** - * return the 'wordSpacing' property - */ - virtual DOMString getWordSpacing() - { - return wordSpacing; - } - - /** - * set the 'wordSpacing' property - */ - virtual void setWordSpacing(const DOMString &val) - throw (dom::DOMException) - { - wordSpacing = val; - } - - /** - * return the 'zIndex' property - */ - virtual DOMString getZIndex() - { - return zIndex; - } - - /** - * set the 'zIndex' property - */ - virtual void setZIndex(const DOMString &val) - throw (dom::DOMException) - { - zIndex = val; - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSS2Properties() - { - } - - /** - * - */ - CSS2Properties(const CSS2Properties &other) - { - assign(other); - } - - /** - * - */ - CSS2Properties &operator=(const CSS2Properties &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSS2Properties &other) - { - azimuth = other.azimuth; - background = other.background; - backgroundAttachment = other.backgroundAttachment; - backgroundColor = other.backgroundColor; - backgroundImage = other.backgroundImage; - backgroundPosition = other.backgroundPosition; - backgroundRepeat = other.backgroundRepeat; - border = other.border; - borderCollapse = other.borderCollapse; - borderColor = other.borderColor; - borderSpacing = other.borderSpacing; - borderStyle = other.borderStyle; - borderTop = other.borderTop; - borderRight = other.borderRight; - borderBottom = other.borderBottom; - borderLeft = other.borderLeft; - borderTopColor = other.borderTopColor; - borderRightColor = other.borderRightColor; - borderBottomColor = other.borderBottomColor; - borderLeftColor = other.borderLeftColor; - borderTopStyle = other.borderTopStyle; - borderRightStyle = other.borderRightStyle; - borderBottomStyle = other.borderBottomStyle; - borderLeftStyle = other.borderLeftStyle; - borderTopWidth = other.borderTopWidth; - borderRightWidth = other.borderRightWidth; - borderBottomWidth = other.borderBottomWidth; - borderLeftWidth = other.borderLeftWidth; - borderWidth = other.borderWidth; - bottom = other.bottom; - captionSide = other.captionSide; - clear = other.clear; - clip = other.clip; - color = other.color; - content = other.content; - counterIncrement = other.counterIncrement; - counterReset = other.counterReset; - cue = other.cue; - cueAfter = other.cueAfter; - cueBefore = other.cueBefore; - cursor = other.cursor; - direction = other.direction; - display = other.display; - elevation = other.elevation; - emptyCells = other.emptyCells; - cssFloat = other.cssFloat; - font = other.font; - fontFamily = other.fontFamily; - fontSize = other.fontSize; - fontSizeAdjust = other.fontSizeAdjust; - fontStretch = other.fontStretch; - fontStyle = other.fontStyle; - fontVariant = other.fontVariant; - fontWeight = other.fontWeight; - height = other.height; - left = other.left; - letterSpacing = other.letterSpacing; - lineHeight = other.lineHeight; - listStyle = other.listStyle; - listStyleImage = other.listStyleImage; - listStylePosition = other.listStylePosition; - listStyleType = other.listStyleType; - margin = other.margin; - marginTop = other.marginTop; - marginRight = other.marginRight; - marginBottom = other.marginBottom; - marginLeft = other.marginLeft; - markerOffset = other.markerOffset; - marks = other.marks; - maxHeight = other.maxHeight; - maxWidth = other.maxWidth; - minHeight = other.minHeight; - minWidth = other.minWidth; - orphans = other.orphans; - outline = other.outline; - outlineColor = other.outlineColor; - outlineStyle = other.outlineStyle; - outlineWidth = other.outlineWidth; - overflow = other.overflow; - padding = other.padding; - paddingTop = other.paddingTop; - paddingRight = other.paddingRight; - paddingBottom = other.paddingBottom; - paddingLeft = other.paddingLeft; - page = other.page; - pageBreakAfter = other.pageBreakAfter; - pageBreakBefore = other.pageBreakBefore; - pageBreakInside = other.pageBreakInside; - pause = other.pause; - pauseAfter = other.pauseAfter; - pauseBefore = other.pauseBefore; - pitch = other.pitch; - pitchRange = other.pitchRange; - playDuring = other.playDuring; - position = other.position; - quotes = other.quotes; - richness = other.richness; - right = other.right; - size = other.size; - speak = other.speak; - speakHeader = other.speakHeader; - speakNumeral = other.speakNumeral; - speakPunctuation = other.speakPunctuation; - speechRate = other.speechRate; - stress = other.stress; - tableLayout = other.tableLayout; - textAlign = other.textAlign; - textDecoration = other.textDecoration; - textIndent = other.textIndent; - textShadow = other.textShadow; - textTransform = other.textTransform; - top = other.top; - unicodeBidi = other.unicodeBidi; - verticalAlign = other.verticalAlign; - visibility = other.visibility; - voiceFamily = other.voiceFamily; - volume = other.volume; - whiteSpace = other.whiteSpace; - widows = other.widows; - width = other.width; - wordSpacing = other.wordSpacing; - zIndex = other.zIndex; - } - - /** - * - */ - virtual ~CSS2Properties() {} - -protected: - - //###################### - //# P R O P E R T I E S - //###################### - DOMString azimuth; - DOMString background; - DOMString backgroundAttachment; - DOMString backgroundColor; - DOMString backgroundImage; - DOMString backgroundPosition; - DOMString backgroundRepeat; - DOMString border; - DOMString borderCollapse; - DOMString borderColor; - DOMString borderSpacing; - DOMString borderStyle; - DOMString borderTop; - DOMString borderRight; - DOMString borderBottom; - DOMString borderLeft; - DOMString borderTopColor; - DOMString borderRightColor; - DOMString borderBottomColor; - DOMString borderLeftColor; - DOMString borderTopStyle; - DOMString borderRightStyle; - DOMString borderBottomStyle; - DOMString borderLeftStyle; - DOMString borderTopWidth; - DOMString borderRightWidth; - DOMString borderBottomWidth; - DOMString borderLeftWidth; - DOMString borderWidth; - DOMString bottom; - DOMString captionSide; - DOMString clear; - DOMString clip; - DOMString color; - DOMString content; - DOMString counterIncrement; - DOMString counterReset; - DOMString cue; - DOMString cueAfter; - DOMString cueBefore; - DOMString cursor; - DOMString direction; - DOMString display; - DOMString elevation; - DOMString emptyCells; - DOMString cssFloat; - DOMString font; - DOMString fontFamily; - DOMString fontSize; - DOMString fontSizeAdjust; - DOMString fontStretch; - DOMString fontStyle; - DOMString fontVariant; - DOMString fontWeight; - DOMString height; - DOMString left; - DOMString letterSpacing; - DOMString lineHeight; - DOMString listStyle; - DOMString listStyleImage; - DOMString listStylePosition; - DOMString listStyleType; - DOMString margin; - DOMString marginTop; - DOMString marginRight; - DOMString marginBottom; - DOMString marginLeft; - DOMString markerOffset; - DOMString marks; - DOMString maxHeight; - DOMString maxWidth; - DOMString minHeight; - DOMString minWidth; - DOMString orphans; - DOMString outline; - DOMString outlineColor; - DOMString outlineStyle; - DOMString outlineWidth; - DOMString overflow; - DOMString padding; - DOMString paddingTop; - DOMString paddingRight; - DOMString paddingBottom; - DOMString paddingLeft; - DOMString page; - DOMString pageBreakAfter; - DOMString pageBreakBefore; - DOMString pageBreakInside; - DOMString pause; - DOMString pauseAfter; - DOMString pauseBefore; - DOMString pitch; - DOMString pitchRange; - DOMString playDuring; - DOMString position; - DOMString quotes; - DOMString richness; - DOMString right; - DOMString size; - DOMString speak; - DOMString speakHeader; - DOMString speakNumeral; - DOMString speakPunctuation; - DOMString speechRate; - DOMString stress; - DOMString tableLayout; - DOMString textAlign; - DOMString textDecoration; - DOMString textIndent; - DOMString textShadow; - DOMString textTransform; - DOMString top; - DOMString unicodeBidi; - DOMString verticalAlign; - DOMString visibility; - DOMString voiceFamily; - DOMString volume; - DOMString whiteSpace; - DOMString widows; - DOMString width; - DOMString wordSpacing; - DOMString zIndex; - - -}; - - - - - - - - -/*######################################################################### -## ViewCSS -#########################################################################*/ - -/** - * This interface represents a CSS view. The getComputedStyle method provides a - * read only access to the computed values of an element. - * - * The expectation is that an instance of the ViewCSS interface can be obtained - * by using binding-specific casting methods on an instance of the AbstractView - * interface. - * - * Since a computed style is related to an Element node, if this element is - * removed from the document, the associated CSSStyleDeclaration and CSSValue - * related to this declaration are no longer valid. - */ -class ViewCSS : virtual public views::AbstractView -{ -public: - - /** - * This method is used to get the computed style as it is defined in [CSS2]. - */ - virtual CSSStyleDeclaration getComputedStyle(const Element &/*elt*/, - const DOMString &/*pseudoElt*/) - { - CSSStyleDeclaration style; - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - ViewCSS() : views::AbstractView() - { - } - - /** - * - */ - ViewCSS(const ViewCSS &other) : views::AbstractView(other) - { - } - - /** - * - */ - ViewCSS &operator=(const ViewCSS &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~ViewCSS() {} -}; - - - - - -/*######################################################################### -## DocumentCSS -#########################################################################*/ - -/** - * This interface represents a document with a CSS view. - * - * The getOverrideStyle method provides a mechanism through which a DOM author - * could effect immediate change to the style of an element without modifying the - * explicitly linked style sheets of a document or the inline style of elements - * in the style sheets. This style sheet comes after the author style sheet in - * the cascade algorithm and is called override style sheet. The override style - * sheet takes precedence over author style sheets. An "!important" declaration - * still takes precedence over a normal declaration. Override, author, and user - * style sheets all may contain "!important" declarations. User "!important" - * rules take precedence over both override and author "!important" rules, and - * override "!important" rules take precedence over author "!important" rules. - * - * The expectation is that an instance of the DocumentCSS interface can be - * obtained by using binding-specific casting methods on an instance of the - * Document interface. - */ -class DocumentCSS : virtual public stylesheets::DocumentStyle -{ -public: - - /** - * This method is used to retrieve the override style declaration for a specified - * element and a specified pseudo-element. - */ - virtual CSSStyleDeclaration getOverrideStyle(const Element */*elt*/, - const DOMString &/*pseudoElt*/) - { - CSSStyleDeclaration style; - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentCSS() : stylesheets::DocumentStyle() - { - } - - /** - * - */ - DocumentCSS(const DocumentCSS &other) : stylesheets::DocumentStyle(other) - { - } - - /** - * - */ - DocumentCSS &operator=(const DocumentCSS &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~DocumentCSS() {} -}; - - - - - - -/*######################################################################### -## DOMImplementationCSS -#########################################################################*/ - -/** - * This interface allows the DOM user to create a CSSStyleSheet outside the - * context of a document. There is no way to associate the new CSSStyleSheet with - * a document in DOM Level 2. - */ -class DOMImplementationCSS : virtual public DOMImplementation -{ -public: - - /** - * Creates a new CSSStyleSheet. - */ - virtual CSSStyleSheet createCSSStyleSheet(const DOMString &/*title*/, - const DOMString &/*media*/) - throw (dom::DOMException) - { - CSSStyleSheet sheet; - return sheet; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMImplementationCSS() {} - - /** - * - */ - DOMImplementationCSS(const DOMImplementationCSS &other) - : DOMImplementation(other) - { - } - - /** - * - */ - DOMImplementationCSS &operator=(const DOMImplementationCSS &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~DOMImplementationCSS() {} -}; - - - - - - - - -} //namespace css -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_CSS_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ diff --git a/src/dom/cssreader.cpp b/src/dom/cssreader.cpp deleted file mode 100644 index 93473b229..000000000 --- a/src/dom/cssreader.cpp +++ /dev/null @@ -1,1684 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "cssreader.h" -#include "ucd.h" - -#include -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace css -{ - -//######################################################################### -//# M E S S A G E S -//######################################################################### - -/** - * Get the column and row number of the given character position - */ -void CssReader::getColumnAndRow(int p, int &colResult, int &rowResult, int &lastNL) -{ - int col = 1; - int row = 1; - int lastnl = 0; - - for (int i=0 ; i

= parselen) - return 0; - XMLCh ch = parsebuf[p]; - //printf("%c", ch); - lastPosition = p; - return ch; -} - - - -/** - * Test if the given substring exists at the given position - * in parsebuf. Use get() in case of out-of-bounds - */ -bool CssReader::match(int pos, const char *str) -{ - while (*str) - { - if (get(pos++) != (XMLCh) *str++) - return false; - } - return true; -} - -/** - * - */ -int CssReader::skipwhite(int p) -{ - while (p < parselen) - { - //# XML COMMENT - if (match(p, "")) - { - p+=3; - done=true; - break; - } - p++; - } - lastPosition = p; - if (!done) - { - error("unterminated comment"); - return -1; - } - } - //# C comment - else if (match(p, "/*")) - { - p+=2; - bool done=false; - while (p'9') - break; - str.push_back(ch); - p++; - } - if (get(p) == '.' && get(p+1)>='0' && get(p+1)<='9') - { - p++; - str.push_back('.'); - while (p < parselen) - { - XMLCh ch = get(p); - if (ch<'0' || ch>'9') - break; - str.push_back(ch); - p++; - } - } - if (p>p0) - { - char *start = (char *)str.c_str(); - char *end = NULL; - double val = strtod(start, &end); - if (end > start) - { - result = val; - return p; - } - } - - //not a number - return p0; -} - - - -/** - * Assume that we are starting on a quote. Ends on the char - * after the final '"' - */ -int CssReader::getQuoted(int p0, DOMString &result) -{ - - int p = p0; - - XMLCh quoteChar = get(p); - if (quoteChar != '"' && quoteChar != '\'') - return p0; - - p++; - - DOMString buf; - - bool done = false; - while (pp) - { - p = p2; - continue; - } - - //Media - p2 = getMedia(p); - if (p2<0) - { - return -1; - } - if (p2>p) - { - p = p2; - continue; - } - - //Page - p2 = getPage(p); - if (p2<0) - { - return -1; - } - if (p2>p) - { - p = p2; - continue; - } - - //none of the above - break; - } - - return p; -} - -/** - * import - * : IMPORT_SYM S* - * [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S* - * ; - */ -int CssReader::getImport(int p0) -{ - int p = p0; - if (!match(p, "@import")) - return p0; - p+=7; - p = skipwhite(p); - - //# STRING | URI - DOMString str; - int p2 = getQuoted(p, str); - if (p2<0) - { - return -1; - } - if (p2<=p) - { - p2 = getUri(p, str); - if (p2<0) - { - return -1; - } - if (p2<=p) - { - error("quoted string or URI required after @import"); - return -1; - } - } - p = p2; - p2 = getMedium(p); - if (p2<0) - return -1; - - p = p2; - p = skipwhite(p); - XMLCh ch = get(p); - if (ch != ';') - { - error("@import must be terminated with ';'"); - return -1; - } - p++; - return p; -} - -/** - * media - * : MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S* - * ; - */ -int CssReader::getMedia(int p0) -{ - int p = p0; - XMLCh ch; - if (!match(p, "@media")) - return p0; - p+=6; - p = skipwhite(p); - - //# MEDIUM LIST - int p2 = getMedium(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("@media must be followed by medium"); - return -1; - } - p = p2; - while (true) - { - ch = get(p); - if (ch != ',') - break; - p2 = getMedium(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("',' in medium list must be followed by medium"); - return -1; - } - p = p2; - } - - p = skipwhite(p); - ch = get(p); - if (ch!='{') - { - error("@media requires '{' for ruleset"); - return -1; - } - p++; - p2 = getRuleSet(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("@media requires ruleset after '{'"); - return -1; - } - p = p2; - ch = get(p); - if (ch != '}') - { - error("@media requires '}' after ruleset"); - return -1; - } - p++; - return p0; -} - -/** - * medium - * : IDENT S* - * ; - */ -int CssReader::getMedium(int p0) -{ - int p = p0; - p = skipwhite(p); - - DOMString ident; - int p2 = getWord(p, ident); - if (p2<0) - return -1; - if (p2<=p) - return p0; - p = p2; - - return p; -} - -/** - * page - * : PAGE_SYM S* pseudo_page? S* - * LBRACE S* declaration [ ';' S* declaration ]* '}' S* - * ; - */ -int CssReader::getPage(int p0) -{ - int p = p0; - - //# @PAGE - p = skipwhite(p); - if (!match(p, "@page")) - return p0; - p+= 5; - - //#PSEUDO PAGE 0 or 1 - p = skipwhite(p); - int p2 = getPseudoPage(p); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - } - - //# { - p=skipwhite(p); - XMLCh ch = get(p); - if (p != '{') - { - error("@page requires '{' before declarations"); - } - p++; - - //# DECLARATION LIST - p = skipwhite(p); - CSSStyleDeclaration declarationList; - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2<=p) - { - error("@page requires declaration(s) after '{'"); - return -1; - } - while (true) - { - p = skipwhite(p2); - XMLCh ch = get(p); - if (ch != ';') - break; - p++; - p = skipwhite(p); - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2<= p) - { - error("@page requires declaration after ';'"); - return -1; - } - } - - //# } - p=skipwhite(p); - ch = get(p); - if (p != '}') - { - error("@page requires '}' after declarations"); - } - p++; - - return p; -} - -/** - * pseudo_page - * : ':' IDENT - * ; - */ -int CssReader::getPseudoPage(int p0) -{ - int p = p0; - if (!match(p, ":")) - return p0; - p++; - DOMString str; - int p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("pseudo-page requires identifier after ':'"); - return -1; - } - p = p2; - return p; -} - -/** - * ruleset - * : selector [ COMMA S* selector ]* - * LBRACE S* declaration [ ';' S* declaration ]* '}' S* - * ; - */ -int CssReader::getRuleSet(int p0) -{ - int p = p0; - XMLCh ch; - - //## SELECTOR - p = skipwhite(p); - int p2 = getSelector(p); - if (p2<0) - return -1; - if (p2<=p) //no selector - { - if (get(p) != '{')//check for selector-less rule - return p0;//not me - } - p = p2; - while (true) - { - p = skipwhite(p); - ch = get(p); - if (ch != ',') - break; - p++; - p = skipwhite(p); - int p2 = getSelector(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("selector required after ',' in list"); - return -1; - } - p = p2; - } - - //## { - ch = get(p); - if (ch != '{') - { - error("'{' required before declarations of ruleset"); - return -1; - } - p++; - - //## DECLARATIONS ( 0 to many ) - CSSStyleDeclaration declarationList; - - p = skipwhite(p); - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - while (true) - { - p = skipwhite(p); - ch = get(p); - if (ch != ';') - break; - p++; - p = skipwhite(p); - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2<=p) - { - //apparently this is ok - //error("declaration required after ';' in ruleset"); - //return -1; - break; - } - p = p2; - } - } - //## } - ch = get(p); - if (ch != '}') - { - error("ruleset requires closing '}'"); - return -1; - } - p++; - p = skipwhite(p); - - return p; -} - -/** - * selector - * : simple_selector [ combinator simple_selector ]* - * ; - */ -int CssReader::getSelector(int p0) -{ - int p = p0; - - //## SIMPLE SELECTOR - p = skipwhite(p); - int p2 = getSimpleSelector(p); - if (p2<0) - return -1; - if (p2<=p) - return p0; //not me - p = p2; - - //## COMBINATORS + MORE SELECTORS - while (true) - { - XMLCh ch = get(p); - bool wasSpace = isspace(ch); - p = skipwhite(p); - ch = get(p); - //# Combinators - //easier to do here than have a getCombinator() - int visibleCombinator = false; - if (ch == '+') - { - visibleCombinator = true; - p++; - } - else if (ch == '>') - { - visibleCombinator = true; - p++; - } - else if (wasSpace) - { - } - else - { - break; - } - p = skipwhite(p); - p2 = getSimpleSelector(p); - if (p2<0) - return -1; - if (p2<=p) - { - if (visibleCombinator) - { - error("need simple selector after combinator"); - return -1; - } - else - { - break; - } - } - p = p2; - } - return p; -} - -/** - * simple_selector - * : element_name [ HASH | class | attrib | pseudo ]* - * | [ HASH | class | attrib | pseudo ]+ - * ; - */ -int CssReader::getSimpleSelector(int p0) -{ - int p = p0; - int p2; - - DOMString str; - - p = skipwhite(p); - - int selectorItems = 0; - - XMLCh ch = get(p); - - //###################### - //# Note: do NOT skipwhite between items. Only within the - //# pseudo function and attrib below - //###################### - - //#Element name 0 or 1 - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null element name"); - return -1; - } - selectorItems++; - p = p2; - } - else if (ch == '*') - { - str = "*"; - p++; - selectorItems++; - } - - - - //## HASH, CLASS, ATTRIB, PSEUDO (0 to many with elem name, 1 to many without) - while (true) - { - XMLCh ch = get(p); - - //# HASH - if (ch == '#') - { - p++; - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for hash"); - return -1; - } - p = p2; - selectorItems++; - } - - //# CLASS - else if (ch == '.') - { - p++; - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for class"); - return -1; - } - p = p2; - selectorItems++; - } - - //# ATTRIB - else if (ch == '[') - { - p++; - p = skipwhite(p); - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for class"); - return -1; - } - p = skipwhite(p2); - bool getRHS=false; - if (match(p, "=")) - { - p++; - getRHS=true; - } - else if (match(p, "~=")) - { - p+=2; - getRHS=true; - } - else if (match(p, "|=")) - { - p+=2; - getRHS=true; - } - if (getRHS) - { - p = skipwhite(p); - ch = get(p); - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null ident on rhs of attrib"); - return -1; - } - p = p2; - } - else if (ch == '\'' || ch =='"') - { - p2 = getQuoted(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null literal string on rhs of attrib"); - return -1; - } - p = p2; - } - }//getRHS - p = skipwhite(p); - ch = get(p); - if (ch != ']') - { - error("attrib needs closing ']'"); - //return -1; - p = skipBlock(p); - return p; - } - p++; - selectorItems++; - } - - //# PSEUDO - else if (ch == ':') - { - p++; - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for pseudo"); - return -1; - } - p = p2; - selectorItems++; - ch = get(p); - if (ch == '(') - { - p++; - p = skipwhite(p); - ch = get(p); - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null function parameter in pseudo"); - return -1; - } - p = skipwhite(p2); - ch = get(p); - } - if (ch != ')') - { - error("function in pseudo needs ')'"); - return -1; - } - p++; - }// ch==( -function- - }//pseudo - - //# none of the above - else - { - break; - } - - }//while - - - if (selectorItems > 0) - return p; - return p0; -} - -/** - * declaration - * : property ':' S* expr prio? - * | {empty} - * ; - */ -int CssReader::getDeclaration(int p0, CSSStyleDeclaration &/*declarationList*/) -{ - int p = p0; - - //## PROPERTY - p = skipwhite(p); - XMLCh ch = get(p); - if (!uni_is_letter(ch)) - return p0; //not me - DOMString propName; - int p2 = getWord(p, propName); - if (p2<0) - return -1; - - //## ':' - p = skipwhite(p2); - ch = get(p); - if (ch != ':') - { - error("declaration requires ':' between name and value"); - return -1; - } - p++; - - //## EXPR - p = skipwhite(p); - p2 = getExpr(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("declaration requires value after ':'"); - return -1; - } - DOMString propVal; - for (int i=p ; ip) - { - //do something - p = p2; - } - - return p; -} - -/** - * prio - * : IMPORTANT_SYM S* - * ; - */ -int CssReader::getPrio(int p0, DOMString &val) -{ - int p = p0; - - //## '!" - p = skipwhite(p); - XMLCh ch = get(p); - if (ch != '!') - return p0; - p++; - - //## "important" - p = skipwhite(p); - if (!match(p, "important")) - { - error("priority symbol is 'important'"); - return -1; - } - p += 9; - val = "important"; - return p; -} - -/** - * expr - * : term [ operator term ]* - * ; - */ -int CssReader::getExpr(int p0) -{ - int p = p0; - - //## TERM - p = skipwhite(p); - int p2 = getTerm(p); - if (p2<0) - return -1; - if (p2<=p) - return p0; //not me - p = p2; - while (p < parselen) - { - p = skipwhite(p); - //#Operator. do this instead of getOperator() - XMLCh ch = get(p); - int visibleTerm = false; - if (ch == '/') - { - visibleTerm = true; - p++; - } - else if (ch == ',') - { - visibleTerm = true; - p++; - } - else - { - //just space. this is allowable between terms, - // so we still need to check for another term - } - p = skipwhite(p); - p2 = getTerm(p); - if (p2<0) - return -1; - if (p2<=p) - { - if (visibleTerm) - { - error("expression requires term after operator"); - return -1; - } - else - { - break; - } - } - p = p2; - } - - return p; -} - -/** - * term - * : unary_operator? - * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | - * TIME S* | FREQ S* | function ] - * | STRING S* | IDENT S* | URI S* | hexcolor - * ; - */ -int CssReader::getTerm(int p0) -{ - int p = p0; - p = skipwhite(p); - int unitType = CSSPrimitiveValue::CSS_UNKNOWN; /// \fixme Why is this variable never used? - //# Unary operator - XMLCh ch = get(p); - bool hasUnary = false; - if (ch == '-') - { - p++; - hasUnary = true; - } - else if (ch == '+') - { - p++; - hasUnary = true; - } - //# NUMERIC - double numVal; - int p2 = getNumber(p, numVal); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - if (match(p, "%")) - { - unitType = CSSPrimitiveValue::CSS_PERCENTAGE; - p++; - } - else if (match(p, "em")) - { - unitType = CSSPrimitiveValue::CSS_EMS; - p+=2; - } - else if (match(p, "ex")) - { - unitType = CSSPrimitiveValue::CSS_EXS; - p+=2; - } - else if (match(p, "px")) - { - unitType = CSSPrimitiveValue::CSS_PX; - p+=2; - } - else if (match(p, "cm")) - { - unitType = CSSPrimitiveValue::CSS_CM; - p+=2; - } - else if (match(p, "mm")) - { - unitType = CSSPrimitiveValue::CSS_MM; - p+=2; - } - else if (match(p, "in")) - { - unitType = CSSPrimitiveValue::CSS_IN; - p+=2; - } - else if (match(p, "pt")) - { - unitType = CSSPrimitiveValue::CSS_PT; - p+=2; - } - else if (match(p, "pc")) - { - unitType = CSSPrimitiveValue::CSS_PC; - p+=2; - } - else if (match(p, "deg")) - { - unitType = CSSPrimitiveValue::CSS_DEG; - p+=3; - } - else if (match(p, "rad")) - { - unitType = CSSPrimitiveValue::CSS_RAD; - p+=3; - } - else if (match(p, "grad")) - { - unitType = CSSPrimitiveValue::CSS_GRAD; - p+=4; - } - else if (match(p, "ms")) - { - unitType = CSSPrimitiveValue::CSS_MS; - p+=2; - } - else if (match(p, "s")) - { - unitType = CSSPrimitiveValue::CSS_S; - p+=1; - } - else if (match(p, "Hz")) - { - unitType = CSSPrimitiveValue::CSS_HZ; - p+=2; - } - else if (match(p, "kHz")) - { - unitType = CSSPrimitiveValue::CSS_KHZ; - p+=2; - } - else if (uni_is_letter(get(p)))//some other string - { - DOMString suffix; - p2 = getWord(p, suffix); - if (p2<0) - return -1; - unitType = CSSPrimitiveValue::CSS_DIMENSION; - p = p2; - } - else //plain number - { - unitType = CSSPrimitiveValue::CSS_NUMBER; - } - return p; - } - - DOMString str; - - //## URI --do before function, as syntax is similar - p2 = getUri(p, str); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on URI"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_URI; - return p; - } - - //## FUNCTION - p2 = getFunction(p); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - return p; - } - - //## STRING - ch = get(p); - if (ch == '"' || ch == '\'') - { - p2 = getQuoted(p, str); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on a string"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_STRING; - return p; - } - } - - //## IDENT - ch = get(p); - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on an identifier"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_IDENT; - return p; - } - } - - - //## HEXCOLOR - p2 = getHexColor(p); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on hex color"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_RGBCOLOR; - return p; - } - - - return p0; -} - -/** - * function - * : FUNCTION S* expr ')' S* - * ; - */ -int CssReader::getFunction(int p0) -{ - int p = p0; - - //## IDENT + ( (both) - DOMString name; - p = skipwhite(p); - int p2 = getWord(p, name); - if (p2<0) - return -1; - if (p2<=p) - return p0; //not me - if (name == "uri" || name=="url") - return p0; //not me - p = skipwhite(p2); - XMLCh ch = get(p); - if (ch != '(') - return p0; //still not me - p++; - - //## EXPR - p = skipwhite(p); - p2 = getExpr(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("function requires expression"); - return -1; - } - p = p2; - - //## ')' - p = skipwhite(p); - ch = get(p); - if (ch != ')') - { - error("function requires closing ')'"); - return -1; - } - p++; - p = skipwhite(p); - - return p; -} - -/** - * There is a constraint on the color that it must - * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F]) - * after the "#"; e.g., "#000" is OK, but "#abcd" is not. - * hexcolor - * : HASH S* - * ; - */ -int CssReader::getHexColor(int p0) -{ - int p = p0; - - //## '#' - p = skipwhite(p); - if (!match(p, "#")) - return p0; - p++; - - //## HEX - DOMString hex; - long hexVal = 0; - while (p < parselen) - { - XMLCh b = get(p); - if (b>='0' && b<='9') - { - hexVal = (hexVal << 4) + (b - '0'); - hex.push_back(b); - p++; - } - else if (b>='a' && b<='f') - { - hexVal = (hexVal << 4) + (b - 'a' + 10); - hex.push_back(b); - p++; - } - else if (b>='A' && b<='F') - { - hexVal = (hexVal << 4) + (b - 'A' + 10); - hex.push_back(b); - p++; - } - else - { - break; - } - } - - if (hex.size() != 3 && hex.size() != 6) - { - error("exactly 3 or 6 hex digits are required after '#'"); - return -1; - } - - return p; -} - - - -/** - * - */ -bool CssReader::parse(const DOMString &str) -{ - /* - int len = str.size(); - for (int i=0 ; i - -#include "domptr.h" - - -/** - * What type of string do we want? Pick one of the following - * Then below, select one of the corresponding typedefs. - */ - -#ifdef DOM_STANDALONE -# include -#else -# include -#endif - -//# Unfortunate hack for a name collision -#ifdef SEVERITY_ERROR -#undef SEVERITY_ERROR -#endif - -#define XMLNSNAME "http://www.w3.org/2000/xmlns/" - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - -/** - * This is the org::w3c::dom::DOMString definition. - * Which type do we want? - */ -#ifdef DOM_STANDALONE -typedef std::string DOMString; -typedef unsigned short XMLCh; -#else -typedef Glib::ustring DOMString; -typedef gunichar XMLCh; -#endif - -/** - * At least 64 bit time stamp value. - */ -typedef unsigned long long DOMTimeStamp; - -/** - * This is used for storing refs to user-supplied data. - */ -typedef void DOMUserData; - - - -/** - * This is used for opaque references to arbitrary objects from - * the DOM tree. - */ -typedef void DOMObject; - - -/** - * Forward references. These are needed because of extensive - * inter-referencing within the DOM tree. - */ -class NodeList; -class NamedNodeMap; -class DOMException; -class DOMStringList; -class NameList; -class DOMImplementationList; -class DOMImplementationSource; -class DOMImplementation; -class TypeInfo; -class UserDataHandler; -class DOMError; -class DOMErrorHandler; -class DOMLocator; -class DOMConfiguration; - -/** - * Smart pointer definitions. Most methods that return references to - * Nodes of various types, will return one of these smart pointers instead, - * to allow refcounting and GC. - */ -class Node; -typedef Ptr NodePtr; -class CharacterData; -typedef Ptr CharacterDataPtr; -class Attr; -typedef Ptr AttrPtr; -class Element; -typedef Ptr ElementPtr; -class Text; -typedef Ptr TextPtr; -class Comment; -typedef Ptr CommentPtr; -class DocumentType; -typedef Ptr DocumentTypePtr; -class CDATASection; -typedef Ptr CDATASectionPtr; -class Notation; -typedef Ptr NotationPtr; -class Entity; -typedef Ptr EntityPtr; -class EntityReference; -typedef Ptr EntityReferencePtr; -class ProcessingInstruction; -typedef Ptr ProcessingInstructionPtr; -class DocumentFragment; -typedef Ptr DocumentFragmentPtr; -class Document; -typedef Ptr DocumentPtr; - - - - -/** - * NOTE: We were originally intending to split ALL specifications into - * interface and implementation. After consideration, though, it behooves - * us to simplify things by implementing the base exception and - * container classes directly: - * - * DOMException - * DOMStringList - * NameList - * DOMImplementationList - * DOMImplementationSource - * DOMImplementation - * NodeList - * NamedNodeMap - */ - - -/*######################################################################### -## DOMException -#########################################################################*/ - -/** - * An Exception class. Not an interface, since this is something that - * all implementations must support. - */ -class DOMException -{ - -public: - - /** - * ExceptionCode - */ - typedef enum - { - 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, - VALIDATION_ERR = 16, - TYPE_MISMATCH_ERR = 17 - } ExceptionCode; - - - - DOMException(const DOMString &reasonMsg) - : msg (reasonMsg) - { } - - DOMException(short theCode) - { - code = theCode; - } - - virtual ~DOMException() throw() - {} - - /** - * What type of exception? One of the ExceptionCodes above. - */ - unsigned short code; - - /** - * Some text describing the context that generated this exception. - */ - DOMString msg; - - /** - * Get a string, translated from the code. - * Like std::exception. Not in spec. - */ - const char *what() - { return (const char *)msg.c_str(); } - - - -}; - - - - - - -/*######################################################################### -## DOMStringList -#########################################################################*/ - -/** - * This holds a list of DOMStrings. This is likely the response to a query, - * or the value of an attribute. - */ -class DOMStringList -{ -public: - - /** - * Get the nth string of the list - */ - virtual DOMString item(unsigned long index) - { - if (index>=strings.size()) - return ""; - return strings[index]; - } - - /** - * How many strings in this list? - */ - virtual unsigned long getLength() - { - return (unsigned long) strings.size(); - } - - /** - * Is the argument string present in this list? Lexically, not identically. - */ - virtual bool contains(const DOMString &str) - { - for (unsigned int i=0; istrings; - -}; - - - -/*######################################################################### -## NameList -#########################################################################*/ - - -/** - * Constains a list of namespaced names. - */ -class NameList -{ -private: - - class NamePair - { - public: - NamePair(const DOMString &theNamespaceURI, const DOMString &theName) - : namespaceURI (theNamespaceURI), - name (theName) - { - } - NamePair(const NamePair &other) - : namespaceURI (other.namespaceURI), - name (other.name) - { - } - NamePair &operator=(const NamePair &other) - { - namespaceURI = other.namespaceURI; - name = other.name; - return *this; - } - virtual ~NamePair() {} - - DOMString namespaceURI; - DOMString name; - }; - -public: - - /** - * Returns a name at the given index. If out of range, return -1. - */ - virtual DOMString getName(unsigned long index) - { - if (index>=namePairs.size()) - return ""; - return namePairs[index].name; - } - - /** - * Returns a namespace at the given index. If out of range, return -1. - */ - virtual DOMString getNamespaceURI(unsigned long index) - { - if (index>=namePairs.size()) - return ""; - return namePairs[index].namespaceURI; - } - - /** - * Return the number of entries in this list. - */ - virtual unsigned long getLength() - { - return (unsigned long)namePairs.size(); - } - - /** - * Return whether the name argument is present in the list. - * This is done lexically, not identically. - */ - virtual bool contains(const DOMString &name) - { - for (unsigned int i=0; i namePairs; - -}; - -/*######################################################################### -## DOMImplementationList -#########################################################################*/ - -/** - * Contains a list of DOMImplementations, with accessors. - */ -class DOMImplementationList -{ -public: - - /** - * Return a DOMImplementation at the given index. If - * out of range, return NULL. - */ - virtual DOMImplementation *item(unsigned long index) - { - if (index >implementations.size()) - return NULL; - return implementations[index]; - } - - /** - * Return the number of DOMImplementations in this list. - */ - virtual unsigned long getLength() - { - return (unsigned long) implementations.size(); - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMImplementationList() {} - - - /** - * - */ - DOMImplementationList(const DOMImplementationList &other) - : implementations (other.implementations) - { - } - - /** - * - */ - DOMImplementationList &operator=(const DOMImplementationList &other) - { - implementations = other.implementations; - return *this; - } - - /** - * - */ - virtual ~DOMImplementationList() {} - -protected: - - std::vectorimplementations; - -}; - - -/*######################################################################### -## DOMImplementationSource -#########################################################################*/ - -/** - * This is usually the first item to be called when creating a Document. - * You will either find one DOMImplementation with a given set of features, - * or return a list that match. Using "" will get any implementation - * available. - */ -class DOMImplementationSource -{ -public: - - /** - * Return the first DOMImplementation with the given set of features. - * Use "" to fetch any implementation. - */ - virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0; - - /** - * Return a list of DOMImplementations with the given set of features. - * Use "" to fetch any implementation. - */ - virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementationSource() {} - -}; - - - - - -/*######################################################################### -## DOMImplementation -#########################################################################*/ - -/** - * This is the class that actually creates a Document. - */ -class DOMImplementation -{ -public: - - /** - * Determine if this implementation has the given feature and version. - */ - virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0; - - - /** - * Create a document type to be used in creating documents. - */ - virtual DocumentTypePtr createDocumentType( - const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException) = 0; - - /** - * Create a DOM document. - */ - virtual DocumentPtr createDocument(const DOMString& namespaceURI, - const DOMString& qualifiedName, - DocumentTypePtr doctype) - throw(DOMException) = 0; - /** - * Return the thing which is the feature of this implementation. Since - * this is a "one size fits all" call, you will need to typecast the - * result to the expected type. - */ - virtual DOMObject *getFeature(const DOMString& feature, - const DOMString& version) = 0; - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementation() {} - -}; - - - - - -/*######################################################################### -## Node -#########################################################################*/ - -/** - * The basic Node class, which is the root of most other - * classes in DOM. Thus it is by far the most important, and the one - * whose implementation we must perform correctly. - */ -class Node -{ -public: - - /** - * Which of the DOM Core node types is this node? - */ - typedef enum - { - 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 - } NodeType; - - /** - * Return the name of this node. - */ - virtual DOMString getNodeName() = 0; - - /** - * Return the value of this node. The interpretation of the - * value is type-specific. - */ - virtual DOMString getNodeValue() throw (DOMException) = 0; - - /** - * Set the value of this node. The interpretation of the - * value is type-specific. - */ - virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0; - - /** - * Return the type of this Node. One of the NodeType values above. - */ - virtual unsigned short getNodeType() = 0; - - /** - * Return the parent which references this node as a child in the DOM - * tree. Return NULL if there is none. - */ - virtual NodePtr getParentNode() = 0; - - /** - * Return a list of the children of this Node. - * NOTE: the spec expects this to be a "live" list that always - * reflects an accurate list of what the Node current possesses, not - * a snapshot. How do we do this? - */ - virtual NodeList getChildNodes() = 0; - - /** - * Return the first sibling of the chidren of this node. Return - * null if there is none. - */ - virtual NodePtr getFirstChild() = 0; - - /** - * Return the last sibling of the children of this node. Return - * null if there is none. - */ - virtual NodePtr getLastChild() = 0; - - /** - * Return the node that is previous to this one in the parent's - * list of children. Return null if there is none. - */ - virtual NodePtr getPreviousSibling() = 0; - - /** - * Return the node that is after this one in the parent's list - * of children. Return null if there is none. - */ - virtual NodePtr getNextSibling() = 0; - - /** - * Get the list of all attributes of this node. - */ - virtual NamedNodeMap &getAttributes() = 0; - - - /** - * Return the document that created or inherited this node. - */ - virtual DocumentPtr getOwnerDocument() = 0; - - /** - * Insert a node as a new child. Place it before the referenced child. - * Place it at the end if the referenced child does not exist. - */ - virtual NodePtr insertBefore(const NodePtr newChild, - const NodePtr refChild) - throw(DOMException) = 0; - - /** - * Insert a node as a new child. Replace the referenced child with it. - * Place it at the end if the referenced child does not exist. - */ - virtual NodePtr replaceChild(const NodePtr newChild, - const NodePtr oldChild) - throw(DOMException) = 0; - - /** - * Remove a node from the list of children. Do nothing if the - * node is not a member of the child list. - */ - virtual NodePtr removeChild(const NodePtr oldChild) - throw(DOMException) = 0; - - /** - * Add the node to the end of this node's child list. - */ - virtual NodePtr appendChild(const NodePtr newChild) - throw(DOMException) = 0; - - /** - * Return true if this node has one or more children, else return false. - */ - virtual bool hasChildNodes() = 0; - - /** - * Return a new node which has the name, type, value, attributes, and - * child list as this one. - * If 'deep' is true, continue cloning recursively with this node's children, - * so that the child list also contains clones of their respective nodes. - */ - virtual NodePtr cloneNode(bool deep) = 0; - - /** - * Adjust this node and its children to have its namespaces and - * prefixes in "canonical" order. - */ - virtual void normalize() = 0; - - /** - * Return true if the named feature is supported by this node, - * else false. - */ - virtual bool isSupported(const DOMString& feature, - const DOMString& version) = 0; - - /** - * Return the namespace of this node. This would be whether the - * namespace were declared explicitly on this node, it has a namespace - * prefix, or it is inherits the namespace from an ancestor node. - */ - virtual DOMString getNamespaceURI() = 0; - - /** - * Return the namespace prefix of this node, if any. For example, if - * the tag were then the prefix would be "svg" - */ - virtual DOMString getPrefix() = 0; - - /** - * Sets the namespace prefix of this node to the given value. This - * does not change the namespaceURI value. - */ - virtual void setPrefix(const DOMString& val) throw(DOMException) = 0; - - /** - * Return the local name of this node. This is merely the name without - * any namespace or prefix. - */ - virtual DOMString getLocalName() = 0; - - /** - * Return true if this node has one or more attributes, else false. - */ - virtual bool hasAttributes() = 0; - - /** - * Return the base URI of this node. This is basically the "location" of this - * node, and is used in resolving the relative locations of other URIs. - */ - virtual DOMString getBaseURI() = 0; - - /** - * DocumentPosition. - * This is used to describe the position of one node relative - * to another in a document - */ - typedef enum - { - DOCUMENT_POSITION_DISCONNECTED = 0x01, - DOCUMENT_POSITION_PRECEDING = 0x02, - DOCUMENT_POSITION_FOLLOWING = 0x04, - DOCUMENT_POSITION_CONTAINS = 0x08, - DOCUMENT_POSITION_CONTAINED_BY = 0x10, - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20 - } DocumentPosition; - - - /** - * Get the position of this node relative to the node argument. - */ - virtual unsigned short compareDocumentPosition( - const NodePtr other) = 0; - - /** - * This is a DOM L3 method. Return the text value of this node and its - * children. This is done by concatenating all of the TEXT_NODE and - * CDATA_SECTION nodes of this node and its children, in order, together. - * Very handy. - */ - virtual DOMString getTextContent() throw(DOMException) = 0; - - - /** - * This is a DOM L3 method. Remember, this is a destructive call. This - * will replace all of the child nodes of this node with a single TEXT_NODE - * with the given text value. - */ - virtual void setTextContent(const DOMString &val) throw(DOMException) = 0; - - - /** - * This will search the tree from this node up, for a prefix that - * has been assigned to the namespace argument. Return "" if not found. - */ - virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0; - - - /** - * Return true if this node is in the namespace of the argument, without - * requiring an explicit namespace declaration or a suffix. - */ - virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0; - - - /** - * This will search the tree from this node up, for a namespace that - * has been assigned the suffix in the argument. Return "" if not found. - */ - virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0; - - - /** - * Return true if the argument node is equal to this one. Use W3C rules - * for equality. - */ - virtual bool isEqualNode(const NodePtr node) =0; - - - - /** - * Return an opaque reference to the named feature. Return null if - * not supported. Using other than "" for the version will look for - * a feature with the given version. - */ - virtual DOMObject *getFeature(const DOMString &feature, - const DOMString &version) =0; - - /** - * Store a user data reference in this node, using the given key. - * A handler is an optional function object that will be called during - * future settings of this value. See UserDataHandler for more info. - */ - virtual DOMUserData *setUserData(const DOMString &key, - const DOMUserData *data, - const UserDataHandler *handler) =0; - - - /** - * Return a reference to the named user data object. Return null - * if it does not exist. - */ - virtual DOMUserData *getUserData(const DOMString &key) =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - Node() : _refCnt(0) - {} - - /** - * - */ - virtual ~Node() {} - -protected: - - friend void incrementRefCount(Node *p); - friend void decrementRefCount(Node *p); - - /** - * For the Ptr smart pointer - */ - int _refCnt; - -}; - - - - -/*######################################################################### -## NodeList -#########################################################################*/ - -/** - * Contains a list of Nodes. This is the standard API container for Nodes, - * and is used in lieu of other lists, arrays, etc, in order to provide - * a consistent API and algorithm. - */ -class NodeList -{ -public: - - /** - * Retrieve the Node at the given index. Return NULL - * if out of range. - */ - virtual NodePtr item(unsigned long index) - { - if (index>=nodes.size()) - return NULL; - return nodes[index]; - } - - /** - * Get the number of nodes in this list - */ - virtual unsigned long getLength() - { - return (unsigned long) nodes.size(); - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - NodeList() {} - - /** - * - */ - NodeList(const NodeList &other) - : nodes (other.nodes) - { - } - - /** - * - */ - NodeList &operator=(const NodeList &other) - { - nodes = other.nodes; - return *this; - } - - /** - * - */ - virtual ~NodeList() {} - - /** - * - */ - virtual void clear() - { - nodes.clear(); - } - -protected: - -friend class NodeImpl; -friend class ElementImpl; - - /* - * - */ - virtual void add(const NodePtr node) - { - nodes.push_back(node); - } - -protected: - - std::vector nodes; - -}; - - - - -/*######################################################################### -## NamedNodeMap -#########################################################################*/ - -/** - * Contains a mapping from name->NodePtr. Used for various purposes. For - * example, a list of Attributes is a NamedNodeMap. - */ -class NamedNodeMap -{ -private: - - /** - * table entry. Not an API item - */ - class NamedNodeMapEntry - { - public: - NamedNodeMapEntry(const DOMString &theNamespaceURI, - const DOMString &theName, - const NodePtr theNode) - : namespaceURI (theNamespaceURI), - name (theName), - node (theNode) - { - } - NamedNodeMapEntry(const NamedNodeMapEntry &other) - { - assign(other); - } - NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other) - { - assign(other); - return *this; - } - virtual ~NamedNodeMapEntry() - { - } - void assign(const NamedNodeMapEntry &other) - { - namespaceURI = other.namespaceURI; - name = other.name; - node = other.node; - } - DOMString namespaceURI; - DOMString name; - NodePtr node; - }; - - -public: - - /** - * Return the named node. Return nullptr if not found. - */ - virtual NodePtr getNamedItem(const DOMString& name) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->name == name) - { - NodePtr node = iter->node; - return node; - } - } - return NULL; - } - - /** - * Adds a node using its nodeName attribute. If a node with that name is already - * present in this map, it is replaced by the new one. Replacing a node by itself - * has no effect. - */ - virtual NodePtr setNamedItem(NodePtr arg) throw(DOMException) - { - if (!arg) - return NULL; - DOMString namespaceURI = arg->getNamespaceURI(); - DOMString name = arg->getNodeName(); - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->name == name) - { - NodePtr node = iter->node; - iter->node = arg; - return node; - } - } - NamedNodeMapEntry entry(namespaceURI, name, arg); - entries.push_back(entry); - return arg; - } - - - /** - * Removes a node specified by name. - */ - virtual NodePtr removeNamedItem(const DOMString& name) throw(DOMException) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->name == name) - { - NodePtr node = iter->node; - entries.erase(iter); - return node; - } - } - return NULL; - } - - /** - * Retrieves an item at the given index. If out of bounds, return NULL - */ - virtual NodePtr item(unsigned long index) - { - if (index>=entries.size()) - return NULL; - return entries[index].node; - } - - /** - * Return the number of items in this map - */ - virtual unsigned long getLength() - { - return (unsigned long)entries.size(); - } - - /** - * Retrieves a node specified by local name and namespace URI. - */ - virtual NodePtr getNamedItemNS(const DOMString& namespaceURI, - const DOMString& localName) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->namespaceURI == namespaceURI && iter->name == localName) - { - NodePtr node = iter->node; - return node; - } - } - return NULL; - } - - /** - * 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. Replacing a node by itself has no effect. - */ - virtual NodePtr setNamedItemNS(NodePtr arg) throw(DOMException) - { - if (!arg) - return NULL; - DOMString namespaceURI = arg->getNamespaceURI(); - DOMString name = arg->getNodeName(); - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->namespaceURI == namespaceURI && iter->name == name) - { - NodePtr node = iter->node; - iter->node = arg; - return node; - } - } - NamedNodeMapEntry entry(namespaceURI, name, arg); - entries.push_back(entry); - return arg; - } - - /** - * Removes a node specified by local name and namespace URI. - */ - virtual NodePtr removeNamedItemNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->namespaceURI == namespaceURI && iter->name == localName) - { - NodePtr node = iter->node; - entries.erase(iter); - return node; - } - } - return NULL; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - NamedNodeMap() {} - - - /** - * - */ - NamedNodeMap(const NamedNodeMap &other) - : entries (other.entries) - { - } - - /** - * - */ - NamedNodeMap &operator=(const NamedNodeMap &other) - { - entries = other.entries; - return *this; - } - - - /** - * - */ - virtual ~NamedNodeMap() {} - -protected: - - std::vector entries; - -}; - - - - -/*######################################################################### -## CharacterData -#########################################################################*/ - -/** - * This is the base class for other text-oriented Nodes, such as TEXT_NODE - * or CDATA_SECTION_NODE. No DOM objects correspond directly to CharacterData. - */ -class CharacterData : virtual public Node -{ -public: - - /** - * This is an alias for getNodeValue() - */ - virtual DOMString getData() throw(DOMException) = 0; - - /** - * This is an alias for setNodeValue() - */ - virtual void setData(const DOMString& val) throw(DOMException) = 0; - - /** - * Return the number of characters contained in this node's data - */ - virtual unsigned long getLength() = 0; - - /** - * Return a substring of this node's data, starting at offset, and - * continuing for 'count' characters. Throw an exception if this goes - * out of range. - */ - virtual DOMString substringData(unsigned long offset, - unsigned long count) - throw(DOMException) = 0; - - /** - * Append the argument string to the end of the node's current data. - */ - virtual void appendData(const DOMString& arg) throw(DOMException) = 0; - - /** - * Insert the argument string at the offset position into the node's - * current data. If the position is out of range, throw an Exception. - */ - virtual void insertData(unsigned long offset, - const DOMString& arg) - throw(DOMException) = 0; - - /** - * Delete 'count' characters from the node's data starting from the - * offset position. If this goes out of range, throw an Exception. - */ - virtual void deleteData(unsigned long offset, - unsigned long count) - throw(DOMException) = 0; - - /** - * Replace the 'count' characters at the offset position with the given - * argument string. If this goes out of range, throw an Exception. - */ - virtual void replaceData(unsigned long offset, - unsigned long count, - const DOMString& arg) - throw(DOMException) = 0; - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~CharacterData() {} - -}; - - - - -/*######################################################################### -## Attr -#########################################################################*/ - -/** - * The Attr interface represents an attribute in an Element object. - * Typically the allowable values for the attribute are defined in a - * schema associated with the document. - * Since Attrs are not considered to be part of the DOM tree, parent, - * previousSibling, and nextSibling are null. - */ -class Attr : virtual public Node -{ -public: - - /** - * Returns the name of this attribute. If Node.localName is different - * from null, this attribute is a qualified name. - */ - virtual DOMString getName() = 0; - - /** - * True if this attribute was explicitly given a value in the instance document, - * false otherwise. If the application changed the value of this attribute node - * (even if it ends up having the same value as the default value) then it is set - * to true. The implementation may handle attributes with default values from - * other schemas similarly but applications should use - * Document.normalizeDocument() to guarantee this information is up-to-date. - */ - virtual bool getSpecified() = 0; - - /** - * Returns the value of the attribute - */ - virtual DOMString getValue() = 0; - - /** - * Sets the value of the attribute - */ - virtual void setValue(const DOMString& val) throw(DOMException) = 0; - - /** - * Return the Element that possesses this attribute - */ - virtual ElementPtr getOwnerElement() = 0; - - - /** - * The type information associated with this attribute. - */ - virtual TypeInfo &getSchemaTypeInfo() = 0; - - - /** - * Returns whether this attribute is known to be of type ID (i.e. to contain an - * identifier for its owner element) or not. When it is and its value is unique, - * the ownerElement of this attribute can be retrieved using the method - * Document.getElementById. - */ - virtual bool getIsId() = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Attr() {} - -}; - - - - - -/*######################################################################### -## Element -#########################################################################*/ - -/** - * The Element interface represents an element in an XML document. - * Elements may have attributes associated with them; since the Element interface - * inherits from Node, the generic Node interface attribute attributes may be - * used to retrieve the set of all attributes for an element. There are methods - * on the Element interface to retrieve either an Attr object by name or an - * attribute value by name. In XML, where an attribute value may contain entity - * references, an 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 Element : virtual public Node -{ -public: - - - /** - * The name of the element. If Node.localName is different from null, - * this attribute is a qualified name. - */ - virtual DOMString getTagName() = 0; - - /** - * Retrieves an attribute value by name. - */ - virtual DOMString getAttribute(const DOMString& name) = 0; - - /** - * 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 Attr node plus any Text and EntityReference nodes, - * build the appropriate subtree, and use setAttributeNode to assign it as the - * value of an attribute. - */ - virtual void setAttribute(const DOMString& name, - const DOMString& value) - throw(DOMException) = 0; - - /** - * Removes an attribute by name. If no attribute with this name is found, - * this method has no effect. - */ - virtual void removeAttribute(const DOMString& name) - throw(DOMException) = 0; - - /** - * Retrieves an attribute node by name. - */ - virtual AttrPtr getAttributeNode(const DOMString& name) = 0; - - /** - * Adds a new attribute node. If an attribute with that name (nodeName) - * is already present in the element, it is replaced by the new one. - * Replacing an attribute node by itself has no effect. - */ - virtual AttrPtr setAttributeNode(AttrPtr newAttr) - throw(DOMException) = 0; - - /** - * Removes the specified attribute node. - */ - virtual AttrPtr removeAttributeNode(AttrPtr oldAttr) - throw(DOMException) = 0; - - /** - * Returns a NodeList of all descendant Elements with a given tag name, - * in document order. - */ - virtual NodeList getElementsByTagName(const DOMString& name) = 0; - - /** - * Retrieves an attribute value by local name and namespace URI. - * Per [XML Namespaces], applications must use the value null as the - * namespaceURI parameter for methods if they wish to have no namespace. - */ - virtual DOMString getAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * 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. - */ - virtual void setAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName, - const DOMString& value) - throw(DOMException) = 0; - - /** - * Removes an attribute by local name and namespace URI. - */ - virtual void removeAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException) = 0; - - /** - * Retrieves an Attr node by local name and namespace URI. - */ - virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * 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. Replacing an attribute node by itself has no effect. - */ - virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr) - throw(DOMException) = 0; - - /** - * Returns a NodeList of all the descendant Elements with a given - * local name and namespace URI in document order. - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * Returns true when an attribute with a given name is specified on - * this element or has a default value, false otherwise. - */ - virtual bool hasAttribute(const DOMString& name) = 0; - - /** - * 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. - */ - virtual bool hasAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * The type information associated with this element. - */ - virtual TypeInfo &getSchemaTypeInfo() = 0; - - - /** - * If the parameter isId is true, this method declares the specified - * attribute to be a user-determined ID attribute. - */ - virtual void setIdAttribute(const DOMString &name, - bool isId) throw (DOMException) = 0; - - /** - * If the parameter isId is true, this method declares the specified - * attribute to be a user-determined ID attribute. - */ - virtual void setIdAttributeNS(const DOMString &namespaceURI, - const DOMString &localName, - bool isId) throw (DOMException) = 0; - - /** - * If the parameter isId is true, this method declares the specified - * attribute to be a user-determined ID attribute. - */ - virtual void setIdAttributeNode(const AttrPtr idAttr, - bool isId) throw (DOMException) = 0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~Element() {} - -}; - - - - - -/*######################################################################### -## Text -#########################################################################*/ - -/** - * The Text interface inherits from CharacterData and represents the textual - * content (termed character data in XML) of an Element or Attr. If there is no - * markup inside an element's content, the text is contained in a single object - * implementing the Text interface that is the only child of the element. If - * there is markup, it is parsed into the information items (elements, comments, - * etc.) and Text nodes that form the list of children of the element. - */ -class Text : virtual public CharacterData -{ -public: - - /** - * Breaks this node into two nodes at the specified offset, keeping both in the - * tree as siblings. After being split, this node will contain all the content up - * to the offset point. A new node of the same type, which contains all the - * content at and after the offset point, is returned. If the original node had a - * parent node, the new node is inserted as the next sibling of the original - * node. When the offset is equal to the length of this node, the new node has no - * data. - */ - virtual TextPtr splitText(unsigned long offset) - throw(DOMException) = 0; - - /** - * Returns whether this text node contains element content whitespace, often - * abusively called "ignorable whitespace". The text node is determined to - * contain whitespace in element content during the load of the document or if - * validation occurs while using Document.normalizeDocument(). - */ - virtual bool getIsElementContentWhitespace()= 0; - - /** - * Returns all text of Text nodes logically-adjacent text nodes - * to this node, concatenated in document order. - */ - virtual DOMString getWholeText() = 0; - - - /** - * Replaces the text of the current node and all logically-adjacent text nodes - * with the specified text. All logically-adjacent text nodes are removed - * including the current node unless it was the recipient of the replacement text. - * - * This method returns the node which received the replacement text. The returned - * node is: - * o null, when the replacement text is the empty string; - * o the current node, except when the current node is read-only; - * o a new Text node of the same type (Text or CDATASection) as - * the current node inserted at the location of the replacement. - */ - virtual TextPtr replaceWholeText(const DOMString &content) - throw(DOMException) = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Text() {} - -}; - - - -/*######################################################################### -## Comment -#########################################################################*/ - -/** - * This interface inherits from CharacterData and represents the content of a - * comment, i.e., all the characters between the starting ''. - * 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 Comment : virtual public CharacterData -{ -public: - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Comment() {} - - -}; - - - -/*######################################################################### -## TypeInfo -#########################################################################*/ - -/** - * The TypeInfo interface represents a type referenced from Element or Attr nodes, - * specified in the schemas associated with the document. The type is a pair of - * a namespace URI and name properties, and depends on the document's schema. - */ -class TypeInfo -{ -public: - - /** - * The name of a type declared for the associated element or attribute, - * or null if unknown. - */ - virtual DOMString getTypeName() - { return typeName; } - - /** - * The namespace of the type declared for the associated element - * or attribute or null if the element does not have declaration or - * if no namespace information is available. - */ - virtual DOMString getTypeNamespace() - { return typeNameSpace; } - - /** - * These are the available values for the derivationMethod parameter used by the - * method TypeInfo.isDerivedFrom(). It is a set of possible types of derivation, - * and the values represent bit positions. If a bit in the derivationMethod - * parameter is set to 1, the corresponding type of derivation will be taken into - * account when evaluating the derivation between the reference type definition - * and the other type definition. When using the isDerivedFrom method, combining - * all of them in the derivationMethod parameter is equivalent to invoking the - * method for each of them separately and combining the results with the OR - * boolean function. This specification only defines the type of derivation for - * XML Schema. - */ - typedef enum - { - DERIVATION_RESTRICTION = 0x00000001, - DERIVATION_EXTENSION = 0x00000002, - DERIVATION_UNION = 0x00000004, - DERIVATION_LIST = 0x00000008 - } DerivationMethod; - - - /** - * This method returns if there is a derivation between the reference - * type definition, i.e. the TypeInfo on which the method is being called, - * and the other type definition, i.e. the one passed as parameters. - */ - virtual bool isDerivedFrom(const DOMString &/*typeNamespaceArg*/, - const DOMString &/*typeNameArg*/, - DerivationMethod /*derivationMethod*/) - { return false; } - - //################## - //# Non-API methods - //################## - - - /** - * - */ - TypeInfo() - {} - - /** - * - */ - TypeInfo(const TypeInfo &other) - { assign(other); } - - /** - * - */ - TypeInfo &operator=(const TypeInfo &other) - { assign(other); return *this; } - - /** - * - */ - virtual ~TypeInfo() {} - -private: - - void assign(const TypeInfo &other) - { - typeName = other.typeName; - typeNameSpace = other.typeNameSpace; - } - - DOMString typeName; - DOMString typeNameSpace; -}; - - - - -/*######################################################################### -## UserDataHandler -#########################################################################*/ - -/** - * When associating an object to a key on a node using Node.setUserData() the - * application can provide a handler that gets called when the node the object is - * associated to is being cloned, imported, or renamed. This can be used by the - * application to implement various behaviors regarding the data it associates to - * the DOM nodes. This interface defines that handler. - */ -class UserDataHandler -{ -public: - - /** - * An integer indicating the type of operation being performed on a node. - */ - typedef enum - { - NODE_CLONED = 1, - NODE_IMPORTED = 2, - NODE_DELETED = 3, - NODE_RENAMED = 4, - NODE_ADOPTED = 5 - } OperationType; - - - /** - * This method is called whenever the node for which this handler - * is registered is imported or cloned. - */ - virtual void handle(unsigned short operation, - const DOMString &key, - const DOMUserData *data, - const NodePtr src, - const NodePtr dst) =0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~UserDataHandler() {} - -}; - - -/*######################################################################### -## DOMError -#########################################################################*/ - -/** - * DOMError is an interface that describes an error. - */ -class DOMError -{ -public: - - /** - * An integer indicating the severity of the error. - */ - typedef enum - { - SEVERITY_WARNING = 1, - SEVERITY_ERROR = 2, - SEVERITY_FATAL_ERROR = 3 - } ErrorSeverity; - - - /** - * The severity of the error, either SEVERITY_WARNING, SEVERITY_ERROR, - * or SEVERITY_FATAL_ERROR. - */ - virtual unsigned short getSeverity() =0; - - /** - * An implementation specific string describing the error that occurred. - */ - virtual DOMString getMessage() =0; - - /** - * A DOMString indicating which related data is expected in relatedData. - * Users should refer to the specification of the error in order to find - * its DOMString type and relatedData definitions if any. - */ - virtual DOMString getType() =0; - - /** - * The related platform dependent exception if any. - */ - virtual DOMObject *getRelatedException() =0; - - /** - * The related DOMError.type dependent data if any. - */ - virtual DOMObject *getRelatedData() =0; - - /** - * The location of the error. - */ - virtual DOMLocator *getLocation() =0; - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~DOMError() {} - -}; - - -/*######################################################################### -## DOMErrorHandler -#########################################################################*/ - -/** - * DOMErrorHandler is a callback interface that the DOM implementation can call - * when reporting errors that happens while processing XML data, or when doing - * some other processing (e.g. validating a document). A DOMErrorHandler object - * can be attached to a Document using the "error-handler" on the - * DOMConfiguration interface. If more than one error needs to be reported during - * an operation, the sequence and numbers of the errors passed to the error - * handler are implementation dependent. - */ -class DOMErrorHandler -{ -public: - - /** - * This method is called on the error handler when an error occurs. - * If an exception is thrown from this method, it is considered to be - * equivalent of returning true. - */ - virtual bool handleError(const DOMError *error) =0; - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMErrorHandler() {} - -}; - - - -/*######################################################################### -## DOMLocator -#########################################################################*/ - -/** - * DOMLocator is an interface that describes a location (e.g. where an error occurred). - */ -class DOMLocator -{ -public: - - /** - * The line number this locator is pointing to, or -1 if there is - * no column number available. - */ - virtual long getLineNumber() =0; - - /** - * The column number this locator is pointing to, or -1 if there is - * no column number available. - */ - virtual long getColumnNumber() =0; - - /** - * The byte offset into the input source this locator is pointing to - * or -1 if there is no byte offset available. - */ - virtual long getByteOffset() =0; - - /** - * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], - * offset into the input source this locator is pointing to or -1 - * if there is no UTF-16 offset available. - */ - virtual long getUtf16Offset() =0; - - - /** - * The node this locator is pointing to, or null if no node is available. - */ - virtual NodePtr getRelatedNode() =0; - - - /** - * The URI this locator is pointing to, or null if no URI is available. - */ - virtual DOMString getUri() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMLocator() {} -}; - - -/*######################################################################### -## DOMConfiguration -#########################################################################*/ - -/** - * The DOMConfiguration interface represents the configuration of a document and - * maintains a table of recognized parameters. Using the configuration, it is - * possible to change Document.normalizeDocument() behavior, such as replacing - * the CDATASection nodes with Text nodes or specifying the type of the schema - * that must be used when the validation of the Document is requested. - * DOMConfiguration objects are also used in [DOM Level 3 Load and Save] in the - * DOMParser and DOMSerializer interfaces. - * - * Look here for a list of valid parameters: - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMConfiguration - */ -class DOMConfiguration -{ -public: - - /** - * Set the value of a parameter. - */ - virtual void setParameter(const DOMString &name, - const DOMUserData *value) - throw (DOMException) =0; - - /** - * Return the value of a parameter if known. - */ - virtual DOMUserData *getParameter(const DOMString &name) - throw (DOMException) =0; - - /** - * Check if setting a parameter to a specific value is supported. - */ - virtual bool canSetParameter(const DOMString &name, - const DOMUserData *data) =0; - - /** - * The list of the parameters supported by this DOMConfiguration - * object and for which at least one value can be set by the application. - * Note that this list can also contain parameter names defined outside - * this specification. - */ - virtual DOMStringList *getParameterNames() =0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~DOMConfiguration() {} - -}; - - - - - - -/*######################################################################### -## CDATASection -#########################################################################*/ - -/** - * 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 cannot be nested. Their primary purpose is for including material - * such as XML fragments, without needing to escape all the delimiters. - */ -class CDATASection : virtual public Text -{ -public: - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~CDATASection() {} - -}; - - - - -/*######################################################################### -## DocumentType -#########################################################################*/ - -/** - * Each Document has a doctype attribute whose value is either null or a - * DocumentType object. The DocumentType interface in the DOM 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 schema - * efforts on DTD representation are not clearly understood as of this writing. - */ -class DocumentType : virtual public Node -{ -public: - - /** - * The name of DTD; i.e., the name immediately following the DOCTYPE keyword. - */ - virtual DOMString getName() = 0; - - /** - * A NamedNodeMap containing the general entities, both external and - * internal, declared in the DTD. Parameter entities are not contained. - * Duplicates are discarded. - */ - virtual NamedNodeMap getEntities() = 0; - - /** - * A NamedNodeMap containing the notations declared in the DTD. Duplicates - * are discarded. Every node in this map also implements the - * Notation interface. - */ - virtual NamedNodeMap getNotations() = 0; - - /** - * The public identifier of the external subset. - */ - virtual DOMString getPublicId() = 0; - - /** - * The system identifier of the external subset. This may be an - * absolute URI or not. - */ - virtual DOMString getSystemId() = 0; - - /** - * The internal subset as a string, or null if there is none. This - * does not contain the delimiting square brackets. - */ - virtual DOMString getInternalSubset() = 0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DocumentType() {} - -}; - - - - - -/*######################################################################### -## Notation -#########################################################################*/ - -/** - * 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 [XML 1.0]), or is used for formal declaration of - * processing instruction targets (see section 2.6 of the XML 1.0 specification - * [XML 1.0]). The nodeName attribute inherited from Node is set to the declared - * name of the notation. - */ -class Notation : virtual public Node -{ -public: - - /** - * The public identifier of this notation. If the public identifier was - * not specified, this is null. - */ - virtual DOMString getPublicId() = 0; - - /** - * The system identifier of this notation. If the system identifier was - * not specified, this is null. This may be an absolute URI or not. - */ - virtual DOMString getSystemId() = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Notation() {} -}; - - - - - - -/*######################################################################### -## Entity -#########################################################################*/ - -/** - * This interface represents a known entity, either parsed or unparsed, in an XML - * document. Note that this models the entity itself not the entity declaration. - */ -class Entity : virtual public Node -{ -public: - - /** - * The public identifier associated with the entity if specified, - * and null otherwise. - */ - virtual DOMString getPublicId() = 0; - - /** - * The system identifier associated with the entity if specified, - * and null otherwise. This may be an absolute URI or not. - */ - virtual DOMString getSystemId() = 0; - - /** - * For unparsed entities, the name of the notation for the entity. - * For parsed entities, this is null. - */ - virtual DOMString getNotationName() = 0; - - /** - * An attribute specifying the encoding used for this entity at the - * time of parsing, when it is an external parsed entity. This is null - * if it an entity from the internal subset or if it is not known. - */ - virtual DOMString getInputEncoding() = 0; - - /** - * An attribute specifying, as part of the text declaration, the encoding - * of this entity, when it is an external parsed entity. This is null otherwise. - */ - virtual DOMString getXmlEncoding() = 0; - - /** - * An attribute specifying, as part of the text declaration, the version - * number of this entity, when it is an external parsed entity. - * This is null otherwise. - */ - virtual DOMString getXmlVersion() = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Entity() {} -}; - - - - - -/*######################################################################### -## EntityReference -#########################################################################*/ - -/** - * EntityReference nodes may be used to represent an entity reference in the tree. - */ -class EntityReference : virtual public Node -{ -public: - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~EntityReference() {} -}; - - - - - -/*######################################################################### -## ProcessingInstruction -#########################################################################*/ - -/** - * The ProcessingInstruction interface represents a "processing instruction", - * used in XML as a way to keep processor-specific information in the text of the - * document. - */ -class ProcessingInstruction : virtual public Node -{ -public: - - /** - * The target of this processing instruction. XML defines this as being - * the first token following the markup that begins the processing instruction. - */ - virtual DOMString getTarget() = 0; - - /** - * The content of this processing instruction. This is from the first non - * white space character after the target to the character immediately - * preceding the ?>. - */ - virtual DOMString getData() = 0; - - /** - * Sets the content above. - */ - virtual void setData(const DOMString& val) throw(DOMException) = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~ProcessingInstruction() {} - -}; - - - - - -/*######################################################################### -## DocumentFragment -#########################################################################*/ - -/** - * DocumentFragment is a "lightweight" or "minimal" 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 Document object could fulfill - * this role, a Document object can potentially be a heavyweight object, - * depending on the underlying implementation. What is really needed for this is - * a very lightweight object. DocumentFragment is such an object. - */ -class DocumentFragment : virtual public Node -{ -public: - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~DocumentFragment() {} -}; - - - - - - -/*######################################################################### -## Document -#########################################################################*/ - -/** - * From the spec: - * - * The 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 Document, the Document interface also contains - * the factory methods needed to create these objects. The Node objects created - * have a ownerDocument attribute which associates them with the Document within - * whose context they were created. - * - */ -class Document : virtual public Node -{ -public: - - /** - * The Document Type Declaration (see DocumentType) associated with this document. - */ - virtual DocumentTypePtr getDoctype() = 0; - - /** - * The DOMImplementation object that handles this document. A DOM application - * may use objects from multiple implementations. - */ - virtual DOMImplementation *getImplementation() = 0; - - /** - * This is a convenience attribute that allows direct access to the child - * node that is the document element of the document. - */ - virtual ElementPtr getDocumentElement() = 0; - - /** - * Creates an element of the type specified. - */ - virtual ElementPtr createElement(const DOMString& tagName) - throw(DOMException) = 0; - - /** - * Creates a new, empty DocumentFragment - */ - virtual DocumentFragmentPtr createDocumentFragment() = 0; - - /** - * Creates an Text node with the text data specified. - */ - virtual TextPtr createTextNode(const DOMString& text) = 0; - - /** - * Creates a new Comment node with the argument text - */ - virtual CommentPtr createComment(const DOMString& text) = 0; - - /** - * Creates a new CDATASection node with the argument text - */ - virtual CDATASectionPtr createCDATASection(const DOMString& text) - throw(DOMException) = 0; - - /** - * Creates a new ProcessingInstruction - */ - virtual ProcessingInstructionPtr - createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException) = 0; - - /** - * Creates a new Attr with the given name, but no value. - */ - virtual AttrPtr createAttribute(const DOMString& name) - throw(DOMException) = 0; - - /** - * Creates a new EntityReference - */ - virtual EntityReferencePtr createEntityReference(const DOMString& name) - throw(DOMException) = 0; - - /** - * Searches the Document in document order for all elements with the given - * tag name - */ - virtual NodeList getElementsByTagName(const DOMString& tagname) = 0; - - - /** - * Imports a node from another document to this document, without altering or - * removing the source node from the original document; this method creates a new - * copy of the source node. The returned node has no parent; (parentNode is - * null). 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, the source node - * is not altered. User data associated to the imported node is not carried over. - * However, if any UserDataHandlers has been specified along with the associated - * data these handlers will be called with the appropriate parameters before this - * method returns. 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. - */ - virtual NodePtr importNode(const NodePtr importedNode, - bool deep) - throw(DOMException) = 0; - - /** - * Creates a new Element with the given namespace and qualifiedName. - * Use "" for no namespace - */ - virtual ElementPtr createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) = 0; - - /** - * Creates a new Attr with the given namespace and qualifiedName. - */ - virtual AttrPtr createAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) = 0; - - /** - * Searches the Document in document order for all elements with the given - * namespace and tag name - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * Gets the element with the given id if it exists, else null. - */ - virtual ElementPtr getElementById(const DOMString& elementId) = 0; - - - /** - * Return the input encoding of this Document - */ - virtual DOMString getInputEncoding() = 0; - - - /** - * Return the XML encoding of this Document - */ - virtual DOMString getXmlEncoding() = 0; - - /** - * An attribute specifying, as part of the XML declaration, whether - * this document is standalone. This is false when unspecified. - */ - virtual bool getXmlStandalone() = 0; - - /** - * Sets whether this is a standalone XML document. No validation is - * done here. - */ - virtual void setXmlStandalone(bool val) throw (DOMException) = 0; - - /** - * Gets the version (1.0, 1.1, etc) of this document. - */ - virtual DOMString getXmlVersion() = 0; - - /** - * Sets the XML version of this document. - */ - virtual void setXmlVersion(const DOMString &version) - throw (DOMException) = 0; - - /** - * An attribute specifying whether error checking is enforced or not. When set to - * false, the implementation is free to not test every possible error case - * normally defined on DOM operations, and not raise any DOMException on DOM - * operations or report errors while using Document.normalizeDocument(). In case - * of error, the behavior is undefined. This attribute is true by default. - */ - virtual bool getStrictErrorChecking() = 0; - - /** - * Sets the value described above. - */ - virtual void setStrictErrorChecking(bool val) = 0; - - - /** - * Gets the document URI (the base location) of this Document. - */ - virtual DOMString getDocumentURI() = 0; - - /** - * Sets the document URI (the base location) of this Document to the - * argument uri. - */ - virtual void setDocumentURI(const DOMString &uri) = 0; - - /** - * Attempts to adopt a node from another document to this document. If supported, - * it changes the ownerDocument of the source node, its children, as well as the - * attached attribute nodes if there are any. If the source node has a parent it - * is first removed from the child list of its parent. This effectively allows - * moving a subtree from one document to another (unlike importNode() which - * create a copy of the source node instead of moving it). When it fails, - * applications should use Document.importNode() instead. Note that if the - * adopted node is already part of this document (i.e. the source and target - * document are the same), this method still has the effect of removing the - * source node from the child list of its parent, if any. - */ - virtual NodePtr adoptNode(const NodePtr source) throw (DOMException) = 0; - - /** - * Get the configuration item associated with this Document - */ - virtual DOMConfiguration *getDomConfig() = 0; - - /** - * This method acts as if the document was going through a save and load cycle, - * putting the document in a "normal" form. As a consequence, this method updates - * the replacement tree of EntityReference nodes and normalizes Text nodes, as - * defined in the method Node.normalize(). Otherwise, the actual result depends - * on the features being set on the Document.domConfig object and governing what - * operations actually take place. Noticeably this method could also make the - * document namespace well-formed according to the algorithm described in - * Namespace Normalization, check the character normalization, remove the - * CDATASection nodes, etc. See DOMConfiguration for details. - */ - virtual void normalizeDocument() = 0; - - /** - * - * Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE. When possible - * this simply changes the name of the given node, otherwise this creates a new - * node with the specified name and replaces the existing node with the new node - * as described below. If simply changing the name of the given node is not - * possible, the following operations are performed: a new node is created, any - * registered event listener is registered on the new node, any user data - * attached to the old node is removed from that node, the old node is removed - * from its parent if it has one, the children are moved to the new node, if the - * renamed node is an Element its attributes are moved to the new node, the new - * node is inserted at the position the old node used to have in its parent's - * child nodes list if it has one, the user data that was attached to the old - * node is attached to the new node. When the node being renamed is an Element - * only the specified attributes are moved, default attributes originated from - * the DTD are updated according to the new element name. In addition, the - * implementation may update default attributes from other schemas. Applications - * should use Document.normalizeDocument() to guarantee these attributes are - * up-to-date. When the node being renamed is an Attr that is attached to an - * Element, the node is first removed from the Element attributes map. Then, once - * renamed, either by modifying the existing node or creating a new one as - * described above, it is put back. - * - * In addition, - * a user data event NODE_RENAMED is fired, - * when the implementation supports the feature "MutationNameEvents", - * each mutation operation involved in this method fires the appropriate - * event, and in the end the event {http://www.w3.org/2001/xml-events, - * DOMElementNameChanged} or {http://www.w3.org/2001/xml-events, - * DOMAttributeNameChanged} is fired. - * - */ - virtual NodePtr renameNode(const NodePtr n, - const DOMString &namespaceURI, - const DOMString &qualifiedName) - throw (DOMException) = 0; - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~Document() {} - -}; - - - - - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOM_H - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp deleted file mode 100644 index 3d9a29592..000000000 --- a/src/dom/domimpl.cpp +++ /dev/null @@ -1,3071 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include -#include "domimpl.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - -/** - * Test if the given substring exists for the length of the string - * in a given buffer - */ -/* -static bool match(const DOMString &buf, char *str) -{ - int pos = 0; - while (*str) - { - if (buf[pos++] != *str++) - return false; - } - return true; -} -*/ - - - -/*######################################################################### -## DOMImplementationSourceImpl -#########################################################################*/ - - -/** - * - */ -DOMImplementationSourceImpl::DOMImplementationSourceImpl() -{ - domImpl = new DOMImplementationImpl(); -} - -/** - * - */ -DOMImplementationSourceImpl::~DOMImplementationSourceImpl() -{ - delete domImpl; -} - -/** - * - */ -DOMImplementation *DOMImplementationSourceImpl::getDOMImplementation( - const DOMString &/*features*/) -{ - return domImpl; -} - -/** - * - */ -DOMImplementationList DOMImplementationSourceImpl::getDOMImplementationList( - const DOMString &/*features*/) -{ - return domImplList; -} - - - - - - - -/*######################################################################### -## DOMImplementationImpl -#########################################################################*/ - - -/** - * - */ -DOMImplementationImpl::DOMImplementationImpl() -{ -} - -/** - * - */ -DOMImplementationImpl::~DOMImplementationImpl() -{ -} - -/** - * - */ -bool DOMImplementationImpl::hasFeature(const DOMString& /*feature*/, - const DOMString& /*version*/) -{ - return false; -} - - -/** - * - */ -DocumentTypePtr DOMImplementationImpl::createDocumentType(const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException) -{ - DocumentTypePtr typeImpl = new DocumentTypeImpl(qualifiedName, - publicId, systemId); - return typeImpl; -} - -/** - * - */ -DocumentPtr DOMImplementationImpl::createDocument( - const DOMString& namespaceURI, - const DOMString& qualifiedName, - DocumentTypePtr doctype) - throw(DOMException) -{ - DocumentPtr doc = new DocumentImpl(this, - namespaceURI, - qualifiedName, - doctype); - return doc; -} - -/** - * - */ -DOMObject *DOMImplementationImpl::getFeature(const DOMString& /*feature*/, - const DOMString& /*version*/) - -{ - return NULL; -} - - - - - -/*######################################################################### -## NodeImpl -#########################################################################*/ - -/** - * Utility for finding the first Element above - * a given node. Used by several methods below - */ -static NodePtr getAncestorElement(NodePtr node) -{ - if (!node.get()) - return NULL; - node = node->getParentNode(); - //Either quit because I am an element, or because I am null - while (node.get()) - { - if (node->getNodeType() == Node::ELEMENT_NODE) - return node; - node = node->getParentNode(); - } - return node; -} - -/** - * - */ -DOMString NodeImpl::getNodeName() -{ - return nodeName; -} - -/** - * - */ -DOMString NodeImpl::getNodeValue() throw (DOMException) -{ - return nodeValue; -} - -/** - * - */ -void NodeImpl::setNodeValue(const DOMString& val) throw (DOMException) -{ - nodeValue = val; -} - -/** - * - */ -unsigned short NodeImpl::getNodeType() -{ - return nodeType; -} - -/** - * - */ -NodePtr NodeImpl::getParentNode() -{ - return parent; -} - -/** - * - */ -NodeList NodeImpl::getChildNodes() -{ - NodeList list; - for (NodeImplPtr node = firstChild ; node.get() ; node=node->next) - list.add(node); - return list; -} - -/** - * - */ -NodePtr NodeImpl::getFirstChild() -{ - return firstChild; -} - -/** - * - */ -NodePtr NodeImpl::getLastChild() -{ - return lastChild; -} - -/** - * - */ -NodePtr NodeImpl::getPreviousSibling() -{ - return prev; -} - -/** - * - */ -NodePtr NodeImpl::getNextSibling() -{ - return next; -} - -/** - * - */ -NamedNodeMap &NodeImpl::getAttributes() -{ - NamedNodeMap &attrs = attributes; - return attrs; -} - - -/** - * - */ -DocumentPtr NodeImpl::getOwnerDocument() -{ - return ownerDocument; -} - -/** - * - */ -NodePtr NodeImpl::insertBefore(const NodePtr newChild, - const NodePtr refChild) - throw(DOMException) -{ - if (!newChild) - return NULL; - - //if no ref, then just append - if (!refChild) - return appendChild(newChild); - - NodeImplPtr newChildImpl = reinterpret_cast(newChild.get()); - for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) - { - if (n == refChild) - { - //link to new - if (n->prev.get()) - n->prev->next = newChildImpl; - else - firstChild = newChildImpl; - n->prev = newChildImpl; - //link from new - newChildImpl->next = n; - newChildImpl->prev = n->prev; - //reflect new location - newChildImpl->parent = this; - newChildImpl->ownerDocument = ownerDocument; - return n; - } - } - return NULL; -} - -/** - * - */ -NodePtr NodeImpl::replaceChild(const NodePtr newChild, - const NodePtr oldChild) - throw(DOMException) -{ - if (!oldChild) - return NULL; - - NodeImplPtr newChildImpl = reinterpret_cast(newChild.get()); - for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) - { - if (n == oldChild) - { - //link to new - if (n->prev.get()) - n->prev->next = newChildImpl; - else - firstChild = newChildImpl; - if (n->next.get()) - n->next->prev = newChildImpl; - else - lastChild = newChildImpl; - //link from new - newChildImpl->next = n->next; - newChildImpl->prev = n->prev; - //reflect new location - newChildImpl->parent = this; - newChildImpl->ownerDocument = ownerDocument; - return n; - } - } - return NULL; -} - -/** - * - */ -NodePtr NodeImpl::removeChild(const NodePtr oldChild) - throw(DOMException) -{ - if (!oldChild) - return NULL; - - for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) - { - if (n == oldChild) - { - if (n->prev.get()) - n->prev->next = n->next; - if (n->next.get()) - n->next->prev = n->prev; - return n; - } - } - return NULL; -} - -/** - * - */ -NodePtr NodeImpl::appendChild(const NodePtr newChild) - throw(DOMException) -{ - if (!newChild) - return NULL; - - NodeImplPtr newChildImpl = - reinterpret_cast (newChild.get()); - - newChildImpl->parent = this; - newChildImpl->ownerDocument = ownerDocument; - - if (!firstChild || !lastChild) - { - //Set up our first member - firstChild = newChildImpl; - lastChild = newChildImpl; - } - else - { - //link at the last position - lastChild->next = newChildImpl; - newChildImpl->prev = lastChild; - lastChild = newChildImpl; - } - - return newChild; -} - -/** - * - */ -bool NodeImpl::hasChildNodes() -{ - return (firstChild != (NodeImpl *)0); -} - -/** - * - */ -NodePtr NodeImpl::cloneNode(bool deep) -{ - NodeImplPtr node = new NodeImpl(ownerDocument, nodeName); - node->parent = parent; - node->prev = prev; - node->next = next; - node->userData = userData; - node->nodeValue = nodeValue; - - if (deep) - { - node->firstChild = node->lastChild = NULL; - for (NodeImplPtr child = firstChild ; child.get() ; child=child->next) - { - node->appendChild(child->cloneNode(deep)); - } - } - else - { - node->firstChild = firstChild; - node->lastChild = lastChild; - } - - return node; -} - -/** - * Concatenate adjoining text subnodes, remove null-length nodes - */ -void NodeImpl::normalize() -{ - //First, concatenate adjoining text nodes - NodeImplPtr next = (NodeImpl *)0; - for (NodeImplPtr child = firstChild ; child.get() ; child=next) - { - if (child->getNodeType() != Node::TEXT_NODE) - continue; - next = NULL; - DOMString sval = child->getNodeValue(); - for (NodeImplPtr sibling = child->next ; sibling.get() ; sibling=next) - { - next = sibling->next; - if (sibling->getNodeType() != Node::TEXT_NODE) - break; - sval.append(sibling->getNodeValue()); - //unlink and delete - child->next = sibling->next; - if (sibling->next.get()) - sibling->next->prev = child; - //delete sibling; - } - child->setNodeValue(sval); - } - - //Next, we remove zero-length text subnodes - next = NULL; - for (NodeImplPtr child = firstChild ; child.get() ; child=next) - { - next = child->next; - if (child->getNodeType() != Node::TEXT_NODE) - continue; - if (child->getNodeValue().size() == 0) - { - //unlink and delete - if (child->prev.get()) - child->prev->next = child->next; - if (child->next.get()) - child->next->prev = child->prev; - //delete child; - } - } - -} - -/** - * - */ -bool NodeImpl::isSupported(const DOMString& /*feature*/, - const DOMString& /*version*/) -{ - //again, no idea - return false; -} - -/** - * - */ -DOMString NodeImpl::getNamespaceURI() -{ - return namespaceURI; -} - -/** - * - */ -DOMString NodeImpl::getPrefix() -{ - return prefix; -} - -/** - * - */ -void NodeImpl::setPrefix(const DOMString& val) throw(DOMException) -{ - prefix = val; - if (prefix.size()>0) - nodeName = prefix + ":" + localName; - else - nodeName = localName; -} - -/** - * - */ -DOMString NodeImpl::getLocalName() -{ - return localName; -} - -/** - * - */ -bool NodeImpl::hasAttributes() -{ - return (attributes.getLength() > 0); -} - -/** - * - */ -DOMString NodeImpl::getBaseURI() -{ - return baseURI; -} - -/** - * - */ -unsigned short NodeImpl::compareDocumentPosition(const NodePtr otherArg) -{ - if (!otherArg || otherArg == (NodePtr )this) - return 0;//no flags - - NodePtr node; - NodePtr other = otherArg; - - //Look above me - for (node=getParentNode() ; node.get() ; node=node->getParentNode()) - if (node == other) - return DOCUMENT_POSITION_CONTAINED_BY; - - //Look above the other guy. See me? - for (node=other->getParentNode() ; node.get() ; node=node->getParentNode()) - if (node == (NodePtr )this) - return DOCUMENT_POSITION_CONTAINS; - - - return DOCUMENT_POSITION_DISCONNECTED | - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; -} - -/** - * - */ -DOMString NodeImpl::getTextContent() throw(DOMException) -{ - DOMString buf; - if (nodeType == TEXT_NODE || - nodeType == CDATA_SECTION_NODE || - nodeType == COMMENT_NODE || - nodeType == PROCESSING_INSTRUCTION_NODE) - buf = getNodeValue(); - else if (nodeType == ELEMENT_NODE || - nodeType == ATTRIBUTE_NODE || - nodeType == ENTITY_NODE || - nodeType == ENTITY_REFERENCE_NODE || - nodeType == DOCUMENT_FRAGMENT_NODE) - { - for (NodePtr n = getFirstChild() ; n.get() ; - n=n->getNextSibling() ) - { - if (n->getNodeType() != COMMENT_NODE && - n->getNodeType() != COMMENT_NODE) - buf.append(n->getTextContent()); - } - } - return buf; -} - - -/** - * - */ -void NodeImpl::setTextContent(const DOMString &val) throw(DOMException) -{ - //Delete children - /** Not necessary. Just let smart pointers to their work - for (NodePtr n = getFirstChild() ; n.get() ; - n=n->getNextSibling() ) - delete n; - */ - firstChild = lastChild = NULL; - - //Replace with a single text node - NodeImplPtr tnode = new NodeImpl(ownerDocument); - tnode->nodeType = Node::TEXT_NODE; - tnode->setNodeValue(val); - appendChild(tnode); -} - - -/** - * From DOM3 Namespace algorithms - */ -DOMString NodeImpl::lookupPrefix(const DOMString &theNamespaceURI) -{ - - if (theNamespaceURI.size()==0) - { - return DOMString(""); - } - - switch (nodeType) - { - case Node::ELEMENT_NODE: - { - ElementPtr elem = reinterpret_cast(this); - return lookupNamespacePrefix(theNamespaceURI, elem); - } - case Node::DOCUMENT_NODE: - { - DocumentPtr doc = reinterpret_cast(this); - ElementPtr elem = doc->getDocumentElement(); - return elem->lookupPrefix(theNamespaceURI); - } - case Node::ENTITY_NODE : - case Node::NOTATION_NODE: - case Node::DOCUMENT_FRAGMENT_NODE: - case Node::DOCUMENT_TYPE_NODE: - return DOMString(""); // type is unknown - case Node::ATTRIBUTE_NODE: - { - AttrPtr attr = reinterpret_cast(this); - ElementPtr elem = attr->getOwnerElement(); - if ( elem.get() ) - { - return elem->lookupPrefix(theNamespaceURI); - } - return DOMString(""); - } - default: - { - //Get ancestor element, if any - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->lookupPrefix(theNamespaceURI); - } - return DOMString(""); - } - }//switch - return DOMString(""); -} - - -/** - * - */ -bool NodeImpl::isDefaultNamespace(const DOMString &theNamespaceURI) -{ - switch (nodeType) - { - case ELEMENT_NODE: - { - if ( namespaceURI.size()>0 && prefix.size()==0 ) - { - return (namespaceURI == theNamespaceURI); - } - NodePtr attr = attributes.getNamedItem("xmlns"); - if ( attr.get() ) - { - return (attr->getNodeValue() == theNamespaceURI); - } - - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->isDefaultNamespace(theNamespaceURI); - } - else - { - return false; - } - } - case DOCUMENT_NODE: - { //just use braces for local declaration - DocumentPtr doc = reinterpret_cast(this); - ElementPtr elem = doc->getDocumentElement(); - return elem->isDefaultNamespace(theNamespaceURI); - } - case ENTITY_NODE: - case NOTATION_NODE: - case DOCUMENT_TYPE_NODE: - case DOCUMENT_FRAGMENT_NODE: - return false; - case ATTRIBUTE_NODE: - {//braces only for scope - AttrPtr attr = reinterpret_cast(this); - ElementPtr ownerElement = attr->getOwnerElement(); - if ( ownerElement.get() ) - { - return ownerElement->isDefaultNamespace(theNamespaceURI); - } - else - { - return false; - } - } - default: - { - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->isDefaultNamespace(theNamespaceURI); - } - else - { - return false; - } - } - }//switch - - return false; -} - - -/** - * - */ -DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) -{ - switch (nodeType) - { - case ELEMENT_NODE: - { - if ( namespaceURI.size()>0 && prefix == thePrefix ) - { - DOMString nsURI = namespaceURI; - return (nsURI); - } - if ( hasAttributes() ) - { - NamedNodeMap attributes = getAttributes(); - int nrAttrs = attributes.getLength(); - for (int i=0 ; igetPrefix() == "xmlns" && attr->getLocalName() == thePrefix ) - { // non default namespace - if (attr->getNodeValue().size()>0) - { - return (attr->getNodeValue()); - } - return DOMString(""); - } - else if (attr->getLocalName() == "xmlns" && thePrefix.size()==0) - { // default namespace - if (attr->getNodeValue().size()>0) - { - return (attr->getNodeValue()); - } - return DOMString(""); - } - } - } - - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->lookupNamespaceURI(thePrefix); - } - return DOMString(""); - } - case DOCUMENT_NODE: - { - DocumentPtr doc = reinterpret_cast(this); - ElementPtr elem = doc->getDocumentElement(); - return elem->lookupNamespaceURI(thePrefix); - } - case ENTITY_NODE: - case NOTATION_NODE: - case DOCUMENT_TYPE_NODE: - case DOCUMENT_FRAGMENT_NODE: - return DOMString(""); - - case ATTRIBUTE_NODE: - { - ElementPtr ownerElement = (reinterpret_cast(this))->getOwnerElement(); - if ( ownerElement.get() ) - { - return ownerElement->lookupNamespaceURI(thePrefix); - } - else - { - return DOMString(""); - } - } - default: - { - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->lookupNamespaceURI(thePrefix); - } - else - { - return DOMString(""); - } - } - }//switch -} - - -/** - * - */ -bool NodeImpl::isEqualNode(const NodePtr nodeArg) -{ - if (!nodeArg) - return false; - - if (nodeArg == static_cast(this)) - return true; - - NodePtr node = nodeArg; - - if (getNodeType() != node->getNodeType() || - getNodeName() != node->getNodeName() || - getLocalName() != node->getLocalName() || - getNamespaceURI() != node->getNamespaceURI() || - getPrefix() != node->getPrefix() || - getNodeValue() != node->getNodeValue() || - getBaseURI() != node->getBaseURI() ) - return false; - - return true; -} - - - -/** - * - */ -DOMObject *NodeImpl::getFeature(const DOMString &/*feature*/, - const DOMString &/*version*/) -{ - //dont know - return NULL; -} - -/** - * - */ -DOMUserData *NodeImpl::setUserData(const DOMString &key, - const DOMUserData *data, - const UserDataHandler *handler) -{ - UserDataEntry *entry = userDataEntries; - UserDataEntry *prev = NULL; - while (entry) - { - if (entry->key == key) - { - DOMUserData *oldData = entry->data; - entry->data = const_cast(data); - entry->handler = const_cast(handler); - return oldData; - } - prev = entry; - entry = entry->next; - } - - //Make a new one - UserDataEntry *newEntry = new UserDataEntry(key, data, handler); - if (!prev) - userDataEntries = newEntry; - else - prev->next = newEntry; - - return NULL; -} - -/** - * - */ -DOMUserData *NodeImpl::getUserData(const DOMString &key) -{ - UserDataEntry *entry = userDataEntries; - while (entry) - { - if (entry->key == key) - return entry->data; - entry = entry->next; - } - return NULL; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -void NodeImpl::setNodeName(const DOMString &qualifiedName) -{ - nodeName = qualifiedName; - prefix = ""; - localName = ""; - for (unsigned int i=0 ; i0 && namespaceURI==theNamespaceURI && - prefix.size()>0 && - originalElement->lookupNamespaceURI(prefix) == theNamespaceURI) - { - return (prefix); - } - - if ( hasAttributes() ) - { - NamedNodeMap attributes = getAttributes(); - int nrAttrs = attributes.getLength(); - for (int i=0 ; igetLocalName(); - if (attr->getPrefix() == "xmlns" && - attr->getNodeValue() == theNamespaceURI && - originalElement->lookupNamespaceURI(attrLocalName) - == theNamespaceURI) - { - return (attrLocalName); - } - } - } - - //Get ancestor element, if any - NodeImplPtr ancestor = parent; - while (ancestor.get() && ancestor->getNodeType()!= Node::ELEMENT_NODE) - ancestor = ancestor->parent; - - if ( ancestor.get() ) - { - return ancestor->lookupNamespacePrefix(theNamespaceURI, originalElement); - } - - return DOMString(""); -} - - -/** - * - */ -NodeImpl::NodeImpl() : Node() -{ - init(); -} - - -/** - * - */ -NodeImpl::NodeImpl(const NodeImpl &other) : Node() -{ - init(); - assign(other); -} - -/** - * - */ -NodeImpl &NodeImpl::operator=(const NodeImpl &other) -{ - init(); - assign(other); - return *this; -} - - -/** - * - */ -NodeImpl::NodeImpl(DocumentImplPtr owner) : Node() -{ - init(); - ownerDocument = owner; -} - -/** - * - */ -NodeImpl::NodeImpl(DocumentImplPtr owner, const DOMString &nodeName) - : Node() -{ - init(); - ownerDocument = owner; - setNodeName(nodeName); -} - -/** - * - */ -NodeImpl::NodeImpl(DocumentImplPtr owner, const DOMString &/*theNamespaceURI*/, - const DOMString &qualifiedName) : Node() -{ - init(); - ownerDocument = owner; - //if (owner) - // namespaceURI = owner->stringCache(theNamespaceURI); - setNodeName(qualifiedName); -} - - - -/** - * - */ -void NodeImpl::init() -{ - nodeType = 0; //none yet - nodeValue = ""; - setNodeName(""); - namespaceURI = ""; - parent = NULL; - prev = NULL; - next = NULL; - userData = NULL; - firstChild = NULL; - lastChild = NULL; - ownerDocument = NULL; - userDataEntries = NULL; -} - -/** - * - */ -void NodeImpl::assign(const NodeImpl &other) -{ - ownerDocument = other.ownerDocument; - prefix = other.prefix; - localName = other.localName; - nodeName = other.nodeName; - nodeValue = other.nodeValue; - namespaceURI = other.namespaceURI; - attributes = other.attributes; -} - - -/** - * - */ -NodeImpl::~NodeImpl() -{ - if (userDataEntries) - delete userDataEntries; - //Delete children - /** Use smart pointers. do not delete explicitly - for (NodePtr n = getFirstChild() ; n.get() ; - n=n->getNextSibling() ) - delete n; - */ - firstChild = lastChild = (NodeImpl *)0; -} - - - -/*######################################################################### -## CharacterDataImpl -#########################################################################*/ - - -/** - * - */ -CharacterDataImpl::CharacterDataImpl() : NodeImpl() -{ -} - -/** - * - */ -CharacterDataImpl::CharacterDataImpl(DocumentImplPtr owner, - const DOMString &theValue) : NodeImpl() -{ - ownerDocument = owner; - nodeValue = theValue; -} - -/** - * - */ -CharacterDataImpl::~CharacterDataImpl() -{ -} - -/** - * - */ -DOMString CharacterDataImpl::getData() throw(DOMException) -{ - return nodeValue; -} - -/** - * - */ -void CharacterDataImpl::setData(const DOMString& val) throw(DOMException) -{ - nodeValue = val; -} - -/** - * - */ -unsigned long CharacterDataImpl::getLength() -{ - return nodeValue.size(); -} - -/** - * - */ -DOMString CharacterDataImpl::substringData(unsigned long offset, - unsigned long count) - throw(DOMException) -{ - return nodeValue.substr(offset, count); -} - -/** - * - */ -void CharacterDataImpl::appendData(const DOMString& arg) throw(DOMException) -{ - nodeValue += arg; -} - -/** - * - */ -void CharacterDataImpl::insertData(unsigned long offset, - const DOMString& arg) - throw(DOMException) -{ - nodeValue.insert(offset, arg); -} - -/** - * - */ -void CharacterDataImpl::deleteData(unsigned long offset, - unsigned long count) - throw(DOMException) -{ - nodeValue.erase(offset, count); -} - -/** - * - */ -void CharacterDataImpl::replaceData(unsigned long offset, - unsigned long count, - const DOMString& arg) - throw(DOMException) -{ - nodeValue.replace(offset, count, arg); -} - - - - - - -/*######################################################################### -## AttrImpl -#########################################################################*/ - -/** - * - */ -DOMString AttrImpl::getName() -{ - return nodeName; -} - -/** - * - */ -bool AttrImpl::getSpecified() -{ - return (nodeValue.size() > 0); -} - -/** - * - */ -DOMString AttrImpl::getValue() -{ - return nodeValue; -} - -/** - * - */ -void AttrImpl::setValue(const DOMString& val) throw(DOMException) -{ - nodeValue = val; -} - -/** - * - */ -ElementPtr AttrImpl::getOwnerElement() -{ - return ownerElement; -} - - -/** - * - */ -TypeInfo &AttrImpl::getSchemaTypeInfo() -{ - return typeInfo; -} - - -/** - * - */ -bool AttrImpl::getIsId() -{ - return (nodeName == "id"); -} - - - -//################## -//# Non-API methods -//################## - - -void AttrImpl::setOwnerElement(const ElementPtr elem) -{ - ownerElement = elem; -} - -/** - * - */ -AttrImpl::AttrImpl(DocumentImplPtr owner, const DOMString &theName) - : NodeImpl() -{ - nodeType = ATTRIBUTE_NODE; - ownerDocument = owner; - setNodeName(theName); -} - -/** - * - */ -AttrImpl::AttrImpl(DocumentImplPtr owner, - const DOMString &/*theNamespaceURI*/, - const DOMString &theQualifiedName) - : NodeImpl() -{ - nodeType = ATTRIBUTE_NODE; - ownerDocument = owner; - //if (owner) - // namespaceURI = owner->stringCache(theNamespaceURI); - setNodeName(theQualifiedName); -} - -/** - * - */ -AttrImpl::~AttrImpl() -{ -} - - - - - -/*######################################################################### -## ElementImpl -#########################################################################*/ - - -/** - * - */ -DOMString ElementImpl::getTagName() -{ - if (prefix.size() > 0) - return prefix + ":" + nodeName; - else - return nodeName; -} - -/** - * - */ -DOMString ElementImpl::getAttribute(const DOMString& name) -{ - NodePtr node = attributes.getNamedItem(name); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return DOMString(""); - AttrPtr attr = reinterpret_cast(node.get()); - return attr->getValue(); -} - -/** - * - */ -void ElementImpl::setAttribute(const DOMString& name, - const DOMString& value) - throw(DOMException) -{ - AttrImplPtr attr = new AttrImpl(ownerDocument, name); - attr->setValue(value); - attr->setOwnerElement(this); - attributes.setNamedItem(attr); -} - -/** - * - */ -void ElementImpl::removeAttribute(const DOMString& name) - throw(DOMException) -{ - attributes.removeNamedItem(name); -} - -/** - * - */ -AttrPtr ElementImpl::getAttributeNode(const DOMString& name) -{ - NodePtr node = attributes.getNamedItem(name); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return NULL; - AttrPtr attr = reinterpret_cast(node.get()); - return attr; -} - -/** - * - */ -AttrPtr ElementImpl::setAttributeNode(AttrPtr attr) - throw(DOMException) -{ - attributes.setNamedItem(attr); - return attr; -} - -/** - * - */ -AttrPtr ElementImpl::removeAttributeNode(AttrPtr attr) - throw(DOMException) -{ - attributes.removeNamedItem(attr->getName()); - return attr; -} - - -/** - * - */ -void ElementImpl::getElementsByTagNameRecursive(NodeList &list, - const DOMString& name, ElementPtr elem) -{ - if (!elem) - return; - - if (name == elem->getTagName()) - list.add(elem); - for (NodePtr node = elem->getFirstChild() ; node.get() ; - node=node->getNextSibling()) - { - if (node->getNodeType() != Node::ELEMENT_NODE) - continue; - ElementPtr childElem = reinterpret_cast(node.get()); - getElementsByTagNameRecursive(list, name, childElem); - } -} - - -/** - * - */ -NodeList ElementImpl::getElementsByTagName(const DOMString& tagName) -{ - NodeList list; - getElementsByTagNameRecursive(list, tagName, this); - return list; -} - -/** - * - */ -DOMString ElementImpl::getAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); - if (!node || node->getNodeType()!=ATTRIBUTE_NODE) - return DOMString(""); - AttrPtr attr = reinterpret_cast(node.get()); - return attr->getValue(); -} - -/** - * - */ -void ElementImpl::setAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName, - const DOMString& value) - throw(DOMException) -{ - AttrImplPtr attr = new AttrImpl(ownerDocument, namespaceURI, qualifiedName); - attr->setValue(value); - attr->setOwnerElement(this); - attributes.setNamedItemNS(attr); -} - -/** - * - */ -void ElementImpl::removeAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException) -{ - attributes.removeNamedItemNS(namespaceURI, localName); -} - -/** - * - */ - AttrPtr ElementImpl::getAttributeNodeNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return (Attr *)0; - AttrPtr attr = reinterpret_cast(node.get()); - return attr; -} - -/** - * - */ -AttrPtr ElementImpl::setAttributeNodeNS(AttrPtr attr) - throw(DOMException) -{ - attributes.setNamedItemNS(attr); - return attr; -} - - -/** - * - */ -void ElementImpl::getElementsByTagNameNSRecursive(NodeList &list, - const DOMString& namespaceURI, - const DOMString& tagName, ElementPtr elem) -{ - if (!elem) - return; - - if (namespaceURI == elem->getNamespaceURI() && tagName == elem->getTagName()) - list.add(elem); - for (NodePtr node = elem->getFirstChild() ; node.get() ; node=node->getNextSibling()) - { - if (node->getNodeType() != Node::ELEMENT_NODE) - continue; - ElementPtr childElem = reinterpret_cast(node.get()); - getElementsByTagNameNSRecursive(list, namespaceURI, tagName, childElem); - } -} - -/** - * - */ -NodeList ElementImpl::getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodeList list; - getElementsByTagNameNSRecursive(list, namespaceURI, localName, this); - return list; -} - -/** - * - */ -bool ElementImpl::hasAttribute(const DOMString& attrName) -{ - NodePtr node = attributes.getNamedItem(attrName); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return false; - return true; -} - -/** - * - */ -bool ElementImpl::hasAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return false; - return true; -} - -/** - * - */ -TypeInfo &ElementImpl::getSchemaTypeInfo() -{ - return typeInfo; -} - - -/** - * - */ -void ElementImpl::setIdAttribute(const DOMString &/*name*/, - bool /*isId*/) throw (DOMException) -{ - //fixme -} - -/** - * - */ -void ElementImpl::setIdAttributeNS(const DOMString &/*namespaceURI*/, - const DOMString &/*localName*/, - bool /*isId*/) throw (DOMException) -{ - //fixme -} - -/** - * - */ -void ElementImpl::setIdAttributeNode(const AttrPtr /*idAttr*/, - bool /*isId*/) throw (DOMException) -{ - //fixme -} - - -//################## -//# Non-API methods -//################## - - -/** - * - */ -ElementImpl::ElementImpl() : NodeImpl() -{ - nodeType = ELEMENT_NODE; -} - -/** - * - */ -ElementImpl::ElementImpl(DocumentImplPtr owner, const DOMString &tagName) - : NodeImpl() -{ - nodeType = ELEMENT_NODE; - ownerDocument = owner; - setNodeName(tagName); -} - -/** - * - */ -ElementImpl::ElementImpl(DocumentImplPtr owner, - const DOMString &/*theNamespaceURI*/, - const DOMString &qualifiedName) : - NodeImpl() -{ - nodeType = ELEMENT_NODE; - ownerDocument = owner; - setNodeName(qualifiedName); -} - -/** - * - */ -ElementImpl::~ElementImpl() -{ -} - - -/** - * - */ -void ElementImpl::normalizeNamespaces() -{ - //printf("### NORMALIZE\n"); - - NamedNodeMap attrs = getAttributes(); - - //####################################### - //# Pick up local namespace declarations - //####################################### - bindingsClear(); //Reset bindings on this node - - int nrAttrs = attrs.getLength(); - for (int i=0; igetNodeType() != Node::ATTRIBUTE_NODE) - continue; - AttrImplPtr attr = reinterpret_cast(attrNode.get()); - DOMString attrName = attr->getLocalName(); - DOMString attrPrefix = attr->getPrefix(); - DOMString attrValue = attr->getNodeValue(); - if (attrName != "xmlns" && attrPrefix != "xmlns") - continue; - - //is the namespace declaration is invalid? - if (attrValue == XMLNSNAME || attrName == attrPrefix) - { - // Note: The prefix xmlns is used only to declare namespace bindings and - // is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. - // It must not be declared. No other prefix may be bound to this namespace name. - - //==> Report an error. - printf("normalizeNamespaces() error: Namespace %s cannot be reassigned\n", - XMLNSNAME); - - } - else - { - //==> Record the namespace declaration - attr->setNamespaceURI(XMLNSNAME); - if (attrPrefix.size() > 0) - bindingsAdd(attrPrefix, attrValue); - else - bindingsAdd("*", attrValue);//default - - } - } - - - //####################################### - //# Fixup element's namespace - //####################################### - if ( namespaceURI.size() > 0 ) - { - DOMString key = prefix; - if (key.size() == 0) - key = "*"; - DOMString binding = bindingsFind(key); - //Element's prefix/namespace pair (or default namespace, if no prefix) - // are within the scope of a binding - if ( binding == namespaceURI ) - { - //==> do nothing, declaration in scope is inherited - - // See section "B.1.1: Scope of a binding" for an example - - } - else - { - - /* - ==> Create a local namespace declaration attr for this namespace, - with Element's current prefix (or a default namespace, if - no prefix). If there's a conflicting local declaration - already present, change its value to use this namespace. - - See section "B.1.2: Conflicting namespace declaration" for an example - */ - DOMString attrName = "xmlns"; - if (prefix.size() > 0) - { - attrName.append(":"); - attrName.append(prefix); - } - setAttribute(attrName, namespaceURI); - // NOTE that this may break other nodes within this Element's - // subtree, if they're already using this prefix. - // They will be repaired when we reach them. - } - } - else // Element has no namespace URI: - { - //############################################### - //# Bob -- alter this from the specs a bit. - //# Since the XmlReader does not set namespaces, - //# do it here - //############################################### - DOMString localName = getLocalName(); - if ( localName.size()==0 ) - { - // DOM Level 1 node - /* - ==> if in process of validation against a namespace aware schema - (i.e XML Schema) report a fatal error: the processor can not recover - in this situation. - Otherwise, report an error: no namespace fixup will be performed on this node. - */ - printf("normalizeNamespaces() error: no localName\n"); - } - else - { - // Element has no pseudo-prefix - //there's a conflicting local default namespace declaration already present - if ( prefix.size()==0 ) - { - //==> change its value to use this empty namespace. - namespaceURI = bindingsFind("*"); - //setAttribute("xmlns", ""); - } - else //#BOB . I added this. - { - namespaceURI = bindingsFind(prefix); - } - // NOTE that this may break other nodes within this Element's - // subtree, if they're already using the default namespaces. - // They will be repaired when we reach them. - } - } - - - //####################################### - //# Examine and polish the attributes - //####################################### - nrAttrs = attrs.getLength(); - for (int i=0; igetNodeType() != Node::ATTRIBUTE_NODE) - continue; - AttrPtr attr = reinterpret_cast(attrNode.get()); - DOMString attrNS = attr->getNamespaceURI(); - DOMString attrPrefix = attr->getPrefix(); - if (attrNS == XMLNSNAME) - continue; - - if ( attrNS.size()>0 ) //Attr[i] has a namespace URI - { - DOMString attrBinding = bindingsFind(attrPrefix); - /* - if attribute has no prefix (default namespace decl does not apply to attributes) - OR - attribute prefix is not declared - OR - conflict: attribute has a prefix that conflicts with a binding - already active in scope - */ - if ( attrPrefix.size() == 0 || attrBinding.size() == 0) - { - //namespaceURI matches an in scope declaration of one or more prefixes) - DOMString prefixForNS = lookupNamespacePrefix(attrNS, this); - if ( prefixForNS.size() > 0 ) - { - // pick the most local binding available; - // if there is more than one pick one arbitrarily - - //==> change attribute's prefix. - attr->setPrefix(prefixForNS); - } - else - { - // the current prefix is not null and it has no in scope declaration) - if ( attrPrefix.size() > 0 || attrBinding.size() == 0 ) - { - //==> declare this prefix - DOMString newAttrName = "xmlns:"; - newAttrName.append(attrPrefix); - setAttribute(newAttrName, attrNS); - bindingsAdd(attrPrefix, attrNS); - } - else - { - // find a prefix following the pattern "NS" +index (starting at 1) - // make sure this prefix is not declared in the current scope. - // create a local namespace declaration attribute - - //==> declare this prefix - char buf[16]; - sprintf(buf, "%d" , ownerDocument->namespaceIndex++); - DOMString newPrefix = "NS"; - newPrefix.append(buf); - DOMString newAttrName = "xmlns:"; - newAttrName.append(newPrefix); - setAttribute(newAttrName, attrNS); - bindingsAdd(newPrefix, attrNS); - //==> change attribute's prefix. - } - } - } - } - else // Attr has no namespace URI - { - // Attr has no localName - if ( attr->getLocalName().size() == 0 ) - { - // DOM Level 1 node - /* - ==> if in process of validation against a namespace aware schema - (i.e XML Schema) report a fatal error: the processor can not recover - in this situation. - Otherwise, report an error: no namespace fixup will be performed on this node. - */ - printf("normalizeNamespaces: no local name for attribute\n"); - } - else - { - // attr has no namespace URI and no prefix - // no action is required, since attrs don't use default - //==> do nothing - } - } - } // end for-all-Attrs - - - //####################################### - //# Recursively normalize children - //####################################### - for (NodePtr child=getFirstChild() ; child.get() ; child=child->getNextSibling()) - { - if (child->getNodeType() != Node::ELEMENT_NODE) - continue; - ElementImplPtr childElement = reinterpret_cast(child.get()); - childElement->normalizeNamespaces(); - } - -} - - -/*######################################################################### -## TextImpl -#########################################################################*/ - - -/** - * - */ -TextImpl::TextImpl() : CharacterDataImpl() -{ - nodeType = TEXT_NODE; - nodeName = "#text"; -} - - -/** - * - */ -TextImpl::TextImpl(DocumentImplPtr owner, const DOMString &value) - : CharacterDataImpl() -{ - nodeType = TEXT_NODE; - nodeName = "#text"; - ownerDocument = owner; - nodeValue = value; -} - - -/** - * - */ -TextImpl::~TextImpl() -{ -} - -/** - * - */ -TextPtr TextImpl::splitText(unsigned long /*offset*/) - throw(DOMException) -{ - return NULL; -} - -/** - * - */ -bool TextImpl::getIsElementContentWhitespace() -{ - return false; -} - -/** - * - */ -DOMString TextImpl::getWholeText() -{ - return nodeValue; -} - - -/** - * - */ -TextPtr TextImpl::replaceWholeText(const DOMString &/*content*/) - throw(DOMException) -{ - return NULL; -} - - -/*######################################################################### -## CommentImpl -#########################################################################*/ - -/** - * - */ -CommentImpl::CommentImpl() : CharacterDataImpl() -{ - nodeType = COMMENT_NODE; - nodeName = "#comment"; -} - - -/** - * - */ -CommentImpl::CommentImpl(DocumentImplPtr owner, const DOMString &value) - : CharacterDataImpl() -{ - nodeType = COMMENT_NODE; - nodeName = "#comment"; - ownerDocument = owner; - nodeValue = value; -} - - -/** - * - */ -CommentImpl::~CommentImpl() -{ -} - - - - - - - -/*######################################################################### -## UserDataHandlerImpl -#########################################################################*/ - - - -/** - * - */ -UserDataHandlerImpl::UserDataHandlerImpl() -{ -} - - -/** - * - */ -UserDataHandlerImpl::~UserDataHandlerImpl() -{ -} - -/** - * - */ -void UserDataHandlerImpl::handle(unsigned short /*operation*/, - const DOMString &/*key*/, - const DOMUserData */*data*/, - const NodePtr /*src*/, - const NodePtr /*dst*/) -{ - //do nothing. do we need anything here? -} - - - -/*######################################################################### -## DOMErrorImpl -#########################################################################*/ - - - -/** - * - */ -DOMErrorImpl::DOMErrorImpl() : - severity(0), - message(), - type() -{ -} - - -/** - * - */ -DOMErrorImpl::~DOMErrorImpl() -{ -} - -/** - * - */ -unsigned short DOMErrorImpl::getSeverity() -{ - return severity; -} - -/** - * - */ -DOMString DOMErrorImpl::getMessage() -{ - return message; -} - -/** - * - */ -DOMString DOMErrorImpl::getType() -{ - return type; -} - -/** - * - */ -DOMObject *DOMErrorImpl::getRelatedException() -{ - return NULL; -} - -/** - * - */ -DOMObject *DOMErrorImpl::getRelatedData() -{ - return NULL; -} - -/** - * - */ -DOMLocator *DOMErrorImpl::getLocation() -{ - //really should fill this in - return NULL; -} - - - - -/*######################################################################### -## DOMErrorHandlerImpl -#########################################################################*/ - - - -/** - * - */ -DOMErrorHandlerImpl::DOMErrorHandlerImpl() -{ -} - - -/** - * - */ -DOMErrorHandlerImpl::~DOMErrorHandlerImpl() -{ -} - -/** - * - */ -bool DOMErrorHandlerImpl::handleError(const DOMError *error) -{ - if (!error) - return false; - return true; -} - - - - -/*######################################################################### -## DOMLocatorImpl -#########################################################################*/ - - -/** - * - */ -DOMLocatorImpl::DOMLocatorImpl() : - lineNumber(0), - columnNumber(0), - byteOffset(0), - utf16Offset(0), - relatedNode(0), - uri() -{ -} - - -/** - * - */ -DOMLocatorImpl::~DOMLocatorImpl() -{ -} - - -/** - * - */ -long DOMLocatorImpl::getLineNumber() -{ - return lineNumber; -} - -/** - * - */ -long DOMLocatorImpl::getColumnNumber() -{ - return columnNumber; -} - -/** - * - */ -long DOMLocatorImpl::getByteOffset() -{ - return byteOffset; -} - -/** - * - */ -long DOMLocatorImpl::getUtf16Offset() -{ - return utf16Offset; -} - - -/** - * - */ -NodePtr DOMLocatorImpl::getRelatedNode() -{ - return relatedNode; -} - - -/** - * - */ -DOMString DOMLocatorImpl::getUri() -{ - return uri; -} - - - -/*######################################################################### -## DOMConfigurationImpl -#########################################################################*/ - - -/** - * - */ -DOMConfigurationImpl::DOMConfigurationImpl() -{ -} - - -/** - * - */ -DOMConfigurationImpl::~DOMConfigurationImpl() -{ -} - -/** - * - */ -void DOMConfigurationImpl::setParameter(const DOMString &/*name*/, - const DOMUserData */*value*/) throw (DOMException) -{ -} - -/** - * - */ -DOMUserData *DOMConfigurationImpl::getParameter(const DOMString &/*name*/) - throw (DOMException) -{ - return NULL; -} - -/** - * - */ -bool DOMConfigurationImpl::canSetParameter(const DOMString &/*name*/, - const DOMUserData */*data*/) -{ - return false; -} - -/** - * - */ -DOMStringList *DOMConfigurationImpl::getParameterNames() -{ - return NULL; -} - - - -/*######################################################################### -## CDATASectionImpl -#########################################################################*/ - -/** - * - */ -CDATASectionImpl::CDATASectionImpl() : TextImpl() -{ - nodeType = CDATA_SECTION_NODE; - nodeName = "#cdata-section"; -} - -/** - * - */ -CDATASectionImpl::CDATASectionImpl(DocumentImplPtr owner, const DOMString &theValue) - : TextImpl() -{ - nodeType = CDATA_SECTION_NODE; - nodeName = "#cdata-section"; - ownerDocument = owner; - nodeValue = theValue; -} - - -/** - * - */ -CDATASectionImpl::~CDATASectionImpl() -{ -} - - - - - -/*######################################################################### -## DocumentTypeImpl -#########################################################################*/ - -/** - * - */ -DocumentTypeImpl::DocumentTypeImpl(const DOMString& theName, - const DOMString& thePublicId, - const DOMString& theSystemId) - : NodeImpl(), - name(), //what with this variable? - publicId(thePublicId), - systemId(theSystemId), - entities(), - notations() -{ - nodeType = DOCUMENT_TYPE_NODE;//of class NodeImpl - nodeName = theName;//of class NodeImpl -} - -/** - * - */ -DocumentTypeImpl::~DocumentTypeImpl() -{ -} - -/** - * - */ -DOMString DocumentTypeImpl::getName() -{ - return nodeName; -} - -/** - * - */ -NamedNodeMap DocumentTypeImpl::getEntities() -{ - return entities; -} - -/** - * - */ -NamedNodeMap DocumentTypeImpl::getNotations() -{ - return notations; -} - -/** - * - */ -DOMString DocumentTypeImpl::getPublicId() -{ - return publicId; -} - -/** - * - */ -DOMString DocumentTypeImpl::getSystemId() -{ - return systemId; -} - -/** - * - */ -DOMString DocumentTypeImpl::getInternalSubset() -{ - return DOMString(""); -} - - - - - - -/*######################################################################### -## NotationImpl -#########################################################################*/ - - - -/** - * - */ -NotationImpl::NotationImpl(DocumentImplPtr owner) : NodeImpl() -{ - nodeType = NOTATION_NODE; - ownerDocument = owner; -} - - -/** - * - */ -NotationImpl::~NotationImpl() -{ -} - -/** - * - */ -DOMString NotationImpl::getPublicId() -{ - return publicId; -} - -/** - * - */ -DOMString NotationImpl::getSystemId() -{ - return systemId; -} - - - - - - - - -/*######################################################################### -## EntityImpl -#########################################################################*/ - - -/** - * - */ -EntityImpl::EntityImpl() : NodeImpl() -{ - nodeType = ENTITY_NODE; -} - - -/** - * - */ -EntityImpl::EntityImpl(DocumentImplPtr owner) : NodeImpl() -{ - nodeType = ENTITY_NODE; - ownerDocument = owner; -} - - -/** - * - */ -EntityImpl::~EntityImpl() -{ -} - -/** - * - */ -DOMString EntityImpl::getPublicId() -{ - return publicId; -} - -/** - * - */ -DOMString EntityImpl::getSystemId() -{ - return systemId; -} - -/** - * - */ -DOMString EntityImpl::getNotationName() -{ - return notationName; -} - -/** - * - */ -DOMString EntityImpl::getInputEncoding() -{ - return inputEncoding; -} - -/** - * - */ -DOMString EntityImpl::getXmlEncoding() -{ - return xmlEncoding; -} - -/** - * - */ -DOMString EntityImpl::getXmlVersion() -{ - return xmlVersion; -} - - - - - - -/*######################################################################### -## EntityReferenceImpl -#########################################################################*/ - - - -/** - * - */ -EntityReferenceImpl::EntityReferenceImpl() : NodeImpl() -{ - nodeType = ENTITY_REFERENCE_NODE; -} - - -/** - * - */ -EntityReferenceImpl::EntityReferenceImpl(DocumentImplPtr owner, - const DOMString &theName) - : NodeImpl() -{ - nodeType = ENTITY_REFERENCE_NODE; - nodeName = theName; - ownerDocument = owner; -} - - -/** - * - */ -EntityReferenceImpl::~EntityReferenceImpl() -{ -} - - - -/*######################################################################### -## ProcessingInstructionImpl -#########################################################################*/ - - - - -/** - * - */ -ProcessingInstructionImpl::ProcessingInstructionImpl(): NodeImpl() -{ - nodeType = PROCESSING_INSTRUCTION_NODE; -} - - - -/** - * - */ -ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImplPtr owner, - const DOMString &target, - const DOMString &data) - : NodeImpl() -{ - nodeType = PROCESSING_INSTRUCTION_NODE; - ownerDocument = owner; - nodeName = target; - nodeValue = data; -} - - -/** - * - */ -ProcessingInstructionImpl::~ProcessingInstructionImpl() -{ -} - - - - -/** - * - */ -DOMString ProcessingInstructionImpl::getTarget() -{ - return nodeName; -} - -/** - * - */ -DOMString ProcessingInstructionImpl::getData() -{ - return nodeValue; -} - -/** - * - */ -void ProcessingInstructionImpl::setData(const DOMString& /*val*/) throw(DOMException) -{ - //do something here -} - - - - - - - -/*######################################################################### -## DocumentFragmentImpl -#########################################################################*/ - -/** - * - */ -DocumentFragmentImpl::DocumentFragmentImpl() : NodeImpl() -{ - nodeType = DOCUMENT_FRAGMENT_NODE; - nodeName = "#document-fragment"; -} - - -/** - * - */ -DocumentFragmentImpl::DocumentFragmentImpl(DocumentImplPtr owner) : NodeImpl() -{ - nodeType = DOCUMENT_FRAGMENT_NODE; - nodeName = "#document-fragment"; - ownerDocument = owner; -} - - -/** - * - */ -DocumentFragmentImpl::~DocumentFragmentImpl() -{ -} - - - - - - -/*######################################################################### -## DocumentImpl -#########################################################################*/ - - - -/** - * - */ -DocumentTypePtr DocumentImpl::getDoctype() -{ - return doctype; -} - -/** - * - */ -DOMImplementation *DocumentImpl::getImplementation() -{ - return parent; -} - -/** - * - */ -ElementPtr DocumentImpl::getDocumentElement() -{ - return documentElement; -} - -/** - * - */ -ElementPtr DocumentImpl::createElement(const DOMString& tagName) - throw(DOMException) -{ - ElementPtr elem = new ElementImpl(this, tagName); - return elem; -} - -/** - * - */ -DocumentFragmentPtr DocumentImpl::createDocumentFragment() -{ - DocumentFragmentPtr frag = new DocumentFragmentImpl(this); - return frag; -} - -/** - * - */ -TextPtr DocumentImpl::createTextNode(const DOMString& data) -{ - TextPtr text = new TextImpl(this, data); - return text; -} - -/** - * - */ -CommentPtr DocumentImpl::createComment(const DOMString& data) -{ - CommentPtr comment = new CommentImpl(this, data); - return comment; -} - -/** - * - */ -CDATASectionPtr DocumentImpl::createCDATASection(const DOMString& data) - throw(DOMException) -{ - CDATASectionPtr cdata = new CDATASectionImpl(this, data); - return cdata; -} - -/** - * - */ -ProcessingInstructionPtr -DocumentImpl::createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException) -{ - ProcessingInstructionPtr pi = - new ProcessingInstructionImpl(this, target, data); - return pi; -} - -/** - * - */ -AttrPtr DocumentImpl::createAttribute(const DOMString& attrName) - throw(DOMException) -{ - AttrPtr attr = new AttrImpl(this, attrName); - return attr; -} - -/** - * - */ -EntityReferencePtr DocumentImpl::createEntityReference(const DOMString& erName) - throw(DOMException) -{ - EntityReferencePtr ref = new EntityReferenceImpl(this, erName); - return ref; -} - - -/** - * - */ -NodeList DocumentImpl::getElementsByTagName(const DOMString& tagname) -{ - NodeList list; - ElementImpl::getElementsByTagNameRecursive(list, - tagname, documentElement); - return list; -} - - -/** - * - */ -NodePtr DocumentImpl::importNode(const NodePtr /*importedNode*/, - bool /*deep*/) - throw(DOMException) -{ - return NULL; -} - -/** - * - */ -ElementPtr DocumentImpl::createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) -{ - ElementPtr elem = new ElementImpl(this, namespaceURI, qualifiedName); - return elem; -} - -/** - * - */ -AttrPtr DocumentImpl::createAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) -{ - AttrPtr attr = new AttrImpl(this, namespaceURI, qualifiedName); - return attr; -} - - -/** - * - */ -NodeList DocumentImpl::getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodeList list; - ElementImpl::getElementsByTagNameNSRecursive(list, namespaceURI, - localName, documentElement); - return list; -} - -/** - * - */ -ElementPtr DocumentImpl::getElementById(const DOMString& elementId) -{ - for (NamedElementItem *entry = elementsById.next; entry ; entry=entry->next) - if (entry->name == elementId) - return entry->elem; - return NULL; -} - - -/** - * - */ -DOMString DocumentImpl::getInputEncoding() -{ - return inputEncoding; -} - - -/** - * - */ -DOMString DocumentImpl::getXmlEncoding() -{ - return xmlEncoding; -} - -/** - * - */ -bool DocumentImpl::getXmlStandalone() -{ - return xmlStandalone; -} - -/** - * - */ -void DocumentImpl::setXmlStandalone(bool val) throw (DOMException) -{ - xmlStandalone = val; -} - -/** - * - */ -DOMString DocumentImpl::getXmlVersion() -{ - return xmlVersion; -} - -/** - * - */ -void DocumentImpl::setXmlVersion(const DOMString &version) throw (DOMException) -{ - xmlVersion = version; -} - -/** - * - */ -bool DocumentImpl::getStrictErrorChecking() -{ - return strictErrorChecking; -} - -/** - * - */ -void DocumentImpl::setStrictErrorChecking(bool val) -{ - strictErrorChecking = val; -} - - -/** - * - */ -DOMString DocumentImpl::getDocumentURI() -{ - return documentURI; -} - -/** - * - */ -void DocumentImpl::setDocumentURI(const DOMString &/*uri*/) -{ - //documentURI = stringCache(uri); -} - -/** - * - */ -NodePtr DocumentImpl::adoptNode(const NodePtr source) throw (DOMException) -{ - return (NodePtr )source; -} - -/** - * - */ -DOMConfiguration *DocumentImpl::getDomConfig() -{ - return domConfig; -} - -/** - * - */ -void DocumentImpl::normalizeDocument() -{ - //i assume that this means adjusting namespaces & prefixes - if (documentElement.get()) - documentElement->normalizeNamespaces(); -} - -/** - * - */ -NodePtr DocumentImpl::renameNode(const NodePtr node, - const DOMString &/*namespaceURI*/, - const DOMString &qualifiedName) - throw (DOMException) -{ - NodeImplPtr nodeImpl = reinterpret_cast (node.get()); - nodeImpl->setNodeName(qualifiedName); - return node; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -DocumentImpl::DocumentImpl(const DOMImplementation *domImpl, - const DOMString &/*theNamespaceURI*/, - const DOMString &theQualifiedName, - const DocumentTypePtr theDoctype) - : NodeImpl(), - namespaceIndex(0), - parent(const_cast(domImpl)), - qualifiedName(theQualifiedName), - xmlStandalone(false), - strictErrorChecking(false), - domConfig(NULL) -{ - nodeType = DOCUMENT_NODE;//of class NodeImpl - nodeName = "#document";//of class NodeImpl - if (theDoctype.get()) //only assign if not null. - doctype = theDoctype; - else - doctype = new DocumentTypeImpl("", "", ""); - documentElement = new ElementImpl(this, "root"); -} - - -/** - * - */ -DocumentImpl::~DocumentImpl() -{ - documentElement = NULL; -} - - - - - - - - - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domimpl.h b/src/dom/domimpl.h deleted file mode 100644 index df586f35e..000000000 --- a/src/dom/domimpl.h +++ /dev/null @@ -1,2029 +0,0 @@ -#ifndef SEEN_DOMIMPL_H -#define SEEN_DOMIMPL_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "dom.h" - -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - - -class DOMImplementationSourceImpl; -class DOMImplementationImpl; -class NodeImpl; -typedef Ptr NodeImplPtr; -class CharacterDataImpl; -class AttrImpl; -typedef Ptr AttrImplPtr; -class ElementImpl; -typedef Ptr ElementImplPtr; -class TextImpl; -class CommentImpl; -class TypeInfoImpl; -class UserDataHandlerImpl; -class DOMErrorImpl; -class DOMErrorHandlerImpl; -class DOMLocatorImpl; -class DOMConfigurationImpl; -class CDATASectionImpl; -class DocumentTypeImpl; -typedef Ptr DocumentTypeImplPtr; -class NotationImpl; -class EntityImpl; -class EntityReferenceImpl; -class ProcessingInstructionImpl; -class DocumentFragmentImpl; -class DocumentImpl; -typedef Ptr DocumentImplPtr; - - - -/*######################################################################### -## DOMImplementationSourceImpl -#########################################################################*/ - -class DOMImplementationSourceImpl : public DOMImplementationSource -{ -public: - - /** - * - */ - virtual DOMImplementation *getDOMImplementation(const DOMString &features); - - /** - * - */ - virtual DOMImplementationList getDOMImplementationList(const DOMString &features); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMImplementationSourceImpl(); - - /** - * - */ - virtual ~DOMImplementationSourceImpl(); - -protected: - - - DOMImplementationImpl *domImpl; - DOMImplementationList domImplList; -}; - - - - - -/*######################################################################### -## DOMImplementationImpl -#########################################################################*/ -/** - * - */ -class DOMImplementationImpl : public DOMImplementation -{ -public: - - - /** - * - */ - DOMImplementationImpl(); - - /** - * - */ - virtual ~DOMImplementationImpl(); - - /** - * - */ - virtual bool hasFeature(const DOMString& feature, const DOMString& version); - - - /** - * - */ - virtual DocumentTypePtr createDocumentType(const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException); - - /** - * - */ - virtual DocumentPtr createDocument(const DOMString& namespaceURI, - const DOMString& qualifiedName, - DocumentTypePtr doctype) - throw(DOMException); - /** - * - */ - virtual DOMObject *getFeature(const DOMString& feature, - const DOMString& version); - - -protected: - -}; - - - - -/*######################################################################### -## NodeImpl -#########################################################################*/ - -/** - * - */ -class NodeImpl : virtual public Node -{ - - friend class DocumentImpl; - -public: - - /** - * - */ - virtual DOMString getNodeName(); - - /** - * - */ - virtual DOMString getNodeValue() throw (DOMException); - - /** - * - */ - virtual void setNodeValue(const DOMString& val) throw (DOMException); - - /** - * - */ - virtual unsigned short getNodeType(); - - /** - * - */ - virtual NodePtr getParentNode(); - - /** - * - */ - virtual NodeList getChildNodes(); - - /** - * - */ - virtual NodePtr getFirstChild(); - - /** - * - */ - virtual NodePtr getLastChild(); - - /** - * - */ - virtual NodePtr getPreviousSibling(); - - /** - * - */ - virtual NodePtr getNextSibling(); - - /** - * - */ - virtual NamedNodeMap &getAttributes(); - - - /** - * - */ - virtual DocumentPtr getOwnerDocument(); - - /** - * - */ - virtual NodePtr insertBefore(const NodePtr newChild, - const NodePtr refChild) - throw(DOMException); - - /** - * - */ - virtual NodePtr replaceChild(const NodePtr newChild, - const NodePtr oldChild) - throw(DOMException); - - /** - * - */ - virtual NodePtr removeChild(const NodePtr oldChild) - throw(DOMException); - - /** - * - */ - virtual NodePtr appendChild(const NodePtr newChild) - throw(DOMException); - - /** - * - */ - virtual bool hasChildNodes(); - - /** - * - */ - virtual NodePtr cloneNode(bool deep); - - /** - * - */ - virtual void normalize(); - - /** - * - */ - virtual bool isSupported(const DOMString& feature, - const DOMString& version); - - /** - * - */ - virtual DOMString getNamespaceURI(); - - /** - * - */ - virtual DOMString getPrefix(); - - /** - * - */ - virtual void setPrefix(const DOMString& val) throw(DOMException); - - /** - * - */ - virtual DOMString getLocalName(); - - /** - * - */ - virtual bool hasAttributes(); - - /** - * - */ - virtual DOMString getBaseURI(); - - /** - * - */ - virtual unsigned short compareDocumentPosition(const NodePtr other); - - /** - * - */ - virtual DOMString getTextContent() throw(DOMException); - - - /** - * - */ - virtual void setTextContent(const DOMString &val) throw(DOMException); - - - /** - * - */ - virtual DOMString lookupPrefix(const DOMString &namespaceURI); - - - /** - * - */ - virtual bool isDefaultNamespace(const DOMString &namespaceURI); - - - /** - * - */ - virtual DOMString lookupNamespaceURI(const DOMString &prefix); - - - /** - * - */ - virtual bool isEqualNode(const NodePtr node); - - - - /** - * - */ - virtual DOMObject *getFeature(const DOMString &feature, - const DOMString &version); - - /** - * - */ - virtual DOMUserData *setUserData(const DOMString &key, - const DOMUserData *data, - const UserDataHandler *handler); - - - /** - * - */ - virtual DOMUserData *getUserData(const DOMString &key); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual void bindingsAdd(const DOMString &prefix, const DOMString &namespaceURI) - { - bindings[prefix] = namespaceURI; - } - - /** - * - */ - virtual void bindingsClear() - { - bindings.clear(); - } - - DOMString bindingsFind(const DOMString &prefix) - { - std::map::iterator iter = - bindings.find(prefix); - if (iter != bindings.end()) - { - DOMString ret = iter->second; - return ret; - } - if (parent.get()) - { - DOMString ret = parent->bindingsFind(prefix); - if (ret.size() > 0) - return ret; - } - return ""; - } - - /** - * - */ - virtual void setNodeName(const DOMString &qualifiedName); - - /** - * - */ - virtual void setNamespaceURI(const DOMString &theNamespaceURI); - - /** - * - */ - DOMString lookupNamespacePrefix(const DOMString &namespaceURI, - NodePtr originalElement); - /** - * - */ - NodeImpl(); - - /** - * - */ - NodeImpl(const NodeImpl &other); - - /** - * - */ - NodeImpl &operator=(const NodeImpl &other); - - /** - * - */ - NodeImpl(DocumentImplPtr owner); - - /** - * - */ - NodeImpl(DocumentImplPtr owner, const DOMString &nodeName); - - /** - * - */ - NodeImpl(DocumentImplPtr owner, const DOMString &namespaceURI, - const DOMString &nodeName); - - /** - * - */ - virtual ~NodeImpl(); - - - /** - * - */ - void assign(const NodeImpl &other); - -protected: - - /** - * Set up the internal values - */ - void init(); - - unsigned short nodeType; - - NodeImplPtr parent; - - NodeImplPtr prev; - - NodeImplPtr next; - - DOMUserData *userData; - - DOMString prefix; - - DOMString localName; - - DOMString nodeName; - - DOMString namespaceURI; - - DOMString baseURI; - - DOMString nodeValue; - - NodeImplPtr firstChild; - NodeImplPtr lastChild; - - DocumentImplPtr ownerDocument; - - NamedNodeMap attributes; - - class UserDataEntry - { - public: - UserDataEntry(const DOMString &theKey, - const DOMUserData *theData, - const UserDataHandler *theHandler) - : next(NULL), - key(theKey), - data(const_cast(theData)), - handler(const_cast(theHandler)) - { - } - - virtual ~UserDataEntry() - { - //delete anything after me, too - if (next) - delete next; - } - - UserDataEntry *next; - DOMString key; - DOMUserData *data; - UserDataHandler *handler; - }; - - UserDataEntry *userDataEntries; - - TypeInfo typeInfo; - - //### Our prefix->namespaceURI bindings - - std::map bindings; - - -}; - - - -/*######################################################################### -## CharacterDataImpl -#########################################################################*/ - -/** - * - */ -class CharacterDataImpl : virtual public CharacterData, protected NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getData() throw(DOMException); - - /** - * - */ - virtual void setData(const DOMString& val) throw(DOMException); - - /** - * - */ - virtual unsigned long getLength(); - - /** - * - */ - virtual DOMString substringData(unsigned long offset, - unsigned long count) - throw(DOMException); - - /** - * - */ - virtual void appendData(const DOMString& arg) throw(DOMException); - - /** - * - */ - virtual void insertData(unsigned long offset, - const DOMString& arg) - throw(DOMException); - - /** - * - */ - virtual void deleteData(unsigned long offset, - unsigned long count) - throw(DOMException); - - /** - * - */ - virtual void replaceData(unsigned long offset, - unsigned long count, - const DOMString& arg) - throw(DOMException); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CharacterDataImpl(); - - - /** - * - */ - CharacterDataImpl(DocumentImplPtr owner, const DOMString &value); - - /** - * - */ - virtual ~CharacterDataImpl(); - -protected: - - //'data' is the nodeValue - -}; - - - - - -/*######################################################################### -## AttrImpl -#########################################################################*/ - -/** - * - */ -class AttrImpl : virtual public Attr, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getName(); - - /** - * - */ - virtual bool getSpecified(); - - /** - * - */ - virtual DOMString getValue(); - - /** - * - */ - virtual void setValue(const DOMString& val) throw(DOMException); - - /** - * - */ - virtual ElementPtr getOwnerElement(); - - - /** - * - */ - virtual TypeInfo &getSchemaTypeInfo(); - - - /** - * - */ - virtual bool getIsId(); - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual void setOwnerElement(const ElementPtr elem); - - /** - * - */ - AttrImpl(DocumentImplPtr owner, const DOMString &name); - - /** - * - */ - AttrImpl(DocumentImplPtr owner, const DOMString &namespaceURI, - const DOMString &name); - - /** - * - */ - virtual ~AttrImpl(); - -protected: - - - ElementPtr ownerElement; - - -}; - - - - - -/*######################################################################### -## ElementImpl -#########################################################################*/ - -/** - * - */ -class ElementImpl : virtual public Element, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getTagName(); - - /** - * - */ - virtual DOMString getAttribute(const DOMString& name); - - /** - * - */ - virtual void setAttribute(const DOMString& name, - const DOMString& value) - throw(DOMException); - - /** - * - */ - virtual void removeAttribute(const DOMString& name) - throw(DOMException); - - /** - * - */ - virtual AttrPtr getAttributeNode(const DOMString& name); - - /** - * - */ - virtual AttrPtr setAttributeNode(AttrPtr newAttr) - throw(DOMException); - - /** - * - */ - virtual AttrPtr removeAttributeNode(AttrPtr oldAttr) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagName(const DOMString& name); - - /** - * - */ - virtual DOMString getAttributeNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual void setAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName, - const DOMString& value) - throw(DOMException); - - /** - * - */ - virtual void removeAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException); - - /** - * - */ - virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual bool hasAttribute(const DOMString& name); - - /** - * - */ - virtual bool hasAttributeNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual TypeInfo &getSchemaTypeInfo(); - - - /** - * - */ - virtual void setIdAttribute(const DOMString &name, - bool isId) throw (DOMException); - - /** - * - */ - virtual void setIdAttributeNS(const DOMString &namespaceURI, - const DOMString &localName, - bool isId) throw (DOMException); - - /** - * - */ - virtual void setIdAttributeNode(const AttrPtr idAttr, - bool isId) throw (DOMException); - - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - ElementImpl(); - - /** - * - */ - ElementImpl(DocumentImplPtr owner, const DOMString &tagName); - - /** - * - */ - ElementImpl(DocumentImplPtr owner, const DOMString &namespaceURI, - const DOMString &tagName); - - /** - * - */ - virtual ~ElementImpl(); - - /** - * - */ - void normalizeNamespaces(); - -protected: - -friend class DocumentImpl; - - static void getElementsByTagNameRecursive(NodeList &list, - const DOMString& name, ElementPtr elem); - static void getElementsByTagNameNSRecursive(NodeList &list, - const DOMString& namespaceURI, const DOMString& tagName, - ElementPtr elem); -}; - - - - - -/*######################################################################### -## TextImpl -#########################################################################*/ - -/** - * - */ -class TextImpl : virtual public Text, protected CharacterDataImpl -{ -public: - - /** - * - */ - virtual TextPtr splitText(unsigned long offset) - throw(DOMException); - - /** - * - */ - virtual bool getIsElementContentWhitespace(); - - /** - * - */ - virtual DOMString getWholeText(); - - - /** - * - */ - virtual TextPtr replaceWholeText(const DOMString &content) - throw(DOMException); - - //################## - //# Non-API methods - //################## - - /** - * - */ - TextImpl(); - - - /** - * - */ - TextImpl(DocumentImplPtr owner, const DOMString &val); - - /** - * - */ - virtual ~TextImpl(); - -protected: - -}; - - - -/*######################################################################### -## CommentImpl -#########################################################################*/ - -/** - * - */ -class CommentImpl : virtual public Comment, protected CharacterDataImpl -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - CommentImpl(); - - /** - * - */ - CommentImpl(DocumentImplPtr owner, const DOMString &theValue); - - /** - * - */ - virtual ~CommentImpl(); -}; - - - -/*######################################################################### -## TypeInfoImpl -#########################################################################*/ - -/** - * - */ -class TypeInfoImpl : public TypeInfo -{ -public: - - /** - * - */ - virtual DOMString getTypeName(); - - /** - * - */ - virtual DOMString getTypeNamespace(); - - /** - * - */ - virtual bool isDerivedFrom(const DOMString &typeNamespaceArg, - const DOMString &typeNameArg, - const DerivationMethod derivationMethod); - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - TypeInfoImpl(const DOMString &typeNamespaceArg, - const DOMString &typeNameArg, - const DerivationMethod derivationMethod); - - /** - * - */ - virtual ~TypeInfoImpl(); - -protected: - - DOMString typeName; - - DOMString typeNamespace; - - unsigned short derivationMethod; - -}; - - - - -/*######################################################################### -## UserDataHandlerImpl -#########################################################################*/ - -/** - * - */ -class UserDataHandlerImpl : public UserDataHandler -{ -public: - - /** - * - */ - virtual void handle(unsigned short operation, - const DOMString &key, - const DOMUserData *data, - const NodePtr src, - const NodePtr dst); - - //################## - //# Non-API methods - //################## - - -protected: - - /** - * - */ - UserDataHandlerImpl(); - - /** - * - */ - virtual ~UserDataHandlerImpl(); -}; - - -/*######################################################################### -## DOMErrorImpl -#########################################################################*/ - -/** - * - */ -class DOMErrorImpl : public DOMError -{ -public: - - /** - * - */ - virtual unsigned short getSeverity(); - - /** - * - */ - virtual DOMString getMessage(); - - /** - * - */ - virtual DOMString getType(); - - /** - * - */ - virtual DOMObject *getRelatedException(); - - /** - * - */ - virtual DOMObject *getRelatedData(); - - /** - * - */ - virtual DOMLocator *getLocation(); - - - //################## - //# Non-API methods - //################## - - -protected: - - /** - * - */ - DOMErrorImpl(); - - /** - * - */ - virtual ~DOMErrorImpl(); - - unsigned short severity; - - DOMString message; - - DOMString type; - - -}; - - -/*######################################################################### -## DOMErrorHandlerImpl -#########################################################################*/ - -/** - * - */ -class DOMErrorHandlerImpl : public DOMErrorHandler -{ -public: - - /** - * - */ - virtual bool handleError(const DOMError *error); - - - - //################## - //# Non-API methods - //################## - - - -protected: - - /** - * - */ - DOMErrorHandlerImpl(); - - /** - * - */ - virtual ~DOMErrorHandlerImpl(); - - -}; - - - -/*######################################################################### -## DOMLocatorImpl -#########################################################################*/ - -/** - * - */ -class DOMLocatorImpl : public DOMLocator -{ -public: - - /** - * - */ - virtual long getLineNumber(); - - /** - * - */ - virtual long getColumnNumber(); - - /** - * - */ - virtual long getByteOffset(); - - /** - * - */ - virtual long getUtf16Offset(); - - - /** - * - */ - virtual NodePtr getRelatedNode(); - - - /** - * - */ - virtual DOMString getUri(); - - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - DOMLocatorImpl(); - - /** - * - */ - virtual ~DOMLocatorImpl(); - -protected: - - - long lineNumber; - - long columnNumber; - - long byteOffset; - - long utf16Offset; - - NodePtr relatedNode; - - DOMString uri; -}; - - -/*######################################################################### -## DOMConfigurationImpl -#########################################################################*/ - -/** - * - */ -class DOMConfigurationImpl : public DOMConfiguration -{ -public: - - /** - * - */ - virtual void setParameter(const DOMString &name, - const DOMUserData *value) throw (DOMException); - - /** - * - */ - virtual DOMUserData *getParameter(const DOMString &name) - throw (DOMException); - - /** - * - */ - virtual bool canSetParameter(const DOMString &name, - const DOMUserData *data); - - /** - * - */ - virtual DOMStringList *getParameterNames(); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMConfigurationImpl(); - - /** - * - */ - virtual ~DOMConfigurationImpl(); - -protected: - -}; - - - - - - -/*######################################################################### -## CDATASectionImpl -#########################################################################*/ -/** - * - */ -class CDATASectionImpl : public CDATASection, public TextImpl -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - CDATASectionImpl(); - - - /** - * - */ - CDATASectionImpl(DocumentImplPtr owner, const DOMString &value); - - /** - * - */ - virtual ~CDATASectionImpl(); - -}; - - - - -/*######################################################################### -## DocumentTypeImpl -#########################################################################*/ - -/** - * - */ -class DocumentTypeImpl : public DocumentType, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getName(); - - /** - * - */ - virtual NamedNodeMap getEntities(); - - /** - * - */ - virtual NamedNodeMap getNotations(); - - /** - * - */ - virtual DOMString getPublicId(); - - /** - * - */ - virtual DOMString getSystemId(); - - /** - * - */ - virtual DOMString getInternalSubset(); - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentTypeImpl(); - - /** - * - */ - DocumentTypeImpl(const DOMString& name, - const DOMString& publicId, - const DOMString& systemId); - /** - * - */ - virtual ~DocumentTypeImpl(); - - -protected: - DOMString name; - DOMString publicId; - DOMString systemId; - - NamedNodeMap entities; - NamedNodeMap notations; - -}; - - - - - -/*######################################################################### -## NotationImpl -#########################################################################*/ - -/** - * - */ -class NotationImpl : public Notation, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getPublicId(); - - /** - * - */ - virtual DOMString getSystemId(); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - NotationImpl(); - - /** - * - */ - NotationImpl(DocumentImplPtr owner); - - /** - * - */ - virtual ~NotationImpl(); - - -protected: - - - - DOMString publicId; - - DOMString systemId; -}; - - - - - - -/*######################################################################### -## EntityImpl -#########################################################################*/ - -/** - * - */ -class EntityImpl : public Entity, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getPublicId(); - - /** - * - */ - virtual DOMString getSystemId(); - - /** - * - */ - virtual DOMString getNotationName(); - - /** - * - */ - virtual DOMString getInputEncoding(); - - /** - * - */ - virtual DOMString getXmlEncoding(); - - /** - * - */ - virtual DOMString getXmlVersion(); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - EntityImpl(); - - - /** - * - */ - EntityImpl(DocumentImplPtr owner); - - /** - * - */ - virtual ~EntityImpl(); - -protected: - - - - DOMString publicId; - - DOMString systemId; - - DOMString notationName; - - DOMString inputEncoding; - - DOMString xmlEncoding; - - DOMString xmlVersion; - -}; - - - - - -/*######################################################################### -## EntityReferenceImpl -#########################################################################*/ -/** - * - */ -class EntityReferenceImpl : public EntityReference, public NodeImpl -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - EntityReferenceImpl(); - - - /** - * - */ - EntityReferenceImpl(DocumentImplPtr owner, const DOMString &theName); - - /** - * - */ - virtual ~EntityReferenceImpl(); - -}; - - - - - -/*######################################################################### -## ProcessingInstructionImpl -#########################################################################*/ - -/** - * - */ -class ProcessingInstructionImpl : - public ProcessingInstruction, - public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getTarget(); - - /** - * - */ - virtual DOMString getData(); - - /** - * - */ - virtual void setData(const DOMString& val) throw(DOMException); - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - ProcessingInstructionImpl(); - - - /** - * - */ - ProcessingInstructionImpl(DocumentImplPtr owner, - const DOMString &target, - const DOMString &data); - - /** - * - */ - virtual ~ProcessingInstructionImpl(); - - -protected: - - - //'target' is nodeName - - //'data' is nodeValue - - -}; - - - - - -/*######################################################################### -## DocumentFragmentImpl -#########################################################################*/ -/** - * - */ -class DocumentFragmentImpl : public DocumentFragment, public NodeImpl -{ - -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentFragmentImpl(); - - /** - * - */ - DocumentFragmentImpl(DocumentImplPtr owner); - - /** - * - */ - virtual ~DocumentFragmentImpl(); - -}; - - - - - - -/*######################################################################### -## DocumentImpl -#########################################################################*/ - -/** - * - */ -class DocumentImpl : virtual public Document, public NodeImpl -{ -public: - - /** - * - */ - virtual DocumentTypePtr getDoctype(); - - /** - * - */ - virtual DOMImplementation *getImplementation(); - - /** - * - */ - virtual ElementPtr getDocumentElement(); - - /** - * - */ - virtual ElementPtr createElement(const DOMString& tagName) - throw(DOMException); - - /** - * - */ - virtual DocumentFragmentPtr createDocumentFragment(); - - /** - * - */ - virtual TextPtr createTextNode(const DOMString& data); - - /** - * - */ - virtual CommentPtr createComment(const DOMString& data); - - /** - * - */ - virtual CDATASectionPtr createCDATASection(const DOMString& data) - throw(DOMException); - - /** - * - */ - virtual ProcessingInstructionPtr createProcessingInstruction( - const DOMString& target, - const DOMString& data) - throw(DOMException); - - /** - * - */ - virtual AttrPtr createAttribute(const DOMString& name) - throw(DOMException); - - /** - * - */ - virtual EntityReferencePtr createEntityReference(const DOMString& name) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagName(const DOMString& tagname); - - - /** - * - */ - virtual NodePtr importNode(const NodePtr importedNode, - bool deep) - throw(DOMException); - - /** - * - */ - virtual ElementPtr createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException); - - /** - * - */ - virtual AttrPtr createAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual ElementPtr getElementById(const DOMString& elementId); - - - /** - * - */ - virtual DOMString getInputEncoding(); - - - /** - * - */ - virtual DOMString getXmlEncoding(); - - /** - * - */ - virtual bool getXmlStandalone(); - - /** - * - */ - virtual void setXmlStandalone(bool val) throw (DOMException); - - /** - * - */ - virtual DOMString getXmlVersion(); - - /** - * - */ - virtual void setXmlVersion(const DOMString &version) throw (DOMException); - - /** - * - */ - virtual bool getStrictErrorChecking(); - - /** - * - */ - virtual void setStrictErrorChecking(bool val); - - - /** - * - */ - virtual DOMString getDocumentURI(); - - /** - * - */ - virtual void setDocumentURI(const DOMString &uri); - - /** - * - */ - virtual NodePtr adoptNode(const NodePtr source) throw (DOMException); - - /** - * - */ - virtual DOMConfiguration *getDomConfig(); - - /** - * - */ - virtual void normalizeDocument(); - - /** - * - */ - virtual NodePtr renameNode(const NodePtr n, - const DOMString &name, - const DOMString &qualifiedName) - throw (DOMException); - - - //################## - //# Non-API methods - //################## - - DocumentImpl(const DOMImplementation *domImpl, - const DOMString &namespaceURI, - const DOMString &qualifiedName, - const DocumentTypePtr doctype); - - virtual ~DocumentImpl(); - - - DOMString *stringCache(const DOMString &val); - - int namespaceIndex; - -protected: - - DOMImplementation *parent; - - DOMString documentURI; - - DOMString qualifiedName; - - DocumentTypePtr doctype; - - ElementImplPtr documentElement; - - class NamedElementItem - { - public: - NamedElementItem() - { - next = NULL; - } - NamedElementItem(const DOMString &nameArg, ElementPtr elemArg) - : next (NULL), - name (nameArg), - elem (elemArg) - { - } - ~NamedElementItem() - { - if (next) - delete next; - } - NamedElementItem *next; - DOMString name; - ElementPtr elem; - }; - - NamedElementItem elementsById; - - - DOMString xmlEncoding; - - DOMString inputEncoding; - - DOMString xmlVersion; - - bool xmlStandalone; - - bool strictErrorChecking; - - DOMConfiguration *domConfig; - - NamedNodeMap namespaceURIs; - - -}; - - - - - - - - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOMIMPL_H - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domptr.cpp b/src/dom/domptr.cpp deleted file mode 100644 index 73999e100..000000000 --- a/src/dom/domptr.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "dom.h" -#include "domptr.h" - - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - - - -/*######################################################################### -## NodePtr -#########################################################################*/ - - - -/** - * Increment the ref counter of the wrapped class instance - */ -void incrementRefCount(Node *p) -{ - if (p) - p->_refCnt++; -} - -/** - * Decrement the ref counter of the wrapped class instance. Delete - * the object if the reference count goes to zero - */ -void decrementRefCount(Node *p) -{ - if (p) - { - if (--(p->_refCnt) < 1) - delete p; - } -} - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domptr.h b/src/dom/domptr.h deleted file mode 100644 index aa9d4c208..000000000 --- a/src/dom/domptr.h +++ /dev/null @@ -1,339 +0,0 @@ -#ifndef SEEN_DOMPTR_H -#define SEEN_DOMPTR_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * More thorough explanations of the various classes and their algorithms - * can be found there. - * - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================= - * NOTES: - * - * Notice that many of the classes defined here are pure virtual. In other - * words, they are purely unimplemented interfaces. For the implementations - * of them, look in domimpl.h and domimpl.cpp. - * - * Also, note that there is a domptr.cpp file that has a couple of necessary - * functions which cannot be in a .h file - * - */ - -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - - -/*######################################################################### -## NodePtr -#########################################################################*/ - -/** - * A simple Smart Pointer class that handles Nodes and all of its - * descendants. This is very similar to shared_ptr, but it is customized - * to handle our needs. - */ -template class Ptr -{ -public: - - /** - * Simple constructor - */ - Ptr() - { _ref = 0; } - - /** - * Constructor upon a reference - */ - template Ptr(const Ptr &other) - { - _ref = other._ref; - incrementRefCount(_ref); - } - - /** - * Constructor upon a reference - */ - Ptr(T * refArg, bool addRef = true) - { - _ref = refArg; - if(addRef) - incrementRefCount(_ref); - } - - - /** - * Copy constructor - */ - Ptr(const Ptr &other) - { - _ref = other._ref; - incrementRefCount(_ref); - } - - /** - * Destructor - */ - virtual ~Ptr() - { - decrementRefCount(_ref); - } - - - /** - * Assignment operator - */ - template Ptr &operator=(const Ptr &other) - { - decrementRefCount(_ref); - _ref = other._ref; - incrementRefCount(_ref); - return *this; - } - - /** - * Assignment operator - */ - Ptr &operator=(const Ptr &other) - { - decrementRefCount(_ref); - _ref = other._ref; - incrementRefCount(_ref); - return *this; - } - - /** - * Assignment operator - */ - template Ptr &operator=(Y * ref) - { - decrementRefCount(_ref); - _ref = ref; - incrementRefCount(_ref); - return *this; - } - - /** - * Assignment operator - */ - template Ptr &operator=(const Y * ref) - { - decrementRefCount(_ref); - _ref = const_cast(ref); - incrementRefCount(_ref); - return *this; - } - - /** - * Return the reference - */ - T * get() const - { - return _ref; - } - - /** - * Dereference operator - */ - T &operator*() const - { - return *_ref; - } - - /** - * Point-to operator - */ - T *operator->() const - { - return _ref; - } - - /** - * NOT bool operator. How to check if we are null without a comparison - */ - bool operator! () const - { - return (_ref == 0); - } - - /** - * Swap what I reference with the other guy - */ - void swap(Ptr &other) - { - T *tmp = _ref; - _ref = other._ref; - other._ref = tmp; - } - - //The referenced item - T *_ref; -}; - - -/** - * Global definitions. Many of these are used to mimic behaviour of - * a real pointer - */ - -/** - * Equality - */ -template inline bool - operator==(const Ptr &a, const Ptr &b) -{ - return a.get() == b.get(); -} - -/** - * Inequality - */ -template inline bool - operator!=(const Ptr &a, const Ptr &b) -{ - return a.get() != b.get(); -} - -/** - * Equality - */ -template inline bool - operator==(const Ptr &a, T * b) -{ - return a.get() == b; -} - -/** - * Inequality - */ -template inline bool - operator!=(const Ptr &a, T * b) -{ - return a.get() != b; -} - -/** - * Equality - */ -template inline bool - operator==(T * a, const Ptr &b) -{ - return a == b.get(); -} - -/** - * Inequality - */ -template inline bool - operator!=(T * a, const Ptr &b) -{ - return a != b.get(); -} - - -/** - * Less than - */ -template inline bool - operator<(const Ptr &a, const Ptr &b) -{ - return std::less()(a.get(), b.get()); -} - -/** - * Swap - */ -template void - swap(Ptr &a, Ptr &b) -{ - a.swap(b); -} - - -/** - * Get the pointer globally, for - */ -template T * - get_pointer(const Ptr &p) -{ - return p.get(); -} - -/** - * Static cast - */ -template Ptr - static_pointer_cast(const Ptr &p) -{ - return static_cast(p.get()); -} - -/** - * Const cast - */ -template Ptr - const_pointer_cast(const Ptr &p) -{ - return const_cast(p.get()); -} - -/** - * Dynamic cast - */ -template Ptr - dynamic_pointer_cast(const Ptr &p) -{ - return dynamic_cast(p.get()); -} - - - -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOMPTR_H - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domstring.cpp b/src/dom/domstring.cpp deleted file mode 100644 index 32e3c078f..000000000 --- a/src/dom/domstring.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#include "domstring.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - -//######################################################################### -//# C O N S T R U C T O R S -//######################################################################### - -DOMString::DOMString() -{ - init(); -} - -DOMString::DOMString(const DOMString &other) -{ - init(); - chars = other.chars; -} - -DOMString::DOMString(const char *str) -{ - init(); - append(str); -} - - -DOMString::~DOMString() -{ - if (cstring) - delete[] cstring; -} - - -/** - * Called only by Constructors - */ -void DOMString::init() -{ - cstring = NULL; - chars.clear(); -} - -//######################################################################### -//# M O D I F Y -//######################################################################### - -DOMString &DOMString::append(const DOMString &str) -{ - unsigned int len = str.size(); - for (unsigned int i=0 ; i::iterator iter = chars.begin(); - chars.erase(iter, iter + count); -} - -DOMString &DOMString::insert(unsigned long pos, const DOMString &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::insert(unsigned long pos, const char *str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::insert(unsigned long pos, const std::string &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - - -DOMString &DOMString::prepend(const DOMString &str) -{ - DOMString tmp = *this; - clear(); - append(str); - append(tmp); - return *this; -} - -DOMString &DOMString::prepend(const char *str) -{ - DOMString tmp = *this; - clear(); - append(str); - append(tmp); - return *this; -} - -DOMString &DOMString::prepend(const std::string &str) -{ - DOMString tmp = *this; - clear(); - append(str); - append(tmp); - return *this; -} - -DOMString &DOMString::replace(unsigned long pos, unsigned long count, - const DOMString &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos+count, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::replace(unsigned long pos, unsigned long count, - const char *str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos+count, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::replace(unsigned long pos, unsigned long count, - const std::string &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos+count, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - - -DOMString &DOMString::push_back(XMLCh ch) -{ - chars.push_back(ch); - return *this; -} - - - -void DOMString::clear() -{ - chars.clear(); - if (cstring) - { - delete[] cstring; - cstring = NULL; - } -} - -//######################################################################### -//# Q U E R Y -//######################################################################### - -XMLCh DOMString::charAt(unsigned long index) const -{ - return chars[index]; -} - -XMLCh DOMString::operator[](unsigned long index) const -{ - return chars[index]; -} - -DOMString DOMString::substr(unsigned long start, unsigned long end) const -{ - DOMString ret; - for (unsigned long i = start; i -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ - -/** - * - */ -typedef unsigned short XMLCh; - -class DOMString -{ -public: - - //############################### - //# C O N S T R U C T O R S - //############################### - - /** - * - */ - DOMString(); - - /** - * - */ - DOMString(const char *str); - - - /** - * - */ - DOMString(const DOMString &str); - - - /** - * - */ - DOMString(const std::string &str); - - /** - * - */ - virtual ~DOMString(); - - - //############################### - //# M O D I F Y - //############################### - - - - /** - * - */ - virtual DOMString &append(const DOMString &str); - virtual DOMString &operator +(const DOMString &str) - { return append(str); } - virtual DOMString &operator +=(const DOMString &str) - { return append(str); } - - /** - * - */ - virtual DOMString &append(const char *str); - - /** - * - */ - virtual DOMString &append(const std::string &str); - - - /** - * - */ - virtual DOMString &assign(const DOMString &str); - - /** - * - */ - DOMString &operator =(const DOMString &a); - - /** - * - */ - virtual DOMString &assign(const char *str); - - /** - * - */ - virtual DOMString &assign(const std::string &str); - - /** - * - */ - virtual void erase(unsigned long pos, unsigned long count); - - /** - * - */ - virtual DOMString &insert(unsigned long pos, const DOMString &str); - - /** - * - */ - virtual DOMString &insert(unsigned long pos, const char *str); - - /** - * - */ - virtual DOMString &insert(unsigned long pos, const std::string &str); - - - /** - * - */ - virtual DOMString &prepend(const DOMString &str); - - /** - * - */ - virtual DOMString &prepend(const char *str); - - /** - * - */ - virtual DOMString &prepend(const std::string &str); - - - /** - * - */ - virtual DOMString &replace(unsigned long pos, unsigned long count, - const DOMString &str); - - /** - * - */ - virtual DOMString &replace(unsigned long pos, unsigned long count, - const char *str); - - /** - * - */ - virtual DOMString &replace(unsigned long pos, unsigned long count, - const std::string &str); - - /** - * - */ - virtual DOMString &push_back(XMLCh ch); - - /** - * - */ - virtual void clear(); - - //############################### - //# Q U E R Y - //############################### - - /** - * - */ - virtual DOMString substr(unsigned long start, unsigned long end) const; - - /** - * - */ - virtual XMLCh charAt(unsigned long index) const; - - /** - * - */ - virtual XMLCh operator[](unsigned long index) const; - - /** - * - */ - virtual unsigned long size() const; - - /** - * - */ - virtual const char *c_str(); - - //############################### - //# C O M P A R I S O N - //############################### - - /** - * - */ - virtual int compare(const DOMString &str) const; - virtual bool operator <(const DOMString &str) const - { return (compare(str)<0) ; } - virtual bool operator <=(const DOMString &str) const - { return (compare(str)<=0) ; } - virtual bool operator >(const DOMString &str) const - { return (compare(str)>0) ; } - virtual bool operator >=(const DOMString &str) const - { return (compare(str)>=0) ; } - virtual bool operator !=(const DOMString &str) const - { return (compare(str)!=0) ; } - virtual bool operator ==(const DOMString &str) const - { return (compare(str)==0) ; } - - /** - * - */ - virtual int compare(const char *str) const; - virtual bool operator <(const char *str) const - { return (compare(str)<0) ; } - virtual bool operator <=(const char *str) const - { return (compare(str)<=0) ; } - virtual bool operator >(const char *str) const - { return (compare(str)>0) ; } - virtual bool operator >=(const char *str) const - { return (compare(str)>=0) ; } - virtual bool operator !=(const char *str) const - { return (compare(str)!=0) ; } - virtual bool operator ==(const char *str) const - { return (compare(str)==0) ; } - - /** - * - */ - virtual int compare(const std::string &str) const; - virtual bool operator <(const std::string &str) const - { return (compare(str)<0) ; } - virtual bool operator <=(const std::string &str) const - { return (compare(str)<=0) ; } - virtual bool operator >(const std::string &str) const - { return (compare(str)>0) ; } - virtual bool operator >=(const std::string &str) const - { return (compare(str)>=0) ; } - virtual bool operator !=(const std::string &str) const - { return (compare(str)!=0) ; } - virtual bool operator ==(const std::string &str) const - { return (compare(str)==0) ; } - - - - -protected: - - void init(); - - char *cstring; - - std::vector chars; - -}; // class DOMString - - - - -//############################### -//# O P E R A T O R S -//############################### - -DOMString &operator +(DOMString &a, const char *b); - -DOMString &operator +(const char *b, DOMString &a); - - - -} //namespace dom -} //namespace w3c -} //namespace org - -#endif // SEEN_DOMSTRING_H -//######################################################################### -//## E N D O F F I L E -//######################################################################### - - diff --git a/src/dom/events.h b/src/dom/events.h deleted file mode 100644 index e62c5d420..000000000 --- a/src/dom/events.h +++ /dev/null @@ -1,1644 +0,0 @@ -#ifndef SEEN_EVENTS_H -#define SEEN_EVENTS_H - -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================== - * NOTES - * - * This Events API follows somewhat this specification: - * http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html - * - * Some of the comments are excerpted from that document. - * - * - */ - - -#include "dom.h" -#include "views.h" - - - - -namespace org { -namespace w3c { -namespace dom { -namespace events { - - - - -//Local definitions -typedef dom::DOMString DOMString; -typedef dom::DOMTimeStamp DOMTimeStamp; -typedef dom::NodePtr NodePtr ; - - - - -//forward declarations -class EventTarget; -class EventListener; -class DocumentEvent; -class CustomEvent; -class UIEvent; -class TextEvent; -class MouseEvent; -class KeyboardEvent; -class MutationEvent; -class MutationNameEvent; - - - -/*######################################################################### -## EventException -#########################################################################*/ - -/** - * Event operations may throw an EventException as specified in their - * method descriptions. - */ -class EventException -{ -public: - - /** - * An integer indicating the type of error generated. - */ - typedef enum - { - UNSPECIFIED_EVENT_TYPE_ERR = 0, - DISPATCH_REQUEST_ERR = 1 - } EventExceptionCode; - - unsigned short code; - - - //################## - //# Non-API methods - //################## - - EventException(short theCode) - { - code = theCode; - } - - virtual ~EventException() throw() - {} - -}; - - - - -/*######################################################################### -## Event -#########################################################################*/ - -/** - * The Event interface is used to provide contextual information about an event - * to the listener processing the event. An object which implements the Event - * interface is passed as the parameter to an EventListener. More specific - * context information is passed to event listeners by deriving additional - * interfaces from Event which contain information directly relating to the type - * of event they represent. These derived interfaces are also implemented by the - * object passed to the event listener. - * - * To create an instance of the Event interface, use the - * DocumentEvent.createEvent("Event") method call. - */ -class Event -{ -public: - - /** - * An integer indicating which phase of the event flow is being processed - * as defined in DOM event flow. - */ - typedef enum - { - CAPTURING_PHASE = 1, - AT_TARGET = 2, - BUBBLING_PHASE = 3 - } PhaseType; - - /** - * The name should be an NCName as defined in [XML Namespaces] and is - * case-sensitive. - * If the attribute Event.namespaceURI is different from null, this - * attribute represents a local name. - */ - virtual DOMString getType() const - { return eventType; } - - /** - * Used to indicate the event target. This attribute contains the target - * node when used with the DOM event flow. - */ - virtual EventTarget *getTarget() - { return target; } - - /** - * Used to indicate the EventTarget whose EventListeners are currently - * being processed. This is particularly useful during the capture and - * bubbling phases. This attribute could contain the target node or a - * target ancestor when used with the DOM event flow. - */ - virtual EventTarget *getCurrentTarget() - { return currentTarget; } - - /** - * Used to indicate which phase of event flow is currently being accomplished. - */ - virtual unsigned short getEventPhase() - { return eventPhase; } - - /** - * Used to indicate whether or not an event is a bubbling event. If the - * event can bubble the value is true, otherwise the value is false. - */ - virtual bool getBubbles() - { return canBubble; } - - /** - * Used to indicate whether or not an event can have its default action - * prevented (see also Default actions and cancelable events). If the - * default action can be prevented the value is true, otherwise the - * value is false. - */ - virtual bool getCancelable() - { return cancelable; } - - /** - * 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. - */ - virtual DOMTimeStamp getTimeStamp() - { return timeStamp; } - - /** - * This method is used to prevent event listeners of the same group to be - * triggered but its effect is deferred until all event listeners attached on the - * currentTarget have been triggered (see Event propagation and event groups). - * Once it has been called, further calls to that method have no additional effect. - */ - virtual 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 (see also Default - * actions and cancelable events), and thus independently of event groups. - * Calling this method for a non-cancelable event has no effect. - */ - virtual void preventDefault() - { - } - - /** - * The initEvent method is used to initialize the value of an Event created - * through the DocumentEvent.createEvent method. This method may only be called - * before the Event has been dispatched via the EventTarget.dispatchEvent() - * method. If the method is called several times before invoking - * EventTarget.dispatchEvent, only the final invocation takes precedence. This - * method has no effect if called after the event has been dispatched. If called - * from a subclass of the Event interface only the values specified in this - * method are modified, all other attributes are left unchanged. - * - * This method sets the Event.type attribute to eventTypeArg, and - * Event.namespaceURI to null. To initialize an event with a namespace URI, use - * the Event.initEventNS(namespaceURIArg, eventTypeArg, ...) method. - */ - virtual void initEvent(const DOMString &eventTypeArg, - bool canBubbleArg, - bool cancelableArg) - { - namespaceURI = ""; - eventType = eventTypeArg; - canBubble = canBubbleArg; - cancelable = cancelableArg; - } - - - /** - * The namespace URI associated with this event at creation time, or - * null if it is unspecified. - */ - virtual DOMString getNamespaceURI() const - { return namespaceURI; } - - /** - * This method will always return false, unless the event implements - * the CustomEvent interface. - */ - virtual bool isCustom() - { return custom; } - - /** - * This method is used to prevent event listeners of the same group to be - * triggered and, unlike stopPropagation its effect is immediate (see Event - * propagation and event groups). Once it has been called, further calls to that - * method have no additional effect. - * - * Note: This method does not prevent the default action from being invoked; use - * Event.preventDefault() for that effect. - */ - virtual void stopImmediatePropagation() - { - } - - /** - * This method will return true if the method Event.preventDefault() - * has been called for this event, false otherwise. - */ - virtual bool isDefaultPrevented() - { return defaultPrevented; } - - /** - * The initEventNS method is used to initialize the value of an Event - * object and has the same behavior as Event.initEvent(). - */ - virtual void initEventNS(const DOMString &namespaceURIArg, - const DOMString &eventTypeArg, - bool canBubbleArg, - bool cancelableArg) - { - namespaceURI = namespaceURIArg; - eventType = eventTypeArg; - canBubble = canBubbleArg; - cancelable = cancelableArg; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - Event() - { - init(); - } - - /** - * - */ - Event(const DOMString &eventTypeArg) - { - init(); - eventType = eventTypeArg; - } - - - /** - * - */ - Event(const Event &other) - { - eventType = other.eventType; - target = other.target; - currentTarget = other.currentTarget; - eventPhase = other.eventPhase; - canBubble = other.canBubble; - cancelable = other.cancelable; - timeStamp = other.timeStamp; - namespaceURI = other.namespaceURI; - custom = other.custom; - defaultPrevented = other.defaultPrevented; - } - - /** - * - */ - virtual ~Event() {} - -protected: - - /** - * - */ - void init() - { - eventType = ""; - target = NULL; - currentTarget = NULL; - eventPhase = 0; - canBubble = false; - cancelable = false; - //timeStamp = other.timeStamp; - namespaceURI = ""; - custom = false; - defaultPrevented = false; - } - - DOMString eventType; - EventTarget *target; - EventTarget *currentTarget; - unsigned short eventPhase; - bool canBubble; - bool cancelable; - DOMTimeStamp timeStamp; - DOMString namespaceURI; - bool custom; - bool defaultPrevented; - -}; - - - - -/*######################################################################### -## EventListener -#########################################################################*/ - -/** - * The EventListener interface is the primary way for handling events. Users - * implement the EventListener interface and register their event listener on an - * EventTarget. The users should also remove their EventListener from its - * EventTarget after they have completed using the listener. - * - * Copying a Node, with methods such as Node.cloneNode or Range.cloneContents, - * does not copy the event listeners attached to it. Event listeners must be - * attached to the newly created Node afterwards if so desired. - * - * Moving a Node, with methods Document.adoptNode, Node.appendChild, or - * Range.extractContents, does not affect the event listeners attached to it. - */ -class EventListener -{ -public: - - /** - * This method is called whenever an event occurs of the event type - * for which the EventListener interface was registered. - */ - virtual void handleEvent(const Event &/*evt*/) - {} - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~EventListener() {} -}; - - - - - - -/*######################################################################### -## EventTarget -#########################################################################*/ - - -/** - * The EventTarget interface is implemented by all the objects which could be - * event targets in an implementation which supports the Event flows. The - * interface allows registration, removal or query of event listeners, and - * dispatch of events to an event target. - * - * When used with DOM event flow, this interface is implemented by all target - * nodes and target ancestors, i.e. all DOM Nodes of the tree support this - * interface when the implementation conforms to DOM Level 3 Events and, - * therefore, this interface can be obtained by using binding-specific casting - * methods on an instance of the Node interface. - * - * Invoking addEventListener or addEventListenerNS multiple times on the same - * EventTarget with the same parameters (namespaceURI, type, listener, and - * useCapture) is considered to be a no-op and thus independently of the event - * group. They do not cause the EventListener to be called more than once and do - * not cause a change in the triggering order. In order to guarantee that an - * event listener will be added to the event target for the specified event group, - * one needs to invoke removeEventListener or removeEventListenerNS first. - */ -class EventTarget -{ -private: - - class EventListenerEntry - { - public: - EventListenerEntry(const DOMString &namespaceURIArg, - const DOMString &eventTypeArg, - const EventListener *listenerArg, - bool useCaptureArg) - { - namespaceURI = namespaceURIArg; - eventType = eventTypeArg; - listener = const_cast(listenerArg); - useCapture = useCaptureArg; - } - - EventListenerEntry(const EventListenerEntry &other) - { - namespaceURI = other.namespaceURI; - eventType = other.eventType; - listener = other.listener; - useCapture = other.useCapture; - } - - virtual ~EventListenerEntry() {} - - DOMString namespaceURI; - DOMString eventType; - EventListener *listener; - bool useCapture; - }; - - - -public: - - /** - * This method allows the registration of an event listener in the default group - * and, depending on the useCapture parameter, on the capture phase of the DOM - * event flow or its target and bubbling phases. - */ - virtual void addEventListener(const DOMString &type, - const EventListener *listener, - bool useCapture) - { - EventListenerEntry entry("", type, listener, useCapture); - listeners.push_back(entry); - } - - /** - * This method allows the removal of event listeners from the default group. - * Calling removeEventListener with arguments which do not identify any currently - * registered EventListener on the EventTarget has no effect. - */ - virtual void removeEventListener(const DOMString &type, - const EventListener *listener, - bool useCapture) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ){ - EventListenerEntry entry = *iter; - if (entry.eventType == type && - entry.listener == listener && - useCapture && entry.useCapture){ - iter = listeners.erase(iter); - } - else{ - ++iter; - } - } - } - - /** - * This method allows the dispatch of events into the implementation's event - * model. The event target of the event is the EventTarget object on which - * dispatchEvent is called. - */ - virtual bool dispatchEvent(const Event &evt) throw(EventException) - { - - for (unsigned int i=0 ; ihandleEvent(evt); - } - } - return true; - } - - - /** - * This method allows the registration of an event listener in a specified group - * or the default group and, depending on the useCapture parameter, on the - * capture phase of the DOM event flow or its target and bubbling phases. - */ - virtual void addEventListenerNS(const DOMString &namespaceURI, - const DOMString &type, - const EventListener *listener, - bool useCapture) - { - EventListenerEntry entry(namespaceURI, type, listener, useCapture); - listeners.push_back(entry); - } - - /** - * This method allows the removal of an event listener, independently of the - * associated event group. - * Calling removeEventListenerNS with arguments which do not identify any - * currently registered EventListener on the EventTarget has no effect. - */ - virtual void removeEventListenerNS(const DOMString &namespaceURI, - const DOMString &type, - const EventListener *listener, - bool useCapture) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ){ - EventListenerEntry entry = *iter; - if (entry.namespaceURI == namespaceURI && - entry.eventType == type && - entry.listener == listener && - useCapture && entry.useCapture){ - iter = listeners.erase(iter); - } - else { - ++iter; - } - } - } - - /** - * This method allows the DOM application to know if an event listener, attached - * to this EventTarget or one of its ancestors, will be triggered by the - * specified event type during the dispatch of the event to this event target or - * one of its descendants. - */ - virtual bool willTriggerNS(const DOMString &namespaceURI, - const DOMString &type) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) - { - EventListenerEntry entry = *iter; - if (entry.namespaceURI == namespaceURI && - entry.eventType == type) - return true; - } - return false; - } - - /** - * This method allows the DOM application to know if this EventTarget contains an - * event listener registered for the specified event type. This is useful for - * determining at which nodes within a hierarchy altered handling of specific - * event types has been introduced, but should not be used to determine whether - * the specified event type triggers an event listener (see - * EventTarget.willTriggerNS()). - */ - virtual bool hasEventListenerNS(const DOMString &namespaceURI, - const DOMString &type) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) - { - EventListenerEntry entry = *iter; - if (entry.namespaceURI == namespaceURI && - entry.eventType == type) - return true; - } - return false; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - EventTarget() {} - - /** - * - */ - EventTarget(const EventTarget &other) - : listeners (other.listeners) - { - } - - /** - * - */ - virtual ~EventTarget() {} - -protected: - - std::vector listeners; - -}; - - - - -/*######################################################################### -## DocumentEvent -#########################################################################*/ - -/** - * The DocumentEvent interface provides a mechanism by which the user can create - * an Event object of a type supported by the implementation. If the feature - * "Events" is supported by the Document object, the DocumentEvent interface must - * be implemented on the same object. If the feature "+Events" is supported by - * the Document object, an object that supports the DocumentEvent interface must - * be returned by invoking the method Node.getFeature("+Events", "3.0") on the - * Document object. - */ -class DocumentEvent : virtual public Event -{ -public: - - /** - * Create an event with the current document - */ - virtual Event createEvent(const DOMString &/*eventType*/) - throw (dom::DOMException) - { - Event event; - return event; - } - - /** - * Test if the implementation can generate events of a specified type. - */ - virtual bool canDispatch(const DOMString &/*namespaceURI*/, - const DOMString &/*type*/) - { - return dispatchable; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentEvent() - : dispatchable(false) - {} - - /** - * - */ - DocumentEvent(const DocumentEvent &other) : Event(other) - { - dispatchable = other.dispatchable; - } - - /** - * - */ - virtual ~DocumentEvent() {} - -protected: - - bool dispatchable; - - -}; - - -/*######################################################################### -## CustomEvent -#########################################################################*/ - -/** - * The CustomEvent interface gives access to the attributes Event.currentTarget - * and Event.eventPhase. It is intended to be used by the DOM Events - * implementation to access the underlying current target and event phase while - * dispatching a custom Event in the tree; it is also intended to be implemented, - * and not used, by DOM applications. - * - * The methods contained in this interface are not intended to be used by a DOM - * application, especially during the dispatch on the Event object. Changing the - * current target or the current phase may result in unpredictable results of the - * event flow. The DOM Events implementation should ensure that both methods - * return the appropriate current target and phase before invoking each event - * listener on the current target to protect DOM applications from malicious - * event listeners. - * - * Note: If this interface is supported by the event object, Event.isCustom() - * must return true. -*/ -class CustomEvent : virtual public Event -{ -public: - - /** - * The setDispatchState method is used by the DOM Events implementation to set - * the values of Event.currentTarget and Event.eventPhase. It also reset the - * states of isPropagationStopped and isImmediatePropagationStopped. - */ - virtual void setDispatchState(const EventTarget */*target*/, - unsigned short /*phase*/) - { - } - - /** - * This method will return true if the method stopPropagation() has been - * called for this event, false in any other cases. - */ - virtual bool isPropagationStopped() - { - return propagationStopped; - } - - /** - * The isImmediatePropagationStopped method is used by the DOM Events - * implementation to know if the method stopImmediatePropagation() has been - * called for this event. It returns true if the method has been called, false - * otherwise. - */ - virtual bool isImmediatePropagationStopped() - { - return immediatePropagationStopped; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CustomEvent() - : propagationStopped(false), - immediatePropagationStopped(false) - {} - - /** - * - */ - CustomEvent(const CustomEvent &other) : Event(other) - { - propagationStopped = other.propagationStopped; - immediatePropagationStopped = other.immediatePropagationStopped; - } - - /** - * - */ - virtual ~CustomEvent() {} - -protected: - - bool propagationStopped; - bool immediatePropagationStopped; - - - -}; - - - - -/*######################################################################### -## UIEvent -#########################################################################*/ - -/** - * The UIEvent interface provides specific contextual information associated with - * User Interface events. - * - * To create an instance of the UIEvent interface, use the - * DocumentEvent.createEvent("UIEvent") method call. - * - * NOTE: - * For dom level 2 and 3, note that views.idl and events.idl disagree on the - * name of Views. We are using level -2- Views - */ -class UIEvent : virtual public Event -{ -public: - - /** - * The view attribute identifies the AbstractView from which the - * event was generated. - */ - virtual views::AbstractView getView() - { return view; } - - /** - * Specifies some detail information about the Event, depending on - * the type of event. - */ - virtual long getDetail() - { return detail; } - - /** - * The initUIEvent method is used to initialize the value of a UIEvent object and - * has the same behavior as Event.initEvent(). - */ - virtual void initUIEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - /** - * The initUIEventNS method is used to initialize the value of a UIEvent object - * and has the same behavior as Event.initEventNS(). - */ - virtual void initUIEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - UIEvent() - : view(), - detail(0) - {} - - /** - * - */ - UIEvent(const UIEvent &other) - : Event(other), - view(other.view), - detail(other.detail) - { - } - - /** - * - */ - virtual ~UIEvent() {} - -protected: - - views::AbstractView view; - long detail; -}; - - - - -/*######################################################################### -## TextEvent -#########################################################################*/ - -/** - * The TextEvent interface provides specific contextual information associated - * with Text Events. - * - * To create an instance of the TextEvent interface, use the - * DocumentEvent.createEvent("TextEvent") method call. - */ -class TextEvent : virtual public UIEvent -{ -public: - - /** - * data holds the value of the characters generated by the character device. This - * may be a single Unicode character or a non-empty sequence of Unicode - * characters [Unicode]. Characters should be normalized as defined by the - * Unicode normalization form NFC, defined in [UTR #15]. This attribute cannot be - * null or contain the empty string. - */ - virtual DOMString getData() - { return data; } - - /** - * The initTextEvent method is used to initialize the value of a TextEvent object - * and has the same behavior as UIEvent.initUIEvent(). The value of - * UIEvent.detail remains undefined. - */ - virtual void initTextEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - /** - * The initTextEventNS method is used to initialize the value of a TextEvent - * object and has the same behavior as UIEvent.initUIEventNS(). The value of - * UIEvent.detail remains undefined. - */ - virtual void initTextEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - TextEvent() {} - - /** - * - */ - TextEvent(const TextEvent &other) : Event(other), UIEvent(other) - { - data = other.data; - } - - /** - * - */ - virtual ~TextEvent() {} - -protected: - - DOMString data; - -}; - - - - - - - - -/*######################################################################### -## MouseEvent -#########################################################################*/ - -/** - * The MouseEvent interface provides specific contextual information associated - * with Mouse events. - * - * 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 theirs descendent - * elements. - * - * To create an instance of the MouseEvent interface, use the - * DocumentEvent.createEvent("MouseEvent") method call. - */ -class MouseEvent : virtual public UIEvent -{ -public: - - /** - * The horizontal coordinate at which the event occurred relative to the - * origin of the screen coordinate system. - */ - virtual long getScreenX() - { return screenX; } - - /** - * The vertical coordinate at which the event occurred relative to the - * origin of the screen coordinate system. - */ - virtual long getScreenY() - { return screenY; } - - /** - * The horizontal coordinate at which the event occurred relative to the - * DOM implementation's client area. - */ - virtual long getClientX() - { return clientX; } - - /** - * The vertical coordinate at which the event occurred relative to the - * DOM implementation's client area. - */ - virtual long getClientY() - { return clientY; } - - /** - * true if the control (Ctrl) key modifier is activated. - */ - virtual bool getCtrlKey() - { return ctrlKey; } - - /** - * true if the shift (Shift) key modifier is activated. - */ - virtual bool getShiftKey() - { return shiftKey; } - - /** - * true if the alt (alternative) key modifier is activated. - */ - virtual bool getAltKey() - { return altKey; } - - /** - * true if the meta (Meta) key modifier is activated. - */ - virtual bool getMetaKey() - { return metaKey; } - - /** - * During mouse events caused by the depression or release of a mouse button, - * button is used to indicate which mouse button changed state. 0 indicates the - * normal button of the mouse (in general on the left or the one button on - * Macintosh mice, used to activate a button or select text). 2 indicates the - * contextual property (in general on the right, used to display a context menu) - * button of the mouse if present. 1 indicates the extra (in general in the - * middle and often combined with the mouse wheel) button. Some mice may provide - * or simulate more buttons, and values higher than 2 can be used to represent - * such buttons. - */ - virtual unsigned short getButton() - { return button; } - - /** - * 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. - */ - virtual EventTarget *getRelatedTarget() - { return relatedTarget; } - - - /** - * This methods queries the state of a modifier using a key identifier. - * The argument is a modifier key identifier, as defined by the - * KeyboardEvent.keyIdentifier attribute. Common modifier keys are "Alt", - * "AltGraph", "CapsLock", "Control", "Meta", "NumLock", "Scroll", or "Shift". - */ - virtual bool getModifierState(const DOMString &/*id*/) - { return false; } - - /** - * The initMouseEvent method is used to initialize the value of a MouseEvent - * object and has the same behavior as UIEvent.initUIEvent(). - */ - virtual void initMouseEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/, - long /*screenXArg*/, - long /*screenYArg*/, - long /*clientXArg*/, - long /*clientYArg*/, - bool /*ctrlKeyArg*/, - bool /*altKeyArg*/, - bool /*shiftKeyArg*/, - bool /*metaKeyArg*/, - unsigned short /*buttonArg*/, - const EventTarget */*relatedTargetArg*/) - { - } - - - /** - * The initMouseEventNS method is used to initialize the value of a - * MouseEvent object and has the same behavior as UIEvent.initUIEventNS(). - */ - virtual void initMouseEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/, - long /*screenXArg*/, - long /*screenYArg*/, - long /*clientXArg*/, - long /*clientYArg*/, - unsigned short /*buttonArg*/, - const EventTarget */*relatedTargetArg*/, - const DOMString &/*modifiersList*/) - { - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - MouseEvent() - : screenX(0), - screenY(0), - clientX(0), - clientY(0), - ctrlKey(false), - shiftKey(false), - altKey(false), - metaKey(false), - button(0), - relatedTarget(NULL) - {} - - /** - * - */ - MouseEvent(const MouseEvent &other) : Event(other), UIEvent(other) - { - screenX = other.screenX; - screenY = other.screenY; - clientX = other.clientX; - clientY = other.clientY; - ctrlKey = other.ctrlKey; - shiftKey = other.shiftKey; - altKey = other.altKey; - metaKey = other.metaKey; - button = other.button; - relatedTarget = other.relatedTarget; - } - - /** - * - */ - virtual ~MouseEvent() {} - -protected: - - long screenX; - long screenY; - long clientX; - long clientY; - bool ctrlKey; - bool shiftKey; - bool altKey; - bool metaKey; - unsigned short button; - EventTarget *relatedTarget; -}; - - - - -/*######################################################################### -## KeyboardEvent -#########################################################################*/ - -/** - * The KeyboardEvent interface provides specific contextual information - * associated with keyboard devices. Each keyboard event references a key using - * an identifier. Keyboard events are commonly directed at the element that has - * the focus. - * - * The KeyboardEvent interface provides convenient attributes for some common - * modifiers keys: KeyboardEvent.ctrlKey, KeyboardEvent.shiftKey, - * KeyboardEvent.altKey, KeyboardEvent.metaKey. These attributes are equivalent - * to use the method KeyboardEvent.getModifierState(keyIdentifierArg) with - * "Control", "Shift", "Alt", or "Meta" respectively. - * - * To create an instance of the KeyboardEvent interface, use the - * DocumentEvent.createEvent("KeyboardEvent") method call. - */ -class KeyboardEvent : virtual public UIEvent -{ -public: - - /** - * This set of constants is used to indicate the location of a key on - * the device. In case a DOM implementation wishes to provide a new - * location information, a value different from the following constant - * values must be used. - */ - typedef enum - { - DOM_KEY_LOCATION_STANDARD = 0x00, - DOM_KEY_LOCATION_LEFT = 0x01, - DOM_KEY_LOCATION_RIGHT = 0x02, - DOM_KEY_LOCATION_NUMPAD = 0x03 - } KeyLocationCode; - - /** - * keyIdentifier holds the identifier of the key. - * Key identifiers can be found here: - * http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/keyset.html#KeySet-Set - * Implementations that are unable to identify a key must use the key - * identifier "Unidentified". - */ - virtual DOMString getKeyIdentifier() - { return keyIdentifier; } - - /** - * The keyLocation attribute contains an indication of the location of - * they key on the device, as described in: - * http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#ID-KeyboardEvent-KeyLocationCode - */ - virtual unsigned long getKeyLocation() - { return keyLocation; } - - /** - * true if the control (Ctrl) key modifier is activated. - */ - virtual bool getCtrlKey() - { return ctrlKey; } - - /** - * true if the shift (Shift) key modifier is activated. - */ - virtual bool getShiftKey() - { return shiftKey; } - - /** - * true if the alternative (Alt) key modifier is activated. - */ - virtual bool getAltKey() - { return altKey; } - - /** - * true if the meta (Meta) key modifier is activated. - */ - virtual bool getMetaKey() - { return metaKey; } - - /** - * This methods queries the state of a modifier using a key identifier. - * The argument is a modifier key identifier. Common modifier keys are "Alt", - * "AltGraph", "CapsLock", "Control", "Meta", "NumLock", "Scroll", or "Shift". - */ - virtual bool getModifierState(const DOMString &/*id*/) - { return false; } - - /** - * The initKeyboardEvent method is used to initialize the value of a - * KeyboardEvent object and has the same behavior as UIEvent.initUIEvent(). The - * value of UIEvent.detail remains undefined. - */ - virtual void initKeyboardEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - const DOMString &/*keyIdentifier*/, - unsigned long /*keyLocation*/, - const DOMString /*modifiersList*/) - { - } - - - - /** - * The initKeyboardEventNS method is used to initialize the value of a - * KeyboardEvent object and has the same behavior as UIEvent.initUIEventNS(). The - * value of UIEvent.detail remains undefined. - */ - virtual void initKeyboardEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - const DOMString &/*keyIdentifier*/, - unsigned long /*keyLocation*/, - const DOMString /*modifiersList*/) - { - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - KeyboardEvent() - : keyIdentifier(), - keyLocation(0), - ctrlKey(false), - shiftKey(false), - altKey(false), - metaKey(false) - {} - - /** - * - */ - KeyboardEvent(const KeyboardEvent &other) : Event(other), UIEvent(other) - { - keyIdentifier = other.keyIdentifier; - keyLocation = other.keyLocation; - ctrlKey = other.ctrlKey; - shiftKey = other.shiftKey; - altKey = other.altKey; - metaKey = other.metaKey; - } - - /** - * - */ - virtual ~KeyboardEvent() {} - -protected: - - DOMString keyIdentifier; - unsigned long keyLocation; - bool ctrlKey; - bool shiftKey; - bool altKey; - bool metaKey; -}; - - - - - - - - - -/*######################################################################### -## MutationEvent -#########################################################################*/ - -/** - * The MutationEvent interface provides specific contextual information - * associated with Mutation events. - * - * To create an instance of the MutationEvent interface, use the - * DocumentEvent.createEvent("MutationEvent") method call. - */ -class MutationEvent : virtual public Event -{ -public: - - /** - * An integer indicating in which way the Attr was changed. - */ - typedef enum - { - MODIFICATION = 1, - ADDITION = 2, - REMOVAL = 3 - } AttrChangeType; - - /** - * 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 - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} event it indicates - * the Attr node which was modified, added, or removed. - */ - virtual NodePtr getRelatedNode() - { return relatedNodePtr ; } - - /** - * prevValue indicates the previous value of the Attr node in - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} events, and of the - * CharacterData node in {"http://www.w3.org/2001/xml-events", - * "DOMCharacterDataModified"} events. - */ - virtual DOMString getPrevValue() - { return prevValue; } - - /** - * newValue indicates the new value of the Attr node in - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} events, and of the - * CharacterData node in {"http://www.w3.org/2001/xml-events", - * "DOMCharacterDataModified"} events. - */ - virtual DOMString getNewValue() - { return newValue; } - - /** - * attrName indicates the name of the changed Attr node in a - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} event. - */ - virtual DOMString getAttrName() - { return attrName; } - - /** - * attrChange indicates the type of change which triggered the - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} event. The values can - * be MODIFICATION, ADDITION, or REMOVAL. - */ - virtual unsigned short getAttrChange() - { - return attrChange; - } - - /** - * The initMutationEvent method is used to initialize the value of a - * MutationEvent object and has the same behavior as Event.initEvent(). - */ - virtual void initMutationEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevValueArg*/, - const DOMString &/*newValueArg*/, - const DOMString &/*attrNameArg*/, - unsigned short /*attrChangeArg*/) - { - } - - /** - * The initMutationEventNS method is used to initialize the value of a - * MutationEvent object and has the same behavior as Event.initEventNS(). - */ - virtual void initMutationEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevValueArg*/, - const DOMString &/*newValueArg*/, - const DOMString &/*attrNameArg*/, - unsigned short /*attrChangeArg*/) - { - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - MutationEvent() - : relatedNodePtr (NULL), - attrChange(0) - { - } - - /** - * - */ - MutationEvent(const MutationEvent &other) : Event(other) - { - relatedNodePtr = other.relatedNodePtr ; - prevValue = other.prevValue; - newValue = other.newValue; - attrName = other.attrName; - attrChange = other.attrChange; - } - - /** - * - */ - virtual ~MutationEvent() {} - -protected: - - NodePtr relatedNodePtr ; - DOMString prevValue; - DOMString newValue; - DOMString attrName; - unsigned short attrChange; - -}; - - - - -/*######################################################################### -## MutationNameEvent -#########################################################################*/ - -/** - * The MutationNameEvent interface provides specific contextual information - * associated with Mutation name event types. - * - * To create an instance of the MutationNameEvent interface, use the - * Document.createEvent("MutationNameEvent") method call. - */ -class MutationNameEvent : virtual public MutationEvent -{ -public: - - /** - * The previous value of the relatedNode's namespaceURI. - */ - virtual DOMString getPrevNamespaceURI() - { return prevNamespaceURI; } - - /** - * The previous value of the relatedNode's nodeName. - */ - virtual DOMString getPrevNodeName() - { return prevNodeName; } - - /** - * The initMutationNameEvent method is used to initialize the value of a - * MutationNameEvent object and has the same behavior as - * MutationEvent.initMutationEvent(). - */ - virtual void initMutationNameEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevNamespaceURIArg*/, - const DOMString &/*prevNodeNameArg*/) - { - } - - - /** - * The initMutationNameEventNS method is used to initialize the value of a - * MutationNameEvent object and has the same behavior as - * MutationEvent.initMutationEventNS(). - */ - virtual void initMutationNameEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevNamespaceURIArg*/, - const DOMString &/*prevNodeNameArg*/) - { - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - MutationNameEvent() {} - - - /** - * - */ - MutationNameEvent(const MutationNameEvent &other) - : Event(other), MutationEvent(other) - { - prevNamespaceURI = other.prevNamespaceURI; - prevNodeName = other.prevNodeName; - } - - - /** - * - */ - virtual ~MutationNameEvent() {} - -protected: - - DOMString prevNamespaceURI; - DOMString prevNodeName; - - -}; - - - - - - -} //namespace events -} //namespace dom -} //namespace w3c -} //namespace org - -#endif // SEEN_EVENTS_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/io/domstream.cpp b/src/dom/io/domstream.cpp deleted file mode 100644 index 1f08c0eee..000000000 --- a/src/dom/io/domstream.cpp +++ /dev/null @@ -1,1228 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * Our base input/output stream classes. These are is directly - * inherited from iostreams, and includes any extra - * functionality that we might need. - * - */ - -#include -#include -#include -#include - -#include "domstream.h" -#include "dom/ucd.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - -//######################################################################### -//# U T I L I T Y -//######################################################################### - -void pipeStream(InputStream &source, OutputStream &dest) -{ - for (;;) - { - int ch = source.get(); - if (ch<0) - break; - dest.put(ch); - } - dest.flush(); -} -/* - - -//######################################################################### -//# F O R M A T T E D P R I N T I N G -//######################################################################### - -static char const *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; -*/ -// static int dprintInt(Writer &outs, - // long arg, int base, - // int flag, int width, int /*precision*/) -/*{ - - DOMString buf; - - //### Get the digits - while (arg > 0) - { - int ch = arg % base; - buf.insert(buf.begin(), digits[ch]); - arg /= base; - } - - if (flag == '#' && base == 16) - { - buf.insert(buf.begin(), 'x'); - buf.insert(buf.begin(), '0'); - } - - if (buf.size() == 0) - buf = "0"; - - int pad = width - (int)buf.size(); - for (int i=0 ; i 0) - pad -= precision + 1; - else if (flag == '#') - pad--; - - - //### Signs - if (negative) - buf.push_back('-'); - else if (flag == '+') - buf.push_back('+'); - - //### Prefix pad - if (pad > 0 && flag == '0') - { - while (pad--) - buf.push_back('0'); - } - - //### Integer digits - intPart = (intPart + 0.1 ) / scale; // turn 12345.678 to .12345678 - while (intDigits--) - { - intPart *= 10.0; - double dig; - intPart = modf(intPart, &dig); - char ch = '0' + (int)dig; - buf.push_back(ch); - } - if (buf.size() == 0) - buf = "0"; - - //### Decimal point - if (flag == '#' || precision > 0) - { - buf.push_back('.'); - } - - //### Fractional digits - while (precision--) - { - fracPart *= 10.0; - double dig; - fracPart = modf(fracPart, &dig); - char ch = '0' + (int)dig; - buf.push_back(ch); - } - - //### Left justify if requested - if (pad > 0 && flag == '-') - { - while (pad--) - buf.push_back(' '); - } - - //### Output the result - for (unsigned int i=0 ; i') - outs.writeString(">"); - else if (ch == '"') - outs.writeString("""); - else if (ch == '\'') - outs.writeString("'"); - else - outs.put(ch); - } - } - else - { - outs.writeString(str); - } - - return 1; -} - - - -static int getint(const DOMString &buf, int pos, int *ret) -{ - int len = buf.size(); - if (!len) - { - *ret = 0; - return pos; - } - - bool has_sign = false; - int val = 0; - if (buf[pos] == '-') - { - has_sign = true; - pos++; - } - while (pos < len) - { - XMLCh ch = buf[pos]; - if (ch >= '0' && ch <= '9') - val = val * 10 + (ch - '0'); - else - break; - pos++; - } - if (has_sign) - val = -val; - - *ret = val; - - return pos; -} - - - -static int dprintf(Writer &outs, const DOMString &fmt, va_list ap) -{ - - int len = fmt.size(); - - for (int pos=0 ; pos < len ; pos++) - { - XMLCh ch = fmt[pos]; - - //## normal character - if (ch != '%') - { - if (outs.put(ch)<0) - { - return -1; - } - continue; - } - - if (++pos >= len) - { - return -1; - } - - ch = fmt[pos]; - - //## is this %% ? - if (ch == '%') // escaped '%' - { - if (outs.put('%')<0) - { - return -1; - } - continue; - } - - //## flag - char flag = '\0'; - if (ch == '-' || ch == '+' || ch == ' ' || - ch == '#' || ch == '0') - { - flag = ch; - if (++pos >= len) - { - return -1; - } - ch = fmt[pos]; - } - - //## width.precision - int width = 0; - int precision = 0; - pos = getint(fmt, pos, &width); - if (pos >= len) - { - return -1; - } - ch = fmt[pos]; - if (ch == '.') - { - if (++pos >= len) - { - return -1; - } - pos = getint(fmt, pos, &precision); - if (pos >= len) - { - return -1; - } - ch = fmt[pos]; - } - - //## length - char length = '\0'; - if (ch == 'l' || ch == 'h') - { - length = ch; - if (++pos >= len) - { - return -1; - } - ch = fmt[pos]; - } - - //## data type - switch (ch) - { - case 'f': - case 'g': - { - double val = va_arg(ap, double); - dprintDouble(outs, val, flag, width, precision); - break; - } - case 'd': - { - long val = 0; - if (length == 'l') - val = va_arg(ap, long); - else if (length == 'h') - val = (long)va_arg(ap, int); - else - val = (long)va_arg(ap, int); - dprintInt(outs, val, 10, flag, width, precision); - break; - } - case 'x': - { - long val = 0; - if (length == 'l') - val = va_arg(ap, long); - else if (length == 'h') - val = (long)va_arg(ap, int); - else - val = (long)va_arg(ap, int); - dprintInt(outs, val, 16, flag, width, precision); - break; - } - case 's': - { - DOMString val = va_arg(ap, char *); - dprintString(outs, val, flag, width, precision); - break; - } - default: - { - break; - } - } - } - - return 1; -} -*/ - -//######################################################################### -//# B A S I C I N P U T S T R E A M -//######################################################################### - -/** - * - */ -BasicInputStream::BasicInputStream(InputStream &sourceStream) - : source(sourceStream) -{ - closed = false; -} - -/** - * Returns the number of bytes that can be read (or skipped over) from - * this input stream without blocking by the next caller of a method for - * this input stream. - */ -int BasicInputStream::available() -{ - if (closed) - return 0; - return source.available(); -} - - -/** - * Closes this input stream and releases any system resources - * associated with the stream. - */ -void BasicInputStream::close() -{ - if (closed) - return; - source.close(); - closed = true; -} - -/** - * Reads the next byte of data from the input stream. -1 if EOF - */ -int BasicInputStream::get() -{ - if (closed) - return -1; - return source.get(); -} - - - -//######################################################################### -//# B A S I C O U T P U T S T R E A M -//######################################################################### - -/** - * - */ -BasicOutputStream::BasicOutputStream(OutputStream &destinationStream) - : destination(destinationStream) -{ - closed = false; -} - -/** - * Closes this output stream and releases any system resources - * associated with this stream. - */ -void BasicOutputStream::close() -{ - if (closed) - return; - destination.close(); - closed = true; -} - -/** - * Flushes this output stream and forces any buffered output - * bytes to be written out. - */ -void BasicOutputStream::flush() -{ - if (closed) - return; - destination.flush(); -} - -/** - * Writes the specified byte to this output stream. - */ -int BasicOutputStream::put(gunichar ch) -{ - if (closed) - return -1; - destination.put(ch); - return 1; -} - - -//######################################################################### -//# B A S I C R E A D E R -//######################################################################### -BasicReader::BasicReader(Reader &sourceReader) -{ - source = &sourceReader; -} - -/** - * Returns the number of bytes that can be read (or skipped over) from - * this reader without blocking by the next caller of a method for - * this reader. - */ -int BasicReader::available() -{ - if (source) - return source->available(); - else - return 0; -} - - -/** - * Closes this reader and releases any system resources - * associated with the reader. - */ -void BasicReader::close() -{ - if (source) - source->close(); -} - -/** - * Reads the next byte of data from the reader. - */ -gunichar BasicReader::get() -{ - if (source) - return source->get(); - else - return (gunichar)-1; -} - - -/** - * Reads a line of data from the reader. - */ -Glib::ustring BasicReader::readLine() -{ - Glib::ustring str; - while (available() > 0) - { - gunichar ch = get(); - if (ch == '\n') - break; - str.push_back(ch); - } - return str; -} - -/** - * Reads a line of data from the reader. - */ -Glib::ustring BasicReader::readWord() -{ - Glib::ustring str; - while (available() > 0) - { - gunichar ch = get(); - if (!g_unichar_isprint(ch)) - break; - str.push_back(ch); - } - return str; -} - - -static bool getLong(Glib::ustring &str, long *val) -{ - const char *begin = str.raw().c_str(); - char *end; - long ival = strtol(begin, &end, 10); - if (str == end) - return false; - *val = ival; - return true; -} - -static bool getULong(Glib::ustring &str, unsigned long *val) -{ - const char *begin = str.raw().c_str(); - char *end; - unsigned long ival = strtoul(begin, &end, 10); - if (str == end) - return false; - *val = ival; - return true; -} - -static bool getDouble(Glib::ustring &str, double *val) -{ - const char *begin = str.raw().c_str(); - char *end; - double ival = strtod(begin, &end); - if (str == end) - return false; - *val = ival; - return true; -} - - - -const Reader &BasicReader::readBool (bool& val ) -{ - Glib::ustring buf = readWord(); - if (buf == "true") - val = true; - else - val = false; - return *this; -} - -const Reader &BasicReader::readShort (short& val ) -{ - Glib::ustring buf = readWord(); - long ival; - if (getLong(buf, &ival)) - val = (short) ival; - return *this; -} - -const Reader &BasicReader::readUnsignedShort (unsigned short& val ) -{ - Glib::ustring buf = readWord(); - unsigned long ival; - if (getULong(buf, &ival)) - val = (unsigned short) ival; - return *this; -} - -const Reader &BasicReader::readInt (int& val ) -{ - Glib::ustring buf = readWord(); - long ival; - if (getLong(buf, &ival)) - val = (int) ival; - return *this; -} - -const Reader &BasicReader::readUnsignedInt (unsigned int& val ) -{ - Glib::ustring buf = readWord(); - unsigned long ival; - if (getULong(buf, &ival)) - val = (unsigned int) ival; - return *this; -} - -const Reader &BasicReader::readLong (long& val ) -{ - Glib::ustring buf = readWord(); - long ival; - if (getLong(buf, &ival)) - val = ival; - return *this; -} - -const Reader &BasicReader::readUnsignedLong (unsigned long& val ) -{ - Glib::ustring buf = readWord(); - unsigned long ival; - if (getULong(buf, &ival)) - val = ival; - return *this; -} - -const Reader &BasicReader::readFloat (float& val ) -{ - Glib::ustring buf = readWord(); - double ival; - if (getDouble(buf, &ival)) - val = (float)ival; - return *this; -} - -const Reader &BasicReader::readDouble (double& val ) -{ - Glib::ustring buf = readWord(); - double ival; - if (getDouble(buf, &ival)) - val = ival; - return *this; -} - - - -//######################################################################### -//# I N P U T S T R E A M R E A D E R -//######################################################################### - - -InputStreamReader::InputStreamReader(InputStream &inputStreamSource) - : inputStream(inputStreamSource) -{ -} - - - -/** - * Close the underlying OutputStream - */ -void InputStreamReader::close() -{ - inputStream.close(); -} - -/** - * Flush the underlying OutputStream - */ -int InputStreamReader::available() -{ - return inputStream.available(); -} - -/** - * Overloaded to receive its bytes from an InputStream - * rather than a Reader - */ -gunichar InputStreamReader::get() -{ - //Do we need conversions here? - gunichar ch = (gunichar)inputStream.get(); - return ch; -} - - - -//######################################################################### -//# S T D R E A D E R -//######################################################################### - - -/** - * - */ -StdReader::StdReader() -{ - inputStream = new StdInputStream(); -} - -/** - * - */ -StdReader::~StdReader() -{ - delete inputStream; -} - - - -/** - * Close the underlying OutputStream - */ -void StdReader::close() -{ - inputStream->close(); -} - -/** - * Flush the underlying OutputStream - */ -int StdReader::available() -{ - return inputStream->available(); -} - -/** - * Overloaded to receive its bytes from an InputStream - * rather than a Reader - */ -gunichar StdReader::get() -{ - //Do we need conversions here? - gunichar ch = (gunichar)inputStream->get(); - return ch; -} - - - - -//######################################################################### -//# B A S I C W R I T E R -//######################################################################### -/** - * - */ -BasicWriter::BasicWriter(const Writer &destinationWriter) -{ - destination = (Writer*) &destinationWriter; -} - -/** - * Closes this writer and releases any system resources - * associated with this writer. - */ -void BasicWriter::close() -{ - if (destination) - destination->close(); -} - -/** - * Flushes this output stream and forces any buffered output - * bytes to be written out. - */ -void BasicWriter::flush() -{ - if (destination) - destination->flush(); -} - -/** - * Writes the specified byte to this output writer. - */ -int BasicWriter::put(gunichar ch) -{ - if (destination && destination->put(ch)>=0) - return 1; - return -1; -} - -/** - * Provide printf()-like formatting - */ -Writer &BasicWriter::printf(char const *fmt, ...) -{ - va_list args; - va_start(args, fmt); - gchar *buf = g_strdup_vprintf(fmt, args); - va_end(args); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} -/** - * Writes the specified character to this output writer. - */ -Writer &BasicWriter::writeChar(char ch) -{ - gunichar uch = ch; - put(uch); - return *this; -} - - -/** - * Writes the specified unicode string to this output writer. - */ -Writer &BasicWriter::writeUString(Glib::ustring &str) -{ - for (int i=0; i< (int)str.size(); i++) - put(str[i]); - return *this; -} - -/** - * Writes the specified standard string to this output writer. - */ -Writer &BasicWriter::writeStdString(std::string &str) -{ - Glib::ustring tmp(str); - writeUString(tmp); - return *this; -} - -/** - * Writes the specified character string to this output writer. - */ -Writer &BasicWriter::writeString(const char *str) -{ - Glib::ustring tmp; - if (str) - tmp = str; - else - tmp = "null"; - writeUString(tmp); - return *this; -} - - - - -/** - * - */ -Writer &BasicWriter::writeBool (bool val ) -{ - if (val) - writeString("true"); - else - writeString("false"); - return *this; -} - - -/** - * - */ -Writer &BasicWriter::writeShort (short val ) -{ - gchar *buf = g_strdup_printf("%d", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - - - -/** - * - */ -Writer &BasicWriter::writeUnsignedShort (unsigned short val ) -{ - gchar *buf = g_strdup_printf("%u", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeInt (int val) -{ - gchar *buf = g_strdup_printf("%d", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeUnsignedInt (unsigned int val) -{ - gchar *buf = g_strdup_printf("%u", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeLong (long val) -{ - gchar *buf = g_strdup_printf("%ld", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeUnsignedLong(unsigned long val) -{ - gchar *buf = g_strdup_printf("%lu", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeFloat(float val) -{ -#if 1 - gchar *buf = g_strdup_printf("%8.3f", val); - if (buf) { - writeString(buf); - g_free(buf); - } -#else - std::string tmp = ftos(val, 'g', 8, 3, 0); - writeStdString(tmp); -#endif - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeDouble(double val) -{ -#if 1 - gchar *buf = g_strdup_printf("%8.3f", val); - if (buf) { - writeString(buf); - g_free(buf); - } -#else - std::string tmp = ftos(val, 'g', 8, 3, 0); - writeStdString(tmp); -#endif - return *this; -} - - - - -//######################################################################### -//# O U T P U T S T R E A M W R I T E R -//######################################################################### - - -OutputStreamWriter::OutputStreamWriter(OutputStream &outputStreamDest) - : outputStream(outputStreamDest) -{ -} - - - -/** - * Close the underlying OutputStream - */ -void OutputStreamWriter::close() -{ - flush(); - outputStream.close(); -} - -/** - * Flush the underlying OutputStream - */ -void OutputStreamWriter::flush() -{ - outputStream.flush(); -} - -/** - * Overloaded to redirect the output chars from the next Writer - * in the chain to an OutputStream instead. - */ -int OutputStreamWriter::put(gunichar ch) -{ - if (outputStream.put(ch)>=0) - return 1; - return -1; -} - -//######################################################################### -//# S T D W R I T E R -//######################################################################### - - -/** - * - */ -StdWriter::StdWriter() -{ - outputStream = new StdOutputStream(); -} - -/** - * - */ -StdWriter::~StdWriter() -{ - delete outputStream; -} - -/** - * Close the underlying OutputStream - */ -void StdWriter::close() -{ - flush(); - outputStream->close(); -} - -/** - * Flush the underlying OutputStream - */ -void StdWriter::flush() -{ - outputStream->flush(); -} - -/** - * Overloaded to redirect the output chars from the next Writer - * in the chain to an OutputStream instead. - */ -int StdWriter::put(gunichar ch) -{ - if (outputStream && (outputStream->put(ch)>=0)) - return 1; - return -1; -} - - - -//############################################### -//# O P E R A T O R S -//############################################### -//# Normally these would be in the .h, but we -//# just want to be absolutely certain that these -//# are never multiply defined. Easy to maintain, -//# though. Just occasionally copy/paste these -//# into the .h , and replace the {} with a ; -//############################################### - - - - -const Reader& operator>> (Reader &reader, bool& val ) - { return reader.readBool(val); } - -const Reader& operator>> (Reader &reader, short &val) - { return reader.readShort(val); } - -const Reader& operator>> (Reader &reader, unsigned short &val) - { return reader.readUnsignedShort(val); } - -const Reader& operator>> (Reader &reader, int &val) - { return reader.readInt(val); } - -const Reader& operator>> (Reader &reader, unsigned int &val) - { return reader.readUnsignedInt(val); } - -const Reader& operator>> (Reader &reader, long &val) - { return reader.readLong(val); } - -const Reader& operator>> (Reader &reader, unsigned long &val) - { return reader.readUnsignedLong(val); } - -const Reader& operator>> (Reader &reader, float &val) - { return reader.readFloat(val); } - -const Reader& operator>> (Reader &reader, double &val) - { return reader.readDouble(val); } - - - -Writer& operator<< (Writer &writer, char val) - { return writer.writeChar(val); } - -Writer& operator<< (Writer &writer, Glib::ustring &val) - { return writer.writeUString(val); } - -Writer& operator<< (Writer &writer, std::string &val) - { return writer.writeStdString(val); } - -Writer& operator<< (Writer &writer, char const *val) - { return writer.writeString(val); } - -Writer& operator<< (Writer &writer, bool val) - { return writer.writeBool(val); } - -Writer& operator<< (Writer &writer, short val) - { return writer.writeShort(val); } - -Writer& operator<< (Writer &writer, unsigned short val) - { return writer.writeUnsignedShort(val); } - -Writer& operator<< (Writer &writer, int val) - { return writer.writeInt(val); } - -Writer& operator<< (Writer &writer, unsigned int val) - { return writer.writeUnsignedInt(val); } - -Writer& operator<< (Writer &writer, long val) - { return writer.writeLong(val); } - -Writer& operator<< (Writer &writer, unsigned long val) - { return writer.writeUnsignedLong(val); } - -Writer& operator<< (Writer &writer, float val) - { return writer.writeFloat(val); } - -Writer& operator<< (Writer &writer, double val) - { return writer.writeDouble(val); } - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### diff --git a/src/dom/io/domstream.h b/src/dom/io/domstream.h deleted file mode 100644 index edd180b83..000000000 --- a/src/dom/io/domstream.h +++ /dev/null @@ -1,684 +0,0 @@ -#ifndef SEEN_DOMSTREAM_H -#define SEEN_DOMSTREAM_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - -class StreamException : public std::exception -{ -public: - - StreamException(const char *theReason) throw() - { reason = theReason; } - StreamException(Glib::ustring &theReason) throw() - { reason = theReason; } - virtual ~StreamException() throw() - { } - char const *what() const throw() - { return reason.c_str(); } - -private: - Glib::ustring reason; - -}; - -//######################################################################### -//# I N P U T S T R E A M -//######################################################################### - -/** - * This interface is the base of all input stream classes. Users who wish - * to make an InputStream that is part of a chain should inherit from - * BasicInputStream. Inherit from this class to make a source endpoint, - * such as a URI or buffer. - * - */ -class InputStream -{ - -public: - - /** - * Constructor. - */ - InputStream() {} - - /** - * Destructor - */ - virtual ~InputStream() {} - - /** - * Return the number of bytes that are currently available - * to be read - */ - virtual int available() = 0; - - /** - * Do whatever it takes to 'close' this input stream - * The most likely implementation of this method will be - * for endpoints that use a resource for their data. - */ - virtual void close() = 0; - - /** - * Read one byte from this input stream. This is a blocking - * call. If no data is currently available, this call will - * not return until it exists. If the user does not want - * their code to block, then the usual solution is: - * if (available() > 0) - * myChar = get(); - * This call returns -1 on end-of-file. - */ - virtual int get() = 0; - -}; // class InputStream - - - - -/** - * This is the class that most users should inherit, to provide - * their own streams. - * - */ -class BasicInputStream : public InputStream -{ - -public: - - BasicInputStream(InputStream &sourceStream); - - virtual ~BasicInputStream() {} - - virtual int available(); - - virtual void close(); - - virtual int get(); - -protected: - - bool closed; - - InputStream &source; - -private: - - -}; // class BasicInputStream - - - -/** - * Convenience class for reading from standard input - */ -class StdInputStream : public InputStream -{ -public: - - int available() - { return 0; } - - void close() - { /* do nothing */ } - - int get() - { return getchar(); } - -}; - - - - - -//######################################################################### -//# O U T P U T S T R E A M -//######################################################################### - -/** - * This interface is the base of all input stream classes. Users who wish - * to make an OutputStream that is part of a chain should inherit from - * BasicOutputStream. Inherit from this class to make a destination endpoint, - * such as a URI or buffer. - */ -class OutputStream -{ - -public: - - /** - * Constructor. - */ - OutputStream() {} - - /** - * Destructor - */ - virtual ~OutputStream() {} - - /** - * This call should - * 1. flush itself - * 2. close itself - * 3. close the destination stream - */ - virtual void close() = 0; - - /** - * This call should push any pending data it might have to - * the destination stream. It should NOT call flush() on - * the destination stream. - */ - virtual void flush() = 0; - - /** - * Send one byte to the destination stream. - */ - virtual int put(gunichar ch) = 0; - - -}; // class OutputStream - - -/** - * This is the class that most users should inherit, to provide - * their own output streams. - */ -class BasicOutputStream : public OutputStream -{ - -public: - - BasicOutputStream(OutputStream &destinationStream); - - virtual ~BasicOutputStream() {} - - virtual void close(); - - virtual void flush(); - - virtual int put(gunichar ch); - -protected: - - bool closed; - - OutputStream &destination; - - -}; // class BasicOutputStream - - - -/** - * Convenience class for writing to standard output - */ -class StdOutputStream : public OutputStream -{ -public: - - void close() - { } - - void flush() - { } - - int put(gunichar ch) - { return putchar(ch); } - -}; - - - - -//######################################################################### -//# R E A D E R -//######################################################################### - -/** - * This interface and its descendants are for unicode character-oriented input - * - */ -class Reader -{ - -public: - - /** - * Constructor. - */ - Reader() {} - - /** - * Destructor - */ - virtual ~Reader() {} - - - virtual int available() = 0; - - virtual void close() = 0; - - virtual gunichar get() = 0; - - virtual Glib::ustring readLine() = 0; - - virtual Glib::ustring readWord() = 0; - - /* Input formatting */ - virtual const Reader& readBool (bool& val ) = 0; - virtual const Reader& operator>> (bool& val ) = 0; - - virtual const Reader& readShort (short &val) = 0; - virtual const Reader& operator>> (short &val) = 0; - - virtual const Reader& readUnsignedShort (unsigned short &val) = 0; - virtual const Reader& operator>> (unsigned short &val) = 0; - - virtual const Reader& readInt (int &val) = 0; - virtual const Reader& operator>> (int &val) = 0; - - virtual const Reader& readUnsignedInt (unsigned int &val) = 0; - virtual const Reader& operator>> (unsigned int &val) = 0; - - virtual const Reader& readLong (long &val) = 0; - virtual const Reader& operator>> (long &val) = 0; - - virtual const Reader& readUnsignedLong (unsigned long &val) = 0; - virtual const Reader& operator>> (unsigned long &val) = 0; - - virtual const Reader& readFloat (float &val) = 0; - virtual const Reader& operator>> (float &val) = 0; - - virtual const Reader& readDouble (double &val) = 0; - virtual const Reader& operator>> (double &val) = 0; - -}; // interface Reader - - - -/** - * This class and its descendants are for unicode character-oriented input - * - */ -class BasicReader : public Reader -{ - -public: - - BasicReader(Reader &sourceStream); - - virtual ~BasicReader() {} - - virtual int available(); - - virtual void close(); - - virtual gunichar get(); - - virtual Glib::ustring readLine(); - - virtual Glib::ustring readWord(); - - /* Input formatting */ - virtual const Reader& readBool (bool& val ); - virtual const Reader& operator>> (bool& val ) - { return readBool(val); } - - virtual const Reader& readShort (short &val); - virtual const Reader& operator>> (short &val) - { return readShort(val); } - - virtual const Reader& readUnsignedShort (unsigned short &val); - virtual const Reader& operator>> (unsigned short &val) - { return readUnsignedShort(val); } - - virtual const Reader& readInt (int &val); - virtual const Reader& operator>> (int &val) - { return readInt(val); } - - virtual const Reader& readUnsignedInt (unsigned int &val); - virtual const Reader& operator>> (unsigned int &val) - { return readUnsignedInt(val); } - - virtual const Reader& readLong (long &val); - virtual const Reader& operator>> (long &val) - { return readLong(val); } - - virtual const Reader& readUnsignedLong (unsigned long &val); - virtual const Reader& operator>> (unsigned long &val) - { return readUnsignedLong(val); } - - virtual const Reader& readFloat (float &val); - virtual const Reader& operator>> (float &val) - { return readFloat(val); } - - virtual const Reader& readDouble (double &val); - virtual const Reader& operator>> (double &val) - { return readDouble(val); } - - -protected: - - Reader *source; - - BasicReader() - { source = NULL; } - -private: - -}; // class BasicReader - - - -/** - * Class for placing a Reader on an open InputStream - * - */ -class InputStreamReader : public BasicReader -{ -public: - - InputStreamReader(InputStream &inputStreamSource); - - /*Overload these 3 for your implementation*/ - virtual int available(); - - virtual void close(); - - virtual gunichar get(); - - -private: - - InputStream &inputStream; - - -}; - -/** - * Convenience class for reading formatted from standard input - * - */ -class StdReader : public BasicReader -{ -public: - - StdReader(); - - virtual ~StdReader(); - - /*Overload these 3 for your implementation*/ - virtual int available(); - - virtual void close(); - - virtual gunichar get(); - - -private: - - InputStream *inputStream; - - -}; - - - -//######################################################################### -//# W R I T E R -//######################################################################### - -/** - * This interface and its descendants are for unicode character-oriented output - * - */ -class Writer -{ - -public: - - /** - * Constructor. - */ - Writer() {} - - /** - * Destructor - */ - virtual ~Writer() {} - - virtual void close() = 0; - - virtual void flush() = 0; - - virtual int put(gunichar ch) = 0; - - /* Formatted output */ - virtual Writer& printf(char const *fmt, ...) G_GNUC_PRINTF(2,3) = 0; - - virtual Writer& writeChar(char val) = 0; - - virtual Writer& writeUString(Glib::ustring &val) = 0; - - virtual Writer& writeStdString(std::string &val) = 0; - - virtual Writer& writeString(const char *str) = 0; - - virtual Writer& writeBool (bool val ) = 0; - - virtual Writer& writeShort (short val ) = 0; - - virtual Writer& writeUnsignedShort (unsigned short val ) = 0; - - virtual Writer& writeInt (int val ) = 0; - - virtual Writer& writeUnsignedInt (unsigned int val ) = 0; - - virtual Writer& writeLong (long val ) = 0; - - virtual Writer& writeUnsignedLong (unsigned long val ) = 0; - - virtual Writer& writeFloat (float val ) = 0; - - virtual Writer& writeDouble (double val ) = 0; - - - -}; // interface Writer - - -/** - * This class and its descendants are for unicode character-oriented output - * - */ -class BasicWriter : public Writer -{ - -public: - - BasicWriter(const Writer &destinationWriter); - - virtual ~BasicWriter() {} - - /*Overload these 3 for your implementation*/ - virtual void close(); - - virtual void flush(); - - virtual int put(gunichar ch); - - - - /* Formatted output */ - virtual Writer &printf(char const *fmt, ...) G_GNUC_PRINTF(2,3); - - virtual Writer& writeChar(char val); - - virtual Writer& writeUString(Glib::ustring &val); - - virtual Writer& writeStdString(std::string &val); - - virtual Writer& writeString(const char *str); - - virtual Writer& writeBool (bool val ); - - virtual Writer& writeShort (short val ); - - virtual Writer& writeUnsignedShort (unsigned short val ); - - virtual Writer& writeInt (int val ); - - virtual Writer& writeUnsignedInt (unsigned int val ); - - virtual Writer& writeLong (long val ); - - virtual Writer& writeUnsignedLong (unsigned long val ); - - virtual Writer& writeFloat (float val ); - - virtual Writer& writeDouble (double val ); - - -protected: - - Writer *destination; - - BasicWriter() - { destination = NULL; } - -private: - -}; // class BasicWriter - - -Writer& operator<< (Writer &writer, char val); - -Writer& operator<< (Writer &writer, Glib::ustring &val); - -Writer& operator<< (Writer &writer, std::string &val); - -Writer& operator<< (Writer &writer, char const *val); - -Writer& operator<< (Writer &writer, bool val); - -Writer& operator<< (Writer &writer, short val); - -Writer& operator<< (Writer &writer, unsigned short val); - -Writer& operator<< (Writer &writer, int val); - -Writer& operator<< (Writer &writer, unsigned int val); - -Writer& operator<< (Writer &writer, long val); - -Writer& operator<< (Writer &writer, unsigned long val); - -Writer& operator<< (Writer &writer, float val); - -Writer& operator<< (Writer &writer, double val); - - -/** - * Class for placing a Writer on an open OutputStream - * - */ -class OutputStreamWriter : public BasicWriter -{ -public: - - OutputStreamWriter(OutputStream &outputStreamDest); - - /*Overload these 3 for your implementation*/ - virtual void close(); - virtual void flush(); - virtual int put(gunichar ch); - - -private: - - OutputStream &outputStream; - - -}; - - -/** - * Convenience class for writing to standard output - */ -class StdWriter : public BasicWriter -{ -public: - StdWriter(); - - virtual ~StdWriter(); - virtual void close(); - virtual void flush(); - virtual int put(gunichar ch); - - -private: - - OutputStream *outputStream; - -}; - -//######################################################################### -//# U T I L I T Y -//######################################################################### - -void pipeStream(InputStream &source, OutputStream &dest); - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOMSTREAM_H - -//######################################################################### -//# E N D O F F I L E -//######################################################################### diff --git a/src/dom/ls.h b/src/dom/ls.h deleted file mode 100644 index 6e9a940f7..000000000 --- a/src/dom/ls.h +++ /dev/null @@ -1,947 +0,0 @@ -#ifndef SEEN_LS_H -#define SEEN_LS_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "dom.h" -#include "events.h" -#include "traversal.h" - -#include "io/domstream.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace ls -{ - - - -//Local definitions -//The idl said Object. Since this is undefined, we will -//use our own class which is designed to be a bit similar to -//java.io streams - -typedef dom::io::InputStream LSInputStream; -typedef dom::io::OutputStream LSOutputStream; -typedef dom::io::Reader LSReader; -typedef dom::io::Writer LSWriter; - - -//local definitions -typedef dom::DOMString DOMString; -typedef dom::DOMConfiguration DOMConfiguration; -typedef dom::Node Node; -typedef dom::NodePtr NodePtr; -typedef dom::Document Document; -typedef dom::DocumentPtr DocumentPtr; -typedef dom::Element Element; -typedef dom::ElementPtr ElementPtr; - - -//forward declarations -class LSParser; -class LSSerializer; -class LSInput; -class LSOutput; -class LSParserFilter; -class LSSerializerFilter; - - - -/*######################################################################### -## LSException -#########################################################################*/ - -/** - * Maybe this should inherit from DOMException? - */ -class LSException -{ - -public: - - LSException(const DOMString &reasonMsg) - { msg = reasonMsg; } - - LSException(short theCode) - { - code = theCode; - } - - virtual ~LSException() throw() - {} - - /** - * - */ - unsigned short code; - - /** - * - */ - DOMString msg; - - /** - * Get a string, translated from the code. - * Like std::exception. Not in spec. - */ - const char *what() - { return msg.c_str(); } - - - -}; - - -/** - * LSExceptionCode - */ -typedef enum - { - PARSE_ERR = 81, - SERIALIZE_ERR = 82 - } XPathExceptionCode; - - -/*######################################################################### -## LSParserFilter -#########################################################################*/ - -/** - * - */ -class LSParserFilter -{ -public: - - // Constants returned by startElement and acceptNode - typedef enum - { - FILTER_ACCEPT = 1, - FILTER_REJECT = 2, - FILTER_SKIP = 3, - FILTER_INTERRUPT = 4 - } ReturnValues; - - - /** - * - */ - virtual unsigned short startElement(const ElementPtr elementArg) =0; - - /** - * - */ - virtual unsigned short acceptNode(const NodePtr nodeArg) =0; - - /** - * - */ - virtual unsigned long getWhatToShow() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSParserFilter() {} - - - -}; - -/*######################################################################### -## LSInput -#########################################################################*/ - -/** - * - */ -class LSInput -{ -public: - - /** - * - */ - virtual LSReader *getCharacterStream() const - { return characterStream; } - - /** - * - */ - virtual void setCharacterStream(const LSReader *val) - { characterStream = (LSReader *)val; } - - /** - * - */ - virtual LSInputStream *getByteStream() const - { return byteStream; } - - /** - * - */ - virtual void setByteStream(const LSInputStream *val) - { byteStream = (LSInputStream *)val; } - - /** - * - */ - virtual DOMString getStringData() const - { return stringData; } - - /** - * - */ - virtual void setStringData(const DOMString &val) - { stringData = val; } - - /** - * - */ - virtual DOMString getSystemId() const - { return systemId; } - - /** - * - */ - virtual void setSystemId(const DOMString &val) - { systemId = val; } - - /** - * - */ - virtual DOMString getPublicId() const - { return publicId; } - - /** - * - */ - virtual void setPublicId(const DOMString &val) - { publicId = val; } - - /** - * - */ - virtual DOMString getBaseURI() const - { return baseURI; } - - /** - * - */ - virtual void setBaseURI(const DOMString &val) - { baseURI = val; } - - /** - * - */ - virtual DOMString getEncoding() const - { return encoding; } - - /** - * - */ - virtual void setEncoding(const DOMString &val) - { encoding = val; } - - /** - * - */ - virtual bool getCertifiedText() const - { return certifiedText; } - - /** - * - */ - virtual void setCertifiedText(bool val) - { certifiedText = val; } - - //################## - //# Non-API methods - //################## - - - /** - * - */ - LSInput() - { - characterStream = NULL; - byteStream = NULL; - stringData = ""; - systemId = ""; - publicId = ""; - baseURI = ""; - encoding = ""; - certifiedText = false; - } - - - - /** - * - */ - LSInput(const LSInput &other) - { - characterStream = other.characterStream; - byteStream = other.byteStream; - stringData = other.stringData; - systemId = other.systemId; - publicId = other.publicId; - baseURI = other.baseURI; - encoding = other.encoding; - certifiedText = other.certifiedText; - } - - /** - * - */ - virtual ~LSInput() - {} - -private: - - LSReader *characterStream; - LSInputStream *byteStream; - DOMString stringData; - DOMString systemId; - DOMString publicId; - DOMString baseURI; - DOMString encoding; - bool certifiedText; - - -}; - - -/*######################################################################### -## LSParser -#########################################################################*/ - -/** - * - */ -class LSParser -{ -public: - - - /** - * - */ - virtual DOMConfiguration *getDomConfig() - { return NULL; } - - /** - * - */ - virtual LSParserFilter *getFilter() - { return filter; } - - /** - * - */ - virtual void setFilter(const LSParserFilter *val) - { filter = const_cast(val); } - - /** - * - */ - virtual bool getAsync() - { return false; } - - /** - * - */ - virtual bool getBusy() - { return false; } - - /** - * - */ - virtual DocumentPtr parse(const LSInput &/*input*/) - throw(dom::DOMException, LSException) - { return NULL; } - - - /** - * - */ - virtual DocumentPtr parseURI(const DOMString &/*uri*/) - throw(dom::DOMException, LSException) - { return NULL; } - - typedef enum - { - ACTION_APPEND_AS_CHILDREN = 1, - ACTION_REPLACE_CHILDREN = 2, - ACTION_INSERT_BEFORE = 3, - ACTION_INSERT_AFTER = 4, - ACTION_REPLACE = 5 - } ActionTypes; - - - /** - * - */ - virtual NodePtr parseWithContext(const LSInput &/*input*/, - const NodePtr /*contextArg*/, - unsigned short /*action*/) - throw(dom::DOMException, LSException) - { return NULL; } - - /** - * - */ - virtual void abort() - {} - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSParser() - { - filter = NULL; - } - - /** - * - */ - LSParser(const LSParser &other) - { - filter = other.filter; - } - - /** - * - */ - virtual ~LSParser() {} - -protected: - - LSParserFilter *filter; -}; - - - -/*######################################################################### -## LSResourceResolver -#########################################################################*/ - -/** - * - */ -class LSResourceResolver -{ -public: - - /** - * - */ - virtual LSInput resolveResource(const DOMString &/*type*/, - const DOMString &/*namespaceURI*/, - const DOMString &/*publicId*/, - const DOMString &/*systemId*/, - const DOMString &/*baseURI*/) - { - LSInput input; - //do something - return input; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSResourceResolver() {} - - /** - * - */ - LSResourceResolver(const LSResourceResolver &/*other*/) - { - } - - /** - * - */ - virtual ~LSResourceResolver() {} - - - -}; - -/*######################################################################### -## LSOutput -#########################################################################*/ - -/** - * - */ -class LSOutput -{ -public: - - /** - * - */ - virtual LSWriter *getCharacterStream() const - { return characterStream; } - - /** - * - */ - virtual void setCharacterStream(const LSWriter *val) - { characterStream = (LSWriter *)val; } - - /** - * - */ - virtual LSOutputStream *getByteStream() const - { return byteStream; } - - /** - * - */ - virtual void setByteStream(const LSOutputStream *val) - { byteStream = (LSOutputStream *) val; } - - /** - * - */ - virtual DOMString getSystemId() const - { return systemId; } - - /** - * - */ - virtual void setSystemId(const DOMString &val) - { systemId = val; } - - /** - * - */ - virtual DOMString getEncoding() const - { return encoding; } - - /** - * - */ - virtual void setEncoding(const DOMString &val) - { encoding = val; } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSOutput() - { - characterStream = NULL; - byteStream = NULL; - systemId = ""; - encoding = ""; - } - - - /** - * - */ - LSOutput(const LSOutput &other) - { - characterStream = other.characterStream; - byteStream = other.byteStream; - systemId = other.systemId; - encoding = other.encoding; - } - - /** - * - */ - virtual ~LSOutput() - {} - -private: - - LSWriter *characterStream; - LSOutputStream *byteStream; - DOMString systemId; - DOMString encoding; - -}; - - -/*######################################################################### -## LSSerializer -#########################################################################*/ - -/** - * - */ -class LSSerializer -{ -public: - - /** - * - */ - virtual DOMConfiguration *getDomConfig() - { return NULL; } - - /** - * - */ - virtual DOMString getNewLine() - { return newLine; } - /** - * - */ - virtual void setNewLine(const DOMString &val) - { newLine = val; } - - /** - * - */ - virtual LSSerializerFilter *getFilter() - { return filter; } - - /** - * - */ - virtual void setFilter(const LSSerializerFilter *val) - { filter = const_cast(val); } - - /** - * - */ - virtual bool write(const NodePtr /*nodeArg*/, - const LSOutput &/*destination*/) - throw (LSException) - { return false; } - - /** - * - */ - virtual bool writeToURI(const NodePtr /*nodeArg*/, - const DOMString &/*uri*/) - throw(LSException) - { return false; } - - /** - * - */ - virtual DOMString writeToString(const NodePtr /*nodeArg*/) - throw(dom::DOMException, LSException) - { - DOMString str; - return str; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSSerializer() - { - filter = NULL; - newLine = "\n"; - } - - /** - * - */ - LSSerializer(const LSSerializer &other) - { - filter = other.filter; - newLine = other.newLine; - } - - /** - * - */ - virtual ~LSSerializer() {} - -protected: - - LSSerializerFilter *filter; - DOMString newLine; - -}; - -/*######################################################################### -## LSProgressEvent -#########################################################################*/ - -/** - * - */ -class LSProgressEvent : virtual public events::Event -{ -public: - - /** - * - */ - virtual LSInput &getInput() - { - return input; - } - - /** - * - */ - virtual unsigned long getPosition() - { return position; } - - /** - * - */ - virtual unsigned long getTotalSize() - { return totalSize; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSProgressEvent(const LSInput &inputArg, unsigned long positionArg, - unsigned long totalSizeArg) : input((LSInput &)inputArg) - { - position = positionArg; - totalSize = totalSizeArg; - } - - - /** - * - */ - LSProgressEvent(const LSProgressEvent &other) - : events::Event(other) , input(other.input) - { - position = other.position; - totalSize = other.totalSize; - } - - - /** - * - */ - virtual ~LSProgressEvent() {} - -protected: - - LSInput &input; - unsigned long position; - unsigned long totalSize; - -}; - -/*######################################################################### -## LSLoadEvent -#########################################################################*/ - -/** - * - */ -class LSLoadEvent : public events::Event -{ -public: - - /** - * - */ - virtual DocumentPtr getNewDocument() - { return newDocument; } - - /** - * - */ - virtual LSInput &getInput() - { return input; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSLoadEvent(const LSInput &inputArg, - const DocumentPtr docArg) - : input((LSInput &)inputArg) - { newDocument = docArg; } - - /** - * - */ - LSLoadEvent(const LSLoadEvent &other) - : events::Event(other) , input(other.input) - { - newDocument = other.newDocument; - } - - /** - * - */ - virtual ~LSLoadEvent() {} - -protected: - - DocumentPtr newDocument; - - LSInput &input; - - -}; - - - -/*######################################################################### -## LSSerializerFilter -#########################################################################*/ - -/** - * - */ -class LSSerializerFilter : virtual public traversal::NodeFilter -{ -public: - - /** - * - */ - virtual unsigned long getWhatToShow() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSSerializerFilter() {} -}; - - - - -/*######################################################################### -## DOMImplementationLS -#########################################################################*/ - -/** - * - */ -class DOMImplementationLS -{ -public: - - typedef enum - { - MODE_SYNCHRONOUS = 1, - MODE_ASYNCHRONOUS = 2 - } DOMImplementationLSMode; - - /** - * To use, for this and subclasses: - * LSParser &parser = myImplementation.createLSParser(mode, schemaType); - */ - virtual LSParser &createLSParser(unsigned short mode, - const DOMString &schemaType) - throw (dom::DOMException) =0; - - /** - * To use, for this and subclasses: - * LSSerializer &serializer = myImplementation.createLSSerializer(); - * - */ - virtual LSSerializer &createLSSerializer() =0; - - /** - * - */ - virtual LSInput createLSInput() =0; - - /** - * - */ - virtual LSOutput createLSOutput() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementationLS() {} -}; - - - - -} //namespace ls -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_LS_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp deleted file mode 100644 index d4da0d5ce..000000000 --- a/src/dom/lsimpl.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "domimpl.h" -#include "events.h" -#include "traversal.h" -#include "lsimpl.h" - -#include -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace ls -{ - - - -/*######################################################################### -## LSParserImpl -#########################################################################*/ - - -/** - * - */ -bool LSParserImpl::getBusy() -{ - return false; -} - -/** - * - */ -DocumentPtr LSParserImpl::parse(const LSInput &input) - throw(dom::DOMException, LSException) -{ - - //#### Check the various inputs of 'input' in order, according - //# to the L&S spec - LSReader *lsreader = input.getCharacterStream(); - if (lsreader) - { - DOMString buf; - while (true) - { - int ch = lsreader->get(); - if (ch < 0) - break; - buf.push_back((XMLCh)ch); - } - XmlReader reader; - DocumentPtr doc = reader.parse(buf); - return doc; - } - - LSInputStream *inputStream = input.getByteStream(); - if (inputStream) - { - DOMString buf; - while (true) - { - int ch = inputStream->get(); - if (ch < 0) - break; - buf.push_back((XMLCh)ch); - } - XmlReader reader; - DocumentPtr doc = reader.parse(buf); - return doc; - } - - DOMString stringData = input.getStringData(); - if (stringData.size() > 0) - { - XmlReader reader; - DocumentPtr doc = reader.parse(stringData); - return doc; - } - - DOMString systemId = input.getSystemId(); - if (systemId.size() > 0) - { - //lets not do this yet - return NULL; - } - - DOMString publicId = input.getPublicId(); - if (publicId.size() > 0) - { - //lets not do this yet - return NULL; - } - - return NULL; -} - - -/** - * - */ -DocumentPtr LSParserImpl::parseURI(const DOMString &/*uri*/) - throw(dom::DOMException, LSException) -{ - return NULL; -} - - /** - * - */ -NodePtr LSParserImpl::parseWithContext(const LSInput &/*input*/, - const NodePtr /*contextArg*/, - unsigned short /*action*/) - throw(dom::DOMException, LSException) -{ - return NULL; -} - - - -//################## -//# Non-API methods -//################## - - - - - - - - - - - -/*######################################################################### -## LSSerializerImpl -#########################################################################*/ - - -/** - * - */ -bool LSSerializerImpl::write( - const NodePtr nodeArg, - const LSOutput &destination) - throw (LSException) -{ - outbuf = ""; - indent = 0; - - writeNode(nodeArg); - - //## Check in order specified in the L&S specs - LSWriter *writer = destination.getCharacterStream(); - if (writer) - { - for (unsigned int i=0 ; iput(ch); - } - return true; - } - - LSOutputStream *outputStream = destination.getByteStream(); - if (outputStream) - { - for (unsigned int i=0 ; iput(ch); - } - return true; - } - - DOMString systemId = destination.getSystemId(); - if (systemId.size() > 0) - { - //DO SOMETHING - return true; - } - - return false; -} - -/** - * - */ -bool LSSerializerImpl::writeToURI(const NodePtr nodeArg, - const DOMString &uriArg) - throw(LSException) -{ - outbuf = ""; - indent = 0; - - writeNode(nodeArg); - - DOMString uri = uriArg; - char *fileName = (char *) uri.c_str(); //temporary hack - FILE *f = fopen(fileName, "wb"); - if (!f) - return false; - for (unsigned int i=0 ; i') - outbuf.append(">"); - else if (ch == '"') - outbuf.append("""); - else if (ch == '\'') - outbuf.append("'"); - else - outbuf.push_back(ch); - } -} - -/** - * - */ -void LSSerializerImpl::writeNode(const NodePtr nodeArg) -{ - NodePtr node = nodeArg; - - int type = node->getNodeType(); - - switch (type) - { - - //############# - //# DOCUMENT - //############# - case Node::DOCUMENT_NODE: - { - DocumentPtr doc = dynamic_cast(node.get()); - writeNode(doc->getDocumentElement()); - } - break; - - //############# - //# TEXT - //############# - case Node::TEXT_NODE: - { - poxml(node->getNodeValue()); - } - break; - - - //############# - //# CDATA - //############# - case Node::CDATA_SECTION_NODE: - { - pos("getNodeValue()); - pos("]]>"); - } - break; - - - //############# - //# ELEMENT - //############# - case Node::ELEMENT_NODE: - { - - indent+=2; - - NamedNodeMap attributes = node->getAttributes(); - int nrAttrs = attributes.getLength(); - - //### Start open tag - spaces(); - po("<"); - pos(node->getNodeName()); - //if (nrAttrs>0) - // pos(newLine); - - //### Attributes - for (int i=0 ; igetNodeName()); - po("=\""); - pos(attr->getNodeValue()); - po("\""); - //pos(newLine); - } - - //### Finish open tag - //if (nrAttrs>0) - // spaces(); - po(">"); - //pos(newLine); - - //### Contents - //spaces(); - pos(node->getNodeValue()); - - //### Children - for (NodePtr child = node->getFirstChild() ; - child.get() ; - child=child->getNextSibling()) - { - writeNode(child); - } - - //### Close tag - //spaces(); - po("getNodeName()); - po(">"); - pos(newLine); - - indent-=2; - } - break; - - }//switch - -} - - - - - - - - - - -} //namespace ls -} //namespace dom -} //namespace w3c -} //namespace org - - - - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/lsimpl.h b/src/dom/lsimpl.h deleted file mode 100644 index fcfd42a4b..000000000 --- a/src/dom/lsimpl.h +++ /dev/null @@ -1,390 +0,0 @@ -#ifndef SEEN_LSIMPL_H -#define SEEN_LSIMPL_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "domimpl.h" -#include "events.h" -#include "traversal.h" -#include "ls.h" - - -#include "xmlreader.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace ls -{ - - -/*######################################################################### -## LSParserImpl -#########################################################################*/ - -/** - * - */ -class LSParserImpl : virtual public LSParser -{ -public: - - typedef enum - { - PARSE_AS_DATA = 0, - PARSE_AS_DOCUMENT = 1 - } ParsingModes; - - /** - * - */ - virtual bool getBusy(); - - /** - * - */ - virtual DocumentPtr parse(const LSInput &input) - throw(dom::DOMException, LSException); - - - /** - * - */ - virtual DocumentPtr parseURI(const DOMString &uri) - throw(dom::DOMException, LSException); - - /** - * - */ - virtual NodePtr parseWithContext(const LSInput &input, - const NodePtr contextArg, - unsigned short action) - throw(dom::DOMException, LSException); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSParserImpl() : - reader(), - filter(0) - {} - - /** - * - */ - LSParserImpl(const LSParserImpl &other) : - LSParser(other), - reader(), - filter(0) - {} - - /** - * - */ - virtual ~LSParserImpl() - {} - - - - //################## - //# Internals - //################## - - -protected: - - XmlReader reader; - LSParserFilter *filter; - -}; - - - - -/*######################################################################### -## LSParserFilterImpl -#########################################################################*/ - -/** - * - */ -class LSParserFilterImpl : virtual public LSParserFilter -{ -public: - - /** - * - */ - virtual unsigned short startElement(const ElementPtr /*elementArg*/) - { return 0; } - - /** - * - */ - virtual unsigned short acceptNode(const NodePtr /*nodeArg*/) - { return 0; } - - /** - * - */ - virtual unsigned long getWhatToShow() - { return 0; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSParserFilterImpl() - {} - - - -}; - -/*######################################################################### -## LSSerializerImpl -#########################################################################*/ - -/** - * - */ -class LSSerializerImpl : virtual public LSSerializer -{ -public: - - - /** - * - */ - virtual bool write(const NodePtr nodeArg, - const LSOutput &destination) - throw (LSException); - - /** - * - */ - virtual bool writeToURI(const NodePtr nodeArg, - const DOMString &uri) - throw(LSException); - - /** - * - */ - virtual DOMString writeToString(const NodePtr nodeArg) - throw(dom::DOMException, LSException); - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSSerializerImpl() : - outbuf(), - indent(0), - domConfig(0), - filter(0) - { - } - - /** - * - */ - virtual ~LSSerializerImpl() - {} - - - -protected: - - /** - * - */ - void writeNode(const NodePtr nodeArg); - -private: - - void spaces(); - - void po(char const *fmt, ...) - #ifdef G_GNUC_PRINTF - G_GNUC_PRINTF(2, 3) - #endif - ; - - void pos(const DOMString &str); - - void poxml(const DOMString &str); - - DOMString outbuf; - - int indent; - - DOMConfiguration *domConfig; - - LSSerializerFilter *filter; - - - -}; - - - - -/*######################################################################### -## LSSerializerFilterImpl -#########################################################################*/ - -/** - * - */ -class LSSerializerFilterImpl : virtual public LSSerializerFilter -{ -public: - - /** - * - */ - virtual unsigned long getWhatToShow() - { return 0; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSSerializerFilterImpl() - {} -}; - - - -/*######################################################################### -## DOMImplementationLSImpl -#########################################################################*/ - -/** - * - */ -class DOMImplementationLSImpl : virtual public DOMImplementationLS -{ -public: - - /** - * - */ - virtual LSParser &createLSParser(unsigned short /*mode*/, - const DOMString &/*schemaType*/) - throw (dom::DOMException) - { - LSParserImpl newParser; - parser = newParser; - return parser; - } - - - /** - * - */ - virtual LSSerializer &createLSSerializer() - { - LSSerializerImpl newSerializer; - serializer = newSerializer; - return serializer; - } - - - /** - * - */ - virtual LSInput createLSInput() - { - LSInput input; - return input; - } - - /** - * - */ - virtual LSOutput createLSOutput() - { - LSOutput output; - return output; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementationLSImpl() {} - -protected: - - LSParserImpl parser; - LSSerializerImpl serializer; -}; - - - - - - -} //namespace ls -} //namespace dom -} //namespace w3c -} //namespace org - - - - -#endif // SEEN_LSIMPL_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/makefile.in b/src/dom/makefile.in deleted file mode 100644 index b505975a6..000000000 --- a/src/dom/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) dom/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) dom/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/dom/mingwenv.bat b/src/dom/mingwenv.bat deleted file mode 100644 index 48e8bf096..000000000 --- a/src/dom/mingwenv.bat +++ /dev/null @@ -1,2 +0,0 @@ -set PATH=c:\mingw\bin;%PATH% -set RM=del diff --git a/src/dom/prop-css.cpp b/src/dom/prop-css.cpp deleted file mode 100644 index 9922b4935..000000000 --- a/src/dom/prop-css.cpp +++ /dev/null @@ -1,1161 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include - - -struct CssProp_def -{ - const char *name; - const char *values; - const char *defaultValue; - const char *appliesTo; - bool inherited; - const char *percentages; - const char *mediaGroups; -}; - -typedef struct CssProp_def CssProp; - -static CssProp cssProps[] = -{ - -{ -"azimuth", -" | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards | inherit", -"center", -"", -true, -"", -"aural" -}, - - -{ -"background-attachment", -"scroll | fixed | inherit", -"scroll", -"", -false, -"", -"visual" -}, - - -{ -"background-color", -" | transparent | inherit", -"transparent", -"", -false, -"", -"visual" -}, - - -{ -"background-image", -" | none | inherit", -"none", -"", -false, -"", -"visual" -}, - - -{ -"background-position", -"[ [ | | left | center | right ] [ | | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit", -"0% 0%", -"", -false, -"refer to the size of the box itself", -"visual" -}, - - -{ -"background-repeat", -"repeat | repeat-x | repeat-y | no-repeat | inherit", -"repeat", -"", -false, -"", -"visual" -}, - - -{ -"background", -"['background-color' || 'background-image' || 'background-repeat' || 'background-attachment' || 'background-position'] | inherit", -"see individual properties", -"", -false, -"allowed on 'background-position", -"visual" -}, - - -{ -"border-collapse", -"collapse | separate | inherit", -"separate", -"table' and 'inline-table' elements", -true, -"", -"visual" -}, - - -{ -"border-color", -"[ | transparent ]{1,4} | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border-spacing", -" ? | inherit", -"0", -"table' and 'inline-table' elements", -true, -"", -"visual" -}, - - -{ -"border-style", -"{1,4} | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border-top' 'border-right' 'border-bottom' 'border-left", -"[ || || 'border-top-color' ] | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border-top-color' 'border-right-color' 'border-bottom-color' 'border-left-color", -" | transparent | inherit", -"the value of the 'color' property", -"", -false, -"", -"visual" -}, - - -{ -"border-top-style' 'border-right-style' 'border-bottom-style' 'border-left-style", -" | inherit", -"none", -"", -false, -"", -"visual" -}, - - -{ -"border-top-width' 'border-right-width' 'border-bottom-width' 'border-left-width", -" | inherit", -"medium", -"", -false, -"", -"visual" -}, - - -{ -"border-width", -"{1,4} | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border", -"[ || || 'border-top-color' ] | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"bottom", -" | | auto | inherit", -"auto", -"positioned elements", -false, -"refer to height of containing block", -"visual" -}, - - -{ -"caption-side", -"top | bottom | inherit", -"top", -"table-caption' elements", -true, -"", -"visual" -}, - - -{ -"clear", -"none | left | right | both | inherit", -"none", -"block-level elements", -false, -"", -"visual" -}, - - -{ -"clip", -" | auto | inherit", -"auto", -"absolutely positioned elements", -false, -"", -"visual" -}, - - -{ -"color", -" | inherit", -"depends on user agent", -"", -true, -"", -"visual" -}, - - -{ -"content", -"normal | [ | | | attr() | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit", -"normal", -":before and :after pseudo-elements", -false, -"", -"all " -}, - - -{ -"counter-increment", -"[ ? ]+ | none | inherit", -"none", -"", -false, -"", -"all " -}, - - -{ -"counter-reset", -"[ ? ]+ | none | inherit", -"none", -"", -false, -"", -"all " -}, - - -{ -"cue-after", -" | none | inherit", -"none", -"", -false, -"", -"aural" -}, - - -{ -"cue-before", -" | none | inherit", -"none", -"", -false, -"", -"aural" -}, - - -{ -"cue", -"[ 'cue-before' || 'cue-after' ] | inherit", -"see individual properties", -"", -false, -"", -"aural" -}, - - -{ -"cursor", -"[ [ ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress ] ] | inherit", -"auto", -"", -true, -"", -"visual, interactive " -}, - - -{ -"direction", -"ltr | rtl | inherit", -"ltr", -"all elements, but see prose", -true, -"", -"visual" -}, - - -{ -"display", -"inline | block | list-item | run-in | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit", -"inline", -"", -false, -"", -"all " -}, - - -{ -"elevation", -" | below | level | above | higher | lower | inherit", -"level", -"", -true, -"", -"aural" -}, - - -{ -"empty-cells", -"show | hide | inherit", -"show", -"table-cell' elements", -true, -"", -"visual" -}, - - -{ -"float", -"left | right | none | inherit", -"none", -"all, but see 9.7", -false, -"", -"visual" -}, - - -{ -"font-family", -"[[ | ] [, | ]* ] | inherit", -"depends on user agent", -"", -true, -"", -"visual" -}, - - -{ -"font-size", -" | | | | inherit", -"medium", -"", -true, -"refer to parent element's font size", -"visual" -}, - - -{ -"font-style", -"normal | italic | oblique | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"font-variant", -"normal | small-caps | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"font-weight", -"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"font", -"[ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit", -"see individual properties", -"", -true, -"see individual properties", -"visual" -}, - - -{ -"height", -" | | auto | inherit", -"auto", -"all elements but non-replaced inline elements, table columns, and column groups", -false, -"see prose", -"visual" -}, - - -{ -"left", -" | | auto | inherit", -"auto", -"positioned elements", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"letter-spacing", -"normal | | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"line-height", -"normal | | | | inherit", -"normal", -"", -true, -"refer to the font size of the element itself", -"visual" -}, - - -{ -"list-style-image", -" | none | inherit", -"none", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"list-style-position", -"inside | outside | inherit", -"outside", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"list-style-type", -"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | none | inherit", -"disc", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"list-style", -"[ 'list-style-type' || 'list-style-position' || 'list-style-image' ] | inherit", -"see individual properties", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"margin-right' 'margin-left", -" | inherit", -"0", -"all elements except elements with table display types other than table and inline-table", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"margin-top' 'margin-bottom", -" | inherit", -"0", -"all elements except elements with table display types other than table and inline-table", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"margin", -"{1,4} | inherit", -"see individual properties", -"all elements except elements with table display types other than table and inline-table", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"max-height", -" | | none | inherit", -"none", -"all elements except non-replaced inline elements and table elements", -false, -"see prose", -"visual" -}, - - -{ -"max-width", -" | | none | inherit", -"none", -"all elements except non-replaced inline elements and table elements", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"min-height", -" | | inherit", -"0", -"all elements except non-replaced inline elements and table elements", -false, -"see prose", -"visual" -}, - - -{ -"min-width", -" | | inherit", -"0", -"all elements except non-replaced inline elements and table elements", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"orphans", -" | inherit", -"2", -"block-level elements", -true, -"", -"visual, paged " -}, - - -{ -"outline-color", -" | invert | inherit", -"invert", -"", -false, -"", -"visual, interactive " -}, - - -{ -"outline-style", -" | inherit", -"none", -"", -false, -"", -"visual, interactive " -}, - - -{ -"outline-width", -" | inherit", -"medium", -"", -false, -"", -"visual, interactive " -}, - - -{ -"outline", -"[ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit", -"see individual properties", -"", -false, -"", -"visual, interactive " -}, - - -{ -"overflow", -"visible | hidden | scroll | auto | inherit", -"visible", -"block-level and replaced elements, table cells, inline blocks", -false, -"", -"visual" -}, - - -{ -"padding-top' 'padding-right' 'padding-bottom' 'padding-left", -" | inherit", -"0", -"all elements except elements with table display types other than table, inline-table, and table-cell", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"padding", -"{1,4} | inherit", -"see individual properties", -"all elements except elements with table display types other than table, inline-table, and table-cell", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"page-break-after", -"auto | always | avoid | left | right | inherit", -"auto", -"block-level elements", -false, -"", -"visual, paged " -}, - - -{ -"page-break-before", -"auto | always | avoid | left | right | inherit", -"auto", -"block-level elements", -false, -"", -"visual, paged " -}, - - -{ -"page-break-inside", -"avoid | auto | inherit", -"auto", -"block-level elements", -true, -"", -"visual, paged " -}, - - -{ -"pause-after", -"