OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 // FIXME: Callers should perform this operation on a Range that includes the | 855 // FIXME: Callers should perform this operation on a Range that includes the |
856 // br if they want style applied to the empty line. | 856 // br if they want style applied to the empty line. |
857 if (start == end && isHTMLBRElement(*start.anchorNode())) | 857 if (start == end && isHTMLBRElement(*start.anchorNode())) |
858 pastEndNode = NodeTraversal::next(*start.anchorNode()); | 858 pastEndNode = NodeTraversal::next(*start.anchorNode()); |
859 | 859 |
860 // Start from the highest fully selected ancestor so that we can modify the | 860 // Start from the highest fully selected ancestor so that we can modify the |
861 // fully selected node. e.g. When applying font-size: large on <font | 861 // fully selected node. e.g. When applying font-size: large on <font |
862 // color="blue">hello</font>, we need to include the font element in our run | 862 // color="blue">hello</font>, we need to include the font element in our run |
863 // to generate <font color="blue" size="4">hello</font> instead of <font | 863 // to generate <font color="blue" size="4">hello</font> instead of <font |
864 // color="blue"><font size="4">hello</font></font> | 864 // color="blue"><font size="4">hello</font></font> |
865 Range* range = Range::create(startNode->document(), start, end); | |
866 Element* editableRoot = rootEditableElement(*startNode); | 865 Element* editableRoot = rootEditableElement(*startNode); |
867 if (startNode != editableRoot) { | 866 if (startNode != editableRoot && start <= end) { |
yosin_UTC9
2017/04/04 04:54:46
Since this function assumes start <= end, e.g. |st
| |
867 const EphemeralRange range = EphemeralRange(start, end); | |
868 while (editableRoot && startNode->parentNode() != editableRoot && | 868 while (editableRoot && startNode->parentNode() != editableRoot && |
869 isNodeVisiblyContainedWithin(*startNode->parentNode(), *range)) | 869 isNodeVisiblyContainedWithin(*startNode->parentNode(), range)) |
870 startNode = startNode->parentNode(); | 870 startNode = startNode->parentNode(); |
871 } | 871 } |
872 | 872 |
873 applyInlineStyleToNodeRange(style, startNode, pastEndNode, editingState); | 873 applyInlineStyleToNodeRange(style, startNode, pastEndNode, editingState); |
874 } | 874 } |
875 | 875 |
876 static bool containsNonEditableRegion(Node& node) { | 876 static bool containsNonEditableRegion(Node& node) { |
877 if (!hasEditableStyle(node)) | 877 if (!hasEditableStyle(node)) |
878 return true; | 878 return true; |
879 | 879 |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2021 | 2021 |
2022 DEFINE_TRACE(ApplyStyleCommand) { | 2022 DEFINE_TRACE(ApplyStyleCommand) { |
2023 visitor->trace(m_style); | 2023 visitor->trace(m_style); |
2024 visitor->trace(m_start); | 2024 visitor->trace(m_start); |
2025 visitor->trace(m_end); | 2025 visitor->trace(m_end); |
2026 visitor->trace(m_styledInlineElement); | 2026 visitor->trace(m_styledInlineElement); |
2027 CompositeEditCommand::trace(visitor); | 2027 CompositeEditCommand::trace(visitor); |
2028 } | 2028 } |
2029 | 2029 |
2030 } // namespace blink | 2030 } // namespace blink |
OLD | NEW |