Commit 62b16970 authored by rniwa@webkit.org's avatar rniwa@webkit.org

2011-02-17 Ryosuke Niwa <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Rename Position::node() to Position::deprecatedNode()
        https://bugs.webkit.org/show_bug.cgi?id=54622

        Done the rename. All calls to node() are replaced by calls to deprecatedNode().

        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::setComposition): Check the nullity of startContainer() instead of startPosition()->node().
        (WebKit::WebViewImpl::confirmComposition): Ditto.
        (WebKit::WebViewImpl::textInputType):
        (WebKit::WebViewImpl::caretOrSelectionBounds):
2011-02-17  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Rename Position::node() to Position::deprecatedNode()
        https://bugs.webkit.org/show_bug.cgi?id=54622

        Replaced the call to node() by a call to containerNode() because the returned node is
        used to determine whether or not the selected contents are editable and such a check
        must be done against the container node.

        * WebCoreSupport/EditorClientQt.cpp:
        (WebCore::EditorClientQt::handleKeyboardEvent):
2011-02-17  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Rename Position::node() to Position::deprecatedNode()
        https://bugs.webkit.org/show_bug.cgi?id=54622

        Done the rename. All calls to node() are replaced by calls to deprecatedNode().

        * webkit/webkitwebview.cpp:
        (webkit_web_view_popup_menu_handler):
2011-02-17  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Rename Position::node() to Position::deprecatedNode()
        https://bugs.webkit.org/show_bug.cgi?id=54622

        * WebView/WebFrame.mm:
        (-[WebFrame _smartDeleteRangeForProposedRange:]):
2011-02-17  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Rename Position::node() to Position::deprecatedNode()
        https://bugs.webkit.org/show_bug.cgi?id=54622

        Replaced the call to node() by a call to containerNode() because the returned node is
        used to determine whether or not the selected contents are editable and such a check
        must be done against the container node.

        * WebCoreSupport/EditorClientHaiku.cpp:
        (WebCore::EditorClientHaiku::handleKeyboardEvent):
2011-02-17  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Rename Position::node() to Position::deprecatedNode()
        https://bugs.webkit.org/show_bug.cgi?id=54622

        Done the rename. All calls to node() are replaced by calls to deprecatedNode() except when
        calls were of the form node()->document() and node()->inDocument() in which case they were
        replaced by anchorNode()->document() and anchorNode()->inDocument() respectively.

        * WebCore.exp.in: Added Position::containerNode.

        The rest abbreviated for simplicity. Please see svn log.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 27659194
