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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 489 } |
490 | 490 |
491 static bool isElementPresentational(const Node* node) | 491 static bool isElementPresentational(const Node* node) |
492 { | 492 { |
493 return node->hasTagName(uTag) || node->hasTagName(sTag) || node->hasTagName(
strikeTag) | 493 return node->hasTagName(uTag) || node->hasTagName(sTag) || node->hasTagName(
strikeTag) |
494 || node->hasTagName(iTag) || node->hasTagName(emTag) || node->hasTagName
(bTag) || node->hasTagName(strongTag); | 494 || node->hasTagName(iTag) || node->hasTagName(emTag) || node->hasTagName
(bTag) || node->hasTagName(strongTag); |
495 } | 495 } |
496 | 496 |
497 static Node* highestAncestorToWrapMarkup(const Range* range, EAnnotateForInterch
ange shouldAnnotate, Node* constrainingAncestor) | 497 static Node* highestAncestorToWrapMarkup(const Range* range, EAnnotateForInterch
ange shouldAnnotate, Node* constrainingAncestor) |
498 { | 498 { |
499 Node* commonAncestor = range->commonAncestorContainer(IGNORE_EXCEPTION); | 499 Node* commonAncestor = range->commonAncestorContainer(); |
500 ASSERT(commonAncestor); | 500 ASSERT(commonAncestor); |
501 Node* specialCommonAncestor = 0; | 501 Node* specialCommonAncestor = 0; |
502 if (shouldAnnotate == AnnotateForInterchange) { | 502 if (shouldAnnotate == AnnotateForInterchange) { |
503 // Include ancestors that aren't completely inside the range but are req
uired to retain | 503 // Include ancestors that aren't completely inside the range but are req
uired to retain |
504 // the structure and appearance of the copied markup. | 504 // the structure and appearance of the copied markup. |
505 specialCommonAncestor = ancestorToRetainStructureAndAppearance(commonAnc
estor); | 505 specialCommonAncestor = ancestorToRetainStructureAndAppearance(commonAnc
estor); |
506 | 506 |
507 if (Node* parentListNode = enclosingNodeOfType(firstPositionInOrBeforeNo
de(range->firstNode()), isListItem)) { | 507 if (Node* parentListNode = enclosingNodeOfType(firstPositionInOrBeforeNo
de(range->firstNode()), isListItem)) { |
508 if (WebCore::areRangesEqual(VisibleSelection::selectionFromContentsO
fNode(parentListNode).toNormalizedRange().get(), range)) { | 508 if (WebCore::areRangesEqual(VisibleSelection::selectionFromContentsO
fNode(parentListNode).toNormalizedRange().get(), range)) { |
509 specialCommonAncestor = parentListNode->parentNode(); | 509 specialCommonAncestor = parentListNode->parentNode(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 541 |
542 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha
nge? | 542 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha
nge? |
543 // FIXME: At least, annotation and style info should probably not be included in
range.markupString() | 543 // FIXME: At least, annotation and style info should probably not be included in
range.markupString() |
544 static String createMarkupInternal(Document& document, const Range* range, const
Range* updatedRange, Vector<Node*>* nodes, | 544 static String createMarkupInternal(Document& document, const Range* range, const
Range* updatedRange, Vector<Node*>* nodes, |
545 EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsolu
teURLs shouldResolveURLs, Node* constrainingAncestor) | 545 EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsolu
teURLs shouldResolveURLs, Node* constrainingAncestor) |
546 { | 546 { |
547 ASSERT(range); | 547 ASSERT(range); |
548 ASSERT(updatedRange); | 548 ASSERT(updatedRange); |
549 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); | 549 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); |
550 | 550 |
551 bool collapsed = updatedRange->collapsed(ASSERT_NO_EXCEPTION); | 551 bool collapsed = updatedRange->collapsed(); |
552 if (collapsed) | 552 if (collapsed) |
553 return emptyString(); | 553 return emptyString(); |
554 Node* commonAncestor = updatedRange->commonAncestorContainer(ASSERT_NO_EXCEP
TION); | 554 Node* commonAncestor = updatedRange->commonAncestorContainer(); |
555 if (!commonAncestor) | 555 if (!commonAncestor) |
556 return emptyString(); | 556 return emptyString(); |
557 | 557 |
558 document.updateLayoutIgnorePendingStylesheets(); | 558 document.updateLayoutIgnorePendingStylesheets(); |
559 | 559 |
560 Node* body = enclosingNodeWithTag(firstPositionInNode(commonAncestor), bodyT
ag); | 560 Node* body = enclosingNodeWithTag(firstPositionInNode(commonAncestor), bodyT
ag); |
561 Node* fullySelectedRoot = 0; | 561 Node* fullySelectedRoot = 0; |
562 // FIXME: Do this for all fully selected blocks, not just the body. | 562 // FIXME: Do this for all fully selected blocks, not just the body. |
563 if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(bod
y).toNormalizedRange().get(), range)) | 563 if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(bod
y).toNormalizedRange().get(), range)) |
564 fullySelectedRoot = body; | 564 fullySelectedRoot = body; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 710 |
711 RefPtr<Node> nodeBeforeContext; | 711 RefPtr<Node> nodeBeforeContext; |
712 RefPtr<Node> nodeAfterContext; | 712 RefPtr<Node> nodeAfterContext; |
713 if (!findNodesSurroundingContext(taggedDocument.get(), nodeBeforeContext, no
deAfterContext)) | 713 if (!findNodesSurroundingContext(taggedDocument.get(), nodeBeforeContext, no
deAfterContext)) |
714 return nullptr; | 714 return nullptr; |
715 | 715 |
716 RefPtrWillBeRawPtr<Range> range = Range::create(*taggedDocument.get(), | 716 RefPtrWillBeRawPtr<Range> range = Range::create(*taggedDocument.get(), |
717 positionAfterNode(nodeBeforeContext.get()).parentAnchoredEquivalent(), | 717 positionAfterNode(nodeBeforeContext.get()).parentAnchoredEquivalent(), |
718 positionBeforeNode(nodeAfterContext.get()).parentAnchoredEquivalent()); | 718 positionBeforeNode(nodeAfterContext.get()).parentAnchoredEquivalent()); |
719 | 719 |
720 Node* commonAncestor = range->commonAncestorContainer(ASSERT_NO_EXCEPTION); | 720 Node* commonAncestor = range->commonAncestorContainer(); |
721 Node* specialCommonAncestor = ancestorToRetainStructureAndAppearanceWithNoRe
nderer(commonAncestor); | 721 Node* specialCommonAncestor = ancestorToRetainStructureAndAppearanceWithNoRe
nderer(commonAncestor); |
722 | 722 |
723 // When there's a special common ancestor outside of the fragment, we must i
nclude it as well to | 723 // When there's a special common ancestor outside of the fragment, we must i
nclude it as well to |
724 // preserve the structure and appearance of the fragment. For example, if th
e fragment contains | 724 // preserve the structure and appearance of the fragment. For example, if th
e fragment contains |
725 // TD, we need to include the enclosing TABLE tag as well. | 725 // TD, we need to include the enclosing TABLE tag as well. |
726 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); | 726 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); |
727 if (specialCommonAncestor) | 727 if (specialCommonAncestor) |
728 fragment->appendChild(specialCommonAncestor); | 728 fragment->appendChild(specialCommonAncestor); |
729 else | 729 else |
730 fragment->parserTakeAllChildrenFrom(toContainerNode(*commonAncestor)); | 730 fragment->parserTakeAllChildrenFrom(toContainerNode(*commonAncestor)); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 return; | 1065 return; |
1066 | 1066 |
1067 RefPtr<Text> textNode = toText(node.get()); | 1067 RefPtr<Text> textNode = toText(node.get()); |
1068 RefPtr<Text> textNext = toText(next); | 1068 RefPtr<Text> textNext = toText(next); |
1069 textNode->appendData(textNext->data()); | 1069 textNode->appendData(textNext->data()); |
1070 if (textNext->parentNode()) // Might have been removed by mutation event. | 1070 if (textNext->parentNode()) // Might have been removed by mutation event. |
1071 textNext->remove(exceptionState); | 1071 textNext->remove(exceptionState); |
1072 } | 1072 } |
1073 | 1073 |
1074 } | 1074 } |
OLD | NEW |