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

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

Issue 792003002: Remove unused nodes argument to createMarkup() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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/markup.h ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 specialCommonAncestor = toHTMLSpanElement(commonAncestor); 553 specialCommonAncestor = toHTMLSpanElement(commonAncestor);
554 554
555 if (HTMLAnchorElement* enclosingAnchor = toHTMLAnchorElement(enclosingElemen tWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : com monAncestor), aTag))) 555 if (HTMLAnchorElement* enclosingAnchor = toHTMLAnchorElement(enclosingElemen tWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : com monAncestor), aTag)))
556 specialCommonAncestor = enclosingAnchor; 556 specialCommonAncestor = enclosingAnchor;
557 557
558 return specialCommonAncestor; 558 return specialCommonAncestor;
559 } 559 }
560 560
561 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha nge? 561 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha nge?
562 // FIXME: At least, annotation and style info should probably not be included in range.markupString() 562 // FIXME: At least, annotation and style info should probably not be included in range.markupString()
563 static String createMarkupInternal(Document& document, const Range* range, const Range* updatedRange, WillBeHeapVector<RawPtrWillBeMember<Node>>* nodes, 563 static String createMarkupInternal(Document& document, const Range* range, const Range* updatedRange,
564 EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsolu teURLs shouldResolveURLs, Node* constrainingAncestor) 564 EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsolu teURLs shouldResolveURLs, Node* constrainingAncestor)
565 { 565 {
566 ASSERT(range); 566 ASSERT(range);
567 ASSERT(updatedRange); 567 ASSERT(updatedRange);
568 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">")); 568 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">"));
569 569
570 bool collapsed = updatedRange->collapsed(); 570 bool collapsed = updatedRange->collapsed();
571 if (collapsed) 571 if (collapsed)
572 return emptyString(); 572 return emptyString();
573 Node* commonAncestor = updatedRange->commonAncestorContainer(); 573 Node* commonAncestor = updatedRange->commonAncestorContainer();
574 if (!commonAncestor) 574 if (!commonAncestor)
575 return emptyString(); 575 return emptyString();
576 576
577 document.updateLayoutIgnorePendingStylesheets(); 577 document.updateLayoutIgnorePendingStylesheets();
578 578
579 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstPosit ionInNode(commonAncestor), bodyTag)); 579 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstPosit ionInNode(commonAncestor), bodyTag));
580 HTMLBodyElement* fullySelectedRoot = nullptr; 580 HTMLBodyElement* fullySelectedRoot = nullptr;
581 // FIXME: Do this for all fully selected blocks, not just the body. 581 // FIXME: Do this for all fully selected blocks, not just the body.
582 if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(bod y).toNormalizedRange().get(), range)) 582 if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(bod y).toNormalizedRange().get(), range))
583 fullySelectedRoot = body; 583 fullySelectedRoot = body;
584 HTMLElement* specialCommonAncestor = highestAncestorToWrapMarkup(updatedRang e, shouldAnnotate, constrainingAncestor); 584 HTMLElement* specialCommonAncestor = highestAncestorToWrapMarkup(updatedRang e, shouldAnnotate, constrainingAncestor);
585 StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, shouldAnnotate , updatedRange, specialCommonAncestor); 585 StyledMarkupAccumulator accumulator(nullptr, shouldResolveURLs, shouldAnnota te, updatedRange, specialCommonAncestor);
586 Node* pastEnd = updatedRange->pastLastNode(); 586 Node* pastEnd = updatedRange->pastLastNode();
587 587
588 Node* startNode = updatedRange->firstNode(); 588 Node* startNode = updatedRange->firstNode();
589 VisiblePosition visibleStart(updatedRange->startPosition(), VP_DEFAULT_AFFIN ITY); 589 VisiblePosition visibleStart(updatedRange->startPosition(), VP_DEFAULT_AFFIN ITY);
590 VisiblePosition visibleEnd(updatedRange->endPosition(), VP_DEFAULT_AFFINITY) ; 590 VisiblePosition visibleEnd(updatedRange->endPosition(), VP_DEFAULT_AFFINITY) ;
591 if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter( visibleStart)) { 591 if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter( visibleStart)) {
592 if (visibleStart == visibleEnd.previous()) 592 if (visibleStart == visibleEnd.previous())
593 return interchangeNewlineString; 593 return interchangeNewlineString;
594 594
595 accumulator.appendString(interchangeNewlineString); 595 accumulator.appendString(interchangeNewlineString);
(...skipping 25 matching lines...) Expand all
621 fullySelectedRootStyle->style()->setProperty(CSSProperty TextDecoration, CSSValueNone); 621 fullySelectedRootStyle->style()->setProperty(CSSProperty TextDecoration, CSSValueNone);
622 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyWebkitTextDecorationsInEffect)) 622 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st yle(), CSSPropertyWebkitTextDecorationsInEffect))
623 fullySelectedRootStyle->style()->setProperty(CSSProperty WebkitTextDecorationsInEffect, CSSValueNone); 623 fullySelectedRootStyle->style()->setProperty(CSSProperty WebkitTextDecorationsInEffect, CSSValueNone);
624 accumulator.wrapWithStyleNode(fullySelectedRootStyle->style( ), document, true); 624 accumulator.wrapWithStyleNode(fullySelectedRootStyle->style( ), document, true);
625 } 625 }
626 } else { 626 } else {
627 // Since this node and all the other ancestors are not in the se lection we want to set RangeFullySelectsNode to DoesNotFullySelectNode 627 // Since this node and all the other ancestors are not in the se lection we want to set RangeFullySelectsNode to DoesNotFullySelectNode
628 // so that styles that affect the exterior of the node are not i ncluded. 628 // so that styles that affect the exterior of the node are not i ncluded.
629 accumulator.wrapWithNode(*ancestor, convertBlocksToInlines, Styl edMarkupAccumulator::DoesNotFullySelectNode); 629 accumulator.wrapWithNode(*ancestor, convertBlocksToInlines, Styl edMarkupAccumulator::DoesNotFullySelectNode);
630 } 630 }
631 if (nodes)
632 nodes->append(ancestor);
633 631
634 if (ancestor == specialCommonAncestor) 632 if (ancestor == specialCommonAncestor)
635 break; 633 break;
636 } 634 }
637 } 635 }
638 636
639 // FIXME: The interchange newline should be placed in the block that it's in , not after all of the content, unconditionally. 637 // FIXME: The interchange newline should be placed in the block that it's in , not after all of the content, unconditionally.
640 if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter( visibleEnd.previous())) 638 if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter( visibleEnd.previous()))
641 accumulator.appendString(interchangeNewlineString); 639 accumulator.appendString(interchangeNewlineString);
642 640
643 return accumulator.takeResults(); 641 return accumulator.takeResults();
644 } 642 }
645 643
646 String createMarkup(const Range* range, WillBeHeapVector<RawPtrWillBeMember<Node >>* nodes, EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor) 644 String createMarkup(const Range* range, EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs, Node* constraining Ancestor)
647 { 645 {
648 if (!range) 646 if (!range)
649 return emptyString(); 647 return emptyString();
650 648
651 Document& document = range->ownerDocument(); 649 Document& document = range->ownerDocument();
652 const Range* updatedRange = range; 650 const Range* updatedRange = range;
653 651
654 return createMarkupInternal(document, range, updatedRange, nodes, shouldAnno tate, convertBlocksToInlines, shouldResolveURLs, constrainingAncestor); 652 return createMarkupInternal(document, range, updatedRange, shouldAnnotate, c onvertBlocksToInlines, shouldResolveURLs, constrainingAncestor);
655 } 653 }
656 654
657 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu ment, const String& markup, const String& baseURL, ParserContentPolicy parserCon tentPolicy) 655 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu ment, const String& markup, const String& baseURL, ParserContentPolicy parserCon tentPolicy)
658 { 656 {
659 // We use a fake body element here to trick the HTML parser to using the InB ody insertion mode. 657 // We use a fake body element here to trick the HTML parser to using the InB ody insertion mode.
660 RefPtrWillBeRawPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(docum ent); 658 RefPtrWillBeRawPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(docum ent);
661 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument); 659 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(doc ument);
662 660
663 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy); 661 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy);
664 662
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (specialCommonAncestor) 744 if (specialCommonAncestor)
747 fragment->appendChild(specialCommonAncestor); 745 fragment->appendChild(specialCommonAncestor);
748 else 746 else
749 fragment->parserTakeAllChildrenFrom(toContainerNode(*commonAncestor)); 747 fragment->parserTakeAllChildrenFrom(toContainerNode(*commonAncestor));
750 748
751 trimFragment(fragment.get(), nodeBeforeContext.get(), nodeAfterContext.get() ); 749 trimFragment(fragment.get(), nodeBeforeContext.get(), nodeAfterContext.get() );
752 750
753 return fragment; 751 return fragment;
754 } 752 }
755 753
756 String createMarkup(const Node* node, EChildrenOnly childrenOnly, WillBeHeapVect or<RawPtrWillBeMember<Node>>* nodes, EAbsoluteURLs shouldResolveURLs) 754 String createMarkup(const Node* node, EChildrenOnly childrenOnly, EAbsoluteURLs shouldResolveURLs)
757 { 755 {
758 if (!node) 756 if (!node)
759 return ""; 757 return "";
760 758
761 MarkupAccumulator accumulator(nodes, shouldResolveURLs); 759 MarkupAccumulator accumulator(nullptr, shouldResolveURLs);
762 return accumulator.serializeNodes(const_cast<Node&>(*node), childrenOnly); 760 return accumulator.serializeNodes(const_cast<Node&>(*node), childrenOnly);
763 } 761 }
764 762
765 static void fillContainerFromString(ContainerNode* paragraph, const String& stri ng) 763 static void fillContainerFromString(ContainerNode* paragraph, const String& stri ng)
766 { 764 {
767 Document& document = paragraph->document(); 765 Document& document = paragraph->document();
768 766
769 if (string.isEmpty()) { 767 if (string.isEmpty()) {
770 paragraph->appendChild(createBlockPlaceholderElement(document)); 768 paragraph->appendChild(createBlockPlaceholderElement(document));
771 return; 769 return;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 node->document().updateLayoutIgnorePendingStylesheets(); 1085 node->document().updateLayoutIgnorePendingStylesheets();
1088 1086
1089 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation Transition, nullptr, 0); 1087 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation Transition, nullptr, 0);
1090 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node)) ; 1088 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node)) ;
1091 1089
1092 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\" content=\"width=device-width, user-scalable=0\">"; 1090 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\" content=\"width=device-width, user-scalable=0\">";
1093 return documentMarkup + accumulator.takeResults(); 1091 return documentMarkup + accumulator.takeResults();
1094 } 1092 }
1095 1093
1096 } 1094 }
OLDNEW
« no previous file with comments | « Source/core/editing/markup.h ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698