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

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

Issue 1311913006: Use PositionWithAffinity as internal representation of VisiblePostion (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-02T14:43:03 Created 5 years, 3 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "wtf/text/CString.h" 42 #include "wtf/text/CString.h"
43 43
44 #ifndef NDEBUG 44 #ifndef NDEBUG
45 #include <stdio.h> 45 #include <stdio.h>
46 #endif 46 #endif
47 47
48 namespace blink { 48 namespace blink {
49 49
50 using namespace HTMLNames; 50 using namespace HTMLNames;
51 51
52 VisiblePosition::VisiblePosition(const Position& position, TextAffinity affinity ) 52 VisiblePosition::VisiblePosition()
53 { 53 {
54 // TODO(yosin) We should make |VisiblePosition| private and make this 54 }
55 // constructor to populate member variables by using |createVisiblePosition( )|. 55
56 *this = createVisiblePosition(position, affinity); 56 VisiblePosition::VisiblePosition(const PositionWithAffinity& positionWithAffinit y)
57 : m_positionWithAffinity(positionWithAffinity)
58 {
57 } 59 }
58 60
59 VisiblePosition VisiblePosition::createWithoutCanonicalization(const PositionWit hAffinity& canonicalized) 61 VisiblePosition VisiblePosition::createWithoutCanonicalization(const PositionWit hAffinity& canonicalized)
60 { 62 {
61 VisiblePosition visiblePosition; 63 return VisiblePosition(canonicalized);
62 visiblePosition.m_deepPosition = canonicalized.position();
63 visiblePosition.m_affinity = canonicalized.affinity();
64 return visiblePosition;
65 } 64 }
66 65
67 template <typename Strategy> 66 template <typename Strategy>
68 PositionWithAffinityTemplate<Strategy> honorEditingBoundaryAtOrBeforeAlgorithm(c onst PositionWithAffinityTemplate<Strategy>& pos, const PositionAlgorithm<Strate gy>& anchor) 67 PositionWithAffinityTemplate<Strategy> honorEditingBoundaryAtOrBeforeAlgorithm(c onst PositionWithAffinityTemplate<Strategy>& pos, const PositionAlgorithm<Strate gy>& anchor)
69 { 68 {
70 if (pos.isNull()) 69 if (pos.isNull())
71 return pos; 70 return pos;
72 71
73 ContainerNode* highestRoot = highestEditableRoot(anchor); 72 ContainerNode* highestRoot = highestEditableRoot(anchor);
74 73
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 164 }
166 165
167 #ifndef NDEBUG 166 #ifndef NDEBUG
168 167
169 void VisiblePosition::debugPosition(const char* msg) const 168 void VisiblePosition::debugPosition(const char* msg) const
170 { 169 {
171 if (isNull()) { 170 if (isNull()) {
172 fprintf(stderr, "Position [%s]: null\n", msg); 171 fprintf(stderr, "Position [%s]: null\n", msg);
173 return; 172 return;
174 } 173 }
175 m_deepPosition.debugPosition(msg); 174 deepEquivalent().debugPosition(msg);
176 } 175 }
177 176
178 void VisiblePosition::formatForDebugger(char* buffer, unsigned length) const 177 void VisiblePosition::formatForDebugger(char* buffer, unsigned length) const
179 { 178 {
180 m_deepPosition.formatForDebugger(buffer, length); 179 deepEquivalent().formatForDebugger(buffer, length);
181 } 180 }
182 181
183 void VisiblePosition::showTreeForThis() const 182 void VisiblePosition::showTreeForThis() const
184 { 183 {
185 m_deepPosition.showTreeForThis(); 184 deepEquivalent().showTreeForThis();
186 } 185 }
187 186
188 #endif 187 #endif
189 188
190 DEFINE_TRACE(VisiblePosition) 189 DEFINE_TRACE(VisiblePosition)
191 { 190 {
192 visitor->trace(m_deepPosition); 191 visitor->trace(m_positionWithAffinity);
193 } 192 }
194 193
195 } // namespace blink 194 } // namespace blink
196 195
197 #ifndef NDEBUG 196 #ifndef NDEBUG
198 197
199 void showTree(const blink::VisiblePosition* vpos) 198 void showTree(const blink::VisiblePosition* vpos)
200 { 199 {
201 if (vpos) 200 if (vpos)
202 vpos->showTreeForThis(); 201 vpos->showTreeForThis();
203 else 202 else
204 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); 203 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n");
205 } 204 }
206 205
207 void showTree(const blink::VisiblePosition& vpos) 206 void showTree(const blink::VisiblePosition& vpos)
208 { 207 {
209 vpos.showTreeForThis(); 208 vpos.showTreeForThis();
210 } 209 }
211 210
212 #endif 211 #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