OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 694 |
695 for (size_t i = preCount; i > 0; --i) | 695 for (size_t i = preCount; i > 0; --i) |
696 append(result, preMarkups[i - 1]); | 696 append(result, preMarkups[i - 1]); |
697 | 697 |
698 for (size_t i = 0; i < postCount; ++i) | 698 for (size_t i = 0; i < postCount; ++i) |
699 append(result, postMarkups[i]); | 699 append(result, postMarkups[i]); |
700 | 700 |
701 return String::adopt(result); | 701 return String::adopt(result); |
702 } | 702 } |
703 | 703 |
| 704 bool isSpecialAncestorBlock(Node* node) |
| 705 { |
| 706 if (!node || !isBlock(node)) |
| 707 return false; |
| 708 |
| 709 return node->hasTagName(listingTag) || |
| 710 node->hasTagName(olTag) || |
| 711 node->hasTagName(preTag) || |
| 712 node->hasTagName(tableTag) || |
| 713 node->hasTagName(ulTag) || |
| 714 node->hasTagName(xmpTag) || |
| 715 node->hasTagName(h1Tag) || |
| 716 node->hasTagName(h2Tag) || |
| 717 node->hasTagName(h3Tag) || |
| 718 node->hasTagName(h4Tag) || |
| 719 node->hasTagName(h5Tag); |
| 720 } |
| 721 |
704 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha
nge? | 722 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForIntercha
nge? |
705 // FIXME: At least, annotation and style info should probably not be included in
range.markupString() | 723 // FIXME: At least, annotation and style info should probably not be included in
range.markupString() |
706 String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
hange annotate, bool convertBlocksToInlines) | 724 String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
hange annotate, bool convertBlocksToInlines) |
707 { | 725 { |
708 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); | 726 DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\""
AppleInterchangeNewline "\">")); |
709 | 727 |
710 if (!range) | 728 if (!range) |
711 return ""; | 729 return ""; |
712 | 730 |
713 Document* document = range->ownerDocument(); | 731 Document* document = range->ownerDocument(); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 // the structure and appearance of the copied markup. | 860 // the structure and appearance of the copied markup. |
843 Node* specialCommonAncestor = 0; | 861 Node* specialCommonAncestor = 0; |
844 Node* commonAncestorBlock = commonAncestor ? enclosingBlock(commonAncestor)
: 0; | 862 Node* commonAncestorBlock = commonAncestor ? enclosingBlock(commonAncestor)
: 0; |
845 if (annotate && commonAncestorBlock) { | 863 if (annotate && commonAncestorBlock) { |
846 if (commonAncestorBlock->hasTagName(tbodyTag) || commonAncestorBlock->ha
sTagName(trTag)) { | 864 if (commonAncestorBlock->hasTagName(tbodyTag) || commonAncestorBlock->ha
sTagName(trTag)) { |
847 Node* table = commonAncestorBlock->parentNode(); | 865 Node* table = commonAncestorBlock->parentNode(); |
848 while (table && !table->hasTagName(tableTag)) | 866 while (table && !table->hasTagName(tableTag)) |
849 table = table->parentNode(); | 867 table = table->parentNode(); |
850 if (table) | 868 if (table) |
851 specialCommonAncestor = table; | 869 specialCommonAncestor = table; |
852 } else if (commonAncestorBlock->hasTagName(listingTag) | 870 } else if (isSpecialAncestorBlock(commonAncestorBlock)) |
853 || commonAncestorBlock->hasTagName(olTag) | |
854 || commonAncestorBlock->hasTagName(preTag) | |
855 || commonAncestorBlock->hasTagName(tableTag) | |
856 || commonAncestorBlock->hasTagName(ulTag) | |
857 || commonAncestorBlock->hasTagName(xmpTag)) | |
858 specialCommonAncestor = commonAncestorBlock; | 871 specialCommonAncestor = commonAncestorBlock; |
859 } | 872 } |
860 | 873 |
861 // Retain the Mail quote level by including all ancestor mail block quotes. | 874 // Retain the Mail quote level by including all ancestor mail block quotes. |
862 if (lastClosed && annotate) { | 875 if (lastClosed && annotate) { |
863 for (Node *ancestor = lastClosed->parentNode(); ancestor; ancestor = anc
estor->parentNode()) | 876 for (Node *ancestor = lastClosed->parentNode(); ancestor; ancestor = anc
estor->parentNode()) |
864 if (isMailBlockquote(ancestor)) | 877 if (isMailBlockquote(ancestor)) |
865 specialCommonAncestor = ancestor; | 878 specialCommonAncestor = ancestor; |
866 } | 879 } |
867 | 880 |
(...skipping 13 matching lines...) Expand all Loading... |
881 if (!specialCommonAncestor && isTabSpanNode(commonAncestor)) | 894 if (!specialCommonAncestor && isTabSpanNode(commonAncestor)) |
882 specialCommonAncestor = commonAncestor; | 895 specialCommonAncestor = commonAncestor; |
883 | 896 |
884 if (Node *enclosingAnchor = enclosingNodeWithTag(Position(specialCommonAnces
tor ? specialCommonAncestor : commonAncestor, 0), aTag)) | 897 if (Node *enclosingAnchor = enclosingNodeWithTag(Position(specialCommonAnces
tor ? specialCommonAncestor : commonAncestor, 0), aTag)) |
885 specialCommonAncestor = enclosingAnchor; | 898 specialCommonAncestor = enclosingAnchor; |
886 | 899 |
887 Node* body = enclosingNodeWithTag(Position(commonAncestor, 0), bodyTag); | 900 Node* body = enclosingNodeWithTag(Position(commonAncestor, 0), bodyTag); |
888 // FIXME: Only include markup for a fully selected root (and ancestors of la
stClosed up to that root) if | 901 // FIXME: Only include markup for a fully selected root (and ancestors of la
stClosed up to that root) if |
889 // there are styles/attributes on those nodes that need to be included to pr
eserve the appearance of the copied markup. | 902 // there are styles/attributes on those nodes that need to be included to pr
eserve the appearance of the copied markup. |
890 // FIXME: Do this for all fully selected blocks, not just the body. | 903 // FIXME: Do this for all fully selected blocks, not just the body. |
891 Node* fullySelectedRoot = body && *Selection::selectionFromContentsOfNode(bo
dy).toRange() == *updatedRange ? body : 0; | 904 Node* fullySelectedRoot = body && *Selection::selectionFromContentsOfNode(bo
dy).toNormalizedRange() == *updatedRange ? body : 0; |
892 if (annotate && fullySelectedRoot) | 905 if (annotate && fullySelectedRoot) |
893 specialCommonAncestor = fullySelectedRoot; | 906 specialCommonAncestor = fullySelectedRoot; |
894 | 907 |
895 if (specialCommonAncestor && lastClosed) { | 908 if (specialCommonAncestor && lastClosed) { |
896 // Also include all of the ancestors of lastClosed up to this special an
cestor. | 909 // Also include all of the ancestors of lastClosed up to this special an
cestor. |
897 for (Node* ancestor = lastClosed->parentNode(); ancestor; ancestor = anc
estor->parentNode()) { | 910 for (Node* ancestor = lastClosed->parentNode(); ancestor; ancestor = anc
estor->parentNode()) { |
898 if (ancestor == fullySelectedRoot && !convertBlocksToInlines) { | 911 if (ancestor == fullySelectedRoot && !convertBlocksToInlines) { |
899 RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRules
AndInlineDecl(fullySelectedRoot); | 912 RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRules
AndInlineDecl(fullySelectedRoot); |
900 | 913 |
901 // Bring the background attribute over, but not as an attribute
because a background attribute on a div | 914 // Bring the background attribute over, but not as an attribute
because a background attribute on a div |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 if (!frame) | 1230 if (!frame) |
1218 return String(); | 1231 return String(); |
1219 | 1232 |
1220 // FIXME: This is always "for interchange". Is that right? See the previous
method. | 1233 // FIXME: This is always "for interchange". Is that right? See the previous
method. |
1221 return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInter
change); | 1234 return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInter
change); |
1222 } | 1235 } |
1223 | 1236 |
1224 } | 1237 } |
1225 | 1238 |
1226 | 1239 |
OLD | NEW |