| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOrBefo
reNode(n), selectTag)) { | 235 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOrBefo
reNode(n), selectTag)) { |
| 236 next = Strategy::nextSkippingChildren(*n); | 236 next = Strategy::nextSkippingChildren(*n); |
| 237 // Don't skip over pastEnd. | 237 // Don't skip over pastEnd. |
| 238 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) | 238 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) |
| 239 next = pastEnd; | 239 next = pastEnd; |
| 240 } else { | 240 } else { |
| 241 // Add the node to the markup if we're not skipping the descendants | 241 // Add the node to the markup if we're not skipping the descendants |
| 242 if (markupAccumulator) | 242 if (markupAccumulator) |
| 243 markupAccumulator->appendStartTag(*n); | 243 appendStartMarkup(*markupAccumulator, *n); |
| 244 | 244 |
| 245 // If node has no children, close the tag now. | 245 // If node has no children, close the tag now. |
| 246 if (Strategy::hasChildren(*n)) { | 246 if (Strategy::hasChildren(*n)) { |
| 247 ancestorsToClose.append(toContainerNode(n)); | 247 ancestorsToClose.append(toContainerNode(n)); |
| 248 continue; | 248 continue; |
| 249 } | 249 } |
| 250 if (markupAccumulator && n->isElementNode()) | 250 if (markupAccumulator && n->isElementNode()) |
| 251 markupAccumulator->appendEndTag(toElement(*n)); | 251 markupAccumulator->appendEndTag(toElement(*n)); |
| 252 lastClosed = n; | 252 lastClosed = n; |
| 253 } | 253 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 accumulator.appendElement(markup, element); | 323 accumulator.appendElement(markup, element); |
| 324 accumulator.pushMarkup(markup.toString()); | 324 accumulator.pushMarkup(markup.toString()); |
| 325 accumulator.appendEndTag(toElement(node)); | 325 accumulator.appendEndTag(toElement(node)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 template<typename Strategy> | 328 template<typename Strategy> |
| 329 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS
tyleIfNeeded(StyledMarkupAccumulator& accumulator, Node& node) | 329 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS
tyleIfNeeded(StyledMarkupAccumulator& accumulator, Node& node) |
| 330 { | 330 { |
| 331 if (!node.isElementNode()) | 331 if (!node.isElementNode()) |
| 332 return nullptr; | 332 return nullptr; |
| 333 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = accumulator.createInlineStyle
(toElement(node)); | 333 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(accumulator
, toElement(node)); |
| 334 if (convertBlocksToInlines() && isBlock(&node)) | 334 if (convertBlocksToInlines() && isBlock(&node)) |
| 335 inlineStyle->forceInline(); | 335 inlineStyle->forceInline(); |
| 336 return inlineStyle; | 336 return inlineStyle; |
| 337 } | 337 } |
| 338 | 338 |
| 339 template<typename Strategy> |
| 340 void StyledMarkupSerializer<Strategy>::appendStartMarkup(StyledMarkupAccumulator
& accumulator, Node& node) |
| 341 { |
| 342 switch (node.nodeType()) { |
| 343 case Node::TEXT_NODE: { |
| 344 Text& text = toText(node); |
| 345 if (text.parentElement() && text.parentElement()->tagQName() == textarea
Tag) { |
| 346 accumulator.appendText(text); |
| 347 break; |
| 348 } |
| 349 accumulator.appendTextWithInlineStyle(text); |
| 350 break; |
| 351 } |
| 352 case Node::ELEMENT_NODE: { |
| 353 Element& element = toElement(node); |
| 354 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(accumul
ator, element); |
| 355 accumulator.appendElement(element, inlineStyle); |
| 356 break; |
| 357 } |
| 358 default: |
| 359 accumulator.appendStartMarkup(node); |
| 360 break; |
| 361 } |
| 362 } |
| 363 |
| 364 template<typename Strategy> |
| 365 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS
tyle(StyledMarkupAccumulator& accumulator, Element& element) |
| 366 { |
| 367 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr; |
| 368 |
| 369 if (accumulator.shouldApplyWrappingStyle(element)) { |
| 370 inlineStyle = accumulator.wrappingStyle()->copy(); |
| 371 inlineStyle->removePropertiesInElementDefaultStyle(&element); |
| 372 inlineStyle->removeStyleConflictingWithStyleOfElement(&element); |
| 373 } else { |
| 374 inlineStyle = EditingStyle::create(); |
| 375 } |
| 376 |
| 377 if (element.isStyledElement() && element.inlineStyle()) |
| 378 inlineStyle->overrideWithStyle(element.inlineStyle()); |
| 379 |
| 380 if (element.isHTMLElement() && shouldAnnotate()) |
| 381 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)
); |
| 382 |
| 383 return inlineStyle; |
| 384 } |
| 385 |
| 339 template class StyledMarkupSerializer<EditingStrategy>; | 386 template class StyledMarkupSerializer<EditingStrategy>; |
| 340 | 387 |
| 341 } // namespace blink | 388 } // namespace blink |
| OLD | NEW |