2011-02-17 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Kent Tamura.
Rename Position::node() to Position::deprecatedNode()
https://bugs.webkit.org/show_bug.cgi?id=54622
Done the rename. All calls to node() are replaced by calls to deprecatedNode() except when
calls were of the form node()->document() and node()->inDocument() in which case they were
replaced by anchorNode()->document() and anchorNode()->inDocument() respectively.
* WebCore.exp.in: Added Position::containerNode.
The rest abbreviated for simplicity. Please see svn log.
2011-02-20 Gavin Barraclough <barraclough@apple.com>
Build fix (remove includes).
......
......@@ -1226,6 +1226,7 @@ __ZNK7WebCore8Document6domainEv
__ZNK7WebCore8IntPointcv7CGPointEv
__ZNK7WebCore8IntPointcv8_NSPointEv
__ZNK7WebCore8Position10downstreamENS_27EditingBoundaryCrossingRuleE
__ZNK7WebCore8Position13containerNodeEv
__ZNK7WebCore8Position24parentAnchoredEquivalentEv
__ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb
__ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb
......
......@@ -578,7 +578,7 @@ VisiblePosition AXObjectCache::visiblePositionForTextMarkerData(TextMarkerData&
if (deepPos.isNull())
return VisiblePosition();
RenderObject* renderer = deepPos.node()->renderer();
RenderObject* renderer = deepPos.deprecatedNode()->renderer();
if (!renderer)
return VisiblePosition();
......@@ -586,7 +586,7 @@ VisiblePosition AXObjectCache::visiblePositionForTextMarkerData(TextMarkerData&
if (!cache->isIDinUse(textMarkerData.axID))
return VisiblePosition();
if (deepPos.node() != textMarkerData.node || deepPos.deprecatedEditingOffset() != textMarkerData.offset)
if (deepPos.deprecatedNode() != textMarkerData.node || deepPos.deprecatedEditingOffset() != textMarkerData.offset)
return VisiblePosition();
return visiblePos;
......@@ -602,7 +602,7 @@ void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerD
return;
Position deepPos = visiblePos.deepEquivalent();
Node* domNode = deepPos.node();
Node* domNode = deepPos.deprecatedNode();
ASSERT(domNode);
if (!domNode)
return;
......
......@@ -222,9 +222,9 @@ static VisiblePosition updateAXLineStartForVisiblePosition(const VisiblePosition
if (tempPosition.isNull())
break;
p = tempPosition.deepEquivalent();
if (!p.node())
if (!p.deprecatedNode())
break;
renderer = p.node()->renderer();
renderer = p.deprecatedNode()->renderer();
if (!renderer || (renderer->isRenderBlock() && !p.deprecatedEditingOffset()))
break;
InlineBox* box;
......@@ -318,7 +318,7 @@ VisiblePositionRange AccessibilityObject::paragraphForPosition(const VisiblePosi
static VisiblePosition startOfStyleRange(const VisiblePosition visiblePos)
{
RenderObject* renderer = visiblePos.deepEquivalent().node()->renderer();
RenderObject* renderer = visiblePos.deepEquivalent().deprecatedNode()->renderer();
RenderObject* startRenderer = renderer;
RenderStyle* style = renderer->style();
......@@ -341,7 +341,7 @@ static VisiblePosition startOfStyleRange(const VisiblePosition visiblePos)
static VisiblePosition endOfStyleRange(const VisiblePosition& visiblePos)
{
RenderObject* renderer = visiblePos.deepEquivalent().node()->renderer();
RenderObject* renderer = visiblePos.deepEquivalent().deprecatedNode()->renderer();
RenderObject* endRenderer = renderer;
RenderStyle* style = renderer->style();
......@@ -649,7 +649,7 @@ AccessibilityObject* AccessibilityObject::accessibilityObjectForPosition(const V
if (visiblePos.isNull())
return 0;
RenderObject* obj = visiblePos.deepEquivalent().node()->renderer();
RenderObject* obj = visiblePos.deepEquivalent().deprecatedNode()->renderer();
if (!obj)
return 0;
......
......@@ -2482,13 +2482,13 @@ int AccessibilityRenderObject::indexForVisiblePosition(const VisiblePosition& po
return 0;
Position indexPosition = pos.deepEquivalent();
if (!indexPosition.node() || indexPosition.node()->rootEditableElement() != node)
if (!indexPosition.anchorNode() || indexPosition.anchorNode()->rootEditableElement() != node)
return 0;
ExceptionCode ec = 0;
RefPtr<Range> range = Range::create(m_renderer->document());
range->setStart(node, 0, ec);
range->setEnd(indexPosition.node(), indexPosition.deprecatedEditingOffset(), ec);
range->setEnd(indexPosition.anchorNode(), indexPosition.deprecatedEditingOffset(), ec);
return TextIterator::rangeLength(range.get());
}
......@@ -2621,7 +2621,7 @@ int AccessibilityRenderObject::index(const VisiblePosition& position) const
if (!isTextControl())
return -1;
Node* node = position.deepEquivalent().node();
Node* node = position.deepEquivalent().deprecatedNode();
if (!node)
return -1;
......
......@@ -1223,7 +1223,7 @@ static gint webkit_accessible_text_get_caret_offset(AtkText* text)
if (!coreObject->isAccessibilityRenderObject())
return 0;
Node* focusedNode = coreObject->selection().end().node();
Node* focusedNode = coreObject->selection().end().deprecatedNode();
if (!focusedNode)
return 0;
......
......@@ -230,7 +230,7 @@ PassRefPtr<CSSComputedStyleDeclaration> Position::computedStyle() const
Position Position::previous(PositionMoveType moveType) const
{
Node* n = node();
Node* n = deprecatedNode();
if (!n)
return *this;
......@@ -269,7 +269,7 @@ Position Position::next(PositionMoveType moveType) const
{
ASSERT(moveType != BackwardDeletion);
Node* n = node();
Node* n = deprecatedNode();
if (!n)
return *this;
......@@ -323,7 +323,7 @@ bool Position::atLastEditingPositionForNode() const
{
if (isNull())
return true;
return m_offset >= lastOffsetForEditing(node());
return m_offset >= lastOffsetForEditing(deprecatedNode());
}
// A position is considered at editing boundary if one of the following is true:
......@@ -336,15 +336,15 @@ bool Position::atLastEditingPositionForNode() const
bool Position::atEditingBoundary() const
{
Position nextPosition = downstream(CanCrossEditingBoundary);
if (atFirstEditingPositionForNode() && nextPosition.isNotNull() && !nextPosition.node()->isContentEditable())
if (atFirstEditingPositionForNode() && nextPosition.isNotNull() && !nextPosition.deprecatedNode()->isContentEditable())
return true;
Position prevPosition = upstream(CanCrossEditingBoundary);
if (atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosition.node()->isContentEditable())
if (atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosition.deprecatedNode()->isContentEditable())
return true;
return nextPosition.isNotNull() && !nextPosition.node()->isContentEditable()
&& prevPosition.isNotNull() && !prevPosition.node()->isContentEditable();
return nextPosition.isNotNull() && !nextPosition.deprecatedNode()->isContentEditable()
&& prevPosition.isNotNull() && !prevPosition.deprecatedNode()->isContentEditable();
}
Node* Position::parentEditingBoundary() const
......@@ -368,26 +368,26 @@ bool Position::atStartOfTree() const
{
if (isNull())
return true;
return !node()->parentNode() && m_offset <= 0;
return !deprecatedNode()->parentNode() && m_offset <= 0;
}
bool Position::atEndOfTree() const
{
if (isNull())
return true;
return !node()->parentNode() && m_offset >= lastOffsetForEditing(node());
return !deprecatedNode()->parentNode() && m_offset >= lastOffsetForEditing(deprecatedNode());
}
int Position::renderedOffset() const
{
if (!node()->isTextNode())
if (!deprecatedNode()->isTextNode())
return m_offset;
if (!node()->renderer())
if (!deprecatedNode()->renderer())
return m_offset;
int result = 0;
RenderText *textRenderer = toRenderText(node()->renderer());
RenderText* textRenderer = toRenderText(deprecatedNode()->renderer());
for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
int start = box->start();
int end = box->start() + box->len();
......@@ -408,7 +408,7 @@ Position Position::previousCharacterPosition(EAffinity affinity) const
if (isNull())
return Position();
Node *fromRootEditableElement = node()->rootEditableElement();
Node* fromRootEditableElement = deprecatedNode()->rootEditableElement();
bool atStartOfLine = isStartOfLine(VisiblePosition(*this, affinity));
bool rendered = isCandidate();
......@@ -417,7 +417,7 @@ Position Position::previousCharacterPosition(EAffinity affinity) const
while (!currentPos.atStartOfTree()) {
currentPos = currentPos.previous();
if (currentPos.node()->rootEditableElement() != fromRootEditableElement)
if (currentPos.deprecatedNode()->rootEditableElement() != fromRootEditableElement)
return *this;
if (atStartOfLine || !rendered) {
......@@ -436,7 +436,7 @@ Position Position::nextCharacterPosition(EAffinity affinity) const
if (isNull())
return Position();
Node *fromRootEditableElement = node()->rootEditableElement();
Node* fromRootEditableElement = deprecatedNode()->rootEditableElement();
bool atEndOfLine = isEndOfLine(VisiblePosition(*this, affinity));
bool rendered = isCandidate();
......@@ -445,7 +445,7 @@ Position Position::nextCharacterPosition(EAffinity affinity) const
while (!currentPos.atEndOfTree()) {
currentPos = currentPos.next();
if (currentPos.node()->rootEditableElement() != fromRootEditableElement)
if (currentPos.deprecatedNode()->rootEditableElement() != fromRootEditableElement)
return *this;
if (atEndOfLine || !rendered) {
......@@ -507,7 +507,7 @@ static bool isStreamer(const PositionIterator& pos)
// in boundary, where endsOfNodeAreVisuallyDistinctPositions(boundary) is true.
Position Position::upstream(EditingBoundaryCrossingRule rule) const
{
Node* startNode = node();
Node* startNode = deprecatedNode();
if (!startNode)
return Position();
......@@ -628,7 +628,7 @@ Position Position::upstream(EditingBoundaryCrossingRule rule) const
// in boundary after the last candidate, where endsOfNodeAreVisuallyDistinctPositions(boundary).
Position Position::downstream(EditingBoundaryCrossingRule rule) const
{
Node* startNode = node();
Node* startNode = deprecatedNode();
if (!startNode)
return Position();
......@@ -764,7 +764,7 @@ bool Position::isCandidate() const
if (isNull())
return false;
RenderObject *renderer = node()->renderer();
RenderObject* renderer = deprecatedNode()->renderer();
if (!renderer)
return false;
......@@ -772,13 +772,13 @@ bool Position::isCandidate() const
return false;
if (renderer->isBR())
return !m_offset && !nodeIsUserSelectNone(node()->parentNode());
return !m_offset && !nodeIsUserSelectNone(deprecatedNode()->parentNode());
if (renderer->isText())
return !nodeIsUserSelectNone(node()) && inRenderedText();
return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText();
if (isTableElement(node()) || editingIgnoresContent(node()))
return (atFirstEditingPositionForNode() || atLastEditingPositionForNode()) && !nodeIsUserSelectNone(node()->parentNode());
if (isTableElement(deprecatedNode()) || editingIgnoresContent(deprecatedNode()))
return (atFirstEditingPositionForNode() || atLastEditingPositionForNode()) && !nodeIsUserSelectNone(deprecatedNode()->parentNode());
if (m_anchorNode->hasTagName(htmlTag))
return false;
......@@ -786,21 +786,21 @@ bool Position::isCandidate() const
if (renderer->isBlockFlow()) {
if (toRenderBlock(renderer)->height() || m_anchorNode->hasTagName(bodyTag)) {
if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer))
return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(node());
return m_anchorNode->isContentEditable() && !Position::nodeIsUserSelectNone(node()) && atEditingBoundary();
return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(deprecatedNode());
return m_anchorNode->isContentEditable() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
}
} else
return m_anchorNode->isContentEditable() && !Position::nodeIsUserSelectNone(node()) && atEditingBoundary();
return m_anchorNode->isContentEditable() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
return false;
}
bool Position::inRenderedText() const
{
if (isNull() || !node()->isTextNode())
if (isNull() || !deprecatedNode()->isTextNode())
return false;
RenderObject *renderer = node()->renderer();
RenderObject* renderer = deprecatedNode()->renderer();
if (!renderer)
return false;
......@@ -833,10 +833,10 @@ static unsigned caretMaxRenderedOffset(const Node* n)
bool Position::isRenderedCharacter() const
{
if (isNull() || !node()->isTextNode())
if (isNull() || !deprecatedNode()->isTextNode())
return false;
RenderObject* renderer = node()->renderer();
RenderObject* renderer = deprecatedNode()->renderer();
if (!renderer)
return false;
......@@ -860,11 +860,11 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
if (isNull() || pos.isNull())
return false;
RenderObject *renderer = node()->renderer();
RenderObject* renderer = deprecatedNode()->renderer();
if (!renderer)
return false;
RenderObject *posRenderer = pos.node()->renderer();
RenderObject* posRenderer = pos.deprecatedNode()->renderer();
if (!posRenderer)
return false;
......@@ -872,32 +872,32 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
posRenderer->style()->visibility() != VISIBLE)
return false;
if (node() == pos.node()) {
if (node()->hasTagName(brTag))
if (deprecatedNode() == pos.deprecatedNode()) {
if (deprecatedNode()->hasTagName(brTag))
return false;
if (m_offset == pos.deprecatedEditingOffset())
return false;
if (!node()->isTextNode() && !pos.node()->isTextNode()) {
if (!deprecatedNode()->isTextNode() && !pos.deprecatedNode()->isTextNode()) {
if (m_offset != pos.deprecatedEditingOffset())
return true;
}
}
if (node()->hasTagName(brTag) && pos.isCandidate())
if (deprecatedNode()->hasTagName(brTag) && pos.isCandidate())
return true;
if (pos.node()->hasTagName(brTag) && isCandidate())
if (pos.deprecatedNode()->hasTagName(brTag) && isCandidate())
return true;
if (node()->enclosingBlockFlowElement() != pos.node()->enclosingBlockFlowElement())
if (deprecatedNode()->enclosingBlockFlowElement() != pos.deprecatedNode()->enclosingBlockFlowElement())
return true;
if (node()->isTextNode() && !inRenderedText())
if (deprecatedNode()->isTextNode() && !inRenderedText())
return false;
if (pos.node()->isTextNode() && !pos.inRenderedText())
if (pos.deprecatedNode()->isTextNode() && !pos.inRenderedText())
return false;
int thisRenderedOffset = renderedOffset();
......@@ -916,8 +916,8 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
LOG(Editing, "thisRenderedOffset: %d\n", thisRenderedOffset);
LOG(Editing, "posRenderer: %p [%p]\n", posRenderer, b2);
LOG(Editing, "posRenderedOffset: %d\n", posRenderedOffset);
LOG(Editing, "node min/max: %d:%d\n", caretMinOffset(node()), caretMaxRenderedOffset(node()));
LOG(Editing, "pos node min/max: %d:%d\n", caretMinOffset(pos.node()), caretMaxRenderedOffset(pos.node()));
LOG(Editing, "node min/max: %d:%d\n", caretMinOffset(deprecatedNode()), caretMaxRenderedOffset(deprecatedNode()));
LOG(Editing, "pos node min/max: %d:%d\n", caretMinOffset(pos.deprecatedNode()), caretMaxRenderedOffset(pos.deprecatedNode()));
LOG(Editing, "----------------------------------------------------------------------\n");
if (!b1 || !b2) {
......@@ -928,13 +928,13 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
return true;
}
if (nextRenderedEditable(node()) == pos.node() &&
thisRenderedOffset == (int)caretMaxRenderedOffset(node()) && posRenderedOffset == 0) {
if (nextRenderedEditable(deprecatedNode()) == pos.deprecatedNode()
&& thisRenderedOffset == (int)caretMaxRenderedOffset(deprecatedNode()) && !posRenderedOffset) {
return false;
}
if (previousRenderedEditable(node()) == pos.node() &&
thisRenderedOffset == 0 && posRenderedOffset == (int)caretMaxRenderedOffset(pos.node())) {
if (previousRenderedEditable(deprecatedNode()) == pos.deprecatedNode()
&& !thisRenderedOffset && posRenderedOffset == (int)caretMaxRenderedOffset(pos.deprecatedNode())) {
return false;
}
......@@ -948,12 +948,12 @@ Position Position::leadingWhitespacePosition(EAffinity affinity, bool considerNo
if (isNull())
return Position();
if (upstream().node()->hasTagName(brTag))
if (upstream().deprecatedNode()->hasTagName(brTag))
return Position();
Position prev = previousCharacterPosition(affinity);
if (prev != *this && prev.node()->inSameContainingBlockFlowElement(node()) && prev.node()->isTextNode()) {
String string = static_cast<Text *>(prev.node())->data();
if (prev != *this && prev.deprecatedNode()->inSameContainingBlockFlowElement(deprecatedNode()) && prev.deprecatedNode()->isTextNode()) {
String string = static_cast<Text *>(prev.deprecatedNode())->data();
UChar c = string[prev.deprecatedEditingOffset()];
if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c))
if (isEditablePosition(prev))
......@@ -1045,11 +1045,11 @@ static Position upstreamIgnoringEditingBoundaries(Position position)
void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDirection, InlineBox*& inlineBox, int& caretOffset) const
{
caretOffset = m_offset;
RenderObject* renderer = node()->renderer();
RenderObject* renderer = deprecatedNode()->renderer();
if (!renderer->isText()) {
inlineBox = 0;
if (canHaveChildrenForEditing(node()) && renderer->isBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) {
if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) {
// Try a visually equivalent position with possibly opposite editability. This helps in case |this| is in
// an editable block but surrounded by non-editable positions. It acts to negate the logic at the beginning
// of RenderObject::createVisiblePosition().
......@@ -1211,7 +1211,7 @@ void Position::debugPosition(const char* msg) const
if (isNull())
fprintf(stderr, "Position [%s]: null\n", msg);
else
fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, node()->nodeName().utf8().data(), node(), m_offset);
fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, deprecatedNode()->nodeName().utf8().data(), deprecatedNode(), m_offset);
}
#ifndef NDEBUG
......@@ -1227,7 +1227,7 @@ void Position::formatForDebugger(char* buffer, unsigned length) const
result += "offset ";
result += String::number(m_offset);
result += " of ";
node()->formatForDebugger(s, sizeof(s));
deprecatedNode()->formatForDebugger(s, sizeof(s));
result += s;
}
......@@ -1254,8 +1254,8 @@ void Position::showAnchorTypeAndOffset() const
void Position::showTreeForThis() const
{
if (node()) {
node()->showTreeForThis();
if (anchorNode()) {
anchorNode()->showTreeForThis();
showAnchorTypeAndOffset();
}
}
......
......@@ -105,7 +105,7 @@ public:
// FIXME: Callers should be moved off of node(), node() is not always the container for this position.
// For nodes which editingIgnoresContent(node()) returns true, positions like [ignoredNode, 0]
// will be treated as before ignoredNode (thus node() is really after the position, not containing it).
Node* node() const { return m_anchorNode.get(); }
Node* deprecatedNode() const { return m_anchorNode.get(); }
// These should only be used for PositionIsOffsetInAnchor positions, unless
// the position is a legacy editing position.
......
......@@ -134,11 +134,11 @@ void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSel
// indentIntoBlockquote could move more than one paragraph if the paragraph
// is in a list item or a table. As a result, endAfterSelection could refer to a position
// no longer in the document.
if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent().node()->inDocument())
if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent().anchorNode()->inDocument())
break;
// Sanity check: Make sure our moveParagraph calls didn't remove endOfNextParagraph.deepEquivalent().node()
// Sanity check: Make sure our moveParagraph calls didn't remove endOfNextParagraph.deepEquivalent().deprecatedNode()
// If somehow we did, return to prevent crashes.
if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent().node()->inDocument()) {
if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent().anchorNode()->inDocument()) {
ASSERT_NOT_REACHED();
return;
}
......@@ -182,8 +182,8 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
RenderStyle* startStyle = renderStyleOfEnclosingTextNode(start);
bool isStartAndEndOnSameNode = false;
if (startStyle) {
isStartAndEndOnSameNode = renderStyleOfEnclosingTextNode(end) && start.node() == end.node();
bool isStartAndEndOfLastParagraphOnSameNode = renderStyleOfEnclosingTextNode(m_endOfLastParagraph) && start.node() == m_endOfLastParagraph.node();
isStartAndEndOnSameNode = renderStyleOfEnclosingTextNode(end) && start.deprecatedNode() == end.deprecatedNode();
bool isStartAndEndOfLastParagraphOnSameNode = renderStyleOfEnclosingTextNode(m_endOfLastParagraph) && start.deprecatedNode() == m_endOfLastParagraph.deprecatedNode();
// Avoid obtanining the start of next paragraph for start
if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNewLineAtPosition(start.previous()) && start.offsetInContainerNode() > 0)
......@@ -192,15 +192,15 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
// If start is in the middle of a text node, split.
if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) {
int startOffset = start.offsetInContainerNode();
splitTextNode(static_cast<Text*>(start.node()), startOffset);
start = positionBeforeNode(start.node());
splitTextNode(static_cast<Text*>(start.deprecatedNode()), startOffset);
start = positionBeforeNode(start.deprecatedNode());
if (isStartAndEndOnSameNode) {
ASSERT(end.offsetInContainerNode() >= startOffset);
end = Position(end.node(), end.offsetInContainerNode() - startOffset, Position::PositionIsOffsetInAnchor);
end = Position(end.deprecatedNode(), end.offsetInContainerNode() - startOffset, Position::PositionIsOffsetInAnchor);
}
if (isStartAndEndOfLastParagraphOnSameNode) {
ASSERT(m_endOfLastParagraph.offsetInContainerNode() >= startOffset);
m_endOfLastParagraph = Position(m_endOfLastParagraph.node(), m_endOfLastParagraph.offsetInContainerNode() - startOffset,
m_endOfLastParagraph = Position(m_endOfLastParagraph.deprecatedNode(), m_endOfLastParagraph.offsetInContainerNode() - startOffset,
Position::PositionIsOffsetInAnchor);
}
}
......@@ -208,13 +208,13 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
RenderStyle* endStyle = renderStyleOfEnclosingTextNode(end);
if (endStyle) {
bool isEndAndEndOfLastParagraphOnSameNode = renderStyleOfEnclosingTextNode(m_endOfLastParagraph) && end.node() == m_endOfLastParagraph.node();
bool isEndAndEndOfLastParagraphOnSameNode = renderStyleOfEnclosingTextNode(m_endOfLastParagraph) && end.deprecatedNode() == m_endOfLastParagraph.deprecatedNode();
// Include \n at the end of line if we're at an empty paragraph
if (endStyle->preserveNewline() && start == end
&& end.offsetInContainerNode() < end.containerNode()->maxCharacterOffset()) {
int endOffset = end.offsetInContainerNode();
if (!isNewLineAtPosition(end.previous()) && isNewLineAtPosition(end))
end = Position(end.node(), endOffset + 1, Position::PositionIsOffsetInAnchor);
end = Position(end.deprecatedNode(), endOffset + 1, Position::PositionIsOffsetInAnchor);
if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNode() >= m_endOfLastParagraph.offsetInContainerNode())
m_endOfLastParagraph = end;
}
......@@ -222,17 +222,17 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
// If end is in the middle of a text node, split.
if (!endStyle->collapseWhiteSpace() && end.offsetInContainerNode()
&& end.offsetInContainerNode() < end.containerNode()->maxCharacterOffset()) {
splitTextNode(static_cast<Text*>(end.node()), end.offsetInContainerNode());
splitTextNode(static_cast<Text*>(end.deprecatedNode()), end.offsetInContainerNode());
if (isStartAndEndOnSameNode)
start = positionBeforeNode(end.node()->previousSibling());
start = positionBeforeNode(end.deprecatedNode()->previousSibling());
if (isEndAndEndOfLastParagraphOnSameNode) {
if (m_endOfLastParagraph.offsetInContainerNode() == end.offsetInContainerNode())
m_endOfLastParagraph = lastPositionInNode(end.node()->previousSibling());
m_endOfLastParagraph = lastPositionInNode(end.deprecatedNode()->previousSibling());
else
m_endOfLastParagraph = Position(end.node(), m_endOfLastParagraph.offsetInContainerNode() - end.offsetInContainerNode(),
m_endOfLastParagraph = Position(end.deprecatedNode(), m_endOfLastParagraph.offsetInContainerNode() - end.offsetInContainerNode(),
Position::PositionIsOffsetInAnchor);
}
end = lastPositionInNode(end.node()->previousSibling());
end = lastPositionInNode(end.deprecatedNode()->previousSibling());
}
}
}
......
......@@ -141,7 +141,7 @@ StyleChange::StyleChange(CSSStyleDeclaration* style, const Position& position)
void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position& position)
{
Document* document = position.node() ? position.node()->document() : 0;
Document* document = position.anchorNode() ? position.anchorNode()->document() : 0;
if (!document || !document->frame())
return;
......@@ -153,7 +153,7 @@ void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position& po
extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedFontDefaultSize());
// Changing the whitespace style in a tab span would collapse the tab into a space.
if (isTabSpanTextNode(position.node()) || isTabSpanNode((position.node())))
if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.deprecatedNode())))
mutableStyle->removeProperty(CSSPropertyWhiteSpace);
// If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle.
......@@ -581,7 +581,7 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style)
// Save and restore the selection endpoints using their indices in the document, since
// addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoints.
// Calculate start and end indices from the start of the tree that they're in.
Node* scope = highestAncestor(visibleStart.deepEquivalent().node());
Node* scope = highestAncestor(visibleStart.deepEquivalent().deprecatedNode());
RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(scope), visibleStart.deepEquivalent().parentAnchoredEquivalent());
RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent());
int startIndex = TextIterator::rangeLength(startRange.get(), true);
......@@ -593,7 +593,7 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style)
while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) {
StyleChange styleChange(style->style(), paragraphStart.deepEquivalent());
if (styleChange.cssStyle().length() || m_r