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

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

Issue 420603002: Use tighter typing in editing/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } 581 }
582 582
583 ASSERT(m_start.anchorNode()->treeScope() == m_end.anchorNode()->treeScope()) ; 583 ASSERT(m_start.anchorNode()->treeScope() == m_end.anchorNode()->treeScope()) ;
584 } 584 }
585 585
586 void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries() 586 void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
587 { 587 {
588 if (m_base.isNull() || m_start.isNull() || m_end.isNull()) 588 if (m_base.isNull() || m_start.isNull() || m_end.isNull())
589 return; 589 return;
590 590
591 Node* baseRoot = highestEditableRoot(m_base); 591 ContainerNode* baseRoot = highestEditableRoot(m_base);
592 Node* startRoot = highestEditableRoot(m_start); 592 ContainerNode* startRoot = highestEditableRoot(m_start);
593 Node* endRoot = highestEditableRoot(m_end); 593 ContainerNode* endRoot = highestEditableRoot(m_end);
594 594
595 Node* baseEditableAncestor = lowestEditableAncestor(m_base.containerNode()); 595 Element* baseEditableAncestor = lowestEditableAncestor(m_base.containerNode( ));
596 596
597 // The base, start and end are all in the same region. No adjustment necess ary. 597 // The base, start and end are all in the same region. No adjustment necess ary.
598 if (baseRoot == startRoot && baseRoot == endRoot) 598 if (baseRoot == startRoot && baseRoot == endRoot)
599 return; 599 return;
600 600
601 // The selection is based in editable content. 601 // The selection is based in editable content.
602 if (baseRoot) { 602 if (baseRoot) {
603 // If the start is outside the base's editable root, cap it at the start of that root. 603 // If the start is outside the base's editable root, cap it at the start of that root.
604 // If the start is in non-editable content that is inside the base's edi table root, put it 604 // If the start is in non-editable content that is inside the base's edi table root, put it
605 // at the first editable position after start inside the base's editable root. 605 // at the first editable position after start inside the base's editable root.
(...skipping 14 matching lines...) Expand all
620 if (m_end.isNull()) 620 if (m_end.isNull())
621 m_end = m_start; 621 m_end = m_start;
622 } 622 }
623 // The selection is based in non-editable content. 623 // The selection is based in non-editable content.
624 } else { 624 } else {
625 // FIXME: Non-editable pieces inside editable content should be atomic, in the same way that editable 625 // FIXME: Non-editable pieces inside editable content should be atomic, in the same way that editable
626 // pieces in non-editable content are atomic. 626 // pieces in non-editable content are atomic.
627 627
628 // The selection ends in editable content or non-editable content inside a different editable ancestor, 628 // The selection ends in editable content or non-editable content inside a different editable ancestor,
629 // move backward until non-editable content inside the same lowest edita ble ancestor is reached. 629 // move backward until non-editable content inside the same lowest edita ble ancestor is reached.
630 Node* endEditableAncestor = lowestEditableAncestor(m_end.containerNode() ); 630 Element* endEditableAncestor = lowestEditableAncestor(m_end.containerNod e());
631 if (endRoot || endEditableAncestor != baseEditableAncestor) { 631 if (endRoot || endEditableAncestor != baseEditableAncestor) {
632 632
633 Position p = previousVisuallyDistinctCandidate(m_end); 633 Position p = previousVisuallyDistinctCandidate(m_end);
634 Node* shadowAncestor = endRoot ? endRoot->shadowHost() : 0; 634 Node* shadowAncestor = endRoot ? endRoot->shadowHost() : 0;
635 if (p.isNull() && shadowAncestor) 635 if (p.isNull() && shadowAncestor)
636 p = positionAfterNode(shadowAncestor); 636 p = positionAfterNode(shadowAncestor);
637 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) { 637 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
638 Node* root = editableRootForPosition(p); 638 Node* root = editableRootForPosition(p);
639 shadowAncestor = root ? root->shadowHost() : 0; 639 shadowAncestor = root ? root->shadowHost() : 0;
640 p = isAtomicNode(p.containerNode()) ? positionInParentBeforeNode (*p.containerNode()) : previousVisuallyDistinctCandidate(p); 640 p = isAtomicNode(p.containerNode()) ? positionInParentBeforeNode (*p.containerNode()) : previousVisuallyDistinctCandidate(p);
641 if (p.isNull() && shadowAncestor) 641 if (p.isNull() && shadowAncestor)
642 p = positionAfterNode(shadowAncestor); 642 p = positionAfterNode(shadowAncestor);
643 } 643 }
644 VisiblePosition previous(p); 644 VisiblePosition previous(p);
645 645
646 if (previous.isNull()) { 646 if (previous.isNull()) {
647 // The selection crosses an Editing boundary. This is a 647 // The selection crosses an Editing boundary. This is a
648 // programmer error in the editing code. Happy debugging! 648 // programmer error in the editing code. Happy debugging!
649 ASSERT_NOT_REACHED(); 649 ASSERT_NOT_REACHED();
650 m_base = Position(); 650 m_base = Position();
651 m_extent = Position(); 651 m_extent = Position();
652 validate(); 652 validate();
653 return; 653 return;
654 } 654 }
655 m_end = previous.deepEquivalent(); 655 m_end = previous.deepEquivalent();
656 } 656 }
657 657
658 // The selection starts in editable content or non-editable content insi de a different editable ancestor, 658 // The selection starts in editable content or non-editable content insi de a different editable ancestor,
659 // move forward until non-editable content inside the same lowest editab le ancestor is reached. 659 // move forward until non-editable content inside the same lowest editab le ancestor is reached.
660 Node* startEditableAncestor = lowestEditableAncestor(m_start.containerNo de()); 660 Element* startEditableAncestor = lowestEditableAncestor(m_start.containe rNode());
661 if (startRoot || startEditableAncestor != baseEditableAncestor) { 661 if (startRoot || startEditableAncestor != baseEditableAncestor) {
662 Position p = nextVisuallyDistinctCandidate(m_start); 662 Position p = nextVisuallyDistinctCandidate(m_start);
663 Node* shadowAncestor = startRoot ? startRoot->shadowHost() : 0; 663 Node* shadowAncestor = startRoot ? startRoot->shadowHost() : 0;
664 if (p.isNull() && shadowAncestor) 664 if (p.isNull() && shadowAncestor)
665 p = positionBeforeNode(shadowAncestor); 665 p = positionBeforeNode(shadowAncestor);
666 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) { 666 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
667 Node* root = editableRootForPosition(p); 667 Node* root = editableRootForPosition(p);
668 shadowAncestor = root ? root->shadowHost() : 0; 668 shadowAncestor = root ? root->shadowHost() : 0;
669 p = isAtomicNode(p.containerNode()) ? positionInParentAfterNode( *p.containerNode()) : nextVisuallyDistinctCandidate(p); 669 p = isAtomicNode(p.containerNode()) ? positionInParentAfterNode( *p.containerNode()) : nextVisuallyDistinctCandidate(p);
670 if (p.isNull() && shadowAncestor) 670 if (p.isNull() && shadowAncestor)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 sel.showTreeForThis(); 857 sel.showTreeForThis();
858 } 858 }
859 859
860 void showTree(const blink::VisibleSelection* sel) 860 void showTree(const blink::VisibleSelection* sel)
861 { 861 {
862 if (sel) 862 if (sel)
863 sel->showTreeForThis(); 863 sel->showTreeForThis();
864 } 864 }
865 865
866 #endif 866 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698