| 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 Node* destinationNode = destination.deepEquivalent().anchorNode(); | 471 Node* destinationNode = destination.deepEquivalent().anchorNode(); |
| 472 Element* sourceBlock = enclosingBlock(sourceNode); | 472 Element* sourceBlock = enclosingBlock(sourceNode); |
| 473 Element* destinationBlock = enclosingBlock(destinationNode); | 473 Element* destinationBlock = enclosingBlock(destinationNode); |
| 474 return !enclosingNodeOfType(source.deepEquivalent(), &isMailPasteAsQuotation
HTMLBlockQuoteElement) | 474 return !enclosingNodeOfType(source.deepEquivalent(), &isMailPasteAsQuotation
HTMLBlockQuoteElement) |
| 475 && sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || isMailHTML
BlockquoteElement(sourceBlock)) | 475 && sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || isMailHTML
BlockquoteElement(sourceBlock)) |
| 476 && enclosingListChild(sourceBlock) == enclosingListChild(destinationNode
) | 476 && enclosingListChild(sourceBlock) == enclosingListChild(destinationNode
) |
| 477 && enclosingTableCell(source.deepEquivalent()) == enclosingTableCell(des
tination.deepEquivalent()) | 477 && enclosingTableCell(source.deepEquivalent()) == enclosingTableCell(des
tination.deepEquivalent()) |
| 478 && (!isHTMLHeaderElement(sourceBlock) || haveSameTagName(sourceBlock, de
stinationBlock)) | 478 && (!isHTMLHeaderElement(sourceBlock) || haveSameTagName(sourceBlock, de
stinationBlock)) |
| 479 // Don't merge to or from a position before or after a block because it
would | 479 // Don't merge to or from a position before or after a block because it
would |
| 480 // be a no-op and cause infinite recursion. | 480 // be a no-op and cause infinite recursion. |
| 481 && !isBlock(sourceNode) && !isBlock(destinationNode); | 481 && !isEnclosingBlock(sourceNode) && !isEnclosingBlock(destinationNode); |
| 482 } | 482 } |
| 483 | 483 |
| 484 // Style rules that match just inserted elements could change their appearance,
like | 484 // Style rules that match just inserted elements could change their appearance,
like |
| 485 // a div inserted into a document with div { display:inline; }. | 485 // a div inserted into a document with div { display:inline; }. |
| 486 void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
edNodes& insertedNodes) | 486 void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
edNodes& insertedNodes) |
| 487 { | 487 { |
| 488 RefPtrWillBeRawPtr<Node> pastEndNode = insertedNodes.pastLastLeaf(); | 488 RefPtrWillBeRawPtr<Node> pastEndNode = insertedNodes.pastLastLeaf(); |
| 489 RefPtrWillBeRawPtr<Node> next = nullptr; | 489 RefPtrWillBeRawPtr<Node> next = nullptr; |
| 490 for (RefPtrWillBeRawPtr<Node> node = insertedNodes.firstNodeInserted(); node
&& node != pastEndNode; node = next) { | 490 for (RefPtrWillBeRawPtr<Node> node = insertedNodes.firstNodeInserted(); node
&& node != pastEndNode; node = next) { |
| 491 // FIXME: <rdar://problem/5371536> Style rules that match pasted content
can change it's appearance | 491 // FIXME: <rdar://problem/5371536> Style rules that match pasted content
can change it's appearance |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 continue; | 562 continue; |
| 563 } | 563 } |
| 564 // There are other styles that style rules can give to style spans, | 564 // There are other styles that style rules can give to style spans, |
| 565 // but these are the two important ones because they'll prevent | 565 // but these are the two important ones because they'll prevent |
| 566 // inserted content from appearing in the right paragraph. | 566 // inserted content from appearing in the right paragraph. |
| 567 // FIXME: Hyatt is concerned that selectively using display:inline w
ill give inconsistent | 567 // FIXME: Hyatt is concerned that selectively using display:inline w
ill give inconsistent |
| 568 // results. We already know one issue because td elements ignore the
ir display property | 568 // results. We already know one issue because td elements ignore the
ir display property |
| 569 // in quirks mode (which Mail.app is always in). We should look for
an alternative. | 569 // in quirks mode (which Mail.app is always in). We should look for
an alternative. |
| 570 | 570 |
| 571 // Mutate using the CSSOM wrapper so we get the same event behavior
as a script. | 571 // Mutate using the CSSOM wrapper so we get the same event behavior
as a script. |
| 572 if (isBlock(element)) | 572 if (isEnclosingBlock(element)) |
| 573 element->style()->setPropertyInternal(CSSPropertyDisplay, "inlin
e", false, IGNORE_EXCEPTION); | 573 element->style()->setPropertyInternal(CSSPropertyDisplay, "inlin
e", false, IGNORE_EXCEPTION); |
| 574 if (element->layoutObject() && element->layoutObject()->style()->isF
loating()) | 574 if (element->layoutObject() && element->layoutObject()->style()->isF
loating()) |
| 575 element->style()->setPropertyInternal(CSSPropertyFloat, "none",
false, IGNORE_EXCEPTION); | 575 element->style()->setPropertyInternal(CSSPropertyFloat, "none",
false, IGNORE_EXCEPTION); |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 | 579 |
| 580 static bool isProhibitedParagraphChild(const AtomicString& name) | 580 static bool isProhibitedParagraphChild(const AtomicString& name) |
| 581 { | 581 { |
| 582 // https://dvcs.w3.org/hg/editing/raw-file/57abe6d3cb60/editing.html#prohibi
ted-paragraph-child | 582 // https://dvcs.w3.org/hg/editing/raw-file/57abe6d3cb60/editing.html#prohibi
ted-paragraph-child |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 return node; | 878 return node; |
| 879 } | 879 } |
| 880 node = parent; | 880 node = parent; |
| 881 } | 881 } |
| 882 return node; | 882 return node; |
| 883 } | 883 } |
| 884 | 884 |
| 885 static bool isInlineHTMLElementWithStyle(const Node* node) | 885 static bool isInlineHTMLElementWithStyle(const Node* node) |
| 886 { | 886 { |
| 887 // We don't want to skip over any block elements. | 887 // We don't want to skip over any block elements. |
| 888 if (isBlock(node)) | 888 if (isEnclosingBlock(node)) |
| 889 return false; | 889 return false; |
| 890 | 890 |
| 891 if (!node->isHTMLElement()) | 891 if (!node->isHTMLElement()) |
| 892 return false; | 892 return false; |
| 893 | 893 |
| 894 // We can skip over elements whose class attribute is | 894 // We can skip over elements whose class attribute is |
| 895 // one of our internal classes. | 895 // one of our internal classes. |
| 896 const HTMLElement* element = toHTMLElement(node); | 896 const HTMLElement* element = toHTMLElement(node); |
| 897 const AtomicString& classAttributeValue = element->getAttribute(classAttr); | 897 const AtomicString& classAttributeValue = element->getAttribute(classAttr); |
| 898 if (classAttributeValue == AppleTabSpanClass) { | 898 if (classAttributeValue == AppleTabSpanClass) { |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 DEFINE_TRACE(ReplaceSelectionCommand) | 1549 DEFINE_TRACE(ReplaceSelectionCommand) |
| 1550 { | 1550 { |
| 1551 visitor->trace(m_startOfInsertedContent); | 1551 visitor->trace(m_startOfInsertedContent); |
| 1552 visitor->trace(m_endOfInsertedContent); | 1552 visitor->trace(m_endOfInsertedContent); |
| 1553 visitor->trace(m_insertionStyle); | 1553 visitor->trace(m_insertionStyle); |
| 1554 visitor->trace(m_documentFragment); | 1554 visitor->trace(m_documentFragment); |
| 1555 CompositeEditCommand::trace(visitor); | 1555 CompositeEditCommand::trace(visitor); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 } // namespace blink | 1558 } // namespace blink |
| OLD | NEW |