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

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

Issue 1193783002: Templatize canonicalizeCandidate() in VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-19T12:59:53 Mark |static| 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 | « no previous file | no next file » | 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 return pos; 535 return pos;
536 536
537 // If this is not editable but |pos| has an editable root, skip to the end 537 // If this is not editable but |pos| has an editable root, skip to the end
538 if (!highestRoot && highestRootOfPos) 538 if (!highestRoot && highestRootOfPos)
539 return VisiblePosition(Position(highestRootOfPos, Position::PositionIsAf terAnchor).parentAnchoredEquivalent()); 539 return VisiblePosition(Position(highestRootOfPos, Position::PositionIsAf terAnchor).parentAnchoredEquivalent());
540 540
541 // That must mean that |pos| is not editable. Return the next position after pos that is in the same editable region as this position 541 // That must mean that |pos| is not editable. Return the next position after pos that is in the same editable region as this position
542 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(), highestRoot); 542 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(), highestRoot);
543 } 543 }
544 544
545 static Position canonicalizeCandidate(const Position& candidate) 545 template <typename PositionType>
546 static PositionType canonicalizeCandidate(const PositionType& candidate)
546 { 547 {
547 if (candidate.isNull()) 548 if (candidate.isNull())
548 return Position(); 549 return PositionType();
549 ASSERT(candidate.isCandidate()); 550 ASSERT(candidate.isCandidate());
550 Position upstream = candidate.upstream(); 551 PositionType upstream = candidate.upstream();
551 if (upstream.isCandidate()) 552 if (upstream.isCandidate())
552 return upstream; 553 return upstream;
553 return candidate; 554 return candidate;
554 } 555 }
555 556
556 Position VisiblePosition::canonicalPosition(const Position& passedPosition) 557 Position VisiblePosition::canonicalPosition(const Position& passedPosition)
557 { 558 {
558 // Sometimes updating selection positions can be extremely expensive and occ ur 559 // Sometimes updating selection positions can be extremely expensive and occ ur
559 // frequently. Often calling preventDefault on mousedown events can avoid 560 // frequently. Often calling preventDefault on mousedown events can avoid
560 // doing unnecessary text selection work. http://crbug.com/472258. 561 // doing unnecessary text selection work. http://crbug.com/472258.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 else 793 else
793 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); 794 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n");
794 } 795 }
795 796
796 void showTree(const blink::VisiblePosition& vpos) 797 void showTree(const blink::VisiblePosition& vpos)
797 { 798 {
798 vpos.showTreeForThis(); 799 vpos.showTreeForThis();
799 } 800 }
800 801
801 #endif 802 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698