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

Side by Side Diff: sky/engine/core/editing/markup.cpp

Issue 665613003: Remove the ability to parse HTML fragments (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 { 522 {
523 if (!range) 523 if (!range)
524 return emptyString(); 524 return emptyString();
525 525
526 Document& document = range->ownerDocument(); 526 Document& document = range->ownerDocument();
527 const Range* updatedRange = range; 527 const Range* updatedRange = range;
528 528
529 return createMarkupInternal(document, range, updatedRange, nodes, shouldAnno tate, convertBlocksToInlines, shouldResolveURLs, constrainingAncestor); 529 return createMarkupInternal(document, range, updatedRange, nodes, shouldAnno tate, convertBlocksToInlines, shouldResolveURLs, constrainingAncestor);
530 } 530 }
531 531
532 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu ment, const String& markup)
533 {
534 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument);
535 fragment->parseHTML(markup, nullptr);
536 return fragment.release();
537 }
538
539 String createMarkup(const Node* node, EChildrenOnly childrenOnly, WillBeHeapVect or<RawPtrWillBeMember<Node> >* nodes, EAbsoluteURLs shouldResolveURLs, Vector<Qu alifiedName>* tagNamesToSkip) 532 String createMarkup(const Node* node, EChildrenOnly childrenOnly, WillBeHeapVect or<RawPtrWillBeMember<Node> >* nodes, EAbsoluteURLs shouldResolveURLs, Vector<Qu alifiedName>* tagNamesToSkip)
540 { 533 {
541 if (!node) 534 if (!node)
542 return ""; 535 return "";
543 536
544 MarkupAccumulator accumulator(nodes, shouldResolveURLs); 537 MarkupAccumulator accumulator(nodes, shouldResolveURLs);
545 return accumulator.serializeNodes(const_cast<Node&>(*node), childrenOnly, ta gNamesToSkip); 538 return accumulator.serializeNodes(const_cast<Node&>(*node), childrenOnly, ta gNamesToSkip);
546 } 539 }
547 540
548 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentForInnerOuterHTML(const S tring& markup, Element* contextElement, const char* method, ExceptionState& exce ptionState)
549 {
550 ASSERT(contextElement);
551 Document& document = isHTMLTemplateElement(*contextElement) ? contextElement ->document().ensureTemplateDocument() : contextElement->document();
552 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument);
553 fragment->parseHTML(markup, contextElement);
554 return fragment;
555 }
556
557 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtrWillBeRawPt r<DocumentFragment> fragment, ExceptionState& exceptionState) 541 void replaceChildrenWithFragment(ContainerNode* container, PassRefPtrWillBeRawPt r<DocumentFragment> fragment, ExceptionState& exceptionState)
558 { 542 {
559 ASSERT(container); 543 ASSERT(container);
560 RefPtrWillBeRawPtr<ContainerNode> containerNode(container); 544 RefPtrWillBeRawPtr<ContainerNode> containerNode(container);
561 545
562 ChildListMutationScope mutation(*containerNode); 546 ChildListMutationScope mutation(*containerNode);
563 547
564 if (!fragment->firstChild()) { 548 if (!fragment->firstChild()) {
565 containerNode->removeChildren(); 549 containerNode->removeChildren();
566 return; 550 return;
(...skipping 22 matching lines...) Expand all
589 if (!next || !next->isTextNode()) 573 if (!next || !next->isTextNode())
590 return; 574 return;
591 575
592 RefPtrWillBeRawPtr<Text> textNext = toText(next); 576 RefPtrWillBeRawPtr<Text> textNext = toText(next);
593 textNode->appendData(textNext->data()); 577 textNode->appendData(textNext->data());
594 if (textNext->parentNode()) // Might have been removed by mutation event. 578 if (textNext->parentNode()) // Might have been removed by mutation event.
595 textNext->remove(exceptionState); 579 textNext->remove(exceptionState);
596 } 580 }
597 581
598 } 582 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698