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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 remainingCharactersToMoveForward -= text.length(); | 302 remainingCharactersToMoveForward -= text.length(); |
303 lastBrOrText = &node; | 303 lastBrOrText = &node; |
304 continue; | 304 continue; |
305 } | 305 } |
306 | 306 |
307 NOTREACHED(); | 307 NOTREACHED(); |
308 } | 308 } |
309 return lastPositionInOrAfterNode(lastBrOrText); | 309 return lastPositionInOrAfterNode(lastBrOrText); |
310 } | 310 } |
311 | 311 |
312 static int indexForPosition(HTMLElement* innerEditor, const Position& passedPosi
tion) | 312 int HTMLTextFormControlElement::indexForPosition(HTMLElement* innerEditor, const
Position& passedPosition) |
313 { | 313 { |
314 if (!innerEditor || !innerEditor->contains(passedPosition.anchorNode()) || p
assedPosition.isNull()) | 314 if (!innerEditor || !innerEditor->contains(passedPosition.anchorNode()) || p
assedPosition.isNull()) |
315 return 0; | 315 return 0; |
316 | 316 |
317 if (Position::beforeNode(innerEditor) == passedPosition) | 317 if (Position::beforeNode(innerEditor) == passedPosition) |
318 return 0; | 318 return 0; |
319 | 319 |
320 int index = 0; | 320 int index = 0; |
321 Node* startNode = passedPosition.computeNodeBeforePosition(); | 321 Node* startNode = passedPosition.computeNodeBeforePosition(); |
322 if (!startNode) | 322 if (!startNode) |
323 startNode = passedPosition.computeContainerNode(); | 323 startNode = passedPosition.computeContainerNode(); |
| 324 if (startNode == innerEditor && passedPosition.isAfterAnchor()) |
| 325 startNode = innerEditor->lastChild(); |
324 DCHECK(startNode); | 326 DCHECK(startNode); |
325 DCHECK(innerEditor->contains(startNode)); | 327 DCHECK(innerEditor->contains(startNode)); |
326 | 328 |
327 for (Node* node = startNode; node; node = NodeTraversal::previous(*node, inn
erEditor)) { | 329 for (Node* node = startNode; node; node = NodeTraversal::previous(*node, inn
erEditor)) { |
328 if (node->isTextNode()) { | 330 if (node->isTextNode()) { |
329 int length = toText(*node).length(); | 331 int length = toText(*node).length(); |
330 if (node == passedPosition.computeContainerNode()) | 332 if (node == passedPosition.computeContainerNode()) |
331 index += std::min(length, passedPosition.offsetInContainerNode()
); | 333 index += std::min(length, passedPosition.offsetInContainerNode()
); |
332 else | 334 else |
333 index += length; | 335 index += length; |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 } | 1021 } |
1020 | 1022 |
1021 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) | 1023 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) |
1022 { | 1024 { |
1023 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); | 1025 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); |
1024 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1026 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
1025 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1027 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
1026 } | 1028 } |
1027 | 1029 |
1028 } // namespace blink | 1030 } // namespace blink |
OLD | NEW |