| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "core/editing/FrameSelection.h" | 41 #include "core/editing/FrameSelection.h" |
| 42 #include "core/editing/HTMLInterchange.h" | 42 #include "core/editing/HTMLInterchange.h" |
| 43 #include "core/editing/SimplifyMarkupCommand.h" | 43 #include "core/editing/SimplifyMarkupCommand.h" |
| 44 #include "core/editing/SmartReplace.h" | 44 #include "core/editing/SmartReplace.h" |
| 45 #include "core/editing/TextIterator.h" | 45 #include "core/editing/TextIterator.h" |
| 46 #include "core/editing/VisibleUnits.h" | 46 #include "core/editing/VisibleUnits.h" |
| 47 #include "core/editing/htmlediting.h" | 47 #include "core/editing/htmlediting.h" |
| 48 #include "core/editing/markup.h" | 48 #include "core/editing/markup.h" |
| 49 #include "core/events/BeforeTextInsertedEvent.h" | 49 #include "core/events/BeforeTextInsertedEvent.h" |
| 50 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
| 51 #include "core/frame/UseCounter.h" |
| 51 #include "core/html/HTMLElement.h" | 52 #include "core/html/HTMLElement.h" |
| 52 #include "core/html/HTMLInputElement.h" | 53 #include "core/html/HTMLInputElement.h" |
| 53 #include "core/rendering/RenderObject.h" | 54 #include "core/rendering/RenderObject.h" |
| 54 #include "core/rendering/RenderText.h" | 55 #include "core/rendering/RenderText.h" |
| 55 #include "wtf/StdLibExtras.h" | 56 #include "wtf/StdLibExtras.h" |
| 56 #include "wtf/Vector.h" | 57 #include "wtf/Vector.h" |
| 57 | 58 |
| 58 namespace WebCore { | 59 namespace WebCore { |
| 59 | 60 |
| 60 using namespace HTMLNames; | 61 using namespace HTMLNames; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 90 | 91 |
| 91 RefPtrWillBeMember<Document> m_document; | 92 RefPtrWillBeMember<Document> m_document; |
| 92 RefPtrWillBeMember<DocumentFragment> m_fragment; | 93 RefPtrWillBeMember<DocumentFragment> m_fragment; |
| 93 bool m_hasInterchangeNewlineAtStart; | 94 bool m_hasInterchangeNewlineAtStart; |
| 94 bool m_hasInterchangeNewlineAtEnd; | 95 bool m_hasInterchangeNewlineAtEnd; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 static bool isInterchangeNewlineNode(const Node *node) | 98 static bool isInterchangeNewlineNode(const Node *node) |
| 98 { | 99 { |
| 99 DEFINE_STATIC_LOCAL(String, interchangeNewlineClassString, (AppleInterchange
Newline)); | 100 DEFINE_STATIC_LOCAL(String, interchangeNewlineClassString, (AppleInterchange
Newline)); |
| 100 return isHTMLBRElement(node) && toElement(node)->getAttribute(classAttr) ==
interchangeNewlineClassString; | 101 if (!isHTMLBRElement(node) || toElement(node)->getAttribute(classAttr) != in
terchangeNewlineClassString) |
| 102 return false; |
| 103 UseCounter::count(node->document(), UseCounter::EditingAppleInterchangeNewli
ne); |
| 104 return true; |
| 101 } | 105 } |
| 102 | 106 |
| 103 static bool isInterchangeConvertedSpaceSpan(const Node *node) | 107 static bool isInterchangeConvertedSpaceSpan(const Node *node) |
| 104 { | 108 { |
| 105 DEFINE_STATIC_LOCAL(String, convertedSpaceSpanClassString, (AppleConvertedSp
ace)); | 109 DEFINE_STATIC_LOCAL(String, convertedSpaceSpanClassString, (AppleConvertedSp
ace)); |
| 106 return node->isHTMLElement() && toHTMLElement(node)->getAttribute(classAttr)
== convertedSpaceSpanClassString; | 110 if (!node->isHTMLElement() || toHTMLElement(node)->getAttribute(classAttr) !
= convertedSpaceSpanClassString) |
| 111 return false; |
| 112 UseCounter::count(node->document(), UseCounter::EditingAppleConvertedSpace); |
| 113 return true; |
| 107 } | 114 } |
| 108 | 115 |
| 109 static Position positionAvoidingPrecedingNodes(Position pos) | 116 static Position positionAvoidingPrecedingNodes(Position pos) |
| 110 { | 117 { |
| 111 // If we're already on a break, it's probably a placeholder and we shouldn't
change our position. | 118 // If we're already on a break, it's probably a placeholder and we shouldn't
change our position. |
| 112 if (editingIgnoresContent(pos.deprecatedNode())) | 119 if (editingIgnoresContent(pos.deprecatedNode())) |
| 113 return pos; | 120 return pos; |
| 114 | 121 |
| 115 // We also stop when changing block flow elements because even though the vi
sual position is the | 122 // We also stop when changing block flow elements because even though the vi
sual position is the |
| 116 // same. E.g., | 123 // same. E.g., |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 return false; | 418 return false; |
| 412 | 419 |
| 413 return !selectionEndWasEndOfParagraph | 420 return !selectionEndWasEndOfParagraph |
| 414 && isEndOfParagraph(endOfInsertedContent) | 421 && isEndOfParagraph(endOfInsertedContent) |
| 415 && !isHTMLBRElement(*endOfInsertedContent.deepEquivalent().deprecatedNod
e()) | 422 && !isHTMLBRElement(*endOfInsertedContent.deepEquivalent().deprecatedNod
e()) |
| 416 && shouldMerge(endOfInsertedContent, next); | 423 && shouldMerge(endOfInsertedContent, next); |
| 417 } | 424 } |
| 418 | 425 |
| 419 static bool isMailPasteAsQuotationNode(const Node* node) | 426 static bool isMailPasteAsQuotationNode(const Node* node) |
| 420 { | 427 { |
| 421 return node && node->hasTagName(blockquoteTag) && toElement(node)->getAttrib
ute(classAttr) == ApplePasteAsQuotation; | 428 if (!node || !node->hasTagName(blockquoteTag) || toElement(node)->getAttribu
te(classAttr) != ApplePasteAsQuotation) |
| 429 return false; |
| 430 UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuotation
); |
| 431 return true; |
| 422 } | 432 } |
| 423 | 433 |
| 424 static bool isHeaderElement(const Node* a) | 434 static bool isHeaderElement(const Node* a) |
| 425 { | 435 { |
| 426 if (!a) | 436 if (!a) |
| 427 return false; | 437 return false; |
| 428 | 438 |
| 429 return a->hasTagName(h1Tag) | 439 return a->hasTagName(h1Tag) |
| 430 || a->hasTagName(h2Tag) | 440 || a->hasTagName(h2Tag) |
| 431 || a->hasTagName(h3Tag) | 441 || a->hasTagName(h3Tag) |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 if (isBlock(node)) | 869 if (isBlock(node)) |
| 860 return false; | 870 return false; |
| 861 | 871 |
| 862 if (!node->isHTMLElement()) | 872 if (!node->isHTMLElement()) |
| 863 return false; | 873 return false; |
| 864 | 874 |
| 865 // We can skip over elements whose class attribute is | 875 // We can skip over elements whose class attribute is |
| 866 // one of our internal classes. | 876 // one of our internal classes. |
| 867 const HTMLElement* element = toHTMLElement(node); | 877 const HTMLElement* element = toHTMLElement(node); |
| 868 const AtomicString& classAttributeValue = element->getAttribute(classAttr); | 878 const AtomicString& classAttributeValue = element->getAttribute(classAttr); |
| 869 if (classAttributeValue == AppleTabSpanClass | 879 if (classAttributeValue == AppleTabSpanClass) { |
| 870 || classAttributeValue == AppleConvertedSpace | 880 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass
); |
| 871 || classAttributeValue == ApplePasteAsQuotation) | |
| 872 return true; | 881 return true; |
| 882 } |
| 883 if (classAttributeValue == AppleConvertedSpace) { |
| 884 UseCounter::count(node->document(), UseCounter::EditingAppleConvertedSpa
ce); |
| 885 return true; |
| 886 } |
| 887 if (classAttributeValue == ApplePasteAsQuotation) { |
| 888 UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuota
tion); |
| 889 return true; |
| 890 } |
| 873 | 891 |
| 874 return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element); | 892 return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element); |
| 875 } | 893 } |
| 876 | 894 |
| 877 inline Node* nodeToSplitToAvoidPastingIntoInlineNodesWithStyle(const Position& i
nsertionPos) | 895 inline Node* nodeToSplitToAvoidPastingIntoInlineNodesWithStyle(const Position& i
nsertionPos) |
| 878 { | 896 { |
| 879 Node* containgBlock = enclosingBlock(insertionPos.containerNode()); | 897 Node* containgBlock = enclosingBlock(insertionPos.containerNode()); |
| 880 return highestEnclosingNodeOfType(insertionPos, isInlineNodeWithStyle, Canno
tCrossEditingBoundary, containgBlock); | 898 return highestEnclosingNodeOfType(insertionPos, isInlineNodeWithStyle, Canno
tCrossEditingBoundary, containgBlock); |
| 881 } | 899 } |
| 882 | 900 |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 void ReplaceSelectionCommand::trace(Visitor* visitor) | 1524 void ReplaceSelectionCommand::trace(Visitor* visitor) |
| 1507 { | 1525 { |
| 1508 visitor->trace(m_startOfInsertedContent); | 1526 visitor->trace(m_startOfInsertedContent); |
| 1509 visitor->trace(m_endOfInsertedContent); | 1527 visitor->trace(m_endOfInsertedContent); |
| 1510 visitor->trace(m_insertionStyle); | 1528 visitor->trace(m_insertionStyle); |
| 1511 visitor->trace(m_documentFragment); | 1529 visitor->trace(m_documentFragment); |
| 1512 CompositeEditCommand::trace(visitor); | 1530 CompositeEditCommand::trace(visitor); |
| 1513 } | 1531 } |
| 1514 | 1532 |
| 1515 } // namespace WebCore | 1533 } // namespace WebCore |
| OLD | NEW |