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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 template<typename Strategy> | 234 template<typename Strategy> |
235 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
stEnd) | 235 Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
stEnd) |
236 { | 236 { |
237 if (!m_markupAccumulator.highestNodeToBeSerialized()) { | 237 if (!m_markupAccumulator.highestNodeToBeSerialized()) { |
238 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, DoN
otEmitString); | 238 Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, DoN
otEmitString); |
239 m_markupAccumulator.setHighestNodeToBeSerialized(lastClosed); | 239 m_markupAccumulator.setHighestNodeToBeSerialized(lastClosed); |
240 } | 240 } |
241 | 241 |
242 Node* highestNodeToBeSerialized = m_markupAccumulator.highestNodeToBeSeriali
zed(); | 242 Node* highestNodeToBeSerialized = m_markupAccumulator.highestNodeToBeSeriali
zed(); |
243 if (highestNodeToBeSerialized && Strategy::parent(*highestNodeToBeSerialized
)) { | 243 if (highestNodeToBeSerialized && Strategy::parent(*highestNodeToBeSerialized
)) { |
244 bool shouldAnnotate = m_shouldAnnotate == AnnotateForInterchange || m_sh
ouldAnnotate == AnnotateForNavigationTransition; | 244 bool shouldAnnotate = m_shouldAnnotate == AnnotateForInterchange; |
245 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::wrappingS
tyleForSerialization(Strategy::parent(*highestNodeToBeSerialized), shouldAnnotat
e); | 245 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::wrappingS
tyleForSerialization(Strategy::parent(*highestNodeToBeSerialized), shouldAnnotat
e); |
246 if (m_shouldAnnotate == AnnotateForNavigationTransition) { | |
247 wrappingStyle->style()->removeProperty(CSSPropertyBackgroundColor); | |
248 wrappingStyle->style()->removeProperty(CSSPropertyBackgroundImage); | |
249 } | |
250 m_markupAccumulator.setWrappingStyle(wrappingStyle.release()); | 246 m_markupAccumulator.setWrappingStyle(wrappingStyle.release()); |
251 } | 247 } |
252 return traverseNodesForSerialization(startNode, pastEnd, EmitString); | 248 return traverseNodesForSerialization(startNode, pastEnd, EmitString); |
253 } | 249 } |
254 | 250 |
255 template<typename Strategy> | 251 template<typename Strategy> |
256 Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
tNode, Node* pastEnd, NodeTraversalMode traversalMode) | 252 Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
tNode, Node* pastEnd, NodeTraversalMode traversalMode) |
257 { | 253 { |
258 const bool shouldEmit = traversalMode == EmitString; | 254 const bool shouldEmit = traversalMode == EmitString; |
259 WillBeHeapVector<RawPtrWillBeMember<ContainerNode>> ancestorsToClose; | 255 WillBeHeapVector<RawPtrWillBeMember<ContainerNode>> ancestorsToClose; |
260 Node* next; | 256 Node* next; |
261 Node* lastClosed = nullptr; | 257 Node* lastClosed = nullptr; |
262 for (Node* n = startNode; n != pastEnd; n = next) { | 258 for (Node* n = startNode; n != pastEnd; n = next) { |
263 // According to <rdar://problem/5730668>, it is possible for n to blow | 259 // According to <rdar://problem/5730668>, it is possible for n to blow |
264 // past pastEnd and become null here. This shouldn't be possible. | 260 // past pastEnd and become null here. This shouldn't be possible. |
265 // This null check will prevent crashes (but create too much markup) | 261 // This null check will prevent crashes (but create too much markup) |
266 // and the ASSERT will hopefully lead us to understanding the problem. | 262 // and the ASSERT will hopefully lead us to understanding the problem. |
267 ASSERT(n); | 263 ASSERT(n); |
268 if (!n) | 264 if (!n) |
269 break; | 265 break; |
270 | 266 |
271 next = Strategy::next(*n); | 267 next = Strategy::next(*n); |
272 bool openedTag = false; | 268 bool openedTag = false; |
273 | 269 |
274 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) { | 270 if (isBlock(n) && canHaveChildrenForEditing(n) && next == pastEnd) { |
275 // Don't write out empty block containers that aren't fully selected
. | 271 // Don't write out empty block containers that aren't fully selected
. |
276 continue; | 272 continue; |
277 } | 273 } |
278 | 274 |
279 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOrBefo
reNode(n), selectTag) && m_shouldAnnotate != AnnotateForNavigationTransition) { | 275 if (!n->layoutObject() && !enclosingElementWithTag(firstPositionInOrBefo
reNode(n), selectTag)) { |
280 next = Strategy::nextSkippingChildren(*n); | 276 next = Strategy::nextSkippingChildren(*n); |
281 // Don't skip over pastEnd. | 277 // Don't skip over pastEnd. |
282 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) | 278 if (pastEnd && Strategy::isDescendantOf(*pastEnd, *n)) |
283 next = pastEnd; | 279 next = pastEnd; |
284 } else { | 280 } else { |
285 // Add the node to the markup if we're not skipping the descendants | 281 // Add the node to the markup if we're not skipping the descendants |
286 if (shouldEmit) | 282 if (shouldEmit) |
287 m_markupAccumulator.appendStartTag(*n); | 283 m_markupAccumulator.appendStartTag(*n); |
288 | 284 |
289 // If node has no children, close the tag now. | 285 // If node has no children, close the tag now. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 328 } |
333 } | 329 } |
334 } | 330 } |
335 | 331 |
336 return lastClosed; | 332 return lastClosed; |
337 } | 333 } |
338 | 334 |
339 template class StyledMarkupSerializer<EditingStrategy>; | 335 template class StyledMarkupSerializer<EditingStrategy>; |
340 | 336 |
341 } // namespace blink | 337 } // namespace blink |
OLD | NEW |