| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 public: | 236 public: |
| 237 static String createMarkup(const PositionTemplate<Strategy>& startPosition,
const PositionTemplate<Strategy>& endPosition, EAnnotateForInterchange shouldAnn
otate = DoNotAnnotateForInterchange, ConvertBlocksToInlines = ConvertBlocksToInl
ines::NotConvert, EAbsoluteURLs shouldResolveURLs = DoNotResolveURLs, Node* cons
trainingAncestor = nullptr); | 237 static String createMarkup(const PositionTemplate<Strategy>& startPosition,
const PositionTemplate<Strategy>& endPosition, EAnnotateForInterchange shouldAnn
otate = DoNotAnnotateForInterchange, ConvertBlocksToInlines = ConvertBlocksToInl
ines::NotConvert, EAbsoluteURLs shouldResolveURLs = DoNotResolveURLs, Node* cons
trainingAncestor = nullptr); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha
nge? | 240 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha
nge? |
| 241 // FIXME: At least, annotation and style info should probably not be included in
range.markupString() | 241 // FIXME: At least, annotation and style info should probably not be included in
range.markupString() |
| 242 template <typename Strategy> | 242 template <typename Strategy> |
| 243 String CreateMarkupAlgorithm<Strategy>::createMarkup(const PositionTemplate<Stra
tegy>& startPosition, const PositionTemplate<Strategy>& endPosition, | 243 String CreateMarkupAlgorithm<Strategy>::createMarkup(const PositionTemplate<Stra
tegy>& startPosition, const PositionTemplate<Strategy>& endPosition, |
| 244 EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocks
ToInlines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor) | 244 EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocks
ToInlines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor) |
| 245 { | 245 { |
| 246 ASSERT(startPosition.isNotNull()); | 246 if (startPosition.isNull() || endPosition.isNull()) |
| 247 ASSERT(endPosition.isNotNull()); | 247 return emptyString(); |
| 248 |
| 248 ASSERT(startPosition.compareTo(endPosition) <= 0); | 249 ASSERT(startPosition.compareTo(endPosition) <= 0); |
| 249 | 250 |
| 250 bool collapsed = startPosition == endPosition; | 251 bool collapsed = startPosition == endPosition; |
| 251 if (collapsed) | 252 if (collapsed) |
| 252 return emptyString(); | 253 return emptyString(); |
| 253 Node* commonAncestor = Strategy::commonAncestor(*startPosition.computeContai
nerNode(), *endPosition.computeContainerNode()); | 254 Node* commonAncestor = Strategy::commonAncestor(*startPosition.computeContai
nerNode(), *endPosition.computeContainerNode()); |
| 254 if (!commonAncestor) | 255 if (!commonAncestor) |
| 255 return emptyString(); | 256 return emptyString(); |
| 256 | 257 |
| 257 Document* document = startPosition.document(); | 258 Document* document = startPosition.document(); |
| 258 document->updateLayoutIgnorePendingStylesheets(); | 259 document->updateLayoutIgnorePendingStylesheets(); |
| 259 | 260 |
| 260 HTMLElement* specialCommonAncestor = highestAncestorToWrapMarkup<Strategy>(s
tartPosition, endPosition, shouldAnnotate, constrainingAncestor); | 261 HTMLElement* specialCommonAncestor = highestAncestorToWrapMarkup<Strategy>(s
tartPosition, endPosition, shouldAnnotate, constrainingAncestor); |
| 261 StyledMarkupSerializer<Strategy> serializer(shouldResolveURLs, shouldAnnotat
e, startPosition, endPosition, specialCommonAncestor, convertBlocksToInlines); | 262 StyledMarkupSerializer<Strategy> serializer(shouldResolveURLs, shouldAnnotat
e, startPosition, endPosition, specialCommonAncestor, convertBlocksToInlines); |
| 262 return serializer.createMarkup(); | 263 return serializer.createMarkup(); |
| 263 } | 264 } |
| 264 | 265 |
| 265 String createMarkup(const Position& startPosition, const Position& endPosition,
EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocksToIn
lines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor) | 266 String createMarkup(const Position& startPosition, const Position& endPosition,
EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocksToIn
lines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor) |
| 266 { | 267 { |
| 267 ASSERT(startPosition.compareTo(endPosition) <= 0); | |
| 268 return CreateMarkupAlgorithm<EditingStrategy>::createMarkup(startPosition, e
ndPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs, constrain
ingAncestor); | 268 return CreateMarkupAlgorithm<EditingStrategy>::createMarkup(startPosition, e
ndPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs, constrain
ingAncestor); |
| 269 } | 269 } |
| 270 | 270 |
| 271 String createMarkup(const PositionInComposedTree& startPosition, const PositionI
nComposedTree& endPosition, EAnnotateForInterchange shouldAnnotate, ConvertBlock
sToInlines convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs, Node* constr
ainingAncestor) | 271 String createMarkup(const PositionInComposedTree& startPosition, const PositionI
nComposedTree& endPosition, EAnnotateForInterchange shouldAnnotate, ConvertBlock
sToInlines convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs, Node* constr
ainingAncestor) |
| 272 { | 272 { |
| 273 ASSERT(startPosition.compareTo(endPosition) <= 0); | |
| 274 return CreateMarkupAlgorithm<EditingInComposedTreeStrategy>::createMarkup(st
artPosition, endPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveU
RLs, constrainingAncestor); | 273 return CreateMarkupAlgorithm<EditingInComposedTreeStrategy>::createMarkup(st
artPosition, endPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveU
RLs, constrainingAncestor); |
| 275 } | 274 } |
| 276 | 275 |
| 277 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu
ment, const String& markup, const String& baseURL, ParserContentPolicy parserCon
tentPolicy) | 276 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu
ment, const String& markup, const String& baseURL, ParserContentPolicy parserCon
tentPolicy) |
| 278 { | 277 { |
| 279 // We use a fake body element here to trick the HTML parser to using the InB
ody insertion mode. | 278 // We use a fake body element here to trick the HTML parser to using the InB
ody insertion mode. |
| 280 RefPtrWillBeRawPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(docum
ent); | 279 RefPtrWillBeRawPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(docum
ent); |
| 281 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc
ument); | 280 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc
ument); |
| 282 | 281 |
| 283 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy); | 282 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 RefPtrWillBeRawPtr<Text> textNext = toText(next); | 699 RefPtrWillBeRawPtr<Text> textNext = toText(next); |
| 701 textNode->appendData(textNext->data()); | 700 textNode->appendData(textNext->data()); |
| 702 if (textNext->parentNode()) // Might have been removed by mutation event. | 701 if (textNext->parentNode()) // Might have been removed by mutation event. |
| 703 textNext->remove(exceptionState); | 702 textNext->remove(exceptionState); |
| 704 } | 703 } |
| 705 | 704 |
| 706 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; | 705 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; |
| 707 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingInComposedTreeS
trategy>; | 706 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingInComposedTreeS
trategy>; |
| 708 | 707 |
| 709 } | 708 } |
| OLD | NEW |