Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/core/html/TextControlElement.cpp

Issue 2951073002: CANCELED: Make ComputeNodeBeforePosition() to return const Node* (Closed)
Patch Set: 2017-06-21T17:59:27 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698