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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 return nullptr; | 451 return nullptr; |
452 | 452 |
453 int start = m_cachedSelectionStart; | 453 int start = m_cachedSelectionStart; |
454 int end = m_cachedSelectionEnd; | 454 int end = m_cachedSelectionEnd; |
455 | 455 |
456 ASSERT(start <= end); | 456 ASSERT(start <= end); |
457 HTMLElement* innerText = innerEditorElement(); | 457 HTMLElement* innerText = innerEditorElement(); |
458 if (!innerText) | 458 if (!innerText) |
459 return nullptr; | 459 return nullptr; |
460 | 460 |
461 if (!innerText->firstChild()) | 461 if (!innerText->hasChildren()) |
462 return Range::create(document(), innerText, 0, innerText, 0); | 462 return Range::create(document(), innerText, 0, innerText, 0); |
463 | 463 |
464 int offset = 0; | 464 int offset = 0; |
465 Node* startNode = 0; | 465 Node* startNode = 0; |
466 Node* endNode = 0; | 466 Node* endNode = 0; |
467 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { | 467 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { |
468 ASSERT(!node->firstChild()); | 468 ASSERT(!node->hasChildren()); |
469 ASSERT(node->isTextNode() || isHTMLBRElement(*node)); | 469 ASSERT(node->isTextNode() || isHTMLBRElement(*node)); |
470 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; | 470 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; |
471 | 471 |
472 if (offset <= start && start <= offset + length) | 472 if (offset <= start && start <= offset + length) |
473 setContainerAndOffsetForRange(node, start - offset, startNode, start
); | 473 setContainerAndOffsetForRange(node, start - offset, startNode, start
); |
474 | 474 |
475 if (offset <= end && end <= offset + length) { | 475 if (offset <= end && end <= offset + length) { |
476 setContainerAndOffsetForRange(node, end - offset, endNode, end); | 476 setContainerAndOffsetForRange(node, end - offset, endNode, end); |
477 break; | 477 break; |
478 } | 478 } |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 Text* textNode = toText(node); | 911 Text* textNode = toText(node); |
912 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi
votPosition.offsetInContainerNode() : 0); | 912 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi
votPosition.offsetInContainerNode() : 0); |
913 if (firstLineBreak != kNotFound) | 913 if (firstLineBreak != kNotFound) |
914 return Position(textNode, firstLineBreak + 1); | 914 return Position(textNode, firstLineBreak + 1); |
915 } | 915 } |
916 } | 916 } |
917 return endOfInnerText(textFormControl); | 917 return endOfInnerText(textFormControl); |
918 } | 918 } |
919 | 919 |
920 } // namespace Webcore | 920 } // namespace Webcore |
OLD | NEW |