OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return markupAccumulator.takeResults(); | 182 return markupAccumulator.takeResults(); |
183 | 183 |
184 firstNode = nextPositionOf(visibleStart).deepEquivalent().anchorNode(); | 184 firstNode = nextPositionOf(visibleStart).deepEquivalent().anchorNode(); |
185 | 185 |
186 if (pastEnd && PositionTemplate<Strategy>::beforeNode(firstNode).compare
To(PositionTemplate<Strategy>::beforeNode(pastEnd)) >= 0) { | 186 if (pastEnd && PositionTemplate<Strategy>::beforeNode(firstNode).compare
To(PositionTemplate<Strategy>::beforeNode(pastEnd)) >= 0) { |
187 // This condition hits in editing/pasteboard/copy-display-none.html. | 187 // This condition hits in editing/pasteboard/copy-display-none.html. |
188 return markupAccumulator.takeResults(); | 188 return markupAccumulator.takeResults(); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 if (!m_lastClosed) | 192 // If there is no the highest node in the selected nodes, |m_lastClosed| can
be #text |
| 193 // when its parent is a formatting tag. In this case, #text is wrapped by <s
pan> tag, |
| 194 // but this text should be wrapped by the formatting tag. See http://crbug.c
om/634482 |
| 195 bool shouldAppendParentTag = false; |
| 196 if (!m_lastClosed) { |
193 m_lastClosed = StyledMarkupTraverser<Strategy>().traverse(firstNode, pas
tEnd); | 197 m_lastClosed = StyledMarkupTraverser<Strategy>().traverse(firstNode, pas
tEnd); |
| 198 if (m_lastClosed && m_lastClosed->isTextNode() && isPresentationalHTMLEl
ement(m_lastClosed->parentNode())) { |
| 199 m_lastClosed = m_lastClosed->parentElement(); |
| 200 shouldAppendParentTag = true; |
| 201 } |
| 202 } |
| 203 |
194 StyledMarkupTraverser<Strategy> traverser(&markupAccumulator, m_lastClosed); | 204 StyledMarkupTraverser<Strategy> traverser(&markupAccumulator, m_lastClosed); |
195 Node* lastClosed = traverser.traverse(firstNode, pastEnd); | 205 Node* lastClosed = traverser.traverse(firstNode, pastEnd); |
196 | 206 |
197 if (m_highestNodeToBeSerialized && lastClosed) { | 207 if (m_highestNodeToBeSerialized && lastClosed) { |
198 // TODO(hajimehoshi): This is calculated at createMarkupInternal too. | 208 // TODO(hajimehoshi): This is calculated at createMarkupInternal too. |
199 Node* commonAncestor = Strategy::commonAncestor(*m_start.computeContaine
rNode(), *m_end.computeContainerNode()); | 209 Node* commonAncestor = Strategy::commonAncestor(*m_start.computeContaine
rNode(), *m_end.computeContainerNode()); |
200 DCHECK(commonAncestor); | 210 DCHECK(commonAncestor); |
201 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(Positi
on::firstPositionInNode(commonAncestor), bodyTag)); | 211 HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(Positi
on::firstPositionInNode(commonAncestor), bodyTag)); |
202 HTMLBodyElement* fullySelectedRoot = nullptr; | 212 HTMLBodyElement* fullySelectedRoot = nullptr; |
203 // FIXME: Do this for all fully selected blocks, not just the body. | 213 // FIXME: Do this for all fully selected blocks, not just the body. |
(...skipping 29 matching lines...) Expand all Loading... |
233 // If the node is not fully selected by the range, then we don't
want to keep styles that affect its relationship to the nodes around it | 243 // If the node is not fully selected by the range, then we don't
want to keep styles that affect its relationship to the nodes around it |
234 // only the ones that affect it and the nodes within it. | 244 // only the ones that affect it and the nodes within it. |
235 if (style && style->style()) | 245 if (style && style->style()) |
236 style->style()->removeProperty(CSSPropertyFloat); | 246 style->style()->removeProperty(CSSPropertyFloat); |
237 traverser.wrapWithNode(*ancestor, style); | 247 traverser.wrapWithNode(*ancestor, style); |
238 } | 248 } |
239 | 249 |
240 if (ancestor == m_highestNodeToBeSerialized) | 250 if (ancestor == m_highestNodeToBeSerialized) |
241 break; | 251 break; |
242 } | 252 } |
| 253 } else if (shouldAppendParentTag) { |
| 254 EditingStyle* style = traverser.createInlineStyleIfNeeded(*m_lastClosed)
; |
| 255 traverser.wrapWithNode(*toContainerNode(m_lastClosed), style); |
243 } | 256 } |
244 | 257 |
245 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. | 258 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. |
246 if (shouldAnnotate() && needInterchangeNewlineAt(visibleEnd)) | 259 if (shouldAnnotate() && needInterchangeNewlineAt(visibleEnd)) |
247 markupAccumulator.appendInterchangeNewline(); | 260 markupAccumulator.appendInterchangeNewline(); |
248 | 261 |
249 return markupAccumulator.takeResults(); | 262 return markupAccumulator.takeResults(); |
250 } | 263 } |
251 | 264 |
252 template<typename Strategy> | 265 template<typename Strategy> |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (element.isHTMLElement() && shouldAnnotate()) | 487 if (element.isHTMLElement() && shouldAnnotate()) |
475 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); | 488 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); |
476 | 489 |
477 return inlineStyle; | 490 return inlineStyle; |
478 } | 491 } |
479 | 492 |
480 template class StyledMarkupSerializer<EditingStrategy>; | 493 template class StyledMarkupSerializer<EditingStrategy>; |
481 template class StyledMarkupSerializer<EditingInFlatTreeStrategy>; | 494 template class StyledMarkupSerializer<EditingInFlatTreeStrategy>; |
482 | 495 |
483 } // namespace blink | 496 } // namespace blink |
OLD | NEW |