| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 unsigned TextControlElement::IndexForPosition(HTMLElement* inner_editor, | 362 unsigned TextControlElement::IndexForPosition(HTMLElement* inner_editor, |
| 363 const Position& passed_position) { | 363 const Position& passed_position) { |
| 364 if (!inner_editor || !inner_editor->contains(passed_position.AnchorNode()) || | 364 if (!inner_editor || !inner_editor->contains(passed_position.AnchorNode()) || |
| 365 passed_position.IsNull()) | 365 passed_position.IsNull()) |
| 366 return 0; | 366 return 0; |
| 367 | 367 |
| 368 if (Position::BeforeNode(inner_editor) == passed_position) | 368 if (Position::BeforeNode(inner_editor) == passed_position) |
| 369 return 0; | 369 return 0; |
| 370 | 370 |
| 371 unsigned index = 0; | 371 unsigned index = 0; |
| 372 Node* start_node = passed_position.ComputeNodeBeforePosition(); | 372 const Node* start_node = passed_position.ComputeNodeBeforePosition(); |
| 373 if (!start_node) | 373 if (!start_node) |
| 374 start_node = passed_position.ComputeContainerNode(); | 374 start_node = passed_position.ComputeContainerNode(); |
| 375 if (start_node == inner_editor && passed_position.IsAfterAnchor()) | 375 if (start_node == inner_editor && passed_position.IsAfterAnchor()) |
| 376 start_node = inner_editor->lastChild(); | 376 start_node = inner_editor->lastChild(); |
| 377 DCHECK(start_node); | 377 DCHECK(start_node); |
| 378 DCHECK(inner_editor->contains(start_node)); | 378 DCHECK(inner_editor->contains(start_node)); |
| 379 | 379 |
| 380 for (Node* node = start_node; node; | 380 for (const Node* node = start_node; node; |
| 381 node = NodeTraversal::Previous(*node, inner_editor)) { | 381 node = NodeTraversal::Previous(*node, inner_editor)) { |
| 382 if (node->IsTextNode()) { | 382 if (node->IsTextNode()) { |
| 383 int length = ToText(*node).length(); | 383 int length = ToText(*node).length(); |
| 384 if (node == passed_position.ComputeContainerNode()) | 384 if (node == passed_position.ComputeContainerNode()) |
| 385 index += std::min(length, passed_position.OffsetInContainerNode()); | 385 index += std::min(length, passed_position.OffsetInContainerNode()); |
| 386 else | 386 else |
| 387 index += length; | 387 index += length; |
| 388 } else if (node->HasTagName(brTag)) { | 388 } else if (node->HasTagName(brTag)) { |
| 389 ++index; | 389 ++index; |
| 390 } | 390 } |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 | 971 |
| 972 void TextControlElement::CopyNonAttributePropertiesFromElement( | 972 void TextControlElement::CopyNonAttributePropertiesFromElement( |
| 973 const Element& source) { | 973 const Element& source) { |
| 974 const TextControlElement& source_element = | 974 const TextControlElement& source_element = |
| 975 static_cast<const TextControlElement&>(source); | 975 static_cast<const TextControlElement&>(source); |
| 976 last_change_was_user_edit_ = source_element.last_change_was_user_edit_; | 976 last_change_was_user_edit_ = source_element.last_change_was_user_edit_; |
| 977 HTMLFormControlElement::CopyNonAttributePropertiesFromElement(source); | 977 HTMLFormControlElement::CopyNonAttributePropertiesFromElement(source); |
| 978 } | 978 } |
| 979 | 979 |
| 980 } // namespace blink | 980 } // namespace blink |
| OLD | NEW |