OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "core/html/HTMLOListElement.h" | 50 #include "core/html/HTMLOListElement.h" |
51 #include "core/html/HTMLParagraphElement.h" | 51 #include "core/html/HTMLParagraphElement.h" |
52 #include "core/html/HTMLTableCellElement.h" | 52 #include "core/html/HTMLTableCellElement.h" |
53 #include "core/html/HTMLUListElement.h" | 53 #include "core/html/HTMLUListElement.h" |
54 #include "core/rendering/RenderObject.h" | 54 #include "core/rendering/RenderObject.h" |
55 #include "core/rendering/RenderTableCell.h" | 55 #include "core/rendering/RenderTableCell.h" |
56 #include "wtf/Assertions.h" | 56 #include "wtf/Assertions.h" |
57 #include "wtf/StdLibExtras.h" | 57 #include "wtf/StdLibExtras.h" |
58 #include "wtf/text/StringBuilder.h" | 58 #include "wtf/text/StringBuilder.h" |
59 | 59 |
60 using namespace std; | |
61 | |
62 namespace WebCore { | 60 namespace WebCore { |
63 | 61 |
64 using namespace HTMLNames; | 62 using namespace HTMLNames; |
65 | 63 |
66 // Atomic means that the node has no children, or has children which are ignored
for the | 64 // Atomic means that the node has no children, or has children which are ignored
for the |
67 // purposes of editing. | 65 // purposes of editing. |
68 bool isAtomicNode(const Node *node) | 66 bool isAtomicNode(const Node *node) |
69 { | 67 { |
70 return node && (!node->hasChildren() || editingIgnoresContent(node)); | 68 return node && (!node->hasChildren() || editingIgnoresContent(node)); |
71 } | 69 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 361 } |
364 | 362 |
365 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP
aragraph, bool endIsEndOfParagraph) | 363 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfP
aragraph, bool endIsEndOfParagraph) |
366 { | 364 { |
367 unsigned length = string.length(); | 365 unsigned length = string.length(); |
368 | 366 |
369 StringBuilder rebalancedString; | 367 StringBuilder rebalancedString; |
370 rebalancedString.reserveCapacity(length); | 368 rebalancedString.reserveCapacity(length); |
371 | 369 |
372 bool previousCharacterWasSpace = false; | 370 bool previousCharacterWasSpace = false; |
373 for (size_t i = 0; i < length; i++) { | 371 for (std::size_t i = 0; i < length; i++) { |
374 UChar c = string[i]; | 372 UChar c = string[i]; |
375 if (!isWhitespace(c)) { | 373 if (!isWhitespace(c)) { |
376 rebalancedString.append(c); | 374 rebalancedString.append(c); |
377 previousCharacterWasSpace = false; | 375 previousCharacterWasSpace = false; |
378 continue; | 376 continue; |
379 } | 377 } |
380 | 378 |
381 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i +
1 == length && endIsEndOfParagraph)) { | 379 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i +
1 == length && endIsEndOfParagraph)) { |
382 rebalancedString.append(noBreakSpace); | 380 rebalancedString.append(noBreakSpace); |
383 previousCharacterWasSpace = false; | 381 previousCharacterWasSpace = false; |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 // if the selection starts just before a paragraph break, skip over it | 1111 // if the selection starts just before a paragraph break, skip over it |
1114 if (isEndOfParagraph(visiblePosition)) | 1112 if (isEndOfParagraph(visiblePosition)) |
1115 return visiblePosition.next().deepEquivalent().downstream(); | 1113 return visiblePosition.next().deepEquivalent().downstream(); |
1116 | 1114 |
1117 // otherwise, make sure to be at the start of the first selected node, | 1115 // otherwise, make sure to be at the start of the first selected node, |
1118 // instead of possibly at the end of the last node before the selection | 1116 // instead of possibly at the end of the last node before the selection |
1119 return visiblePosition.deepEquivalent().downstream(); | 1117 return visiblePosition.deepEquivalent().downstream(); |
1120 } | 1118 } |
1121 | 1119 |
1122 } // namespace WebCore | 1120 } // namespace WebCore |
OLD | NEW |