| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
| 3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
| 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 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 | 1086 |
| 1087 // -------- | 1087 // -------- |
| 1088 | 1088 |
| 1089 template <typename Strategy> | 1089 template <typename Strategy> |
| 1090 static String createPlainText(const EphemeralRangeTemplate<Strategy>& range, Tex
tIteratorBehaviorFlags behavior) | 1090 static String createPlainText(const EphemeralRangeTemplate<Strategy>& range, Tex
tIteratorBehaviorFlags behavior) |
| 1091 { | 1091 { |
| 1092 if (range.isNull()) | 1092 if (range.isNull()) |
| 1093 return emptyString(); | 1093 return emptyString(); |
| 1094 | 1094 |
| 1095 TextIteratorAlgorithm<Strategy> it(range.startPosition(), range.endPosition(
), behavior); | 1095 TextIteratorAlgorithm<Strategy> it(range.startPosition(), range.endPosition(
), behavior); |
| 1096 |
| 1097 if (it.atEnd()) |
| 1098 return emptyString(); |
| 1099 |
| 1096 // The initial buffer size can be critical for performance: https://bugs.web
kit.org/show_bug.cgi?id=81192 | 1100 // The initial buffer size can be critical for performance: https://bugs.web
kit.org/show_bug.cgi?id=81192 |
| 1097 static const unsigned initialCapacity = 1 << 15; | 1101 static const unsigned initialCapacity = 1 << 15; |
| 1098 | 1102 |
| 1099 unsigned bufferLength = 0; | |
| 1100 StringBuilder builder; | 1103 StringBuilder builder; |
| 1101 builder.reserveCapacity(initialCapacity); | 1104 builder.reserveCapacity(initialCapacity); |
| 1102 | 1105 |
| 1103 for (; !it.atEnd(); it.advance()) { | 1106 for (; !it.atEnd(); it.advance()) |
| 1104 it.text().appendTextToStringBuilder(builder); | 1107 it.text().appendTextToStringBuilder(builder); |
| 1105 bufferLength += it.length(); | |
| 1106 } | |
| 1107 | 1108 |
| 1108 if (!bufferLength) | 1109 if (builder.isEmpty()) |
| 1109 return emptyString(); | 1110 return emptyString(); |
| 1110 | 1111 |
| 1111 return builder.toString(); | 1112 return builder.toString(); |
| 1112 } | 1113 } |
| 1113 | 1114 |
| 1114 String plainText(const EphemeralRange& range, TextIteratorBehaviorFlags behavior
) | 1115 String plainText(const EphemeralRange& range, TextIteratorBehaviorFlags behavior
) |
| 1115 { | 1116 { |
| 1116 return createPlainText<EditingStrategy>(range, behavior); | 1117 return createPlainText<EditingStrategy>(range, behavior); |
| 1117 } | 1118 } |
| 1118 | 1119 |
| 1119 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior
Flags behavior) | 1120 String plainText(const EphemeralRangeInComposedTree& range, TextIteratorBehavior
Flags behavior) |
| 1120 { | 1121 { |
| 1121 return createPlainText<EditingInComposedTreeStrategy>(range, behavior); | 1122 return createPlainText<EditingInComposedTreeStrategy>(range, behavior); |
| 1122 } | 1123 } |
| 1123 | 1124 |
| 1124 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; | 1125 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingStrategy>; |
| 1125 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS
trategy>; | 1126 template class CORE_TEMPLATE_EXPORT TextIteratorAlgorithm<EditingInComposedTreeS
trategy>; |
| 1126 | 1127 |
| 1127 } // namespace blink | 1128 } // namespace blink |
| OLD | NEW |