Commit 4e32ebc3 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

Reviewed by Darin Adler.

        Make m_offset private and change all callers to use deprecatedEditingOffset().
        https://bugs.webkit.org/show_bug.cgi?id=25472

        Per Darin's suggestion, this was just a simple search replace
        of .m_offset with .deprecatedEditingOffset().

        There was one change in InsertParagraphSeparatorCommand::doApply to use
        Position::moveToOffset(0) instead of .m_offset = 0;

        * dom/Position.cpp:
        (WebCore::Position::rendersInDifferentPosition):
        (WebCore::Position::leadingWhitespacePosition):
        * dom/Position.h:
        (WebCore::Position::deprecatedEditingOffset):
        (WebCore::Position::moveToOffset):
        (WebCore::operator==):
        * dom/PositionIterator.h:
        (WebCore::PositionIterator::PositionIterator):
        * dom/Range.cpp:
        (WebCore::Range::create):
        (WebCore::Range::compareBoundaryPoints):
        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
        (WebCore::ApplyStyleCommand::applyInlineStyleToRange):
        (WebCore::ApplyStyleCommand::removeInlineStyle):
        (WebCore::ApplyStyleCommand::nodeFullySelected):
        (WebCore::ApplyStyleCommand::nodeFullyUnselected):
        (WebCore::ApplyStyleCommand::splitTextAtStartIfNeeded):
        (WebCore::ApplyStyleCommand::splitTextAtEndIfNeeded):
        (WebCore::ApplyStyleCommand::splitTextElementAtStartIfNeeded):
        (WebCore::ApplyStyleCommand::splitTextElementAtEndIfNeeded):
        (WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
        (WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):
        (WebCore::ApplyStyleCommand::joinChildTextNodes):
        * editing/BreakBlockquoteCommand.cpp:
        (WebCore::BreakBlockquoteCommand::doApply):
        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::insertNodeAt):
        (WebCore::CompositeEditCommand::positionOutsideTabSpan):
        (WebCore::CompositeEditCommand::rebalanceWhitespaceAt):
        (WebCore::CompositeEditCommand::prepareWhitespaceAtPositionForSplit):
        (WebCore::CompositeEditCommand::deleteInsignificantText):
        (WebCore::CompositeEditCommand::moveParagraphs):
        (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph):
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::updatePositionForNodeRemoval):
        (WebCore::updatePositionForTextRemoval):
        (WebCore::DeleteSelectionCommand::handleGeneralDelete):
        (WebCore::DeleteSelectionCommand::fixupWhitespace):
        * editing/Editor.cpp:
        (WebCore::Editor::setComposition):
        (WebCore::Editor::advanceToNextMisspelling):
        (WebCore::Editor::getCompositionSelection):
        * editing/InsertLineBreakCommand.cpp:
        (WebCore::InsertLineBreakCommand::doApply):
        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply):
        * editing/InsertTextCommand.cpp:
        (WebCore::InsertTextCommand::performTrivialReplace):
        (WebCore::InsertTextCommand::input):
        (WebCore::InsertTextCommand::insertTab):
        * editing/MoveSelectionCommand.cpp:
        (WebCore::MoveSelectionCommand::doApply):
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply):
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::debugRenderer):
        * editing/TextIterator.cpp:
        (WebCore::TextIterator::rangeFromLocationAndLength):
        * editing/TypingCommand.cpp:
        (WebCore::TypingCommand::deleteKeyPressed):
        (WebCore::TypingCommand::forwardDeleteKeyPressed):
        * editing/VisiblePosition.cpp:
        (WebCore::VisiblePosition::characterAfter):
        (WebCore::VisiblePosition::debugPosition):
        (WebCore::makeRange):
        (WebCore::setStart):
        (WebCore::setEnd):
        * editing/VisibleSelection.cpp:
        (WebCore::VisibleSelection::toNormalizedRange):
        (WebCore::makeSearchRange):
        (WebCore::VisibleSelection::debugPosition):
        (WebCore::VisibleSelection::showTreeForThis):
        * editing/htmlediting.cpp:
        (WebCore::comparePositions):
        (WebCore::rangeCompliantEquivalent):
        * editing/visible_units.cpp:
        (WebCore::previousBoundary):
        (WebCore::nextBoundary):
        (WebCore::startPositionForLine):
        (WebCore::startOfLine):
        (WebCore::endPositionForLine):
        (WebCore::nextLinePosition):
        (WebCore::startOfParagraph):
        (WebCore::endOfParagraph):
        (WebCore::logicalStartPositionForLine):
        (WebCore::logicalEndPositionForLine):
        * page/AccessibilityObject.cpp:
        (WebCore::updateAXLineStartForVisiblePosition):
        * page/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::indexForVisiblePosition):
        * page/DOMSelection.cpp:
        (WebCore::DOMSelection::anchorOffset):
        (WebCore::DOMSelection::focusOffset):
        (WebCore::DOMSelection::baseOffset):
        (WebCore::DOMSelection::extentOffset):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::handleMousePressEventSingleClick):
        * page/Frame.cpp:
        (WebCore::Frame::selectionLayoutChanged):
        * page/mac/AccessibilityObjectWrapper.mm:
        (textMarkerForVisiblePosition):
        (visiblePositionForTextMarker):
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::indexForVisiblePosition):
        * rendering/RenderTreeAsText.cpp:
        (WebCore::writeSelection):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1fce1e2a
