 Chromium Code Reviews
 Chromium Code Reviews Issue 281383006:
  Navigation transitions: Added createStyledMarkupForNavigationTransition  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 281383006:
  Navigation transitions: Added createStyledMarkupForNavigationTransition  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/core/editing/markup.cpp | 
| diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp | 
| index 9236c00bd4d0044d5e09b0f7c3a6ce0e639699eb..bc3a96803faee0062febdcdf4fa301a04fe8db02 100644 | 
| --- a/Source/core/editing/markup.cpp | 
| +++ b/Source/core/editing/markup.cpp | 
| @@ -146,7 +146,7 @@ private: | 
| enum NodeTraversalMode { EmitString, DoNotEmitString }; | 
| Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTraversalMode); | 
| - bool shouldAnnotate() { return m_shouldAnnotate == AnnotateForInterchange; } | 
| + bool shouldAnnotate() const { return m_shouldAnnotate == AnnotateForInterchange || m_shouldAnnotate == AnnotateForNavigationTransition; } | 
| bool shouldApplyWrappingStyle(const Node& node) const | 
| { | 
| return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode() == node.parentNode() | 
| @@ -317,6 +317,9 @@ void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element | 
| if (shouldAnnotate()) | 
| newInlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)); | 
| + if (&element == m_highestNodeToBeSerialized && m_shouldAnnotate == AnnotateForNavigationTransition) | 
| 
esprehn
2014/06/26 09:32:55
You don't need the &
 
oystein (OOO til 10th of July)
2014/06/26 23:13:43
I do, m_highestNodeToBeSerialized is a RawPtrWillB
 | 
| + newInlineStyle->addAbsolutePositioningFromElement(element); | 
| + | 
| if (addDisplayInline) | 
| newInlineStyle->forceInline(); | 
| @@ -343,8 +346,12 @@ Node* StyledMarkupAccumulator::serializeNodes(Node* startNode, Node* pastEnd) | 
| m_highestNodeToBeSerialized = lastClosed; | 
| } | 
| - if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode()) | 
| + if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode()) { | 
| m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(m_highestNodeToBeSerialized->parentNode(), shouldAnnotate()); | 
| + if (m_shouldAnnotate == AnnotateForNavigationTransition) | 
| + m_wrappingStyle->style()->removeProperty(CSSPropertyBackground); | 
| 
esprehn
2014/06/26 09:32:55
This doesn't work, background is a shorthand so yo
 
oystein (OOO til 10th of July)
2014/06/26 23:13:43
Done.
 | 
| + } | 
| + | 
| return traverseNodesForSerialization(startNode, pastEnd, EmitString); | 
| } | 
| @@ -371,7 +378,7 @@ Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, No | 
| // Don't write out empty block containers that aren't fully selected. | 
| continue; | 
| - if (!n->renderer() && !enclosingNodeWithTag(firstPositionInOrBeforeNode(n), selectTag)) { | 
| + if (!n->renderer() && !enclosingNodeWithTag(firstPositionInOrBeforeNode(n), selectTag) && m_shouldAnnotate != AnnotateForNavigationTransition) { | 
| next = NodeTraversal::nextSkippingChildren(*n); | 
| // Don't skip over pastEnd. | 
| if (pastEnd && pastEnd->isDescendantOf(n)) | 
| @@ -1083,4 +1090,13 @@ void mergeWithNextTextNode(PassRefPtrWillBeRawPtr<Node> node, ExceptionState& ex | 
| textNext->remove(exceptionState); | 
| } | 
| +String createStyledMarkupForNavigationTransition(Node* node) | 
| +{ | 
| + StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigationTransition, nullptr, 0); | 
| + accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node)); | 
| + | 
| + static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\" content=\"width=device-width, user-scalable=0\">"; | 
| 
esprehn
2014/06/26 09:32:55
Why not use the meta viewport from the original do
 
oystein (OOO til 10th of July)
2014/06/26 23:13:43
The idea is that we'll enforce the whole navigatio
 | 
| + return documentMarkup + accumulator.takeResults(); | 
| +} | 
| + | 
| } |