Chromium Code Reviews| 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 || isHTMLStyleElement(*node) | 787 || isHTMLStyleElement(*node) |
| 788 || isHTMLTitleElement(*node)) { | 788 || isHTMLTitleElement(*node)) { |
| 789 next = NodeTraversal::nextSkippingChildren(*node); | 789 next = NodeTraversal::nextSkippingChildren(*node); |
| 790 fragment.removeNode(node); | 790 fragment.removeNode(node); |
| 791 } else { | 791 } else { |
| 792 next = NodeTraversal::next(*node); | 792 next = NodeTraversal::next(*node); |
| 793 } | 793 } |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 | 796 |
| 797 static bool followBlockElementStyle(const Node* node) | |
| 798 { | |
| 799 if (!node->isHTMLElement()) | |
| 800 return false; | |
| 801 | |
| 802 const HTMLElement& element = toHTMLElement(*node); | |
| 803 return element.hasTagName(liTag) | |
|
yosin_UTC9
2016/06/28 01:27:50
Is it better to check "display:block", "display:ta
joone
2016/06/28 08:41:43
Done.
| |
| 804 || element.hasTagName(preTag) | |
| 805 || element.hasTagName(tdTag) | |
| 806 || element.hasTagName(h1Tag) | |
| 807 || element.hasTagName(h2Tag) | |
| 808 || element.hasTagName(h3Tag) | |
| 809 || element.hasTagName(h4Tag) | |
| 810 || element.hasTagName(h5Tag); | |
|
yosin_UTC9
2016/06/28 01:27:50
Could you explain why do you omit H6?
https://deve
joone
2016/06/28 08:41:43
I just missed h6.
| |
| 811 } | |
| 812 | |
| 797 // Remove style spans before insertion if they are unnecessary. It's faster bec ause we'll | 813 // Remove style spans before insertion if they are unnecessary. It's faster bec ause we'll |
| 798 // avoid doing a layout. | 814 // avoid doing a layout. |
| 799 static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Position& insertionPos) | 815 static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Position& insertionPos) |
| 800 { | 816 { |
| 801 Node* topNode = fragment.firstChild(); | 817 Node* topNode = fragment.firstChild(); |
| 802 if (!isHTMLSpanElement(topNode)) | 818 if (!isHTMLSpanElement(topNode)) |
| 803 return false; | 819 return false; |
| 804 | 820 |
| 805 // Handling the case where we are doing Paste as Quotation or pasting into q uoted content is more complicated (see handleStyleSpans) | 821 // Handling the case where we are doing Paste as Quotation or pasting into q uoted content is more complicated (see handleStyleSpans) |
| 806 // and doesn't receive the optimization. | 822 // and doesn't receive the optimization. |
| 807 if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || enclosingNodeOfT ype(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossE ditingBoundary)) | 823 if (isMailPasteAsQuotationHTMLBlockQuoteElement(topNode) || enclosingNodeOfT ype(firstPositionInOrBeforeNode(topNode), isMailHTMLBlockquoteElement, CanCrossE ditingBoundary)) |
| 808 return false; | 824 return false; |
| 809 | 825 |
| 810 // Remove style spans to follow the styles of list item when |fragment| beco mes a list item. | 826 // Remove style spans to follow the styles of parent block element when |fra gment| becomes a part of it. |
| 811 // See bug http://crbug.com/335955. | 827 // See bugs http://crbug.com/226941 and http://crbug.com/335955. |
| 812 HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode); | 828 HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode); |
| 813 if (isListItem(enclosingBlock(insertionPos.anchorNode()))) { | 829 const Node* node = insertionPos.anchorNode(); |
| 830 // |node| can be an inline element like <br> under <li> | |
| 831 // e.g.) editing/execCommand/switch-list-type.html | |
| 832 // editing/deleting/backspace-merge-into-block.html | |
| 833 if (node->layoutObject() && node->layoutObject()->isInline()) { | |
|
yosin_UTC9
2016/06/28 01:27:50
Let's use Node::computedStyle() rather than layout
joone
2016/06/28 08:41:43
Done.
| |
| 834 if (!(node = enclosingBlock(insertionPos.anchorNode()))) | |
| 835 return false; | |
| 836 } | |
| 837 | |
| 838 if (followBlockElementStyle(node)) { | |
| 814 fragment.removeNodePreservingChildren(wrappingStyleSpan); | 839 fragment.removeNodePreservingChildren(wrappingStyleSpan); |
| 815 return true; | 840 return true; |
| 816 } | 841 } |
| 817 | 842 |
| 818 // Either there are no style spans in the fragment or a WebKit client has ad ded content to the fragment | 843 // Either there are no style spans in the fragment or a WebKit client has ad ded content to the fragment |
| 819 // before inserting it. Look for and handle style spans after insertion. | 844 // before inserting it. Look for and handle style spans after insertion. |
| 820 if (!isLegacyAppleHTMLSpanElement(topNode)) | 845 if (!isLegacyAppleHTMLSpanElement(topNode)) |
| 821 return false; | 846 return false; |
| 822 | 847 |
| 823 EditingStyle* styleAtInsertionPos = EditingStyle::create(insertionPos.parent AnchoredEquivalent()); | 848 EditingStyle* styleAtInsertionPos = EditingStyle::create(insertionPos.parent AnchoredEquivalent()); |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1729 visitor->trace(m_startOfInsertedContent); | 1754 visitor->trace(m_startOfInsertedContent); |
| 1730 visitor->trace(m_endOfInsertedContent); | 1755 visitor->trace(m_endOfInsertedContent); |
| 1731 visitor->trace(m_insertionStyle); | 1756 visitor->trace(m_insertionStyle); |
| 1732 visitor->trace(m_documentFragment); | 1757 visitor->trace(m_documentFragment); |
| 1733 visitor->trace(m_startOfInsertedRange); | 1758 visitor->trace(m_startOfInsertedRange); |
| 1734 visitor->trace(m_endOfInsertedRange); | 1759 visitor->trace(m_endOfInsertedRange); |
| 1735 CompositeEditCommand::trace(visitor); | 1760 CompositeEditCommand::trace(visitor); |
| 1736 } | 1761 } |
| 1737 | 1762 |
| 1738 } // namespace blink | 1763 } // namespace blink |
| OLD | NEW |