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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 Node* next; | 285 Node* next; |
286 Node* lastClosed = nullptr; | 286 Node* lastClosed = nullptr; |
287 for (Node* n = startNode; n && n != pastEnd; n = next) { | 287 for (Node* n = startNode; n && n != pastEnd; n = next) { |
288 // If |n| is a selection boundary such as <input>, traverse the child | 288 // If |n| is a selection boundary such as <input>, traverse the child |
289 // nodes in the DOM tree instead of the composed tree. | 289 // nodes in the DOM tree instead of the composed tree. |
290 if (handleSelectionBoundary<Strategy>(*n)) { | 290 if (handleSelectionBoundary<Strategy>(*n)) { |
291 lastClosed = StyledMarkupTraverser<EditingStrategy>(m_accumulator, m
_lastClosed.get()).traverse(n, EditingStrategy::nextSkippingChildren(*n)); | 291 lastClosed = StyledMarkupTraverser<EditingStrategy>(m_accumulator, m
_lastClosed.get()).traverse(n, EditingStrategy::nextSkippingChildren(*n)); |
292 next = EditingInComposedTreeStrategy::nextSkippingChildren(*n); | 292 next = EditingInComposedTreeStrategy::nextSkippingChildren(*n); |
293 } else { | 293 } else { |
294 next = Strategy::next(*n); | 294 next = Strategy::next(*n); |
295 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) { | 295 if (isEnclosingBlock(n) && canHaveChildrenForEditing(n) && next == p
astEnd) { |
296 // Don't write out empty block containers that aren't fully sele
cted. | 296 // Don't write out empty block containers that aren't fully sele
cted. |
297 continue; | 297 continue; |
298 } | 298 } |
299 | 299 |
300 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOr
BeforeNode(n), selectTag)) { | 300 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOr
BeforeNode(n), selectTag)) { |
301 next = Strategy::nextSkippingChildren(*n); | 301 next = Strategy::nextSkippingChildren(*n); |
302 // Don't skip over pastEnd. | 302 // Don't skip over pastEnd. |
303 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) | 303 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) |
304 next = pastEnd; | 304 next = pastEnd; |
305 } else { | 305 } else { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 return lastClosed; | 356 return lastClosed; |
357 } | 357 } |
358 | 358 |
359 template<typename Strategy> | 359 template<typename Strategy> |
360 bool StyledMarkupTraverser<Strategy>::needsInlineStyle(const Element& element) | 360 bool StyledMarkupTraverser<Strategy>::needsInlineStyle(const Element& element) |
361 { | 361 { |
362 if (!element.isHTMLElement()) | 362 if (!element.isHTMLElement()) |
363 return false; | 363 return false; |
364 if (shouldAnnotate()) | 364 if (shouldAnnotate()) |
365 return true; | 365 return true; |
366 return convertBlocksToInlines() && isBlock(&element); | 366 return convertBlocksToInlines() && isEnclosingBlock(&element); |
367 } | 367 } |
368 | 368 |
369 template<typename Strategy> | 369 template<typename Strategy> |
370 void StyledMarkupTraverser<Strategy>::wrapWithNode(ContainerNode& node, PassRefP
trWillBeRawPtr<EditingStyle> style) | 370 void StyledMarkupTraverser<Strategy>::wrapWithNode(ContainerNode& node, PassRefP
trWillBeRawPtr<EditingStyle> style) |
371 { | 371 { |
372 if (!m_accumulator) | 372 if (!m_accumulator) |
373 return; | 373 return; |
374 StringBuilder markup; | 374 StringBuilder markup; |
375 if (node.isDocumentNode()) { | 375 if (node.isDocumentNode()) { |
376 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node)); | 376 MarkupFormatter::appendXMLDeclaration(markup, toDocument(node)); |
(...skipping 12 matching lines...) Expand all Loading... |
389 } | 389 } |
390 | 390 |
391 template<typename Strategy> | 391 template<typename Strategy> |
392 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineSt
yleIfNeeded(Node& node) | 392 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineSt
yleIfNeeded(Node& node) |
393 { | 393 { |
394 if (!m_accumulator) | 394 if (!m_accumulator) |
395 return nullptr; | 395 return nullptr; |
396 if (!node.isElementNode()) | 396 if (!node.isElementNode()) |
397 return nullptr; | 397 return nullptr; |
398 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(n
ode)); | 398 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(n
ode)); |
399 if (convertBlocksToInlines() && isBlock(&node)) | 399 if (convertBlocksToInlines() && isEnclosingBlock(&node)) |
400 inlineStyle->forceInline(); | 400 inlineStyle->forceInline(); |
401 return inlineStyle; | 401 return inlineStyle; |
402 } | 402 } |
403 | 403 |
404 template<typename Strategy> | 404 template<typename Strategy> |
405 void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node) | 405 void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node) |
406 { | 406 { |
407 if (!m_accumulator) | 407 if (!m_accumulator) |
408 return; | 408 return; |
409 switch (node.nodeType()) { | 409 switch (node.nodeType()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 if (element.isHTMLElement() && shouldAnnotate()) | 475 if (element.isHTMLElement() && shouldAnnotate()) |
476 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); | 476 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); |
477 | 477 |
478 return inlineStyle; | 478 return inlineStyle; |
479 } | 479 } |
480 | 480 |
481 template class StyledMarkupSerializer<EditingStrategy>; | 481 template class StyledMarkupSerializer<EditingStrategy>; |
482 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; | 482 template class StyledMarkupSerializer<EditingInComposedTreeStrategy>; |
483 | 483 |
484 } // namespace blink | 484 } // namespace blink |
OLD | NEW |