OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 { | 286 { |
287 ASSERT(index >= 0); | 287 ASSERT(index >= 0); |
288 if (index == 0) { | 288 if (index == 0) { |
289 Node* node = NodeTraversal::next(*innerEditor, innerEditor); | 289 Node* node = NodeTraversal::next(*innerEditor, innerEditor); |
290 if (node && node->isTextNode()) | 290 if (node && node->isTextNode()) |
291 return Position(node, 0, Position::PositionIsOffsetInAnchor); | 291 return Position(node, 0, Position::PositionIsOffsetInAnchor); |
292 return Position(innerEditor, 0, Position::PositionIsOffsetInAnchor); | 292 return Position(innerEditor, 0, Position::PositionIsOffsetInAnchor); |
293 } | 293 } |
294 int remainingCharactersToMoveForward = index; | 294 int remainingCharactersToMoveForward = index; |
295 Node* lastBrOrText = innerEditor; | 295 Node* lastBrOrText = innerEditor; |
296 for (Node* node = NodeTraversal::next(*innerEditor, innerEditor); node; node
= NodeTraversal::next(*node, innerEditor)) { | 296 for (Node& node : NodeTraversal::descendantsOf(*innerEditor)) { |
297 ASSERT(remainingCharactersToMoveForward >= 0); | 297 ASSERT(remainingCharactersToMoveForward >= 0); |
298 if (node->hasTagName(brTag)) { | 298 if (node.hasTagName(brTag)) { |
299 if (remainingCharactersToMoveForward == 0) | 299 if (remainingCharactersToMoveForward == 0) |
300 return positionBeforeNode(node); | 300 return positionBeforeNode(&node); |
301 --remainingCharactersToMoveForward; | 301 --remainingCharactersToMoveForward; |
302 lastBrOrText = node; | 302 lastBrOrText = &node; |
303 continue; | 303 continue; |
304 } | 304 } |
305 | 305 |
306 if (node->isTextNode()) { | 306 if (node.isTextNode()) { |
307 Text& text = toText(*node); | 307 Text& text = toText(node); |
308 if (remainingCharactersToMoveForward < static_cast<int>(text.length(
))) | 308 if (remainingCharactersToMoveForward < static_cast<int>(text.length(
))) |
309 return Position(&text, remainingCharactersToMoveForward); | 309 return Position(&text, remainingCharactersToMoveForward); |
310 remainingCharactersToMoveForward -= text.length(); | 310 remainingCharactersToMoveForward -= text.length(); |
311 lastBrOrText = node; | 311 lastBrOrText = &node; |
312 continue; | 312 continue; |
313 } | 313 } |
314 | 314 |
315 ASSERT_NOT_REACHED(); | 315 ASSERT_NOT_REACHED(); |
316 } | 316 } |
317 return lastPositionInOrAfterNode(lastBrOrText); | 317 return lastPositionInOrAfterNode(lastBrOrText); |
318 } | 318 } |
319 | 319 |
320 static int indexForPosition(HTMLElement* innerEditor, const Position& passedPosi
tion) | 320 static int indexForPosition(HTMLElement* innerEditor, const Position& passedPosi
tion) |
321 { | 321 { |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 Text* textNode = toText(node); | 960 Text* textNode = toText(node); |
961 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi
votPosition.offsetInContainerNode() : 0); | 961 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi
votPosition.offsetInContainerNode() : 0); |
962 if (firstLineBreak != kNotFound) | 962 if (firstLineBreak != kNotFound) |
963 return Position(textNode, firstLineBreak + 1); | 963 return Position(textNode, firstLineBreak + 1); |
964 } | 964 } |
965 } | 965 } |
966 return endOfInnerText(textFormControl); | 966 return endOfInnerText(textFormControl); |
967 } | 967 } |
968 | 968 |
969 } // namespace blink | 969 } // namespace blink |
OLD | NEW |