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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 newSelection.setWithoutValidation(startPosition, endPosition); | 386 newSelection.setWithoutValidation(startPosition, endPosition); |
387 newSelection.setIsDirectional(direction != SelectionHasNoDirection); | 387 newSelection.setIsDirectional(direction != SelectionHasNoDirection); |
388 | 388 |
389 frame->selection().setSelection(newSelection, FrameSelection::CloseTyping |
FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); | 389 frame->selection().setSelection(newSelection, FrameSelection::CloseTyping |
FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); |
390 } | 390 } |
391 | 391 |
392 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
onst | 392 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
onst |
393 { | 393 { |
394 if (index <= 0) | 394 if (index <= 0) |
395 return VisiblePosition(firstPositionInNode(innerEditorElement()), DOWNST
REAM); | 395 return VisiblePosition(firstPositionInNode(innerEditorElement()), DOWNST
REAM); |
396 RefPtrWillBeRawPtr<Range> range = Range::create(document()); | 396 Position start, end; |
397 range->selectNodeContents(innerEditorElement(), ASSERT_NO_EXCEPTION); | 397 bool selected = Range::selectNodeContents(innerEditorElement(), start, end); |
398 CharacterIterator it(range.get()); | 398 if (!selected) |
| 399 return VisiblePosition(); |
| 400 CharacterIterator it(start, end); |
399 it.advance(index - 1); | 401 it.advance(index - 1); |
400 return VisiblePosition(it.range()->endPosition(), UPSTREAM); | 402 return VisiblePosition(it.endPosition(), UPSTREAM); |
401 } | 403 } |
402 | 404 |
403 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p
os) const | 405 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p
os) const |
404 { | 406 { |
405 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); | 407 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); |
406 if (enclosingTextFormControl(indexPosition) != this) | 408 if (enclosingTextFormControl(indexPosition) != this) |
407 return 0; | 409 return 0; |
408 ASSERT(indexPosition.document()); | 410 ASSERT(indexPosition.document()); |
409 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document()); | 411 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document()); |
410 range->setStart(innerEditorElement(), 0, ASSERT_NO_EXCEPTION); | 412 range->setStart(innerEditorElement(), 0, ASSERT_NO_EXCEPTION); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 Text* textNode = toText(node); | 960 Text* textNode = toText(node); |
959 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); |
960 if (firstLineBreak != kNotFound) | 962 if (firstLineBreak != kNotFound) |
961 return Position(textNode, firstLineBreak + 1); | 963 return Position(textNode, firstLineBreak + 1); |
962 } | 964 } |
963 } | 965 } |
964 return endOfInnerText(textFormControl); | 966 return endOfInnerText(textFormControl); |
965 } | 967 } |
966 | 968 |
967 } // namespace Webcore | 969 } // namespace Webcore |
OLD | NEW |