Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Unified Diff: Source/core/editing/markup.cpp

Issue 281383006: Navigation transitions: Added createStyledMarkupForNavigationTransition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review fixes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/editing/markup.cpp
diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp
index c0591bf59aac0ab0ea692a30b036b6202e5bcfa7..7ac30589bdcacdc986fb6d129b06116b293bb40e 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)
+ newInlineStyle->addAbsolutePositioningFromElement(element);
+
if (addDisplayInline)
newInlineStyle->forceInline();
@@ -343,8 +346,14 @@ 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(CSSPropertyBackgroundColor);
+ m_wrappingStyle->style()->removeProperty(CSSPropertyBackgroundImage);
+ }
+ }
+
return traverseNodesForSerialization(startNode, pastEnd, EmitString);
}
@@ -371,7 +380,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))
@@ -1095,4 +1104,13 @@ void mergeWithNextTextNode(PassRefPtrWillBeRawPtr<Node> node, ExceptionState& ex
textNext->remove(exceptionState);
}
+String createStyledMarkupForNavigationTransition(Node* node)
+{
+ StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigationTransition, nullptr, 0);
esprehn 2014/07/14 22:04:31 What updates the style of the page before you get
oystein (OOO til 10th of July) 2014/07/14 22:44:57 Not sure what you're asking here, exactly. If ther
+ accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node));
+
+ static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\" content=\"width=device-width, user-scalable=0\">";
+ return documentMarkup + accumulator.takeResults();
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698