| 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 29 matching lines...) Expand all Loading... |
| 40 #include "core/editing/iterators/TextIterator.h" | 40 #include "core/editing/iterators/TextIterator.h" |
| 41 #include "core/editing/markup.h" | 41 #include "core/editing/markup.h" |
| 42 #include "core/html/HTMLBodyElement.h" | 42 #include "core/html/HTMLBodyElement.h" |
| 43 #include "core/html/HTMLElement.h" | 43 #include "core/html/HTMLElement.h" |
| 44 #include "wtf/text/StringBuilder.h" | 44 #include "wtf/text/StringBuilder.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 const String& styleNodeCloseTag(bool isBlock) | 50 const String& styleNodeCloseTag(StyleTagType isBlock) |
| 51 { | 51 { |
| 52 DEFINE_STATIC_LOCAL(const String, divClose, ("</div>")); | 52 DEFINE_STATIC_LOCAL(const String, divClose, ("</div>")); |
| 53 DEFINE_STATIC_LOCAL(const String, styleSpanClose, ("</span>")); | 53 DEFINE_STATIC_LOCAL(const String, styleSpanClose, ("</span>")); |
| 54 return isBlock ? divClose : styleSpanClose; | 54 return isBlock == StyleTagType::Block ? divClose : styleSpanClose; |
| 55 } | 55 } |
| 56 | 56 |
| 57 template<typename PositionType> | 57 template<typename PositionType> |
| 58 TextOffset toTextOffset(const PositionType& position) | 58 TextOffset toTextOffset(const PositionType& position) |
| 59 { | 59 { |
| 60 if (position.isNull()) | 60 if (position.isNull()) |
| 61 return TextOffset(); | 61 return TextOffset(); |
| 62 | 62 |
| 63 if (!position.containerNode()->isTextNode()) | 63 if (!position.containerNode()->isTextNode()) |
| 64 return TextOffset(); | 64 return TextOffset(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 fullySelectedRootStyle->style()->setProperty(CSSPropertyBack
groundImage, "url('" + fullySelectedRoot->getAttribute(backgroundAttr) + "')"); | 169 fullySelectedRootStyle->style()->setProperty(CSSPropertyBack
groundImage, "url('" + fullySelectedRoot->getAttribute(backgroundAttr) + "')"); |
| 170 | 170 |
| 171 if (fullySelectedRootStyle->style()) { | 171 if (fullySelectedRootStyle->style()) { |
| 172 // Reset the CSS properties to avoid an assertion error in a
ddStyleMarkup(). | 172 // Reset the CSS properties to avoid an assertion error in a
ddStyleMarkup(). |
| 173 // This assertion is caused at least when we select all text
of a <body> element whose | 173 // This assertion is caused at least when we select all text
of a <body> element whose |
| 174 // 'text-decoration' property is "inherit", and copy it. | 174 // 'text-decoration' property is "inherit", and copy it. |
| 175 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st
yle(), CSSPropertyTextDecoration)) | 175 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st
yle(), CSSPropertyTextDecoration)) |
| 176 fullySelectedRootStyle->style()->setProperty(CSSProperty
TextDecoration, CSSValueNone); | 176 fullySelectedRootStyle->style()->setProperty(CSSProperty
TextDecoration, CSSValueNone); |
| 177 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st
yle(), CSSPropertyWebkitTextDecorationsInEffect)) | 177 if (!propertyMissingOrEqualToNone(fullySelectedRootStyle->st
yle(), CSSPropertyWebkitTextDecorationsInEffect)) |
| 178 fullySelectedRootStyle->style()->setProperty(CSSProperty
WebkitTextDecorationsInEffect, CSSValueNone); | 178 fullySelectedRootStyle->style()->setProperty(CSSProperty
WebkitTextDecorationsInEffect, CSSValueNone); |
| 179 wrapWithStyleNode(fullySelectedRootStyle->style(), true); | 179 wrapWithStyleNode(fullySelectedRootStyle->style(), StyleTagT
ype::Block); |
| 180 } | 180 } |
| 181 } else { | 181 } else { |
| 182 // Since this node and all the other ancestors are not in the se
lection we want to set RangeFullySelectsNode to DoesNotFullySelectNode | 182 // Since this node and all the other ancestors are not in the se
lection we want to set RangeFullySelectsNode to DoesNotFullySelectNode |
| 183 // so that styles that affect the exterior of the node are not i
ncluded. | 183 // so that styles that affect the exterior of the node are not i
ncluded. |
| 184 wrapWithNode(*ancestor, StyledMarkupAccumulator::DoesNotFullySel
ectNode); | 184 wrapWithNode(*ancestor, RangeFullySelectsNode::DoesNotSelect); |
| 185 } | 185 } |
| 186 | 186 |
| 187 if (ancestor == m_highestNodeToBeSerialized) | 187 if (ancestor == m_highestNodeToBeSerialized) |
| 188 break; | 188 break; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. | 192 // FIXME: The interchange newline should be placed in the block that it's in
, not after all of the content, unconditionally. |
| 193 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v
isibleEnd)) | 193 if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(v
isibleEnd)) |
| 194 m_markupAccumulator.appendString(interchangeNewlineString); | 194 m_markupAccumulator.appendString(interchangeNewlineString); |
| 195 | 195 |
| 196 return takeResults(); | 196 return takeResults(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 template<typename Strategy> | 199 template<typename Strategy> |
| 200 void StyledMarkupSerializer<Strategy>::wrapWithNode(ContainerNode& node, typenam
e StyledMarkupAccumulator::RangeFullySelectsNode rangeFullySelectsNode) | 200 void StyledMarkupSerializer<Strategy>::wrapWithNode(ContainerNode& node, RangeFu
llySelectsNode rangeFullySelectsNode) |
| 201 { | 201 { |
| 202 StringBuilder markup; | 202 StringBuilder markup; |
| 203 if (node.isElementNode()) | 203 if (node.isElementNode()) { |
| 204 m_markupAccumulator.appendElement(markup, toElement(node), convertBlocks
ToInlines() && isBlock(&node), rangeFullySelectsNode); | 204 AddDisplayInline addDisplayInline = convertBlocksToInlines() && isBlock(
&node) ? AddDisplayInline::DoesAdd : AddDisplayInline::DoesNotAdd; |
| 205 else | 205 m_markupAccumulator.appendElement(markup, toElement(node), addDisplayInl
ine, rangeFullySelectsNode); |
| 206 } else { |
| 206 m_markupAccumulator.appendStartMarkup(markup, node, 0); | 207 m_markupAccumulator.appendStartMarkup(markup, node, 0); |
| 208 } |
| 207 m_reversedPrecedingMarkup.append(markup.toString()); | 209 m_reversedPrecedingMarkup.append(markup.toString()); |
| 208 if (node.isElementNode()) | 210 if (node.isElementNode()) |
| 209 m_markupAccumulator.appendEndTag(toElement(node)); | 211 m_markupAccumulator.appendEndTag(toElement(node)); |
| 210 } | 212 } |
| 211 | 213 |
| 212 template<typename Strategy> | 214 template<typename Strategy> |
| 213 void StyledMarkupSerializer<Strategy>::wrapWithStyleNode(StylePropertySet* style
, bool isBlock) | 215 void StyledMarkupSerializer<Strategy>::wrapWithStyleNode(StylePropertySet* style
, StyleTagType isBlock) |
| 214 { | 216 { |
| 215 StringBuilder openTag; | 217 StringBuilder openTag; |
| 216 m_markupAccumulator.appendStyleNodeOpenTag(openTag, style, isBlock); | 218 m_markupAccumulator.appendStyleNodeOpenTag(openTag, style, isBlock); |
| 217 m_reversedPrecedingMarkup.append(openTag.toString()); | 219 m_reversedPrecedingMarkup.append(openTag.toString()); |
| 218 m_markupAccumulator.appendString(styleNodeCloseTag(isBlock)); | 220 m_markupAccumulator.appendString(styleNodeCloseTag(isBlock)); |
| 219 } | 221 } |
| 220 | 222 |
| 221 template<typename Strategy> | 223 template<typename Strategy> |
| 222 String StyledMarkupSerializer<Strategy>::takeResults() | 224 String StyledMarkupSerializer<Strategy>::takeResults() |
| 223 { | 225 { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 lastClosed = parent; | 332 lastClosed = parent; |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 | 335 |
| 334 return lastClosed; | 336 return lastClosed; |
| 335 } | 337 } |
| 336 | 338 |
| 337 template class StyledMarkupSerializer<EditingStrategy>; | 339 template class StyledMarkupSerializer<EditingStrategy>; |
| 338 | 340 |
| 339 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |