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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleSelection.cpp

Issue 1412713003: Reland 'Use FrameSelection::selectedText where possible.' Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reimplement setSelectionInTextFormControl: use setSelection. Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // TODO(yosin) This function breaks the invariant of this class. 643 // TODO(yosin) This function breaks the invariant of this class.
644 // But because we use VisibleSelection to store values in editing commands for 644 // But because we use VisibleSelection to store values in editing commands for
645 // use when undoing the command, we need to be able to create a selection that 645 // use when undoing the command, we need to be able to create a selection that
646 // while currently invalid, will be valid once the changes are undone. This is a 646 // while currently invalid, will be valid once the changes are undone. This is a
647 // design problem. To fix it we either need to change the invariants of 647 // design problem. To fix it we either need to change the invariants of
648 // |VisibleSelection| or create a new class for editing to use that can 648 // |VisibleSelection| or create a new class for editing to use that can
649 // manipulate selections that are not currently valid. 649 // manipulate selections that are not currently valid.
650 template <typename Strategy> 650 template <typename Strategy>
651 void VisibleSelectionTemplate<Strategy>::setWithoutValidation(const PositionTemp late<Strategy>& base, const PositionTemplate<Strategy>& extent) 651 void VisibleSelectionTemplate<Strategy>::setWithoutValidation(const PositionTemp late<Strategy>& base, const PositionTemplate<Strategy>& extent)
652 { 652 {
653 ASSERT(!base.isNull()); 653 if (base.isNull() || extent.isNull()) {
654 ASSERT(!extent.isNull()); 654 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>();
655 updateSelectionType();
656 return;
657 }
655 658
656 // TODO(hajimehoshi): We doubt this assertion is needed. This was introduced 659 // TODO(hajimehoshi): We doubt this assertion is needed. This was introduced
657 // by http://trac.webkit.org/browser/trunk/WebCore/editing/Selection.cpp?ann otate=blame&rev=21071 660 // by http://trac.webkit.org/browser/trunk/WebCore/editing/Selection.cpp?ann otate=blame&rev=21071
658 ASSERT(m_affinity == TextAffinity::Downstream); 661 ASSERT(m_affinity == TextAffinity::Downstream);
659 662
660 m_base = base; 663 m_base = base;
661 m_extent = extent; 664 m_extent = extent;
662 m_baseIsFirst = base.compareTo(extent) <= 0; 665 m_baseIsFirst = base.compareTo(extent) <= 0;
663 if (m_baseIsFirst) { 666 if (m_baseIsFirst) {
664 m_start = base; 667 m_start = base;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 { 1136 {
1134 sel.showTreeForThis(); 1137 sel.showTreeForThis();
1135 } 1138 }
1136 1139
1137 void showTree(const blink::VisibleSelectionInComposedTree* sel) 1140 void showTree(const blink::VisibleSelectionInComposedTree* sel)
1138 { 1141 {
1139 if (sel) 1142 if (sel)
1140 sel->showTreeForThis(); 1143 sel->showTreeForThis();
1141 } 1144 }
1142 #endif 1145 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698