| 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if (!n) | 375 if (!n) |
| 376 break; | 376 break; |
| 377 | 377 |
| 378 next = NodeTraversal::next(*n); | 378 next = NodeTraversal::next(*n); |
| 379 bool openedTag = false; | 379 bool openedTag = false; |
| 380 | 380 |
| 381 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) | 381 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) |
| 382 // Don't write out empty block containers that aren't fully selected
. | 382 // Don't write out empty block containers that aren't fully selected
. |
| 383 continue; | 383 continue; |
| 384 | 384 |
| 385 if (!n->renderer() && !enclosingElementWithTag(firstPositionInOrBeforeNo
de(n), selectTag) && m_shouldAnnotate != AnnotateForNavigationTransition) { | 385 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOrBefo
reNode(n), selectTag) && m_shouldAnnotate != AnnotateForNavigationTransition) { |
| 386 next = NodeTraversal::nextSkippingChildren(*n); | 386 next = NodeTraversal::nextSkippingChildren(*n); |
| 387 // Don't skip over pastEnd. | 387 // Don't skip over pastEnd. |
| 388 if (pastEnd && pastEnd->isDescendantOf(n)) | 388 if (pastEnd && pastEnd->isDescendantOf(n)) |
| 389 next = pastEnd; | 389 next = pastEnd; |
| 390 } else { | 390 } else { |
| 391 // Add the node to the markup if we're not skipping the descendants | 391 // Add the node to the markup if we're not skipping the descendants |
| 392 if (shouldEmit) | 392 if (shouldEmit) |
| 393 appendStartTag(*n); | 393 appendStartTag(*n); |
| 394 | 394 |
| 395 // If node has no children, close the tag now. | 395 // If node has no children, close the tag now. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 418 lastClosed = ancestor; | 418 lastClosed = ancestor; |
| 419 ancestorsToClose.removeLast(); | 419 ancestorsToClose.removeLast(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Surround the currently accumulated markup with markup for ancesto
rs we never opened as we leave the subtree(s) rooted at those ancestors. | 422 // Surround the currently accumulated markup with markup for ancesto
rs we never opened as we leave the subtree(s) rooted at those ancestors. |
| 423 ContainerNode* nextParent = next ? next->parentNode() : 0; | 423 ContainerNode* nextParent = next ? next->parentNode() : 0; |
| 424 if (next != pastEnd && n != nextParent) { | 424 if (next != pastEnd && n != nextParent) { |
| 425 Node* lastAncestorClosedOrSelf = n->isDescendantOf(lastClosed) ?
lastClosed : n; | 425 Node* lastAncestorClosedOrSelf = n->isDescendantOf(lastClosed) ?
lastClosed : n; |
| 426 for (ContainerNode* parent = lastAncestorClosedOrSelf->parentNod
e(); parent && parent != nextParent; parent = parent->parentNode()) { | 426 for (ContainerNode* parent = lastAncestorClosedOrSelf->parentNod
e(); parent && parent != nextParent; parent = parent->parentNode()) { |
| 427 // All ancestors that aren't in the ancestorsToClose list sh
ould either be a) unrendered: | 427 // All ancestors that aren't in the ancestorsToClose list sh
ould either be a) unrendered: |
| 428 if (!parent->renderer()) | 428 if (!parent->layoutObject()) |
| 429 continue; | 429 continue; |
| 430 // or b) ancestors that we never encountered during a pre-or
der traversal starting at startNode: | 430 // or b) ancestors that we never encountered during a pre-or
der traversal starting at startNode: |
| 431 ASSERT(startNode->isDescendantOf(parent)); | 431 ASSERT(startNode->isDescendantOf(parent)); |
| 432 if (shouldEmit) | 432 if (shouldEmit) |
| 433 wrapWithNode(*parent); | 433 wrapWithNode(*parent); |
| 434 lastClosed = parent; | 434 lastClosed = parent; |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 } | 438 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 specialCommonAncestor = toHTMLElement(ancestor); | 530 specialCommonAncestor = toHTMLElement(ancestor); |
| 531 } | 531 } |
| 532 } | 532 } |
| 533 | 533 |
| 534 // Retain the Mail quote level by including all ancestor mail block quot
es. | 534 // Retain the Mail quote level by including all ancestor mail block quot
es. |
| 535 if (HTMLQuoteElement* highestMailBlockquote = toHTMLQuoteElement(highest
EnclosingNodeOfType(firstPositionInOrBeforeNode(range->firstNode()), isMailHTMLB
lockquoteElement, CanCrossEditingBoundary))) | 535 if (HTMLQuoteElement* highestMailBlockquote = toHTMLQuoteElement(highest
EnclosingNodeOfType(firstPositionInOrBeforeNode(range->firstNode()), isMailHTMLB
lockquoteElement, CanCrossEditingBoundary))) |
| 536 specialCommonAncestor = highestMailBlockquote; | 536 specialCommonAncestor = highestMailBlockquote; |
| 537 } | 537 } |
| 538 | 538 |
| 539 Node* checkAncestor = specialCommonAncestor ? specialCommonAncestor : common
Ancestor; | 539 Node* checkAncestor = specialCommonAncestor ? specialCommonAncestor : common
Ancestor; |
| 540 if (checkAncestor->renderer()) { | 540 if (checkAncestor->layoutObject()) { |
| 541 HTMLElement* newSpecialCommonAncestor = toHTMLElement(highestEnclosingNo
deOfType(firstPositionInNode(checkAncestor), &isPresentationalHTMLElement, CanCr
ossEditingBoundary, constrainingAncestor)); | 541 HTMLElement* newSpecialCommonAncestor = toHTMLElement(highestEnclosingNo
deOfType(firstPositionInNode(checkAncestor), &isPresentationalHTMLElement, CanCr
ossEditingBoundary, constrainingAncestor)); |
| 542 if (newSpecialCommonAncestor) | 542 if (newSpecialCommonAncestor) |
| 543 specialCommonAncestor = newSpecialCommonAncestor; | 543 specialCommonAncestor = newSpecialCommonAncestor; |
| 544 } | 544 } |
| 545 | 545 |
| 546 // If a single tab is selected, commonAncestor will be a text node inside a
tab span. | 546 // If a single tab is selected, commonAncestor will be a text node inside a
tab span. |
| 547 // If two or more tabs are selected, commonAncestor will be the tab span. | 547 // If two or more tabs are selected, commonAncestor will be the tab span. |
| 548 // In either case, if there is a specialCommonAncestor already, it will nece
ssarily be above | 548 // In either case, if there is a specialCommonAncestor already, it will nece
ssarily be above |
| 549 // any tab span that needs to be included. | 549 // any tab span that needs to be included. |
| 550 if (!specialCommonAncestor && isTabHTMLSpanElementTextNode(commonAncestor)) | 550 if (!specialCommonAncestor && isTabHTMLSpanElementTextNode(commonAncestor)) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 812 |
| 813 if (element.hasOneChild()) | 813 if (element.hasOneChild()) |
| 814 return element.firstChild()->isTextNode() || element.firstChild()->hasCh
ildren(); | 814 return element.firstChild()->isTextNode() || element.firstChild()->hasCh
ildren(); |
| 815 | 815 |
| 816 return element.hasChildCount(2) && isTabHTMLSpanElementTextNode(element.firs
tChild()->firstChild()) && element.lastChild()->isTextNode(); | 816 return element.hasChildCount(2) && isTabHTMLSpanElementTextNode(element.firs
tChild()->firstChild()) && element.lastChild()->isTextNode(); |
| 817 } | 817 } |
| 818 | 818 |
| 819 static bool shouldPreserveNewline(const Range& range) | 819 static bool shouldPreserveNewline(const Range& range) |
| 820 { | 820 { |
| 821 if (Node* node = range.firstNode()) { | 821 if (Node* node = range.firstNode()) { |
| 822 if (LayoutObject* renderer = node->renderer()) | 822 if (LayoutObject* renderer = node->layoutObject()) |
| 823 return renderer->style()->preserveNewline(); | 823 return renderer->style()->preserveNewline(); |
| 824 } | 824 } |
| 825 | 825 |
| 826 if (Node* node = range.startPosition().anchorNode()) { | 826 if (Node* node = range.startPosition().anchorNode()) { |
| 827 if (LayoutObject* renderer = node->renderer()) | 827 if (LayoutObject* renderer = node->layoutObject()) |
| 828 return renderer->style()->preserveNewline(); | 828 return renderer->style()->preserveNewline(); |
| 829 } | 829 } |
| 830 | 830 |
| 831 return false; | 831 return false; |
| 832 } | 832 } |
| 833 | 833 |
| 834 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromText(Range* context,
const String& text) | 834 PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromText(Range* context,
const String& text) |
| 835 { | 835 { |
| 836 if (!context) | 836 if (!context) |
| 837 return nullptr; | 837 return nullptr; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 node->document().updateLayoutIgnorePendingStylesheets(); | 1085 node->document().updateLayoutIgnorePendingStylesheets(); |
| 1086 | 1086 |
| 1087 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); | 1087 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); |
| 1088 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; | 1088 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; |
| 1089 | 1089 |
| 1090 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\">"; |
| 1091 return documentMarkup + accumulator.takeResults(); | 1091 return documentMarkup + accumulator.takeResults(); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 } | 1094 } |
| OLD | NEW |