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

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

Issue 2082503003: ASSERT -> DCHECK conversions in core/editing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 615
616 // The selection is based in editable content. 616 // The selection is based in editable content.
617 if (baseRoot) { 617 if (baseRoot) {
618 // If the start is outside the base's editable root, cap it at the start of that root. 618 // If the start is outside the base's editable root, cap it at the start of that root.
619 // If the start is in non-editable content that is inside the base's edi table root, put it 619 // If the start is in non-editable content that is inside the base's edi table root, put it
620 // at the first editable position after start inside the base's editable root. 620 // at the first editable position after start inside the base's editable root.
621 if (startRoot != baseRoot) { 621 if (startRoot != baseRoot) {
622 const VisiblePositionTemplate<Strategy> first = firstEditableVisible PositionAfterPositionInRoot(m_start, *baseRoot); 622 const VisiblePositionTemplate<Strategy> first = firstEditableVisible PositionAfterPositionInRoot(m_start, *baseRoot);
623 m_start = first.deepEquivalent(); 623 m_start = first.deepEquivalent();
624 if (m_start.isNull()) { 624 if (m_start.isNull()) {
625 ASSERT_NOT_REACHED(); 625 NOTREACHED();
626 m_start = m_end; 626 m_start = m_end;
627 } 627 }
628 } 628 }
629 // If the end is outside the base's editable root, cap it at the end of that root. 629 // If the end is outside the base's editable root, cap it at the end of that root.
630 // If the end is in non-editable content that is inside the base's root, put it 630 // If the end is in non-editable content that is inside the base's root, put it
631 // at the last editable position before the end inside the base's root. 631 // at the last editable position before the end inside the base's root.
632 if (endRoot != baseRoot) { 632 if (endRoot != baseRoot) {
633 const VisiblePositionTemplate<Strategy> last = lastEditableVisiblePo sitionBeforePositionInRoot(m_end, *baseRoot); 633 const VisiblePositionTemplate<Strategy> last = lastEditableVisiblePo sitionBeforePositionInRoot(m_end, *baseRoot);
634 m_end = last.deepEquivalent(); 634 m_end = last.deepEquivalent();
635 if (m_end.isNull()) 635 if (m_end.isNull())
(...skipping 18 matching lines...) Expand all
654 shadowAncestor = root ? root->shadowHost() : nullptr; 654 shadowAncestor = root ? root->shadowHost() : nullptr;
655 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St rategy>::inParentBeforeNode(*p.computeContainerNode()) : previousVisuallyDistinc tCandidate(p); 655 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St rategy>::inParentBeforeNode(*p.computeContainerNode()) : previousVisuallyDistinc tCandidate(p);
656 if (p.isNull() && shadowAncestor) 656 if (p.isNull() && shadowAncestor)
657 p = PositionTemplate<Strategy>::afterNode(shadowAncestor); 657 p = PositionTemplate<Strategy>::afterNode(shadowAncestor);
658 } 658 }
659 const VisiblePositionTemplate<Strategy> previous = createVisiblePosi tion(p); 659 const VisiblePositionTemplate<Strategy> previous = createVisiblePosi tion(p);
660 660
661 if (previous.isNull()) { 661 if (previous.isNull()) {
662 // The selection crosses an Editing boundary. This is a 662 // The selection crosses an Editing boundary. This is a
663 // programmer error in the editing code. Happy debugging! 663 // programmer error in the editing code. Happy debugging!
664 ASSERT_NOT_REACHED(); 664 NOTREACHED();
665 m_base = PositionTemplate<Strategy>(); 665 m_base = PositionTemplate<Strategy>();
666 m_extent = PositionTemplate<Strategy>(); 666 m_extent = PositionTemplate<Strategy>();
667 validate(); 667 validate();
668 return; 668 return;
669 } 669 }
670 m_end = previous.deepEquivalent(); 670 m_end = previous.deepEquivalent();
671 } 671 }
672 672
673 // The selection starts in editable content or non-editable content insi de a different editable ancestor, 673 // The selection starts in editable content or non-editable content insi de a different editable ancestor,
674 // move forward until non-editable content inside the same lowest editab le ancestor is reached. 674 // move forward until non-editable content inside the same lowest editab le ancestor is reached.
675 Element* startEditableAncestor = lowestEditableAncestor(m_start.computeC ontainerNode()); 675 Element* startEditableAncestor = lowestEditableAncestor(m_start.computeC ontainerNode());
676 if (startRoot || startEditableAncestor != baseEditableAncestor) { 676 if (startRoot || startEditableAncestor != baseEditableAncestor) {
677 PositionTemplate<Strategy> p = nextVisuallyDistinctCandidate(m_start ); 677 PositionTemplate<Strategy> p = nextVisuallyDistinctCandidate(m_start );
678 Element* shadowAncestor = startRoot ? startRoot->shadowHost() : null ptr; 678 Element* shadowAncestor = startRoot ? startRoot->shadowHost() : null ptr;
679 if (p.isNull() && shadowAncestor) 679 if (p.isNull() && shadowAncestor)
680 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor); 680 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor);
681 while (p.isNotNull() && !(lowestEditableAncestor(p.computeContainerN ode()) == baseEditableAncestor && !isEditablePosition(p))) { 681 while (p.isNotNull() && !(lowestEditableAncestor(p.computeContainerN ode()) == baseEditableAncestor && !isEditablePosition(p))) {
682 Element* root = rootEditableElementOf(p); 682 Element* root = rootEditableElementOf(p);
683 shadowAncestor = root ? root->shadowHost() : nullptr; 683 shadowAncestor = root ? root->shadowHost() : nullptr;
684 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St rategy>::inParentAfterNode(*p.computeContainerNode()) : nextVisuallyDistinctCand idate(p); 684 p = isAtomicNode(p.computeContainerNode()) ? PositionTemplate<St rategy>::inParentAfterNode(*p.computeContainerNode()) : nextVisuallyDistinctCand idate(p);
685 if (p.isNull() && shadowAncestor) 685 if (p.isNull() && shadowAncestor)
686 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor); 686 p = PositionTemplate<Strategy>::beforeNode(shadowAncestor);
687 } 687 }
688 const VisiblePositionTemplate<Strategy> next = createVisiblePosition (p); 688 const VisiblePositionTemplate<Strategy> next = createVisiblePosition (p);
689 689
690 if (next.isNull()) { 690 if (next.isNull()) {
691 // The selection crosses an Editing boundary. This is a 691 // The selection crosses an Editing boundary. This is a
692 // programmer error in the editing code. Happy debugging! 692 // programmer error in the editing code. Happy debugging!
693 ASSERT_NOT_REACHED(); 693 NOTREACHED();
694 m_base = PositionTemplate<Strategy>(); 694 m_base = PositionTemplate<Strategy>();
695 m_extent = PositionTemplate<Strategy>(); 695 m_extent = PositionTemplate<Strategy>();
696 validate(); 696 validate();
697 return; 697 return;
698 } 698 }
699 m_start = next.deepEquivalent(); 699 m_start = next.deepEquivalent();
700 } 700 }
701 } 701 }
702 702
703 // Correct the extent if necessary. 703 // Correct the extent if necessary.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 { 908 {
909 sel.showTreeForThis(); 909 sel.showTreeForThis();
910 } 910 }
911 911
912 void showTree(const blink::VisibleSelectionInFlatTree* sel) 912 void showTree(const blink::VisibleSelectionInFlatTree* sel)
913 { 913 {
914 if (sel) 914 if (sel)
915 sel->showTreeForThis(); 915 sel->showTreeForThis();
916 } 916 }
917 #endif 917 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/RenderedPosition.cpp ('k') | third_party/WebKit/Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698