#ifndef _DOM2_RangeImpl_h_
#define _DOM2_RangeImpl_h_
#include "dom/dom2_range.h"
#include "misc/shared.h"
namespace DOM {
class RangeImpl : public khtml::Shared<RangeImpl>
{
friend class DocumentImpl;
public:
RangeImpl(DocumentPtr *_ownerDocument);
RangeImpl(DocumentPtr *_ownerDocument,
NodeImpl *_startContainer, long _startOffset,
NodeImpl *_endContainer, long _endOffset);
~RangeImpl();
NodeImpl *startContainer(int &exceptioncode) const;
long startOffset(int &exceptioncode) const;
NodeImpl *endContainer(int &exceptioncode) const;
long endOffset(int &exceptioncode) const;
bool collapsed(int &exceptioncode) const;
NodeImpl *commonAncestorContainer(int &exceptioncode);
static NodeImpl *commonAncestorContainer(NodeImpl *containerA, NodeImpl *containerB);
void setStart ( NodeImpl *refNode, long offset, int &exceptioncode );
void setEnd ( NodeImpl *refNode, long offset, int &exceptioncode );
void collapse ( bool toStart, int &exceptioncode );
short compareBoundaryPoints ( Range::CompareHow how, RangeImpl *sourceRange, int &exceptioncode );
short compareBoundaryPoints ( NodeImpl *containerA, long offsetA, NodeImpl *containerB, long offsetB );
bool boundaryPointsValid ( );
void deleteContents ( int &exceptioncode );
DocumentFragmentImpl *extractContents ( int &exceptioncode );
DocumentFragmentImpl *cloneContents ( int &exceptioncode );
void insertNode( NodeImpl *newNode, int &exceptioncode );
DOMString toString ( int &exceptioncode );
DOMString toHTML ( );
DocumentFragmentImpl *createContextualFragment ( DOMString &html, int &exceptioncode );
void detach ( int &exceptioncode );
bool isDetached() const;
RangeImpl *cloneRange(int &exceptioncode);
void setStartAfter( NodeImpl *refNode, int &exceptioncode );
void setEndBefore( NodeImpl *refNode, int &exceptioncode );
void setEndAfter( NodeImpl *refNode, int &exceptioncode );
void selectNode( NodeImpl *refNode, int &exceptioncode );
void selectNodeContents( NodeImpl *refNode, int &exceptioncode );
void surroundContents( NodeImpl *newParent, int &exceptioncode );
void setStartBefore( NodeImpl *refNode, int &exceptioncode );
enum ActionType {
DELETE_CONTENTS,
EXTRACT_CONTENTS,
CLONE_CONTENTS
};
DocumentFragmentImpl *processContents ( ActionType action, int &exceptioncode );
bool readOnly() { return false; }
protected:
DocumentPtr *m_ownerDocument;
NodeImpl *m_startContainer;
unsigned long m_startOffset;
NodeImpl *m_endContainer;
unsigned long m_endOffset;
bool m_detached;
private:
void checkNodeWOffset( NodeImpl *n, int offset, int &exceptioncode) const;
void checkNodeBA( NodeImpl *n, int &exceptioncode ) const;
void setStartContainer(NodeImpl *_startContainer);
void setEndContainer(NodeImpl *_endContainer);
void checkDeleteExtract(int &exceptioncode);
bool containedByReadOnly();
};
};
#endif