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

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

Issue 1958093002: CONTINUED Make FrameSelection to hold non-canonicalized positions Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2017-01-16T20:04:35 Created 3 years, 11 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 m_affinity = TextAffinity::Downstream; 473 m_affinity = TextAffinity::Downstream;
474 } 474 }
475 475
476 template <typename Strategy> 476 template <typename Strategy>
477 void VisibleSelectionTemplate<Strategy>::validate(TextGranularity granularity) { 477 void VisibleSelectionTemplate<Strategy>::validate(TextGranularity granularity) {
478 DCHECK(!needsLayoutTreeUpdate(m_base)); 478 DCHECK(!needsLayoutTreeUpdate(m_base));
479 DCHECK(!needsLayoutTreeUpdate(m_extent)); 479 DCHECK(!needsLayoutTreeUpdate(m_extent));
480 // TODO(xiaochengh): Add a DocumentLifecycle::DisallowTransitionScope here. 480 // TODO(xiaochengh): Add a DocumentLifecycle::DisallowTransitionScope here.
481 481
482 m_granularity = granularity; 482 m_granularity = granularity;
483 m_hasTrailingWhitespace = false; 483 if (m_granularity != WordGranularity)
484 m_hasTrailingWhitespace = false;
484 setBaseAndExtentToDeepEquivalents(); 485 setBaseAndExtentToDeepEquivalents();
485 if (m_base.isNull() || m_extent.isNull()) { 486 if (m_base.isNull() || m_extent.isNull()) {
486 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>(); 487 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>();
487 updateSelectionType(); 488 updateSelectionType();
488 return; 489 return;
489 } 490 }
490 491
491 const PositionTemplate<Strategy> start = m_baseIsFirst ? m_base : m_extent; 492 const PositionTemplate<Strategy> start = m_baseIsFirst ? m_base : m_extent;
492 const PositionTemplate<Strategy> newStart = computeStartRespectingGranularity( 493 const PositionTemplate<Strategy> newStart = computeStartRespectingGranularity(
493 PositionWithAffinityTemplate<Strategy>(start, m_affinity), granularity); 494 PositionWithAffinityTemplate<Strategy>(start, m_affinity), granularity);
(...skipping 15 matching lines...) Expand all
509 // it is useful to make to make the selection "canonical" (if only for 510 // it is useful to make to make the selection "canonical" (if only for
510 // purposes of comparing selections). This is an ideal point of the code 511 // purposes of comparing selections). This is an ideal point of the code
511 // to do this operation, since all selection changes that result in a 512 // to do this operation, since all selection changes that result in a
512 // RANGE come through here before anyone uses it. 513 // RANGE come through here before anyone uses it.
513 // TODO(yosin) Canonicalizing is good, but haven't we already done it 514 // TODO(yosin) Canonicalizing is good, but haven't we already done it
514 // (when we set these two positions to |VisiblePosition| 515 // (when we set these two positions to |VisiblePosition|
515 // |deepEquivalent()|s above)? 516 // |deepEquivalent()|s above)?
516 m_start = mostForwardCaretPosition(m_start); 517 m_start = mostForwardCaretPosition(m_start);
517 m_end = mostBackwardCaretPosition(m_end); 518 m_end = mostBackwardCaretPosition(m_end);
518 } 519 }
520 if (!m_hasTrailingWhitespace)
521 return;
522 appendTrailingWhitespace();
519 } 523 }
520 524
521 template <typename Strategy> 525 template <typename Strategy>
522 bool VisibleSelectionTemplate<Strategy>::isValidFor( 526 bool VisibleSelectionTemplate<Strategy>::isValidFor(
523 const Document& document) const { 527 const Document& document) const {
524 if (isNone()) 528 if (isNone())
525 return true; 529 return true;
526 530
527 return m_base.document() == &document && !m_base.isOrphan() && 531 return m_base.document() == &document && !m_base.isOrphan() &&
528 !m_extent.isOrphan() && !m_start.isOrphan() && !m_end.isOrphan(); 532 !m_extent.isOrphan() && !m_start.isOrphan() && !m_end.isOrphan();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 847
844 void showTree(const blink::VisibleSelectionInFlatTree& sel) { 848 void showTree(const blink::VisibleSelectionInFlatTree& sel) {
845 sel.showTreeForThis(); 849 sel.showTreeForThis();
846 } 850 }
847 851
848 void showTree(const blink::VisibleSelectionInFlatTree* sel) { 852 void showTree(const blink::VisibleSelectionInFlatTree* sel) {
849 if (sel) 853 if (sel)
850 sel->showTreeForThis(); 854 sel->showTreeForThis();
851 } 855 }
852 #endif 856 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698