khtml Library API Documentation

khtml::LinearDocument Class Reference

Represents the whole document in terms of lines. More...

#include <khtml_caret_p.h>

List of all members.

Public Types

typedef LineIterator Iterator

Public Member Functions

 LinearDocument (KHTMLPart *part, DOM::NodeImpl *node, long offset, CaretAdvancePolicy advancePolicy, DOM::ElementImpl *baseElem)
bool isValid () const
int count () const
Iterator current ()
const Iteratorend () const
Iterator preEnd ()
Iterator begin ()
const IteratorpreBegin () const
CaretAdvancePolicy advancePolicy () const
RenderObject * baseObject () const

Protected Member Functions

void initPreBeginIterator ()
void initEndIterator ()

Protected Attributes

CaretBoxLineDeleter cblDeleter
DOM::NodeImpl * node
long offset
Iterator _preBegin
Iterator _end
KHTMLPartm_part
CaretAdvancePolicy advPol
RenderObject * base

Friends

class LineIterator
class EditableLineIterator
class ErgonomicEditableLineIterator
class CaretBoxIterator
class EditableCaretBoxIterator
class EditableCharacterIterator


Detailed Description

Represents the whole document in terms of lines.

SGML documents are trees. But for navigation, this representation is not practical. Therefore this class serves as a helper to represent the document as a linear list of lines. Its usage somewhat resembles STL semantics like begin and end as well as iterators.

The lines itself are represented as caret line boxes.

LinearDocument instances are not meant to be kept over the lifetime of their associated document, but constructed from (node, offset) pairs whenever line traversal is needed. This is because the underlying InlineFlowBox objects may be destroyed and recreated (e. g. by resizing the window, adding/removing elements).

Author:
Leo Savernik
Since:
3.2

Definition at line 633 of file khtml_caret_p.h.


Constructor & Destructor Documentation

khtml::LinearDocument::LinearDocument KHTMLPart part,
DOM::NodeImpl *  node,
long  offset,
CaretAdvancePolicy  advancePolicy,
DOM::ElementImpl *  baseElem
 

Creates a new instance, and initializes it to the line specified by the parameters below.

Creation will fail if node is invisible or defect.

Parameters:
part part within which everything is taking place.
node document node with which to start
offset zero-based offset within this node.
advancePolicy caret advance policy
baseElem base element which the caret must not advance beyond (0 means whole document). The base element will be ignored if it cannot serve as a base (to see if this is the case, check whether LinearDocument::baseFlow()->element() != base)


Member Function Documentation

bool khtml::LinearDocument::isValid  )  const [inline]
 

Tells whether this list contains any lines.

Returns:
true if this document contains lines, false otherwise. Note that an empty document contains at least one line, so this method only returns false if the document could not be initialised for some reason.

Definition at line 664 of file khtml_caret_p.h.

int khtml::LinearDocument::count  )  const
 

Returns the count of lines.

Warning: This function is expensive. Call it once and cache the value.

FIXME: It's not implemented yet (and maybe never will)

Definition at line 1265 of file khtml_caret.cpp.

LinearDocument::Iterator khtml::LinearDocument::current  ) 
 

Returns a line iterator containing the current position as its starting value.

Definition at line 1271 of file khtml_caret.cpp.

const Iterator& khtml::LinearDocument::end  )  const [inline]
 

Returns a line iterator pointing right after the end of the document.

Definition at line 687 of file khtml_caret_p.h.

Referenced by begin(), khtml::EditableCharacterIterator::EditableCharacterIterator(), khtml::ErgonomicEditableLineIterator::operator++(), khtml::EditableCharacterIterator::operator++(), and khtml::ErgonomicEditableLineIterator::operator--().

LinearDocument::Iterator khtml::LinearDocument::preEnd  ) 
 

Returns a line iterator pointing to the very last line of the document.

Definition at line 1290 of file khtml_caret.cpp.

References preBegin().

LinearDocument::Iterator khtml::LinearDocument::begin  ) 
 

Returns a line iterator pointing to the very first line of the document.

Definition at line 1276 of file khtml_caret.cpp.

References end().

const Iterator& khtml::LinearDocument::preBegin  )  const [inline]
 

Returns a line iterator pointing just before the very first line of the document (this is somewhat an emulation of reverse iterators).

Definition at line 703 of file khtml_caret_p.h.

Referenced by khtml::ErgonomicEditableLineIterator::operator++(), khtml::ErgonomicEditableLineIterator::operator--(), khtml::EditableCharacterIterator::operator--(), and preEnd().

CaretAdvancePolicy khtml::LinearDocument::advancePolicy  )  const [inline]
 

Returns the current caret advance policy.

Definition at line 708 of file khtml_caret_p.h.

Referenced by khtml::EditableLineIterator::advance(), and khtml::ErgonomicEditableLineIterator::determineTopologicalElement().

RenderObject* khtml::LinearDocument::baseObject  )  const [inline]
 

Returns the base render object which the caret must not advance beyond.

Note that HTML documents are usually restricted to the body element.

Returns:
the base render object or 0 if the whole document is valid.

Definition at line 717 of file khtml_caret_p.h.

Referenced by khtml::ErgonomicEditableLineIterator::determineTopologicalElement(), khtml::LineIterator::LineIterator(), khtml::LineIterator::nextBlock(), and khtml::LineIterator::prevBlock().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Jan 15 13:34:55 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003