Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Source/core/editing/serializers/Serialization.cpp

Issue 1417363002: Revert of Use FrameSelection::selectedText where possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (startPosition.isNull() || endPosition.isNull()) 246 ASSERT(startPosition.isNotNull());
247 return emptyString(); 247 ASSERT(endPosition.isNotNull());
248
249 ASSERT(startPosition.compareTo(endPosition) <= 0); 248 ASSERT(startPosition.compareTo(endPosition) <= 0);
250 249
251 bool collapsed = startPosition == endPosition; 250 bool collapsed = startPosition == endPosition;
252 if (collapsed) 251 if (collapsed)
253 return emptyString(); 252 return emptyString();
254 Node* commonAncestor = Strategy::commonAncestor(*startPosition.computeContai nerNode(), *endPosition.computeContainerNode()); 253 Node* commonAncestor = Strategy::commonAncestor(*startPosition.computeContai nerNode(), *endPosition.computeContainerNode());
255 if (!commonAncestor) 254 if (!commonAncestor)
256 return emptyString(); 255 return emptyString();
257 256
258 Document* document = startPosition.document(); 257 Document* document = startPosition.document();
259 document->updateLayoutIgnorePendingStylesheets(); 258 document->updateLayoutIgnorePendingStylesheets();
260 259
261 HTMLElement* specialCommonAncestor = highestAncestorToWrapMarkup<Strategy>(s tartPosition, endPosition, shouldAnnotate, constrainingAncestor); 260 HTMLElement* specialCommonAncestor = highestAncestorToWrapMarkup<Strategy>(s tartPosition, endPosition, shouldAnnotate, constrainingAncestor);
262 StyledMarkupSerializer<Strategy> serializer(shouldResolveURLs, shouldAnnotat e, startPosition, endPosition, specialCommonAncestor, convertBlocksToInlines); 261 StyledMarkupSerializer<Strategy> serializer(shouldResolveURLs, shouldAnnotat e, startPosition, endPosition, specialCommonAncestor, convertBlocksToInlines);
263 return serializer.createMarkup(); 262 return serializer.createMarkup();
264 } 263 }
265 264
266 String createMarkup(const Position& startPosition, const Position& endPosition, EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocksToIn lines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor) 265 String createMarkup(const Position& startPosition, const Position& endPosition, EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocksToIn lines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor)
267 { 266 {
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);
273 return CreateMarkupAlgorithm<EditingInComposedTreeStrategy>::createMarkup(st artPosition, endPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveU RLs, constrainingAncestor); 274 return CreateMarkupAlgorithm<EditingInComposedTreeStrategy>::createMarkup(st artPosition, endPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveU RLs, constrainingAncestor);
274 } 275 }
275 276
276 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu ment, const String& markup, const String& baseURL, ParserContentPolicy parserCon tentPolicy) 277 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu ment, const String& markup, const String& baseURL, ParserContentPolicy parserCon tentPolicy)
277 { 278 {
278 // We use a fake body element here to trick the HTML parser to using the InB ody insertion mode. 279 // We use a fake body element here to trick the HTML parser to using the InB ody insertion mode.
279 RefPtrWillBeRawPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(docum ent); 280 RefPtrWillBeRawPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(docum ent);
280 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument); 281 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument);
281 282
282 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy); 283 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 RefPtrWillBeRawPtr<Text> textNext = toText(next); 700 RefPtrWillBeRawPtr<Text> textNext = toText(next);
700 textNode->appendData(textNext->data()); 701 textNode->appendData(textNext->data());
701 if (textNext->parentNode()) // Might have been removed by mutation event. 702 if (textNext->parentNode()) // Might have been removed by mutation event.
702 textNext->remove(exceptionState); 703 textNext->remove(exceptionState);
703 } 704 }
704 705
705 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; 706 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>;
706 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingInComposedTreeS trategy>; 707 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingInComposedTreeS trategy>;
707 708
708 } 709 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698