......@@ -27,6 +27,128 @@
(WebCore::logicalEndOfLine): Added. Similar to endOfLine.
* editing/visible_units.h:
 
2009-04-29 Eric Seidel <eric@webkit.org>
Reviewed by Darin Adler.
Make m_offset private and change all callers to use deprecatedEditingOffset().
https://bugs.webkit.org/show_bug.cgi?id=25472
Per Darin's suggestion, this was just a simple search replace
of .m_offset with .deprecatedEditingOffset().
There was one change in InsertParagraphSeparatorCommand::doApply to use
Position::moveToOffset(0) instead of .m_offset = 0;
* dom/Position.cpp:
(WebCore::Position::rendersInDifferentPosition):
(WebCore::Position::leadingWhitespacePosition):
* dom/Position.h:
(WebCore::Position::deprecatedEditingOffset):
(WebCore::Position::moveToOffset):
(WebCore::operator==):
* dom/PositionIterator.h:
(WebCore::PositionIterator::PositionIterator):
* dom/Range.cpp:
(WebCore::Range::create):
(WebCore::Range::compareBoundaryPoints):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::applyInlineStyleToRange):
(WebCore::ApplyStyleCommand::removeInlineStyle):
(WebCore::ApplyStyleCommand::nodeFullySelected):
(WebCore::ApplyStyleCommand::nodeFullyUnselected):
(WebCore::ApplyStyleCommand::splitTextAtStartIfNeeded):
(WebCore::ApplyStyleCommand::splitTextAtEndIfNeeded):
(WebCore::ApplyStyleCommand::splitTextElementAtStartIfNeeded):
(WebCore::ApplyStyleCommand::splitTextElementAtEndIfNeeded):
(WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
(WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):
(WebCore::ApplyStyleCommand::joinChildTextNodes):
* editing/BreakBlockquoteCommand.cpp:
(WebCore::BreakBlockquoteCommand::doApply):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::insertNodeAt):
(WebCore::CompositeEditCommand::positionOutsideTabSpan):
(WebCore::CompositeEditCommand::rebalanceWhitespaceAt):
(WebCore::CompositeEditCommand::prepareWhitespaceAtPositionForSplit):
(WebCore::CompositeEditCommand::deleteInsignificantText):
(WebCore::CompositeEditCommand::moveParagraphs):
(WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph):
* editing/DeleteSelectionCommand.cpp:
(WebCore::updatePositionForNodeRemoval):
(WebCore::updatePositionForTextRemoval):
(WebCore::DeleteSelectionCommand::handleGeneralDelete):
(WebCore::DeleteSelectionCommand::fixupWhitespace):
* editing/Editor.cpp:
(WebCore::Editor::setComposition):
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::getCompositionSelection):
* editing/InsertLineBreakCommand.cpp:
(WebCore::InsertLineBreakCommand::doApply):
* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::doApply):
* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::performTrivialReplace):
(WebCore::InsertTextCommand::input):
(WebCore::InsertTextCommand::insertTab):
* editing/MoveSelectionCommand.cpp:
(WebCore::MoveSelectionCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
* editing/SelectionController.cpp:
(WebCore::SelectionController::debugRenderer):
* editing/TextIterator.cpp:
(WebCore::TextIterator::rangeFromLocationAndLength):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):
* editing/VisiblePosition.cpp:
(WebCore::VisiblePosition::characterAfter):
(WebCore::VisiblePosition::debugPosition):
(WebCore::makeRange):
(WebCore::setStart):
(WebCore::setEnd):
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::toNormalizedRange):
(WebCore::makeSearchRange):
(WebCore::VisibleSelection::debugPosition):
(WebCore::VisibleSelection::showTreeForThis):
* editing/htmlediting.cpp:
(WebCore::comparePositions):
(WebCore::rangeCompliantEquivalent):
* editing/visible_units.cpp:
(WebCore::previousBoundary):
(WebCore::nextBoundary):
(WebCore::startPositionForLine):
(WebCore::startOfLine):
(WebCore::endPositionForLine):
(WebCore::nextLinePosition):
(WebCore::startOfParagraph):
(WebCore::endOfParagraph):
(WebCore::logicalStartPositionForLine):
(WebCore::logicalEndPositionForLine):
* page/AccessibilityObject.cpp:
(WebCore::updateAXLineStartForVisiblePosition):
* page/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::indexForVisiblePosition):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::anchorOffset):
(WebCore::DOMSelection::focusOffset):
(WebCore::DOMSelection::baseOffset):
(WebCore::DOMSelection::extentOffset):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEventSingleClick):
* page/Frame.cpp:
(WebCore::Frame::selectionLayoutChanged):
* page/mac/AccessibilityObjectWrapper.mm:
(textMarkerForVisiblePosition):
(visiblePositionForTextMarker):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::indexForVisiblePosition):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeSelection):
2009-04-29 Eric Seidel <eric@webkit.org>
 
