Chromium Code Reviews| 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 accumulator.appendText(toText(node)); | |
| 345 break; | |
| 346 case Node::ELEMENT_NODE: { | |
| 347 Element& element = toElement(node); | |
| 348 RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(accumulator, element); | |
|
yosin_UTC9
2015/06/17 01:07:31
nit: better to use |inlineStyle| rather than |styl
hajimehoshi
2015/06/17 04:33:51
Done.
| |
| 349 accumulator.appendElement(element, style); | |
| 350 break; | |
| 351 } | |
| 352 default: | |
| 353 accumulator.appendStartMarkup(node); | |
| 354 break; | |
| 355 } | |
| 356 } | |
| 357 | |
| 358 template<typename Strategy> | |
| 359 RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS tyle(StyledMarkupAccumulator& accumulator, Element& element) | |
| 360 { | |
| 361 RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr; | |
| 362 | |
| 363 if (accumulator.shouldApplyWrappingStyle(element)) { | |
| 364 inlineStyle = accumulator.wrappingStyle()->copy(); | |
| 365 inlineStyle->removePropertiesInElementDefaultStyle(&element); | |
| 366 inlineStyle->removeStyleConflictingWithStyleOfElement(&element); | |
| 367 } else { | |
| 368 inlineStyle = EditingStyle::create(); | |
| 369 } | |
| 370 | |
| 371 if (element.isStyledElement() && element.inlineStyle()) | |
| 372 inlineStyle->overrideWithStyle(element.inlineStyle()); | |
| 373 | |
| 374 if (element.isHTMLElement() && shouldAnnotate()) | |
| 375 inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element) ); | |
| 376 | |
| 377 return inlineStyle; | |
| 378 } | |
| 379 | |
| 339 template class StyledMarkupSerializer<EditingStrategy>; | 380 template class StyledMarkupSerializer<EditingStrategy>; |
| 340 | 381 |
| 341 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |