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

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

Issue 1123563003: Improving direction-based selection strategy. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 m_start = base; 586 m_start = base;
587 m_end = extent; 587 m_end = extent;
588 } else { 588 } else {
589 m_start = extent; 589 m_start = extent;
590 m_end = base; 590 m_end = base;
591 } 591 }
592 m_selectionType = base == extent ? CaretSelection : RangeSelection; 592 m_selectionType = base == extent ? CaretSelection : RangeSelection;
593 didChange(); 593 didChange();
594 } 594 }
595 595
596 void VisibleSelection::setWithoutValidation(const Position& base, const Position & extent, const Position& start, const Position& end)
597 {
598 ASSERT(!base.isNull());
599 ASSERT(!extent.isNull());
600 ASSERT(!start.isNull());
601 ASSERT(!end.isNull());
602 ASSERT(m_affinity == DOWNSTREAM);
603 ASSERT(comparePositions(start, end) <= 0);
604 m_base = base;
605 m_extent = extent;
606 m_baseIsFirst = comparePositions(base, extent) <= 0;
607 m_start = start;
608 m_end = end;
609 m_selectionType = base == extent ? CaretSelection : RangeSelection;
610 didChange();
611 }
612
596 static Position adjustPositionForEnd(const Position& currentPosition, Node* star tContainerNode) 613 static Position adjustPositionForEnd(const Position& currentPosition, Node* star tContainerNode)
597 { 614 {
598 TreeScope& treeScope = startContainerNode->treeScope(); 615 TreeScope& treeScope = startContainerNode->treeScope();
599 616
600 ASSERT(currentPosition.containerNode()->treeScope() != treeScope); 617 ASSERT(currentPosition.containerNode()->treeScope() != treeScope);
601 618
602 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.container Node())) { 619 if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.container Node())) {
603 if (ancestor->contains(startContainerNode)) 620 if (ancestor->contains(startContainerNode))
604 return positionAfterNode(ancestor); 621 return positionAfterNode(ancestor);
605 return positionBeforeNode(ancestor); 622 return positionBeforeNode(ancestor);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 sel.showTreeForThis(); 939 sel.showTreeForThis();
923 } 940 }
924 941
925 void showTree(const blink::VisibleSelection* sel) 942 void showTree(const blink::VisibleSelection* sel)
926 { 943 {
927 if (sel) 944 if (sel)
928 sel->showTreeForThis(); 945 sel->showTreeForThis();
929 } 946 }
930 947
931 #endif 948 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698