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); |
yosin_UTC9
2014/09/12 01:02:24
It seems utilizing |selected| makes cleaner.
if (
Mads Ager (chromium)
2014/09/12 10:52:08
Done.
| |
398 CharacterIterator it(range.get()); | 398 ASSERT_UNUSED(selected, selected); |
399 CharacterIterator it(start, end); | |
399 it.advance(index - 1); | 400 it.advance(index - 1); |
400 return VisiblePosition(it.range()->endPosition(), UPSTREAM); | 401 return VisiblePosition(it.endPosition(), UPSTREAM); |
401 } | 402 } |
402 | 403 |
403 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p os) const | 404 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p os) const |
404 { | 405 { |
405 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); | 406 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); |
406 if (enclosingTextFormControl(indexPosition) != this) | 407 if (enclosingTextFormControl(indexPosition) != this) |
407 return 0; | 408 return 0; |
408 ASSERT(indexPosition.document()); | 409 ASSERT(indexPosition.document()); |
409 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document()); | 410 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document()); |
410 range->setStart(innerEditorElement(), 0, ASSERT_NO_EXCEPTION); | 411 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); | 959 Text* textNode = toText(node); |
959 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi votPosition.offsetInContainerNode() : 0); | 960 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi votPosition.offsetInContainerNode() : 0); |
960 if (firstLineBreak != kNotFound) | 961 if (firstLineBreak != kNotFound) |
961 return Position(textNode, firstLineBreak + 1); | 962 return Position(textNode, firstLineBreak + 1); |
962 } | 963 } |
963 } | 964 } |
964 return endOfInnerText(textFormControl); | 965 return endOfInnerText(textFormControl); |
965 } | 966 } |
966 | 967 |
967 } // namespace Webcore | 968 } // namespace Webcore |
OLD | NEW |