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

Side by Side Diff: Source/core/editing/markup.cpp

Issue 1148633010: Refactoring: Separate MarkupAccumulator into MarkupFormatter and MarkupAccumulator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 } 325 }
326 326
327 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkupWithContext(Doc ument& document, const String& markup, unsigned fragmentStart, unsigned fragment End, 327 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkupWithContext(Doc ument& document, const String& markup, unsigned fragmentStart, unsigned fragment End,
328 const String& baseURL, ParserContentPolicy parserContentPolicy) 328 const String& baseURL, ParserContentPolicy parserContentPolicy)
329 { 329 {
330 // FIXME: Need to handle the case where the markup already contains these ma rkers. 330 // FIXME: Need to handle the case where the markup already contains these ma rkers.
331 331
332 StringBuilder taggedMarkup; 332 StringBuilder taggedMarkup;
333 taggedMarkup.append(markup.left(fragmentStart)); 333 taggedMarkup.append(markup.left(fragmentStart));
334 MarkupAccumulator::appendComment(taggedMarkup, fragmentMarkerTag); 334 MarkupFormatter::appendComment(taggedMarkup, fragmentMarkerTag);
335 taggedMarkup.append(markup.substring(fragmentStart, fragmentEnd - fragmentSt art)); 335 taggedMarkup.append(markup.substring(fragmentStart, fragmentEnd - fragmentSt art));
336 MarkupAccumulator::appendComment(taggedMarkup, fragmentMarkerTag); 336 MarkupFormatter::appendComment(taggedMarkup, fragmentMarkerTag);
337 taggedMarkup.append(markup.substring(fragmentEnd)); 337 taggedMarkup.append(markup.substring(fragmentEnd));
338 338
339 RefPtrWillBeRawPtr<DocumentFragment> taggedFragment = createFragmentFromMark up(document, taggedMarkup.toString(), baseURL, parserContentPolicy); 339 RefPtrWillBeRawPtr<DocumentFragment> taggedFragment = createFragmentFromMark up(document, taggedMarkup.toString(), baseURL, parserContentPolicy);
340 340
341 RefPtrWillBeRawPtr<Comment> nodeBeforeContext = nullptr; 341 RefPtrWillBeRawPtr<Comment> nodeBeforeContext = nullptr;
342 RefPtrWillBeRawPtr<Comment> nodeAfterContext = nullptr; 342 RefPtrWillBeRawPtr<Comment> nodeAfterContext = nullptr;
343 if (!findNodesSurroundingContext(taggedFragment.get(), nodeBeforeContext, no deAfterContext)) 343 if (!findNodesSurroundingContext(taggedFragment.get(), nodeBeforeContext, no deAfterContext))
344 return nullptr; 344 return nullptr;
345 345
346 RefPtrWillBeRawPtr<Document> taggedDocument = Document::create(); 346 RefPtrWillBeRawPtr<Document> taggedDocument = Document::create();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 515 }
516 return fragment.release(); 516 return fragment.release();
517 } 517 }
518 518
519 String urlToMarkup(const KURL& url, const String& title) 519 String urlToMarkup(const KURL& url, const String& title)
520 { 520 {
521 StringBuilder markup; 521 StringBuilder markup;
522 markup.appendLiteral("<a href=\""); 522 markup.appendLiteral("<a href=\"");
523 markup.append(url.string()); 523 markup.append(url.string());
524 markup.appendLiteral("\">"); 524 markup.appendLiteral("\">");
525 MarkupAccumulator::appendCharactersReplacingEntities(markup, title, 0, title .length(), EntityMaskInPCDATA); 525 MarkupFormatter::appendCharactersReplacingEntities(markup, title, 0, title.l ength(), EntityMaskInPCDATA);
526 markup.appendLiteral("</a>"); 526 markup.appendLiteral("</a>");
527 return markup.toString(); 527 return markup.toString();
528 } 528 }
529 529
530 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentForInnerOuterHTML(const S tring& markup, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& exceptionState) 530 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentForInnerOuterHTML(const S tring& markup, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& exceptionState)
531 { 531 {
532 ASSERT(contextElement); 532 ASSERT(contextElement);
533 Document& document = isHTMLTemplateElement(*contextElement) ? contextElement ->document().ensureTemplateDocument() : contextElement->document(); 533 Document& document = isHTMLTemplateElement(*contextElement) ? contextElement ->document().ensureTemplateDocument() : contextElement->document();
534 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument); 534 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument);
535 535
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 696
697 RefPtrWillBeRawPtr<Text> textNext = toText(next); 697 RefPtrWillBeRawPtr<Text> textNext = toText(next);
698 textNode->appendData(textNext->data()); 698 textNode->appendData(textNext->data());
699 if (textNext->parentNode()) // Might have been removed by mutation event. 699 if (textNext->parentNode()) // Might have been removed by mutation event.
700 textNext->remove(exceptionState); 700 textNext->remove(exceptionState);
701 } 701 }
702 702
703 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>; 703 template class CORE_TEMPLATE_EXPORT CreateMarkupAlgorithm<EditingStrategy>;
704 704
705 } 705 }
OLDNEW
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698