OLD | NEW |
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 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 String StyledMarkupAccumulator::renderedText(Node& node, const Range* range) | 242 String StyledMarkupAccumulator::renderedText(Node& node, const Range* range) |
243 { | 243 { |
244 if (!node.isTextNode()) | 244 if (!node.isTextNode()) |
245 return String(); | 245 return String(); |
246 | 246 |
247 const Text& textNode = toText(node); | 247 const Text& textNode = toText(node); |
248 unsigned startOffset = 0; | 248 unsigned startOffset = 0; |
249 unsigned endOffset = textNode.length(); | 249 unsigned endOffset = textNode.length(); |
250 | 250 |
251 if (range && node == range->startContainer()) | 251 TextIteratorBehavior behavior = TextIteratorDefaultBehavior; |
252 startOffset = range->startOffset(); | 252 if (range) { |
253 if (range && node == range->endContainer()) | 253 if (node == range->startContainer()) |
254 endOffset = range->endOffset(); | 254 startOffset = range->startOffset(); |
255 | 255 |
| 256 if (node == range->endContainer()) |
| 257 endOffset = range->endOffset(); |
| 258 else |
| 259 behavior = TextIteratorBehavesAsIfNodesFollowing; |
| 260 } |
256 Position start = createLegacyEditingPosition(&node, startOffset); | 261 Position start = createLegacyEditingPosition(&node, startOffset); |
257 Position end = createLegacyEditingPosition(&node, endOffset); | 262 Position end = createLegacyEditingPosition(&node, endOffset); |
258 return plainText(Range::create(node.document(), start, end).get()); | 263 return plainText(Range::create(node.document(), start, end).get(), behavior)
; |
259 } | 264 } |
260 | 265 |
261 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Rang
e* range) | 266 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Rang
e* range) |
262 { | 267 { |
263 if (!range) | 268 if (!range) |
264 return node.nodeValue(); | 269 return node.nodeValue(); |
265 | 270 |
266 String str = node.nodeValue(); | 271 String str = node.nodeValue(); |
267 if (node == range->endContainer()) | 272 if (node == range->endContainer()) |
268 str.truncate(range->endOffset()); | 273 str.truncate(range->endOffset()); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 return; | 1049 return; |
1045 | 1050 |
1046 RefPtr<Text> textNode = toText(node.get()); | 1051 RefPtr<Text> textNode = toText(node.get()); |
1047 RefPtr<Text> textNext = toText(next); | 1052 RefPtr<Text> textNext = toText(next); |
1048 textNode->appendData(textNext->data()); | 1053 textNode->appendData(textNext->data()); |
1049 if (textNext->parentNode()) // Might have been removed by mutation event. | 1054 if (textNext->parentNode()) // Might have been removed by mutation event. |
1050 textNext->remove(exceptionState); | 1055 textNext->remove(exceptionState); |
1051 } | 1056 } |
1052 | 1057 |
1053 } | 1058 } |
OLD | NEW |