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

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

Issue 1203613003: Make inSameLine() in VisibleUnits.cpp to work with positions in composed tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-24T17:52:54 Get rid of redundant explict in RenderedPosition Created 5 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
« no previous file with comments | « Source/core/editing/VisiblePosition.h ('k') | Source/core/editing/VisibleUnits.h » ('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, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 VisiblePosition right = VisiblePosition(pos, DOWNSTREAM); 438 VisiblePosition right = VisiblePosition(pos, DOWNSTREAM);
439 ASSERT(right != *this); 439 ASSERT(right != *this);
440 440
441 if (!stayInEditableContent) 441 if (!stayInEditableContent)
442 return right; 442 return right;
443 443
444 return directionOfEnclosingBlock(right.deepEquivalent()) == LTR ? honorEditi ngBoundaryAtOrAfter(right) : honorEditingBoundaryAtOrBefore(right); 444 return directionOfEnclosingBlock(right.deepEquivalent()) == LTR ? honorEditi ngBoundaryAtOrAfter(right) : honorEditingBoundaryAtOrBefore(right);
445 } 445 }
446 446
447 template <typename PositionWithAffinityType> 447 template <typename PositionWithAffinityType>
448 PositionWithAffinityType honorEditingBoundaryAtOrBeforeAlgorithm(const PositionW ithAffinityType& pos, const Position& anchor) 448 PositionWithAffinityType honorEditingBoundaryAtOrBeforeAlgorithm(const PositionW ithAffinityType& pos, const typename PositionWithAffinityType::PositionType& anc hor)
449 { 449 {
450 if (pos.isNull()) 450 if (pos.isNull())
451 return pos; 451 return pos;
452 452
453 ContainerNode* highestRoot = highestEditableRoot(anchor); 453 ContainerNode* highestRoot = highestEditableRoot(anchor);
454 454
455 // Return empty position if pos is not somewhere inside the editable region containing this position 455 // Return empty position if pos is not somewhere inside the editable region containing this position
456 if (highestRoot && !pos.position().deprecatedNode()->isDescendantOf(highestR oot)) 456 if (highestRoot && !pos.position().deprecatedNode()->isDescendantOf(highestR oot))
457 return PositionWithAffinityType(); 457 return PositionWithAffinityType();
458 458
(...skipping 10 matching lines...) Expand all
469 469
470 // Return the last position before pos that is in the same editable region a s this position 470 // Return the last position before pos that is in the same editable region a s this position
471 return lastEditablePositionBeforePositionInRoot(pos.position(), highestRoot) ; 471 return lastEditablePositionBeforePositionInRoot(pos.position(), highestRoot) ;
472 } 472 }
473 473
474 PositionWithAffinity honorEditingBoundaryAtOrBeforeOf(const PositionWithAffinity & pos, const Position& anchor) 474 PositionWithAffinity honorEditingBoundaryAtOrBeforeOf(const PositionWithAffinity & pos, const Position& anchor)
475 { 475 {
476 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor); 476 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor);
477 } 477 }
478 478
479 PositionInComposedTreeWithAffinity honorEditingBoundaryAtOrBeforeOf(const Positi onInComposedTreeWithAffinity& pos, const PositionInComposedTree& anchor)
480 {
481 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor);
482 }
483
479 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrBefore(const VisiblePos ition &pos) const 484 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrBefore(const VisiblePos ition &pos) const
480 { 485 {
481 return VisiblePosition(honorEditingBoundaryAtOrBeforeOf(PositionWithAffinity (pos.deepEquivalent(), pos.affinity()), deepEquivalent())); 486 return VisiblePosition(honorEditingBoundaryAtOrBeforeOf(PositionWithAffinity (pos.deepEquivalent(), pos.affinity()), deepEquivalent()));
482 } 487 }
483 488
484 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrAfter(const VisiblePosi tion &pos) const 489 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrAfter(const VisiblePosi tion &pos) const
485 { 490 {
486 if (pos.isNull()) 491 if (pos.isNull())
487 return pos; 492 return pos;
488 493
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 else 835 else
831 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); 836 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n");
832 } 837 }
833 838
834 void showTree(const blink::VisiblePosition& vpos) 839 void showTree(const blink::VisiblePosition& vpos)
835 { 840 {
836 vpos.showTreeForThis(); 841 vpos.showTreeForThis();
837 } 842 }
838 843
839 #endif 844 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.h ('k') | Source/core/editing/VisibleUnits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698