2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef __dom_position_h__
27 #define __dom_position_h__
37 Position() : m_node(0), m_offset(0) {};
38 Position(NodeImpl
*node
, long offset
);
39 Position(const Position
&);
42 NodeImpl
*node() const { return m_node
; }
43 long offset() const { return m_offset
; }
45 ElementImpl
*element() const;
47 long renderedOffset() const;
49 bool isEmpty() const { return m_node
== 0; }
50 bool notEmpty() const { return m_node
!= 0; }
52 Position
equivalentLeafPosition() const;
53 Position
previousRenderedEditablePosition() const;
54 Position
nextRenderedEditablePosition() const;
55 Position
previousCharacterPosition() const;
56 Position
nextCharacterPosition() const;
57 Position
previousWordPosition() const;
58 Position
nextWordPosition() const;
59 Position
previousLinePosition(int x
) const;
60 Position
nextLinePosition(int x
) const;
61 Position
equivalentUpstreamPosition() const;
62 Position
equivalentDownstreamPosition() const;
63 Position
equivalentRangeCompliantPosition() const;
64 Position
equivalentShallowPosition() const;
65 bool atStartOfContainingEditableBlock() const;
66 bool atStartOfRootEditableElement() const;
67 bool inRenderedContent() const;
68 bool inRenderedText() const;
69 bool rendersOnSameLine(const Position
&pos
) const;
70 bool rendersInDifferentPosition(const Position
&pos
) const;
71 bool isFirstRenderedPositionOnLine() const;
72 bool isLastRenderedPositionOnLine() const;
73 bool isLastRenderedPositionInEditableBlock() const;
74 bool inFirstEditableInRootEditableElement() const;
75 bool inLastEditableInRootEditableElement() const;
76 bool inFirstEditableInContainingEditableBlock() const;
77 bool inLastEditableInContainingEditableBlock() const;
79 Position
&operator=(const Position
&o
);
81 friend bool operator==(const Position
&a
, const Position
&b
);
82 friend bool operator!=(const Position
&a
, const Position
&b
);
84 void debugPosition(const char *msg
="") const;
91 inline bool operator==(const Position
&a
, const Position
&b
)
93 return a
.node() == b
.node() && a
.offset() == b
.offset();
96 inline bool operator!=(const Position
&a
, const Position
&b
)
103 #endif // __dom_position_h__