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

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

Issue 2969183002: Use FrameSelection::Granularity in TextControlElement::ComputeSelection{Start,End}() (Closed)
Patch Set: 2017-07-05T15:47:49 Created 3 years, 5 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 | « no previous file | 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 if (!frame) 496 if (!frame)
497 return 0; 497 return 0;
498 { 498 {
499 // To avoid regression on speedometer benchmark[1] test, we should not 499 // To avoid regression on speedometer benchmark[1] test, we should not
500 // update layout tree in this code block. 500 // update layout tree in this code block.
501 // [1] http://browserbench.org/Speedometer/ 501 // [1] http://browserbench.org/Speedometer/
502 DocumentLifecycle::DisallowTransitionScope disallow_transition( 502 DocumentLifecycle::DisallowTransitionScope disallow_transition(
503 GetDocument().Lifecycle()); 503 GetDocument().Lifecycle());
504 const SelectionInDOMTree& selection = 504 const SelectionInDOMTree& selection =
505 frame->Selection().GetSelectionInDOMTree(); 505 frame->Selection().GetSelectionInDOMTree();
506 if (selection.Granularity() == kCharacterGranularity) { 506 if (frame->Selection().Granularity() == kCharacterGranularity) {
507 return IndexForPosition(InnerEditorElement(), 507 return IndexForPosition(InnerEditorElement(),
508 selection.ComputeStartPosition()); 508 selection.ComputeStartPosition());
509 } 509 }
510 } 510 }
511 const VisibleSelection& visible_selection = 511 const VisibleSelection& visible_selection =
512 frame->Selection().ComputeVisibleSelectionInDOMTreeDeprecated(); 512 frame->Selection().ComputeVisibleSelectionInDOMTreeDeprecated();
513 return IndexForPosition(InnerEditorElement(), visible_selection.Start()); 513 return IndexForPosition(InnerEditorElement(), visible_selection.Start());
514 } 514 }
515 515
516 unsigned TextControlElement::selectionEnd() const { 516 unsigned TextControlElement::selectionEnd() const {
(...skipping 10 matching lines...) Expand all
527 if (!frame) 527 if (!frame)
528 return 0; 528 return 0;
529 { 529 {
530 // To avoid regression on speedometer benchmark[1] test, we should not 530 // To avoid regression on speedometer benchmark[1] test, we should not
531 // update layout tree in this code block. 531 // update layout tree in this code block.
532 // [1] http://browserbench.org/Speedometer/ 532 // [1] http://browserbench.org/Speedometer/
533 DocumentLifecycle::DisallowTransitionScope disallow_transition( 533 DocumentLifecycle::DisallowTransitionScope disallow_transition(
534 GetDocument().Lifecycle()); 534 GetDocument().Lifecycle());
535 const SelectionInDOMTree& selection = 535 const SelectionInDOMTree& selection =
536 frame->Selection().GetSelectionInDOMTree(); 536 frame->Selection().GetSelectionInDOMTree();
537 if (selection.Granularity() == kCharacterGranularity) { 537 if (frame->Selection().Granularity() == kCharacterGranularity) {
538 return IndexForPosition(InnerEditorElement(), 538 return IndexForPosition(InnerEditorElement(),
539 selection.ComputeEndPosition()); 539 selection.ComputeEndPosition());
540 } 540 }
541 } 541 }
542 const VisibleSelection& visible_selection = 542 const VisibleSelection& visible_selection =
543 frame->Selection().ComputeVisibleSelectionInDOMTreeDeprecated(); 543 frame->Selection().ComputeVisibleSelectionInDOMTreeDeprecated();
544 return IndexForPosition(InnerEditorElement(), visible_selection.End()); 544 return IndexForPosition(InnerEditorElement(), visible_selection.End());
545 } 545 }
546 546
547 static const AtomicString& DirectionString( 547 static const AtomicString& DirectionString(
(...skipping 423 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698