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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 String StyledMarkupAccumulator::renderedText(Node& node, const Range* range) | 257 String StyledMarkupAccumulator::renderedText(Node& node, const Range* range) |
258 { | 258 { |
259 if (!node.isTextNode()) | 259 if (!node.isTextNode()) |
260 return String(); | 260 return String(); |
261 | 261 |
262 Text& textNode = toText(node); | 262 Text& textNode = toText(node); |
263 unsigned startOffset = 0; | 263 unsigned startOffset = 0; |
264 unsigned endOffset = textNode.length(); | 264 unsigned endOffset = textNode.length(); |
265 | 265 |
266 if (range && textNode == range->startContainer()) | 266 TextIteratorBehavior behavior = TextIteratorDefaultBehavior; |
267 startOffset = range->startOffset(); | 267 if (range) { |
268 if (range && textNode == range->endContainer()) | 268 if (textNode == range->startContainer()) |
269 endOffset = range->endOffset(); | 269 startOffset = range->startOffset(); |
| 270 |
| 271 if (textNode == range->endContainer()) |
| 272 endOffset = range->endOffset(); |
| 273 else |
| 274 behavior = TextIteratorBehavesAsIfNodesFollowing; |
| 275 } |
270 | 276 |
271 Position start = createLegacyEditingPosition(&textNode, startOffset); | 277 Position start = createLegacyEditingPosition(&textNode, startOffset); |
272 Position end = createLegacyEditingPosition(&textNode, endOffset); | 278 Position end = createLegacyEditingPosition(&textNode, endOffset); |
273 return plainText(Range::create(textNode.document(), start, end).get()); | 279 return plainText(Range::create(textNode.document(), start, end).get(), behav
ior); |
274 } | 280 } |
275 | 281 |
276 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Rang
e* range) | 282 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Rang
e* range) |
277 { | 283 { |
278 if (!range) | 284 if (!range) |
279 return node.nodeValue(); | 285 return node.nodeValue(); |
280 | 286 |
281 String str = node.nodeValue(); | 287 String str = node.nodeValue(); |
282 if (node == range->endContainer()) | 288 if (node == range->endContainer()) |
283 str.truncate(range->endOffset()); | 289 str.truncate(range->endOffset()); |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 node->document().updateLayoutIgnorePendingStylesheets(); | 1093 node->document().updateLayoutIgnorePendingStylesheets(); |
1088 | 1094 |
1089 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); | 1095 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); |
1090 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; | 1096 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; |
1091 | 1097 |
1092 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; | 1098 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; |
1093 return documentMarkup + accumulator.takeResults(); | 1099 return documentMarkup + accumulator.takeResults(); |
1094 } | 1100 } |
1095 | 1101 |
1096 } | 1102 } |
OLD | NEW |