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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameSerializer.cpp

Issue 2560693002: Disable form elements in MHTML (Closed)
Patch Set: Address feedback Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 class SerializerMarkupAccumulator : public MarkupAccumulator { 91 class SerializerMarkupAccumulator : public MarkupAccumulator {
92 STACK_ALLOCATED(); 92 STACK_ALLOCATED();
93 93
94 public: 94 public:
95 SerializerMarkupAccumulator(FrameSerializer::Delegate&, 95 SerializerMarkupAccumulator(FrameSerializer::Delegate&,
96 const Document&, 96 const Document&,
97 HeapVector<Member<Node>>&); 97 HeapVector<Member<Node>>&);
98 ~SerializerMarkupAccumulator() override; 98 ~SerializerMarkupAccumulator() override;
99 99
100 protected: 100 protected:
101 void appendCustomAttributes(StringBuilder&,
102 const Element&,
103 Namespaces*) override;
101 void appendText(StringBuilder& out, Text&) override; 104 void appendText(StringBuilder& out, Text&) override;
102 bool shouldIgnoreAttribute(const Element&, const Attribute&) override; 105 bool shouldIgnoreAttribute(const Element&, const Attribute&) override;
103 void appendElement(StringBuilder& out, Element&, Namespaces*) override; 106 void appendElement(StringBuilder& out, Element&, Namespaces*) override;
104 void appendAttribute(StringBuilder& out, 107 void appendAttribute(StringBuilder& out,
105 const Element&, 108 const Element&,
106 const Attribute&, 109 const Attribute&,
107 Namespaces*) override; 110 Namespaces*) override;
108 void appendStartTag(Node&, Namespaces* = nullptr) override; 111 void appendStartTag(Node&, Namespaces* = nullptr) override;
109 void appendEndTag(const Element&) override; 112 void appendEndTag(const Element&) override;
110 113
(...skipping 21 matching lines...) Expand all
132 FrameSerializer::Delegate& delegate, 135 FrameSerializer::Delegate& delegate,
133 const Document& document, 136 const Document& document,
134 HeapVector<Member<Node>>& nodes) 137 HeapVector<Member<Node>>& nodes)
135 : MarkupAccumulator(ResolveAllURLs), 138 : MarkupAccumulator(ResolveAllURLs),
136 m_delegate(delegate), 139 m_delegate(delegate),
137 m_document(&document), 140 m_document(&document),
138 m_nodes(nodes) {} 141 m_nodes(nodes) {}
139 142
140 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() {} 143 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() {}
141 144
145 void SerializerMarkupAccumulator::appendCustomAttributes(
146 StringBuilder& result,
147 const Element& element,
148 Namespaces* namespaces) {
149 Vector<Attribute> attributes = m_delegate.getCustomAttributes(element);
150 for (const auto& attribute : attributes)
151 appendAttribute(result, element, attribute, namespaces);
152 }
153
142 void SerializerMarkupAccumulator::appendText(StringBuilder& result, 154 void SerializerMarkupAccumulator::appendText(StringBuilder& result,
143 Text& text) { 155 Text& text) {
144 Element* parent = text.parentElement(); 156 Element* parent = text.parentElement();
145 if (parent && !shouldIgnoreElement(*parent)) 157 if (parent && !shouldIgnoreElement(*parent))
146 MarkupAccumulator::appendText(result, text); 158 MarkupAccumulator::appendText(result, text);
147 } 159 }
148 160
149 bool SerializerMarkupAccumulator::shouldIgnoreAttribute( 161 bool SerializerMarkupAccumulator::shouldIgnoreAttribute(
150 const Element& element, 162 const Element& element,
151 const Attribute& attribute) { 163 const Attribute& attribute) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 emitsMinus = ch == '-'; 570 emitsMinus = ch == '-';
559 builder.append(ch); 571 builder.append(ch);
560 } 572 }
561 CString escapedUrl = builder.toString().ascii(); 573 CString escapedUrl = builder.toString().ascii();
562 return String::format("saved from url=(%04d)%s", 574 return String::format("saved from url=(%04d)%s",
563 static_cast<int>(escapedUrl.length()), 575 static_cast<int>(escapedUrl.length()),
564 escapedUrl.data()); 576 escapedUrl.data());
565 } 577 }
566 578
567 } // namespace blink 579 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.h ('k') | third_party/WebKit/Source/web/WebFrameSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698