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

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

Issue 182383012: Have positionInParentBeforeNode() / positionInParentAfterNode() take a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/ReplaceSelectionCommand.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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 Node* endEditableAncestor = lowestEditableAncestor(m_end.containerNode() ); 564 Node* endEditableAncestor = lowestEditableAncestor(m_end.containerNode() );
565 if (endRoot || endEditableAncestor != baseEditableAncestor) { 565 if (endRoot || endEditableAncestor != baseEditableAncestor) {
566 566
567 Position p = previousVisuallyDistinctCandidate(m_end); 567 Position p = previousVisuallyDistinctCandidate(m_end);
568 Node* shadowAncestor = endRoot ? endRoot->shadowHost() : 0; 568 Node* shadowAncestor = endRoot ? endRoot->shadowHost() : 0;
569 if (p.isNull() && shadowAncestor) 569 if (p.isNull() && shadowAncestor)
570 p = positionAfterNode(shadowAncestor); 570 p = positionAfterNode(shadowAncestor);
571 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) { 571 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
572 Node* root = editableRootForPosition(p); 572 Node* root = editableRootForPosition(p);
573 shadowAncestor = root ? root->shadowHost() : 0; 573 shadowAncestor = root ? root->shadowHost() : 0;
574 p = isAtomicNode(p.containerNode()) ? positionInParentBeforeNode (p.containerNode()) : previousVisuallyDistinctCandidate(p); 574 p = isAtomicNode(p.containerNode()) ? positionInParentBeforeNode (*p.containerNode()) : previousVisuallyDistinctCandidate(p);
575 if (p.isNull() && shadowAncestor) 575 if (p.isNull() && shadowAncestor)
576 p = positionAfterNode(shadowAncestor); 576 p = positionAfterNode(shadowAncestor);
577 } 577 }
578 VisiblePosition previous(p); 578 VisiblePosition previous(p);
579 579
580 if (previous.isNull()) { 580 if (previous.isNull()) {
581 // The selection crosses an Editing boundary. This is a 581 // The selection crosses an Editing boundary. This is a
582 // programmer error in the editing code. Happy debugging! 582 // programmer error in the editing code. Happy debugging!
583 ASSERT_NOT_REACHED(); 583 ASSERT_NOT_REACHED();
584 m_base = Position(); 584 m_base = Position();
585 m_extent = Position(); 585 m_extent = Position();
586 validate(); 586 validate();
587 return; 587 return;
588 } 588 }
589 m_end = previous.deepEquivalent(); 589 m_end = previous.deepEquivalent();
590 } 590 }
591 591
592 // The selection starts in editable content or non-editable content insi de a different editable ancestor, 592 // The selection starts in editable content or non-editable content insi de a different editable ancestor,
593 // move forward until non-editable content inside the same lowest editab le ancestor is reached. 593 // move forward until non-editable content inside the same lowest editab le ancestor is reached.
594 Node* startEditableAncestor = lowestEditableAncestor(m_start.containerNo de()); 594 Node* startEditableAncestor = lowestEditableAncestor(m_start.containerNo de());
595 if (startRoot || startEditableAncestor != baseEditableAncestor) { 595 if (startRoot || startEditableAncestor != baseEditableAncestor) {
596 Position p = nextVisuallyDistinctCandidate(m_start); 596 Position p = nextVisuallyDistinctCandidate(m_start);
597 Node* shadowAncestor = startRoot ? startRoot->shadowHost() : 0; 597 Node* shadowAncestor = startRoot ? startRoot->shadowHost() : 0;
598 if (p.isNull() && shadowAncestor) 598 if (p.isNull() && shadowAncestor)
599 p = positionBeforeNode(shadowAncestor); 599 p = positionBeforeNode(shadowAncestor);
600 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) { 600 while (p.isNotNull() && !(lowestEditableAncestor(p.containerNode()) == baseEditableAncestor && !isEditablePosition(p))) {
601 Node* root = editableRootForPosition(p); 601 Node* root = editableRootForPosition(p);
602 shadowAncestor = root ? root->shadowHost() : 0; 602 shadowAncestor = root ? root->shadowHost() : 0;
603 p = isAtomicNode(p.containerNode()) ? positionInParentAfterNode( p.containerNode()) : nextVisuallyDistinctCandidate(p); 603 p = isAtomicNode(p.containerNode()) ? positionInParentAfterNode( *p.containerNode()) : nextVisuallyDistinctCandidate(p);
604 if (p.isNull() && shadowAncestor) 604 if (p.isNull() && shadowAncestor)
605 p = positionBeforeNode(shadowAncestor); 605 p = positionBeforeNode(shadowAncestor);
606 } 606 }
607 VisiblePosition next(p); 607 VisiblePosition next(p);
608 608
609 if (next.isNull()) { 609 if (next.isNull()) {
610 // The selection crosses an Editing boundary. This is a 610 // The selection crosses an Editing boundary. This is a
611 // programmer error in the editing code. Happy debugging! 611 // programmer error in the editing code. Happy debugging!
612 ASSERT_NOT_REACHED(); 612 ASSERT_NOT_REACHED();
613 m_base = Position(); 613 m_base = Position();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 sel.showTreeForThis(); 734 sel.showTreeForThis();
735 } 735 }
736 736
737 void showTree(const WebCore::VisibleSelection* sel) 737 void showTree(const WebCore::VisibleSelection* sel)
738 { 738 {
739 if (sel) 739 if (sel)
740 sel->showTreeForThis(); 740 sel->showTreeForThis();
741 } 741 }
742 742
743 #endif 743 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698