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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 const String& styleNodeCloseTag(bool isBlock = false); | 129 const String& styleNodeCloseTag(bool isBlock = false); |
130 virtual void appendText(StringBuilder& out, Text&) OVERRIDE; | 130 virtual void appendText(StringBuilder& out, Text&) OVERRIDE; |
131 String renderedText(Node&, const Range*); | 131 String renderedText(Node&, const Range*); |
132 String stringValueForRange(const Node&, const Range*); | 132 String stringValueForRange(const Node&, const Range*); |
133 void appendElement(StringBuilder& out, Element&, bool addDisplayInline, Rang eFullySelectsNode); | 133 void appendElement(StringBuilder& out, Element&, bool addDisplayInline, Rang eFullySelectsNode); |
134 virtual void appendElement(StringBuilder& out, Element& element, Namespaces* ) OVERRIDE { appendElement(out, element, false, DoesFullySelectNode); } | 134 virtual void appendElement(StringBuilder& out, Element& element, Namespaces* ) OVERRIDE { appendElement(out, element, false, DoesFullySelectNode); } |
135 | 135 |
136 enum NodeTraversalMode { EmitString, DoNotEmitString }; | 136 enum NodeTraversalMode { EmitString, DoNotEmitString }; |
137 Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTrav ersalMode); | 137 Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTrav ersalMode); |
138 | 138 |
139 bool shouldAnnotate() { return m_shouldAnnotate == AnnotateForInterchange; } | 139 bool shouldAnnotate() const { return m_shouldAnnotate == AnnotateForIntercha nge || m_shouldAnnotate == AnnotateForNavigationTransition; } |
140 bool shouldApplyWrappingStyle(const Node& node) const | 140 bool shouldApplyWrappingStyle(const Node& node) const |
141 { | 141 { |
142 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->paren tNode() == node.parentNode() | 142 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->paren tNode() == node.parentNode() |
143 && m_wrappingStyle && m_wrappingStyle->style(); | 143 && m_wrappingStyle && m_wrappingStyle->style(); |
144 } | 144 } |
145 | 145 |
146 Vector<String> m_reversedPrecedingMarkup; | 146 Vector<String> m_reversedPrecedingMarkup; |
147 const EAnnotateForInterchange m_shouldAnnotate; | 147 const EAnnotateForInterchange m_shouldAnnotate; |
148 Node* m_highestNodeToBeSerialized; | 148 Node* m_highestNodeToBeSerialized; |
149 RefPtr<EditingStyle> m_wrappingStyle; | 149 RefPtr<EditingStyle> m_wrappingStyle; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 } else | 298 } else |
299 newInlineStyle = EditingStyle::create(); | 299 newInlineStyle = EditingStyle::create(); |
300 | 300 |
301 if (element.isStyledElement() && element.inlineStyle()) | 301 if (element.isStyledElement() && element.inlineStyle()) |
302 newInlineStyle->overrideWithStyle(element.inlineStyle()); | 302 newInlineStyle->overrideWithStyle(element.inlineStyle()); |
303 | 303 |
304 if (shouldAnnotateOrForceInline) { | 304 if (shouldAnnotateOrForceInline) { |
305 if (shouldAnnotate()) | 305 if (shouldAnnotate()) |
306 newInlineStyle->mergeStyleFromRulesForSerialization(&toHTMLEleme nt(element)); | 306 newInlineStyle->mergeStyleFromRulesForSerialization(&toHTMLEleme nt(element)); |
307 | 307 |
308 if (&element == m_highestNodeToBeSerialized && m_shouldAnnotate == A nnotateForNavigationTransition) | |
yosin_UTC9
2014/05/29 03:58:52
nit: You don't need |&| for |element|. |Node| has
oystein (OOO til 10th of July)
2014/05/29 18:26:49
Done.
| |
309 newInlineStyle->addAbsolutePositioningFromElement(&element); | |
310 | |
308 if (addDisplayInline) | 311 if (addDisplayInline) |
309 newInlineStyle->forceInline(); | 312 newInlineStyle->forceInline(); |
310 | 313 |
311 // If the node is not fully selected by the range, then we don't wan t to keep styles that affect its relationship to the nodes around it | 314 // If the node is not fully selected by the range, then we don't wan t to keep styles that affect its relationship to the nodes around it |
312 // only the ones that affect it and the nodes within it. | 315 // only the ones that affect it and the nodes within it. |
313 if (rangeFullySelectsNode == DoesNotFullySelectNode && newInlineStyl e->style()) | 316 if (rangeFullySelectsNode == DoesNotFullySelectNode && newInlineStyl e->style()) |
314 newInlineStyle->style()->removeProperty(CSSPropertyFloat); | 317 newInlineStyle->style()->removeProperty(CSSPropertyFloat); |
315 } | 318 } |
316 | 319 |
317 if (!newInlineStyle->isEmpty()) { | 320 if (!newInlineStyle->isEmpty()) { |
318 out.appendLiteral(" style=\""); | 321 out.appendLiteral(" style=\""); |
319 appendAttributeValue(out, newInlineStyle->style()->asText(), documen tIsHTML); | 322 appendAttributeValue(out, newInlineStyle->style()->asText(), documen tIsHTML); |
320 out.append('\"'); | 323 out.append('\"'); |
321 } | 324 } |
322 } | 325 } |
323 | 326 |
324 appendCloseTag(out, element); | 327 appendCloseTag(out, element); |
325 } | 328 } |
326 | 329 |
327 Node* StyledMarkupAccumulator::serializeNodes(Node* startNode, Node* pastEnd) | 330 Node* StyledMarkupAccumulator::serializeNodes(Node* startNode, Node* pastEnd) |
328 { | 331 { |
329 if (!m_highestNodeToBeSerialized) { | 332 if (!m_highestNodeToBeSerialized) { |
330 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, DoN otEmitString); | 333 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, DoN otEmitString); |
331 m_highestNodeToBeSerialized = lastClosed; | 334 m_highestNodeToBeSerialized = lastClosed; |
332 } | 335 } |
333 | 336 |
334 if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode() ) | 337 if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode() ) { |
335 m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(m_highestN odeToBeSerialized->parentNode(), shouldAnnotate()); | 338 m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(m_highestN odeToBeSerialized->parentNode(), shouldAnnotate()); |
339 if (m_shouldAnnotate == AnnotateForNavigationTransition) | |
340 m_wrappingStyle->style()->removeProperty(CSSPropertyBackground); | |
esprehn
2014/05/22 18:29:06
Huh?
| |
341 } | |
342 | |
336 | 343 |
337 return traverseNodesForSerialization(startNode, pastEnd, EmitString); | 344 return traverseNodesForSerialization(startNode, pastEnd, EmitString); |
338 } | 345 } |
339 | 346 |
340 Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, No de* pastEnd, NodeTraversalMode traversalMode) | 347 Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, No de* pastEnd, NodeTraversalMode traversalMode) |
341 { | 348 { |
342 const bool shouldEmit = traversalMode == EmitString; | 349 const bool shouldEmit = traversalMode == EmitString; |
343 Vector<Node*> ancestorsToClose; | 350 Vector<Node*> ancestorsToClose; |
344 Node* next; | 351 Node* next; |
345 Node* lastClosed = 0; | 352 Node* lastClosed = 0; |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 if (!next || !next->isTextNode()) | 1071 if (!next || !next->isTextNode()) |
1065 return; | 1072 return; |
1066 | 1073 |
1067 RefPtrWillBeRawPtr<Text> textNode = toText(node.get()); | 1074 RefPtrWillBeRawPtr<Text> textNode = toText(node.get()); |
1068 RefPtrWillBeRawPtr<Text> textNext = toText(next); | 1075 RefPtrWillBeRawPtr<Text> textNext = toText(next); |
1069 textNode->appendData(textNext->data()); | 1076 textNode->appendData(textNext->data()); |
1070 if (textNext->parentNode()) // Might have been removed by mutation event. | 1077 if (textNext->parentNode()) // Might have been removed by mutation event. |
1071 textNext->remove(exceptionState); | 1078 textNext->remove(exceptionState); |
1072 } | 1079 } |
1073 | 1080 |
1081 String createStyledMarkupForNavigationTransition(Node* node) | |
1082 { | |
1083 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation Transition, 0, 0); | |
1084 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node)) ; | |
esprehn
2014/05/22 18:29:06
This code doesn't make sense, why are you going to
| |
1085 | |
1086 return accumulator.takeResults(); | |
1074 } | 1087 } |
1088 | |
1089 } | |
OLD | NEW |