OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 toHTMLElement(nodeAfterInsertionPosition)->getAttribute(styleAttr)); | 132 toHTMLElement(nodeAfterInsertionPosition)->getAttribute(styleAttr)); |
133 | 133 |
134 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 134 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
135 | 135 |
136 if (wasEndOfParagraph && | 136 if (wasEndOfParagraph && |
137 !isEndOfParagraph(createVisiblePosition(lastParagraphInBlockNode)) && | 137 !isEndOfParagraph(createVisiblePosition(lastParagraphInBlockNode)) && |
138 !isStartOfParagraph(createVisiblePosition(lastParagraphInBlockNode))) | 138 !isStartOfParagraph(createVisiblePosition(lastParagraphInBlockNode))) |
139 insertBlockPlaceholder(lastParagraphInBlockNode, editingState); | 139 insertBlockPlaceholder(lastParagraphInBlockNode, editingState); |
140 } | 140 } |
141 | 141 |
142 Element* FormatBlockCommand::elementForFormatBlockCommand(Range* range) { | 142 Element* FormatBlockCommand::elementForFormatBlockCommand( |
143 if (!range) | 143 const EphemeralRange& range) { |
yoichio
2017/03/02 09:21:36
How about passing |selection| directly from caller
yosin_UTC9
2017/03/02 10:05:43
No, we don't want to increase usage of |VisibleSel
| |
144 return 0; | 144 Node* commonAncestor = Range::commonAncestorContainer( |
Xiaocheng
2017/03/02 20:21:05
How about waiting until https://codereview.chromiu
yosin_UTC9
2017/03/09 05:18:40
Done.
| |
145 | 145 range.startPosition().computeContainerNode(), |
146 Node* commonAncestor = range->commonAncestorContainer(); | 146 range.endPosition().computeContainerNode()); |
147 while (commonAncestor && !isElementForFormatBlock(commonAncestor)) | 147 while (commonAncestor && !isElementForFormatBlock(commonAncestor)) |
148 commonAncestor = commonAncestor->parentNode(); | 148 commonAncestor = commonAncestor->parentNode(); |
149 | 149 |
150 if (!commonAncestor) | 150 if (!commonAncestor) |
151 return 0; | 151 return 0; |
152 | 152 |
153 Element* element = rootEditableElement(*range->startContainer()); | 153 Element* element = |
154 rootEditableElement(*range.startPosition().computeContainerNode()); | |
154 if (!element || commonAncestor->contains(element)) | 155 if (!element || commonAncestor->contains(element)) |
155 return 0; | 156 return 0; |
156 | 157 |
157 return commonAncestor->isElementNode() ? toElement(commonAncestor) : 0; | 158 return commonAncestor->isElementNode() ? toElement(commonAncestor) : 0; |
158 } | 159 } |
159 | 160 |
160 bool isElementForFormatBlock(const QualifiedName& tagName) { | 161 bool isElementForFormatBlock(const QualifiedName& tagName) { |
161 DEFINE_STATIC_LOCAL( | 162 DEFINE_STATIC_LOCAL( |
162 HashSet<QualifiedName>, blockTags, | 163 HashSet<QualifiedName>, blockTags, |
163 ({ | 164 ({ |
(...skipping 18 matching lines...) Expand all Loading... | |
182 if (isEnclosingBlock(&runner)) | 183 if (isEnclosingBlock(&runner)) |
183 lastBlock = &runner; | 184 lastBlock = &runner; |
184 if (isHTMLListElement(&runner)) | 185 if (isHTMLListElement(&runner)) |
185 return hasEditableStyle(*runner.parentNode()) ? runner.parentNode() | 186 return hasEditableStyle(*runner.parentNode()) ? runner.parentNode() |
186 : &runner; | 187 : &runner; |
187 } | 188 } |
188 return lastBlock; | 189 return lastBlock; |
189 } | 190 } |
190 | 191 |
191 } // namespace blink | 192 } // namespace blink |
OLD | NEW |