# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# html_miscimpl.h

    00001 /*
    00002  * This file is part of the DOM implementation for KDE.
    00003  *
    00004  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    00005  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    00006  *
    00007  * This library is free software; you can redistribute it and/or
    00008  * modify it under the terms of the GNU Library General Public
    00009  * License as published by the Free Software Foundation; either
    00010  * version 2 of the License, or (at your option) any later version.
    00011  *
    00012  * This library is distributed in the hope that it will be useful,
    00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015  * Library General Public License for more details.
    00016  *
    00017  * You should have received a copy of the GNU Library General Public License
    00018  * along with this library; see the file COPYING.LIB.  If not, write to
    00019  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00020  * Boston, MA 02111-1307, USA.
    00021  *
    00022  * $Id: html_miscimpl.h,v 1.22.2.2 2003/06/24 22:00:24 faure Exp $
    00023  */
    00024 #ifndef HTML_MISCIMPL_H
    00025 #define HTML_MISCIMPL_H
    00026
    00027 #include "html_elementimpl.h"
    00028 #include "misc/shared.h"
    00029
    00030 namespace DOM {
    00031
    00032 class Node;
    00033 class DOMString;
    00034 class HTMLCollection;
    00035
    00036 class HTMLBaseFontElementImpl : public HTMLElementImpl
    00037 {
    00038 public:
    00039     HTMLBaseFontElementImpl(DocumentPtr *doc);
    00040
    00041     ~HTMLBaseFontElementImpl();
    00042
    00043     virtual Id id() const;
    00044 };
    00045
    00046 // -------------------------------------------------------------------------
    00047
    00048 class HTMLCollectionImpl : public khtml::Shared<HTMLCollectionImpl>
    00049 {
    00050     friend class DOM::HTMLCollection;
    00051 public:
    00052     enum Type {
    00053         // from HTMLDocument
    00054         DOC_IMAGES,    // all IMG elements in the document
    00055         DOC_APPLETS,   // all OBJECT and APPLET elements
    00056         DOC_FORMS,     // all FORMS
    00057         DOC_LINKS,     // all A _and_ AREA elements with a value for href
    00058         DOC_ANCHORS,      // all A elements with a value for name
    00059         // from HTMLTable, HTMLTableSection, HTMLTableRow
    00060         TABLE_ROWS,    // all rows in this table or tablesection
    00061         TABLE_TBODIES, // all TBODY elements in this table
    00062         TSECTION_ROWS, // all rows elements in this table section
    00063         TR_CELLS,      // all CELLS in this row
    00064         // from SELECT
    00065         SELECT_OPTIONS,
    00066         // from HTMLMap
    00067         MAP_AREAS,
    00068         DOC_ALL,        // "all" elements (IE)
    00069         NODE_CHILDREN   // first-level children (IE)
    00070     };
    00071
    00072     HTMLCollectionImpl(NodeImpl *_base, int _tagId);
    00073
    00074     virtual ~HTMLCollectionImpl();
    00075     unsigned long length() const;
    00076     // This method is o(n), so you should't use it to iterate over all items. Use firstItem/nextItem instead.
    00077     NodeImpl *item ( unsigned long index ) const;
    00078     virtual NodeImpl *firstItem() const;
    00079     virtual NodeImpl *nextItem() const;
    00080
    00081     NodeImpl *namedItem ( const DOMString &name ) const;
    00082     // In case of multiple items named the same way
    00083     NodeImpl *nextNamedItem( const DOMString &name ) const;
    00084
    00085 protected:
    00086     virtual unsigned long calcLength(NodeImpl *current) const;
    00087     virtual NodeImpl *getItem(NodeImpl *current, int index, int &pos) const;
    00088     virtual NodeImpl *getNamedItem(NodeImpl *current, int attr_id, const DOMString &name) const;
    00089     virtual NodeImpl *nextNamedItemInternal( const DOMString &name ) const;
    00090     // the base node, the collection refers to
    00091     NodeImpl *base;
    00092     // The collection list the following elements
    00093     int type;
    00094
    00095     // ### add optimization, so that a linear loop through the
    00096     // Collection [using item(i)] is O(n) and not O(n^2)!
    00097     // But for that we need to get notified in case of changes in the dom structure...
    00098     //NodeImpl *current;
    00099     //int currentPos;
    00100
    00101     // For firstItem()/nextItem()
    00102     mutable NodeImpl *currentItem;
    00103     // For nextNamedItem()
    00104     mutable bool idsDone;
    00105 };
    00106
    00107 // this whole class is just a big hack to find form elements even in
    00108 // malformed HTML elements
    00109 // the famous <table><tr><form><td> problem
    00110 class HTMLFormCollectionImpl : public HTMLCollectionImpl
    00111 {
    00112 public:
    00113     // base must inherit HTMLGenericFormElementImpl or this won't work
    00114     HTMLFormCollectionImpl(NodeImpl* _base)
    00115         : HTMLCollectionImpl(_base, 0)
    00116     {};
    00117     ~HTMLFormCollectionImpl() { };
    00118
    00119     virtual NodeImpl *firstItem() const;
    00120     virtual NodeImpl *nextItem() const;
    00121 protected:
    00122     virtual unsigned long calcLength(NodeImpl* current) const;
    00123     virtual NodeImpl *getItem(NodeImpl *current, int index, int& pos) const;
    00124     virtual NodeImpl *getNamedItem(NodeImpl* current, int attr_id, const DOMString& name) const;
    00125     virtual NodeImpl *nextNamedItemInternal( const DOMString &name ) const;
    00126 private:
    00127     NodeImpl* getNamedFormItem(int attr_id, const DOMString& name, int duplicateNumber) const;
    00128     mutable int currentPos;
    00129 };
    00130
    00131
    00132 } //namespace
    00133
    00134 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:56 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001