| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 if (element->isURLAttribute(*it) && !it->value().isEmpty()) | 121 if (element->isURLAttribute(*it) && !it->value().isEmpty()) |
| 122 changes.append(AttributeChange(element, it->name(), KURL(parsedB
aseURL, it->value()).string())); | 122 changes.append(AttributeChange(element, it->name(), KURL(parsedB
aseURL, it->value()).string())); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 size_t numChanges = changes.size(); | 126 size_t numChanges = changes.size(); |
| 127 for (size_t i = 0; i < numChanges; ++i) | 127 for (size_t i = 0; i < numChanges; ++i) |
| 128 changes[i].apply(); | 128 changes[i].apply(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 class StyledMarkupAccumulator FINAL : public MarkupAccumulator { | 131 class StyledMarkupAccumulator final : public MarkupAccumulator { |
| 132 public: | 132 public: |
| 133 enum RangeFullySelectsNode { DoesFullySelectNode, DoesNotFullySelectNode }; | 133 enum RangeFullySelectsNode { DoesFullySelectNode, DoesNotFullySelectNode }; |
| 134 | 134 |
| 135 StyledMarkupAccumulator(WillBeHeapVector<RawPtrWillBeMember<Node> >* nodes,
EAbsoluteURLs, EAnnotateForInterchange, RawPtr<const Range>, Node* highestNodeTo
BeSerialized = 0); | 135 StyledMarkupAccumulator(WillBeHeapVector<RawPtrWillBeMember<Node> >* nodes,
EAbsoluteURLs, EAnnotateForInterchange, RawPtr<const Range>, Node* highestNodeTo
BeSerialized = 0); |
| 136 Node* serializeNodes(Node* startNode, Node* pastEnd); | 136 Node* serializeNodes(Node* startNode, Node* pastEnd); |
| 137 void appendString(const String& s) { return MarkupAccumulator::appendString(
s); } | 137 void appendString(const String& s) { return MarkupAccumulator::appendString(
s); } |
| 138 void wrapWithNode(ContainerNode&, bool convertBlocksToInlines = false, Range
FullySelectsNode = DoesFullySelectNode); | 138 void wrapWithNode(ContainerNode&, bool convertBlocksToInlines = false, Range
FullySelectsNode = DoesFullySelectNode); |
| 139 void wrapWithStyleNode(StylePropertySet*, const Document&, bool isBlock = fa
lse); | 139 void wrapWithStyleNode(StylePropertySet*, const Document&, bool isBlock = fa
lse); |
| 140 String takeResults(); | 140 String takeResults(); |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 void appendStyleNodeOpenTag(StringBuilder&, StylePropertySet*, const Documen
t&, bool isBlock = false); | 143 void appendStyleNodeOpenTag(StringBuilder&, StylePropertySet*, const Documen
t&, bool isBlock = false); |
| 144 const String& styleNodeCloseTag(bool isBlock = false); | 144 const String& styleNodeCloseTag(bool isBlock = false); |
| 145 virtual void appendText(StringBuilder& out, Text&) OVERRIDE; | 145 virtual void appendText(StringBuilder& out, Text&) override; |
| 146 String renderedText(Node&, const Range*); | 146 String renderedText(Node&, const Range*); |
| 147 String stringValueForRange(const Node&, const Range*); | 147 String stringValueForRange(const Node&, const Range*); |
| 148 void appendElement(StringBuilder& out, Element&, bool addDisplayInline, Rang
eFullySelectsNode); | 148 void appendElement(StringBuilder& out, Element&, bool addDisplayInline, Rang
eFullySelectsNode); |
| 149 virtual void appendElement(StringBuilder& out, Element& element, Namespaces*
) OVERRIDE { appendElement(out, element, false, DoesFullySelectNode); } | 149 virtual void appendElement(StringBuilder& out, Element& element, Namespaces*
) override { appendElement(out, element, false, DoesFullySelectNode); } |
| 150 | 150 |
| 151 enum NodeTraversalMode { EmitString, DoNotEmitString }; | 151 enum NodeTraversalMode { EmitString, DoNotEmitString }; |
| 152 Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTrav
ersalMode); | 152 Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTrav
ersalMode); |
| 153 | 153 |
| 154 bool shouldAnnotate() const { return m_shouldAnnotate == AnnotateForIntercha
nge || m_shouldAnnotate == AnnotateForNavigationTransition; } | 154 bool shouldAnnotate() const { return m_shouldAnnotate == AnnotateForIntercha
nge || m_shouldAnnotate == AnnotateForNavigationTransition; } |
| 155 bool shouldApplyWrappingStyle(const Node& node) const | 155 bool shouldApplyWrappingStyle(const Node& node) const |
| 156 { | 156 { |
| 157 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->paren
tNode() == node.parentNode() | 157 return m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->paren
tNode() == node.parentNode() |
| 158 && m_wrappingStyle && m_wrappingStyle->style(); | 158 && m_wrappingStyle && m_wrappingStyle->style(); |
| 159 } | 159 } |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 node->document().updateLayoutIgnorePendingStylesheets(); | 1089 node->document().updateLayoutIgnorePendingStylesheets(); |
| 1090 | 1090 |
| 1091 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); | 1091 StyledMarkupAccumulator accumulator(0, ResolveAllURLs, AnnotateForNavigation
Transition, nullptr, 0); |
| 1092 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; | 1092 accumulator.serializeNodes(node, NodeTraversal::nextSkippingChildren(*node))
; |
| 1093 | 1093 |
| 1094 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; | 1094 static const char* documentMarkup = "<!DOCTYPE html><meta name=\"viewport\"
content=\"width=device-width, user-scalable=0\">"; |
| 1095 return documentMarkup + accumulator.takeResults(); | 1095 return documentMarkup + accumulator.takeResults(); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 } | 1098 } |
| OLD | NEW |