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

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

Issue 1085163002: Introduce EditingAlgorithm<Traversal> class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-04-15T16:50:42 Rebase for Position.h updates Created 5 years, 8 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/htmlediting.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 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 LayoutObject* renderer = enclosingBlockElement->layoutObject(); 357 LayoutObject* renderer = enclosingBlockElement->layoutObject();
358 return renderer ? renderer->style()->direction() : LTR; 358 return renderer ? renderer->style()->direction() : LTR;
359 } 359 }
360 360
361 // This method is used to create positions in the DOM. It returns the maximum va lid offset 361 // This method is used to create positions in the DOM. It returns the maximum va lid offset
362 // in a node. It returns 1 for some elements even though they do not have childr en, which 362 // in a node. It returns 1 for some elements even though they do not have childr en, which
363 // creates technically invalid DOM Positions. Be sure to call parentAnchoredEqui valent 363 // creates technically invalid DOM Positions. Be sure to call parentAnchoredEqui valent
364 // on a Position before using it to create a DOM Range, or an exception will be thrown. 364 // on a Position before using it to create a DOM Range, or an exception will be thrown.
365 int lastOffsetForEditing(const Node* node) 365 int lastOffsetForEditing(const Node* node)
366 { 366 {
367 ASSERT(node); 367 return EditingStrategy::lastOffsetForEditing(node);
368 if (!node)
369 return 0;
370 if (node->offsetInCharacters())
371 return node->maxCharacterOffset();
372
373 if (node->hasChildren())
374 return node->countChildren();
375
376 // NOTE: This should preempt the childNodeCount for, e.g., select nodes
377 if (editingIgnoresContent(node))
378 return 1;
379
380 return 0;
381 } 368 }
382 369
383 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP aragraph, bool endIsEndOfParagraph) 370 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP aragraph, bool endIsEndOfParagraph)
384 { 371 {
385 unsigned length = string.length(); 372 unsigned length = string.length();
386 373
387 StringBuilder rebalancedString; 374 StringBuilder rebalancedString;
388 rebalancedString.reserveCapacity(length); 375 rebalancedString.reserveCapacity(length);
389 376
390 bool previousCharacterWasSpace = false; 377 bool previousCharacterWasSpace = false;
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 // if the selection starts just before a paragraph break, skip over it 1182 // if the selection starts just before a paragraph break, skip over it
1196 if (isEndOfParagraph(visiblePosition)) 1183 if (isEndOfParagraph(visiblePosition))
1197 return visiblePosition.next().deepEquivalent().downstream(); 1184 return visiblePosition.next().deepEquivalent().downstream();
1198 1185
1199 // otherwise, make sure to be at the start of the first selected node, 1186 // otherwise, make sure to be at the start of the first selected node,
1200 // instead of possibly at the end of the last node before the selection 1187 // instead of possibly at the end of the last node before the selection
1201 return visiblePosition.deepEquivalent().downstream(); 1188 return visiblePosition.deepEquivalent().downstream();
1202 } 1189 }
1203 1190
1204 } // namespace blink 1191 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/htmlediting.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698