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

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

Issue 1288883002: Make SelectionController not to set invalid selection by mouse down (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-13T18:48:09 Created 5 years, 4 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 | « Source/core/editing/VisibleSelection.h ('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) 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 731
732 void VisibleSelection::resetPositionsInComposedTree() 732 void VisibleSelection::resetPositionsInComposedTree()
733 { 733 {
734 m_baseInComposedTree = toPositionInComposedTree(m_base); 734 m_baseInComposedTree = toPositionInComposedTree(m_base);
735 m_extentInComposedTree = toPositionInComposedTree(m_extent); 735 m_extentInComposedTree = toPositionInComposedTree(m_extent);
736 m_endInComposedTree = toPositionInComposedTree(m_end); 736 m_endInComposedTree = toPositionInComposedTree(m_end);
737 m_startInComposedTree = toPositionInComposedTree(m_start); 737 m_startInComposedTree = toPositionInComposedTree(m_start);
738 adjustStartAndEndInComposedTree(); 738 adjustStartAndEndInComposedTree();
739 } 739 }
740 740
741 bool VisibleSelection::isValidFor(const Document& document) const
742 {
743 if (isNone())
744 return true;
745
746 return m_base.document() == &document
747 && !m_base.isOrphan() && !m_extent.isOrphan()
748 && !m_start.isOrphan() && !m_end.isOrphan()
749 && !m_baseInComposedTree.isOrphan() && !m_extentInComposedTree.isOrphan( )
750 && !m_startInComposedTree.isOrphan() && !m_endInComposedTree.isOrphan();
751 }
752
741 // FIXME: This function breaks the invariant of this class. 753 // FIXME: This function breaks the invariant of this class.
742 // But because we use VisibleSelection to store values in editing commands for u se when 754 // But because we use VisibleSelection to store values in editing commands for u se when
743 // undoing the command, we need to be able to create a selection that while curr ently 755 // undoing the command, we need to be able to create a selection that while curr ently
744 // invalid, will be valid once the changes are undone. This is a design problem. 756 // invalid, will be valid once the changes are undone. This is a design problem.
745 // To fix it we either need to change the invariants of VisibleSelection or crea te a new 757 // To fix it we either need to change the invariants of VisibleSelection or crea te a new
746 // class for editing to use that can manipulate selections that are not currentl y valid. 758 // class for editing to use that can manipulate selections that are not currentl y valid.
747 void VisibleSelection::setWithoutValidation(const Position& base, const Position & extent) 759 void VisibleSelection::setWithoutValidation(const Position& base, const Position & extent)
748 { 760 {
749 ASSERT(!base.isNull()); 761 ASSERT(!base.isNull());
750 ASSERT(!extent.isNull()); 762 ASSERT(!extent.isNull());
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 sel.showTreeForThis(); 1252 sel.showTreeForThis();
1241 } 1253 }
1242 1254
1243 void showTree(const blink::VisibleSelection* sel) 1255 void showTree(const blink::VisibleSelection* sel)
1244 { 1256 {
1245 if (sel) 1257 if (sel)
1246 sel->showTreeForThis(); 1258 sel->showTreeForThis();
1247 } 1259 }
1248 1260
1249 #endif 1261 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698