No review, rolling out a patch.
......@@ -765,11 +765,11 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
if (node()->hasTagName(brTag))
return false;
if (m_offset == pos.m_offset)
if (m_offset == pos.deprecatedEditingOffset())
return false;
if (!node()->isTextNode() && !pos.node()->isTextNode()) {
if (m_offset != pos.m_offset)
if (m_offset != pos.deprecatedEditingOffset())
return true;
}
}
......@@ -843,7 +843,7 @@ Position Position::leadingWhitespacePosition(EAffinity affinity, bool considerNo
Position prev = previousCharacterPosition(affinity);
if (prev != *this && prev.node()->inSameContainingBlockFlowElement(node()) && prev.node()->isTextNode()) {
String string = static_cast<Text *>(prev.node())->data();
UChar c = string[prev.m_offset];
UChar c = string[prev.deprecatedEditingOffset()];
if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c))
if (isEditablePosition(prev))
return prev;
......
......@@ -71,6 +71,12 @@ public:
return m_offset;
}
// New code should not use this function.
int deprecatedEditingOffset() const
{
return m_offset;
}
// These are convenience methods which are smart about whether the position is neighbor anchored or parent anchored
Node* computeNodeBeforePosition() const;
Node* computeNodeAfterPosition() const;
......@@ -90,6 +96,7 @@ public:
}
void moveToOffset(int offset)
{
// FIXME: This should eventually ASSERT(anchorType() == PositionIsOffsetInAnchor);
m_offset = offset;
}
......@@ -158,18 +165,17 @@ private:
Position nextCharacterPosition(EAffinity) const;
RefPtr<Node> m_anchorNode;
public:
// m_offset can be the offset inside m_anchorNode, or if editingIgnoresContent(m_anchorNode)
// returns true, then other places in editing will treat m_offset == 0 as "before the anchor"
// and m_offset > 0 as "after the anchor node". See rangeCompliantEquivalent for more info.
int m_offset; // FIXME: This should be made private.
int m_offset;
};
inline bool operator==(const Position& a, const Position& b)
{
// FIXME: In <div><img></div> [div, 0] != [img, 0] even though most of the
// editing code will treat them as identical.
return a.anchorNode() == b.anchorNode() && a.m_offset == b.m_offset;
return a.anchorNode() == b.anchorNode() && a.deprecatedEditingOffset() == b.deprecatedEditingOffset();
}
inline bool operator!=(const Position& a, const Position& b)
......
......@@ -45,8 +45,8 @@ public:
PositionIterator(const Position& pos)
: m_parent(pos.node())
, m_child(m_parent->childNode(pos.m_offset))
, m_offset(m_child ? 0 : pos.m_offset)
, m_child(m_parent->childNode(pos.deprecatedEditingOffset()))
, m_offset(m_child ? 0 : pos.deprecatedEditingOffset())
{
}
operator Position() const;
......
......@@ -90,7 +90,7 @@ PassRefPtr<Range> Range::create(PassRefPtr<Document> ownerDocument, PassRefPtr<N
PassRefPtr<Range> Range::create(PassRefPtr<Document> ownerDocument, const Position& start, const Position& end)
{
return adoptRef(new Range(ownerDocument, start.node(), start.m_offset, end.node(), end.m_offset));
return adoptRef(new Range(ownerDocument, start.node(), start.deprecatedEditingOffset(), end.node(), end.deprecatedEditingOffset()));
}
Range::~Range()
......@@ -528,7 +528,7 @@ short Range::compareBoundaryPoints(Node* containerA, int offsetA, Node* containe
short Range::compareBoundaryPoints(const Position& a, const Position& b)
{
return compareBoundaryPoints(a.node(), a.m_offset, b.node(), b.m_offset);
return compareBoundaryPoints(a.node(), a.deprecatedEditingOffset(), b.node(), b.deprecatedEditingOffset());
}
bool Range::boundaryPointsValid() const
......
......@@ -520,7 +520,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration
start = start.upstream(); // Move upstream to ensure we do not add redundant spans.
Node *startNode = start.node();
if (startNode->isTextNode() && start.m_offset >= caretMaxOffset(startNode)) // Move out of text node if range does not include its characters.
if (startNode->isTextNode() && start.deprecatedEditingOffset() >= caretMaxOffset(startNode)) // Move out of text node if range does not include its characters.
startNode = startNode->traverseNextNode();
// Store away font size before making any changes to the document.
......@@ -868,7 +868,7 @@ void ApplyStyleCommand::applyInlineStyleToRange(CSSMutableStyleDeclaration* styl
bool rangeIsEmpty = false;
if (start.m_offset >= caretMaxOffset(start.node())) {
if (start.deprecatedEditingOffset() >= caretMaxOffset(start.node())) {
node = node->traverseNextNode();
Position newStart = Position(node, 0);
if (!node || Range::compareBoundaryPoints(end, newStart) < 0)
......@@ -878,7 +878,7 @@ void ApplyStyleCommand::applyInlineStyleToRange(CSSMutableStyleDeclaration* styl
if (!rangeIsEmpty) {
// pastEndNode is the node after the last fully selected node.
Node* pastEndNode = end.node();
if (end.m_offset >= caretMaxOffset(end.node()))
if (end.deprecatedEditingOffset() >= caretMaxOffset(end.node()))
pastEndNode = end.node()->traverseNextSibling();
// FIXME: Callers should perform this operation on a Range that includes the br
// if they want style applied to the empty line.
......@@ -1239,14 +1239,14 @@ void ApplyStyleCommand::removeInlineStyle(PassRefPtr<CSSMutableStyleDeclaration>
if (s.node() == elem) {
// Since elem must have been fully selected, and it is at the start
// of the selection, it is clear we can set the new s offset to 0.
ASSERT(s.m_offset <= caretMinOffset(s.node()));
ASSERT(s.deprecatedEditingOffset() <= caretMinOffset(s.node()));
s = Position(next, 0);
}
if (e.node() == elem) {
// Since elem must have been fully selected, and it is at the end
// of the selection, it is clear we can set the new e offset to
// the max range offset of prev.
ASSERT(e.m_offset >= maxRangeOffset(e.node()));
ASSERT(e.deprecatedEditingOffset() >= maxRangeOffset(e.node()));
e = Position(prev, maxRangeOffset(prev));
}
}
......@@ -1267,7 +1267,7 @@ bool ApplyStyleCommand::nodeFullySelected(Node *node, const Position &start, con
ASSERT(node->isElementNode());
Position pos = Position(node, node->childNodeCount()).upstream();
return Range::compareBoundaryPoints(node, 0, start.node(), start.m_offset) >= 0 &&
return Range::compareBoundaryPoints(node, 0, start.node(), start.deprecatedEditingOffset()) >= 0 &&
Range::compareBoundaryPoints(pos, end) <= 0;
}
......@@ -1278,7 +1278,7 @@ bool ApplyStyleCommand::nodeFullyUnselected(Node *node, const Position &start, c
Position pos = Position(node, node->childNodeCount()).upstream();
bool isFullyBeforeStart = Range::compareBoundaryPoints(pos, start) < 0;
bool isFullyAfterEnd = Range::compareBoundaryPoints(node, 0, end.node(), end.m_offset) > 0;
bool isFullyAfterEnd = Range::compareBoundaryPoints(node, 0, end.node(), end.deprecatedEditingOffset()) > 0;
return isFullyBeforeStart || isFullyAfterEnd;
}
......@@ -1286,11 +1286,11 @@ bool ApplyStyleCommand::nodeFullyUnselected(Node *node, const Position &start, c
bool ApplyStyleCommand::splitTextAtStartIfNeeded(const Position &start, const Position &end)
{
if (start.node()->isTextNode() && start.m_offset > caretMinOffset(start.node()) && start.m_offset < caretMaxOffset(start.node())) {
int endOffsetAdjustment = start.node() == end.node() ? start.m_offset : 0;
if (start.node()->isTextNode() && start.deprecatedEditingOffset() > caretMinOffset(start.node()) && start.deprecatedEditingOffset() < caretMaxOffset(start.node())) {
int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
Text *text = static_cast<Text *>(start.node());
splitTextNode(text, start.m_offset);
updateStartEnd(Position(start.node(), 0), Position(end.node(), end.m_offset - endOffsetAdjustment));
splitTextNode(text, start.deprecatedEditingOffset());
updateStartEnd(Position(start.node(), 0), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
return true;
}
return false;
......@@ -1298,15 +1298,15 @@ bool ApplyStyleCommand::splitTextAtStartIfNeeded(const Position &start, const Po
bool ApplyStyleCommand::splitTextAtEndIfNeeded(const Position &start, const Position &end)
{
if (end.node()->isTextNode() && end.m_offset > caretMinOffset(end.node()) && end.m_offset < caretMaxOffset(end.node())) {
if (end.node()->isTextNode() && end.deprecatedEditingOffset() > caretMinOffset(end.node()) && end.deprecatedEditingOffset() < caretMaxOffset(end.node())) {
Text *text = static_cast<Text *>(end.node());
splitTextNode(text, end.m_offset);
splitTextNode(text, end.deprecatedEditingOffset());
Node *prevNode = text->previousSibling();
ASSERT(prevNode);
Node *startNode = start.node() == end.node() ? prevNode : start.node();
ASSERT(startNode);
updateStartEnd(Position(startNode, start.m_offset), Position(prevNode, caretMaxOffset(prevNode)));
updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(prevNode, caretMaxOffset(prevNode)));
return true;
}
return false;
......@@ -1314,12 +1314,12 @@ bool ApplyStyleCommand::splitTextAtEndIfNeeded(const Position &start, const Posi
bool ApplyStyleCommand::splitTextElementAtStartIfNeeded(const Position &start, const Position &end)
{
if (start.node()->isTextNode() && start.m_offset > caretMinOffset(start.node()) && start.m_offset < caretMaxOffset(start.node())) {
int endOffsetAdjustment = start.node() == end.node() ? start.m_offset : 0;
if (start.node()->isTextNode() && start.deprecatedEditingOffset() > caretMinOffset(start.node()) && start.deprecatedEditingOffset() < caretMaxOffset(start.node())) {
int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
Text *text = static_cast<Text *>(start.node());
splitTextNodeContainingElement(text, start.m_offset);
splitTextNodeContainingElement(text, start.deprecatedEditingOffset());
updateStartEnd(Position(start.node()->parentNode(), start.node()->nodeIndex()), Position(end.node(), end.m_offset - endOffsetAdjustment));
updateStartEnd(Position(start.node()->parentNode(), start.node()->nodeIndex()), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
return true;
}
return false;
......@@ -1327,15 +1327,15 @@ bool ApplyStyleCommand::splitTextElementAtStartIfNeeded(const Position &start, c
bool ApplyStyleCommand::splitTextElementAtEndIfNeeded(const Position &start, const Position &end)
{
if (end.node()->isTextNode() && end.m_offset > caretMinOffset(end.node()) && end.m_offset < caretMaxOffset(end.node())) {
if (end.node()->isTextNode() && end.deprecatedEditingOffset() > caretMinOffset(end.node()) && end.deprecatedEditingOffset() < caretMaxOffset(end.node())) {
Text *text = static_cast<Text *>(end.node());
splitTextNodeContainingElement(text, end.m_offset);
splitTextNodeContainingElement(text, end.deprecatedEditingOffset());
Node *prevNode = text->parent()->previousSibling()->lastChild();
ASSERT(prevNode);
Node *startNode = start.node() == end.node() ? prevNode : start.node();
ASSERT(startNode);
updateStartEnd(Position(startNode, start.m_offset), Position(prevNode->parent(), prevNode->nodeIndex() + 1));
updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(prevNode->parent(), prevNode->nodeIndex() + 1));
return true;
}
return false;
......@@ -1379,10 +1379,10 @@ static bool areIdenticalElements(Node *first, Node *second)
bool ApplyStyleCommand::mergeStartWithPreviousIfIdentical(const Position &start, const Position &end)
{
Node *startNode = start.node();
int startOffset = start.m_offset;
int startOffset = start.deprecatedEditingOffset();
if (isAtomicNode(start.node())) {
if (start.m_offset != 0)
if (start.deprecatedEditingOffset() != 0)
return false;
// note: prior siblings could be unrendered elements. it's silly to miss the
......@@ -1411,7 +1411,7 @@ bool ApplyStyleCommand::mergeStartWithPreviousIfIdentical(const Position &start,
int startOffsetAdjustment = startChild->nodeIndex();
int endOffsetAdjustment = startNode == end.node() ? startOffsetAdjustment : 0;
updateStartEnd(Position(startNode, startOffsetAdjustment), Position(end.node(), end.m_offset + endOffsetAdjustment));
updateStartEnd(Position(startNode, startOffsetAdjustment), Position(end.node(), end.deprecatedEditingOffset() + endOffsetAdjustment));
return true;
}
......@@ -1421,7 +1421,7 @@ bool ApplyStyleCommand::mergeStartWithPreviousIfIdentical(const Position &start,
bool ApplyStyleCommand::mergeEndWithNextIfIdentical(const Position &start, const Position &end)
{
Node *endNode = end.node();
int endOffset = end.m_offset;
int endOffset = end.deprecatedEditingOffset();
if (isAtomicNode(endNode)) {
if (endOffset < caretMaxOffset(endNode))
......@@ -1451,7 +1451,7 @@ bool ApplyStyleCommand::mergeEndWithNextIfIdentical(const Position &start, const
ASSERT(startNode);
int endOffset = nextChild ? nextChild->nodeIndex() : nextElement->childNodes()->length();
updateStartEnd(Position(startNode, start.m_offset), Position(nextElement, endOffset));
updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(nextElement, endOffset));
return true;
}
......@@ -1607,9 +1607,9 @@ void ApplyStyleCommand::joinChildTextNodes(Node *node, const Position &start, co
Text *childText = static_cast<Text *>(child);
Text *nextText = static_cast<Text *>(next);
if (next == start.node())
newStart = Position(childText, childText->length() + start.m_offset);
newStart = Position(childText, childText->length() + start.deprecatedEditingOffset());
if (next == end.node())
newEnd = Position(childText, childText->length() + end.m_offset);
newEnd = Position(childText, childText->length() + end.deprecatedEditingOffset());
String textToMove = nextText->data();
insertTextIntoNode(childText, childText->length(), textToMove);
removeNode(next);
......
......@@ -101,12 +101,12 @@ void BreakBlockquoteCommand::doApply()
// Split at pos if in the middle of a text node.
if (startNode->isTextNode()) {
Text* textNode = static_cast<Text*>(startNode);
if ((unsigned)pos.m_offset >= textNode->length()) {
if ((unsigned)pos.deprecatedEditingOffset() >= textNode->length()) {
startNode = startNode->traverseNextNode();
ASSERT(startNode);
} else if (pos.m_offset > 0)
splitTextNode(textNode, pos.m_offset);
} else if (pos.m_offset > 0) {
} else if (pos.deprecatedEditingOffset() > 0)
splitTextNode(textNode, pos.deprecatedEditingOffset());
} else if (pos.deprecatedEditingOffset() > 0) {
startNode = startNode->traverseNextNode();
ASSERT(startNode);
}
......
......@@ -157,7 +157,7 @@ void CompositeEditCommand::insertNodeAt(PassRefPtr<Node> insertChild, const Posi
// likewise for replaced elements, brs, etc.
Position p = rangeCompliantEquivalent(editingPosition);
Node* refChild = p.node();
int offset = p.m_offset;
int offset = p.deprecatedEditingOffset();
if (canHaveChildrenForEditing(refChild)) {
Node* child = refChild->firstChild();
......@@ -327,13 +327,13 @@ Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
Node* tabSpan = tabSpanNode(pos.node());
if (pos.m_offset <= caretMinOffset(pos.node()))
if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.node()))
return positionBeforeNode(tabSpan);
if (pos.m_offset >= caretMaxOffset(pos.node()))
if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()))
return positionAfterNode(tabSpan);
splitTextNodeContainingElement(static_cast<Text *>(pos.node()), pos.m_offset);
splitTextNodeContainingElement(static_cast<Text *>(pos.node()), pos.deprecatedEditingOffset());
return positionBeforeNode(tabSpan);
}
......@@ -392,7 +392,7 @@ void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position)
String text = textNode->data();
ASSERT(!text.isEmpty());
int offset = position.m_offset;
int offset = position.deprecatedEditingOffset();
// If neither text[offset] nor text[offset - 1] are some form of whitespace, do nothing.
if (!isWhitespace(text[offset])) {
offset--;
......@@ -449,9 +449,9 @@ void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
Position previous(previousVisiblePos.deepEquivalent());
if (isCollapsibleWhitespace(previousVisiblePos.characterAfter()) && previous.node()->isTextNode() && !previous.node()->hasTagName(brTag))
replaceTextInNode(static_cast<Text*>(previous.node()), previous.m_offset, 1, nonBreakingSpaceString());
replaceTextInNode(static_cast<Text*>(previous.node()), previous.deprecatedEditingOffset(), 1, nonBreakingSpaceString());
if (isCollapsibleWhitespace(visiblePos.characterAfter()) && position.node()->isTextNode() && !position.node()->hasTagName(brTag))
replaceTextInNode(static_cast<Text*>(position.node()), position.m_offset, 1, nonBreakingSpaceString());
replaceTextInNode(static_cast<Text*>(position.node()), position.deprecatedEditingOffset(), 1, nonBreakingSpaceString());
}
void CompositeEditCommand::rebalanceWhitespace()
......@@ -542,8 +542,8 @@ void CompositeEditCommand::deleteInsignificantText(const Position& start, const
next = node->traverseNextNode();
if (node->isTextNode()) {
Text* textNode = static_cast<Text*>(node);
int startOffset = node == start.node() ? start.m_offset : 0;
int endOffset = node == end.node() ? end.m_offset : textNode->length();
int startOffset = node == start.node() ? start.deprecatedEditingOffset() : 0;
int endOffset = node == end.node() ? end.deprecatedEditingOffset() : textNode->length();
deleteInsignificantText(textNode, startOffset, endOffset);
}
if (node == end.node())
......@@ -776,7 +776,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
// start and end can't be used directly to create a Range; they are "editing positions"
Position startRangeCompliant = rangeCompliantEquivalent(start);
Position endRangeCompliant = rangeCompliantEquivalent(end);
RefPtr<Range> range = Range::create(document(), startRangeCompliant.node(), startRangeCompliant.m_offset, endRangeCompliant.node(), endRangeCompliant.m_offset);
RefPtr<Range> range = Range::create(document(), startRangeCompliant.node(), startRangeCompliant.deprecatedEditingOffset(), endRangeCompliant.node(), endRangeCompliant.deprecatedEditingOffset());
// FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It
// shouldn't matter though, since moved paragraphs will usually be quite small.
......@@ -825,7 +825,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
if (textNode->length() == 1)
removeNodeAndPruneAncestors(node);
else
deleteTextFromNode(textNode, position.m_offset, 1);
deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1);
}
}
......@@ -949,7 +949,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph()
removeNode(caretPos.node());
prune(beforeBR.node());
} else {
ASSERT(caretPos.m_offset == 0);
ASSERT(caretPos.deprecatedEditingOffset() == 0);
Text* textNode = static_cast<Text*>(caretPos.node());
Node* parentNode = textNode->parentNode();
// The preserved newline must be the first thing in the node, since otherwise the previous
......
......@@ -314,8 +314,8 @@ static void updatePositionForNodeRemoval(Node* node, Position& position)
{
if (position.isNull())
return;
if (node->parent() == position.node() && node->nodeIndex() < (unsigned)position.m_offset)
position = Position(position.node(), position.m_offset - 1);
if (node->parent() == position.node() && node->nodeIndex() < (unsigned)position.deprecatedEditingOffset())
position = Position(position.node(), position.deprecatedEditingOffset() - 1);
if (position.node() == node || position.node()->isDescendantOf(node))
position = positionBeforeNode(node);
}
......@@ -381,9 +381,9 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node)
static void updatePositionForTextRemoval(Node* node, int offset, int count, Position& position)
{
if (position.node() == node) {
if (position.m_offset > offset + count)
position = Position(position.node(), position.m_offset - count);
else if (position.m_offset > offset)
if (position.deprecatedEditingOffset() > offset + count)
position = Position(position.node(), position.deprecatedEditingOffset() - count);
else if (position.deprecatedEditingOffset() > offset)
position = Position(position.node(), offset);
}
}
......@@ -401,7 +401,7 @@ void DeleteSelectionCommand::deleteTextFromNode(PassRefPtr<Text> node, unsigned
void DeleteSelectionCommand::handleGeneralDelete()
{
int startOffset = m_upstreamStart.m_offset;
int startOffset = m_upstreamStart.deprecatedEditingOffset();
Node* startNode = m_upstreamStart.node();
// Never remove the start block unless it's a table, in which case we won't merge content in.
......@@ -430,13 +430,13 @@ void DeleteSelectionCommand::handleGeneralDelete()
if (!startNode->renderer() || (startOffset == 0 && m_downstreamEnd.atLastEditingPositionForNode())) {
// just delete
removeNode(startNode);
} else if (m_downstreamEnd.m_offset - startOffset > 0) {
} else if (m_downstreamEnd.deprecatedEditingOffset() - startOffset > 0) {
if (startNode->isTextNode()) {
// in a text node that needs to be trimmed
Text* text = static_cast<Text*>(startNode);
deleteTextFromNode(text, startOffset, m_downstreamEnd.m_offset - startOffset);
deleteTextFromNode(text, startOffset, m_downstreamEnd.deprecatedEditingOffset() - startOffset);
} else {
removeChildrenInRange(startNode, startOffset, m_downstreamEnd.m_offset);
removeChildrenInRange(startNode, startOffset, m_downstreamEnd.deprecatedEditingOffset());
m_endingPosition = m_upstreamStart;
}
}
......@@ -467,14 +467,14 @@ void DeleteSelectionCommand::handleGeneralDelete()
// if we just removed a node from the end container, update end position so the
// check above will work
if (node->parentNode() == m_downstreamEnd.node()) {
ASSERT(node->nodeIndex() < (unsigned)m_downstreamEnd.m_offset);
m_downstreamEnd = Position(m_downstreamEnd.node(), m_downstreamEnd.m_offset - 1);
ASSERT(node->nodeIndex() < (unsigned)m_downstreamEnd.deprecatedEditingOffset());
m_downstreamEnd = Position(m_downstreamEnd.node(), m_downstreamEnd.deprecatedEditingOffset() - 1);
}
removeNode(node.get());
node = nextNode.get();
} else {
Node* n = node->lastDescendant();
if (m_downstreamEnd.node() == n && m_downstreamEnd.m_offset >= caretMaxOffset(n)) {
if (m_downstreamEnd.node() == n && m_downstreamEnd.deprecatedEditingOffset() >= caretMaxOffset(n)) {
removeNode(node.get());
node = 0;
} else
......@@ -482,7 +482,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
}
}
if (m_downstreamEnd.node() != startNode && !m_upstreamStart.node()->isDescendantOf(m_downstreamEnd.node()) && m_downstreamEnd.node()->inDocument() && m_downstreamEnd.m_offset >= caretMinOffset(m_downstreamEnd.node())) {
if (m_downstreamEnd.node() != startNode && !m_upstreamStart.node()->isDescendantOf(m_downstreamEnd.node()) && m_downstreamEnd.node()->inDocument() && m_downstreamEnd.deprecatedEditingOffset() >= caretMinOffset(m_downstreamEnd.node())) {
if (m_downstreamEnd.atLastEditingPositionForNode() && !canHaveChildrenForEditing(m_downstreamEnd.node())) {
// The node itself is fully selected, not just its contents. Delete it.
removeNode(m_downstreamEnd.node());
......@@ -490,8 +490,8 @@ void DeleteSelectionCommand::handleGeneralDelete()
if (m_downstreamEnd.node()->isTextNode()) {
// in a text node that needs to be trimmed
Text *text = static_cast<Text *>(m_downstreamEnd.node());