| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 if (range && textNode == range->endContainer()) | 212 if (range && textNode == range->endContainer()) |
| 213 endOffset = range->endOffset(); | 213 endOffset = range->endOffset(); |
| 214 | 214 |
| 215 Position start = createLegacyEditingPosition(&textNode, startOffset); | 215 Position start = createLegacyEditingPosition(&textNode, startOffset); |
| 216 Position end = createLegacyEditingPosition(&textNode, endOffset); | 216 Position end = createLegacyEditingPosition(&textNode, endOffset); |
| 217 return plainText(Range::create(textNode.document(), start, end).get()); | 217 return plainText(Range::create(textNode.document(), start, end).get()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Rang
e* range) | 220 String StyledMarkupAccumulator::stringValueForRange(const Node& node, const Rang
e* range) |
| 221 { | 221 { |
| 222 if (!node.isTextNode()) |
| 223 return emptyString(); |
| 224 String text = toText(node).data(); |
| 222 if (!range) | 225 if (!range) |
| 223 return node.nodeValue(); | 226 return text; |
| 224 | |
| 225 String str = node.nodeValue(); | |
| 226 if (node == range->endContainer()) | 227 if (node == range->endContainer()) |
| 227 str.truncate(range->endOffset()); | 228 text.truncate(range->endOffset()); |
| 228 if (node == range->startContainer()) | 229 if (node == range->startContainer()) |
| 229 str.remove(0, range->startOffset()); | 230 text.remove(0, range->startOffset()); |
| 230 return str; | 231 return text; |
| 231 } | 232 } |
| 232 | 233 |
| 233 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) | 234 void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) |
| 234 { | 235 { |
| 235 const bool documentIsHTML = element.document().isHTMLDocument(); | 236 const bool documentIsHTML = element.document().isHTMLDocument(); |
| 236 appendOpenTag(out, element, 0); | 237 appendOpenTag(out, element, 0); |
| 237 | 238 |
| 238 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); | 239 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldA
nnotate() || addDisplayInline); |
| 239 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); | 240 const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldAp
plyWrappingStyle(element); |
| 240 | 241 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 if (!next || !next->isTextNode()) | 574 if (!next || !next->isTextNode()) |
| 574 return; | 575 return; |
| 575 | 576 |
| 576 RefPtr<Text> textNext = toText(next); | 577 RefPtr<Text> textNext = toText(next); |
| 577 textNode->appendData(textNext->data()); | 578 textNode->appendData(textNext->data()); |
| 578 if (textNext->parentNode()) // Might have been removed by mutation event. | 579 if (textNext->parentNode()) // Might have been removed by mutation event. |
| 579 textNext->remove(exceptionState); | 580 textNext->remove(exceptionState); |
| 580 } | 581 } |
| 581 | 582 |
| 582 } | 583 } |
| OLD | NEW |