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

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

Issue 1191193002: Hide canonicalPosition in VisiblePosition from header file (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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') | 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) 51 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity)
52 { 52 {
53 init(pos, affinity); 53 init(pos, affinity);
54 } 54 }
55 55
56 VisiblePosition::VisiblePosition(const PositionWithAffinity& positionWithAffinit y) 56 VisiblePosition::VisiblePosition(const PositionWithAffinity& positionWithAffinit y)
57 { 57 {
58 init(positionWithAffinity.position(), positionWithAffinity.affinity()); 58 init(positionWithAffinity.position(), positionWithAffinity.affinity());
59 } 59 }
60 60
61 static Position canonicalPosition(const Position& passedPosition);
tkent 2015/06/19 03:53:58 Usually we don't add forward declaration for a sta
62
61 void VisiblePosition::init(const Position& position, EAffinity affinity) 63 void VisiblePosition::init(const Position& position, EAffinity affinity)
62 { 64 {
63 m_affinity = affinity; 65 m_affinity = affinity;
64 66
65 m_deepPosition = canonicalPosition(position); 67 m_deepPosition = canonicalPosition(position);
66 68
67 // When not at a line wrap, make sure to end up with DOWNSTREAM affinity. 69 // When not at a line wrap, make sure to end up with DOWNSTREAM affinity.
68 if (m_affinity == UPSTREAM && (isNull() || inSameLine(VisiblePosition(positi on, DOWNSTREAM), *this))) 70 if (m_affinity == UPSTREAM && (isNull() || inSameLine(VisiblePosition(positi on, DOWNSTREAM), *this)))
69 m_affinity = DOWNSTREAM; 71 m_affinity = DOWNSTREAM;
70 } 72 }
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 { 548 {
547 if (candidate.isNull()) 549 if (candidate.isNull())
548 return Position(); 550 return Position();
549 ASSERT(candidate.isCandidate()); 551 ASSERT(candidate.isCandidate());
550 Position upstream = candidate.upstream(); 552 Position upstream = candidate.upstream();
551 if (upstream.isCandidate()) 553 if (upstream.isCandidate())
552 return upstream; 554 return upstream;
553 return candidate; 555 return candidate;
554 } 556 }
555 557
556 Position VisiblePosition::canonicalPosition(const Position& passedPosition) 558 static Position canonicalPosition(const Position& passedPosition)
557 { 559 {
558 // Sometimes updating selection positions can be extremely expensive and occ ur 560 // Sometimes updating selection positions can be extremely expensive and occ ur
559 // frequently. Often calling preventDefault on mousedown events can avoid 561 // frequently. Often calling preventDefault on mousedown events can avoid
560 // doing unnecessary text selection work. http://crbug.com/472258. 562 // doing unnecessary text selection work. http://crbug.com/472258.
561 TRACE_EVENT0("blink", "VisiblePosition::canonicalPosition"); 563 TRACE_EVENT0("blink", "VisiblePosition::canonicalPosition");
562 564
563 // The updateLayout call below can do so much that even the position passed 565 // The updateLayout call below can do so much that even the position passed
564 // in to us might get changed as a side effect. Specifically, there are code 566 // in to us might get changed as a side effect. Specifically, there are code
565 // paths that pass selection endpoints, and updateLayout can change the sele ction. 567 // paths that pass selection endpoints, and updateLayout can change the sele ction.
566 Position position = passedPosition; 568 Position position = passedPosition;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 else 794 else
793 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); 795 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n");
794 } 796 }
795 797
796 void showTree(const blink::VisiblePosition& vpos) 798 void showTree(const blink::VisiblePosition& vpos)
797 { 799 {
798 vpos.showTreeForThis(); 800 vpos.showTreeForThis();
799 } 801 }
800 802
801 #endif 803 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698