Index: third_party/WebKit/Source/web/WebFrameSerializerImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp b/third_party/WebKit/Source/web/WebFrameSerializerImpl.cpp |
similarity index 88% |
rename from third_party/WebKit/Source/web/WebPageSerializerImpl.cpp |
rename to third_party/WebKit/Source/web/WebFrameSerializerImpl.cpp |
index 545f3a00256b4cd7bfba84bc182dfab911344680..ce5e7a31899349568117760b1c72dd5271b993b8 100644 |
--- a/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp |
+++ b/third_party/WebKit/Source/web/WebFrameSerializerImpl.cpp |
@@ -75,13 +75,14 @@ |
// override the incorrect base URL and make sure we alway load correct local |
// saved resource files. |
-#include "web/WebPageSerializerImpl.h" |
+#include "web/WebFrameSerializerImpl.h" |
#include "core/HTMLNames.h" |
#include "core/dom/Document.h" |
#include "core/dom/DocumentType.h" |
#include "core/dom/Element.h" |
#include "core/editing/serializers/Serialization.h" |
+#include "core/frame/FrameSerializer.h" |
#include "core/html/HTMLAllCollection.h" |
#include "core/html/HTMLElement.h" |
#include "core/html/HTMLFormElement.h" |
@@ -89,7 +90,6 @@ |
#include "core/html/HTMLMetaElement.h" |
#include "core/loader/DocumentLoader.h" |
#include "core/loader/FrameLoader.h" |
-#include "core/page/PageSerializer.h" |
#include "public/platform/WebVector.h" |
#include "web/WebLocalFrameImpl.h" |
#include "wtf/text/TextEncoding.h" |
@@ -98,12 +98,13 @@ namespace blink { |
// Maximum length of data buffer which is used to temporary save generated |
// html content data. This is a soft limit which might be passed if a very large |
-// contegious string is found in the page. |
+// contegious string is found in the html document. |
static const unsigned dataBufferCapacity = 65536; |
-WebPageSerializerImpl::SerializeDomParam::SerializeDomParam(const KURL& url, |
- const WTF::TextEncoding& textEncoding, |
- Document* document) |
+WebFrameSerializerImpl::SerializeDomParam::SerializeDomParam( |
+ const KURL& url, |
+ const WTF::TextEncoding& textEncoding, |
+ Document* document) |
: url(url) |
, textEncoding(textEncoding) |
, document(document) |
@@ -117,7 +118,7 @@ WebPageSerializerImpl::SerializeDomParam::SerializeDomParam(const KURL& url, |
{ |
} |
-String WebPageSerializerImpl::preActionBeforeSerializeOpenTag( |
+String WebFrameSerializerImpl::preActionBeforeSerializeOpenTag( |
const Element* element, SerializeDomParam* param, bool* needSkip) |
{ |
StringBuilder result; |
@@ -143,7 +144,7 @@ String WebPageSerializerImpl::preActionBeforeSerializeOpenTag( |
// Add MOTW declaration before html tag. |
// See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. |
- result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(param->url)); |
+ result.append(WebFrameSerializer::generateMarkOfTheWebDeclaration(param->url)); |
} else if (isHTMLBaseElement(*element)) { |
// Comment the BASE tag when serializing dom. |
result.appendLiteral("<!--"); |
@@ -175,7 +176,7 @@ String WebPageSerializerImpl::preActionBeforeSerializeOpenTag( |
return result.toString(); |
} |
-String WebPageSerializerImpl::postActionAfterSerializeOpenTag( |
+String WebFrameSerializerImpl::postActionAfterSerializeOpenTag( |
const Element* element, SerializeDomParam* param) |
{ |
StringBuilder result; |
@@ -187,14 +188,14 @@ String WebPageSerializerImpl::postActionAfterSerializeOpenTag( |
if (!param->haveAddedCharsetDeclaration |
&& isHTMLHeadElement(*element)) { |
param->haveAddedCharsetDeclaration = true; |
- // Check meta element. WebKit only pre-parse the first 512 bytes |
- // of the document. If the whole <HEAD> is larger and meta is the |
- // end of head part, then this kind of pages aren't decoded correctly |
- // because of this issue. So when we serialize the DOM, we need to |
- // make sure the meta will in first child of head tag. |
+ // Check meta element. WebKit only pre-parse the first 512 bytes of the |
+ // document. If the whole <HEAD> is larger and meta is the end of head |
+ // part, then this kind of html documents aren't decoded correctly |
+ // because of this issue. So when we serialize the DOM, we need to make |
+ // sure the meta will in first child of head tag. |
// See http://bugs.webkit.org/show_bug.cgi?id=16621. |
// First we generate new content for writing correct META element. |
- result.append(WebPageSerializer::generateMetaCharsetDeclaration( |
+ result.append(WebFrameSerializer::generateMetaCharsetDeclaration( |
String(param->textEncoding.name()))); |
param->haveAddedContentsBeforeEnd = true; |
@@ -207,7 +208,7 @@ String WebPageSerializerImpl::postActionAfterSerializeOpenTag( |
return result.toString(); |
} |
-String WebPageSerializerImpl::preActionBeforeSerializeEndTag( |
+String WebFrameSerializerImpl::preActionBeforeSerializeEndTag( |
const Element* element, SerializeDomParam* param, bool* needSkip) |
{ |
String result; |
@@ -230,7 +231,7 @@ String WebPageSerializerImpl::preActionBeforeSerializeEndTag( |
// After we finish serializing end tag of a element, we give the target |
// element a chance to do some post work to add some additional data. |
-String WebPageSerializerImpl::postActionAfterSerializeEndTag( |
+String WebFrameSerializerImpl::postActionAfterSerializeEndTag( |
const Element* element, SerializeDomParam* param) |
{ |
StringBuilder result; |
@@ -241,24 +242,25 @@ String WebPageSerializerImpl::postActionAfterSerializeEndTag( |
if (isHTMLBaseElement(*element)) { |
result.appendLiteral("-->"); |
// Append a new base tag declaration. |
- result.append(WebPageSerializer::generateBaseTagDeclaration( |
+ result.append(WebFrameSerializer::generateBaseTagDeclaration( |
param->document->baseTarget())); |
} |
return result.toString(); |
} |
-void WebPageSerializerImpl::saveHTMLContentToBuffer( |
+void WebFrameSerializerImpl::saveHTMLContentToBuffer( |
const String& result, SerializeDomParam* param) |
{ |
m_dataBuffer.append(result); |
- encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsNotFinished, |
- param, |
- DoNotForceFlush); |
+ encodeAndFlushBuffer( |
+ WebFrameSerializerClient::CurrentFrameIsNotFinished, |
+ param, |
+ DoNotForceFlush); |
} |
-void WebPageSerializerImpl::encodeAndFlushBuffer( |
- WebPageSerializerClient::PageSerializationStatus status, |
+void WebFrameSerializerImpl::encodeAndFlushBuffer( |
+ WebFrameSerializerClient::FrameSerializationStatus status, |
SerializeDomParam* param, |
FlushOption flushOption) |
{ |
@@ -278,8 +280,9 @@ void WebPageSerializerImpl::encodeAndFlushBuffer( |
// TODO(yosin): We should utilize |MarkupFormatter| here to share code, |
// especially escaping attribute values, done by |WebEntities| |m_htmlEntities| |
// and |m_xmlEntities|. |
-void WebPageSerializerImpl::openTagToString(Element* element, |
- SerializeDomParam* param) |
+void WebFrameSerializerImpl::openTagToString( |
+ Element* element, |
+ SerializeDomParam* param) |
{ |
bool needSkip; |
StringBuilder result; |
@@ -340,8 +343,9 @@ void WebPageSerializerImpl::openTagToString(Element* element, |
} |
// Serialize end tag of an specified element. |
-void WebPageSerializerImpl::endTagToString(Element* element, |
- SerializeDomParam* param) |
+void WebFrameSerializerImpl::endTagToString( |
+ Element* element, |
+ SerializeDomParam* param) |
{ |
bool needSkip; |
StringBuilder result; |
@@ -358,7 +362,7 @@ void WebPageSerializerImpl::endTagToString(Element* element, |
// Check whether we have to write end tag for empty element. |
if (param->isHTMLDocument) { |
result.append('>'); |
- // FIXME: This code is horribly wrong. WebPageSerializerImpl must die. |
+ // FIXME: This code is horribly wrong. WebFrameSerializerImpl must die. |
if (!element->isHTMLElement() || !toHTMLElement(element)->ieForbidsInsertHTML()) { |
// We need to write end tag when it is required. |
result.appendLiteral("</"); |
@@ -376,8 +380,9 @@ void WebPageSerializerImpl::endTagToString(Element* element, |
saveHTMLContentToBuffer(result.toString(), param); |
} |
-void WebPageSerializerImpl::buildContentForNode(Node* node, |
- SerializeDomParam* param) |
+void WebFrameSerializerImpl::buildContentForNode( |
+ Node* node, |
+ SerializeDomParam* param) |
{ |
switch (node->nodeType()) { |
case Node::ELEMENT_NODE: |
@@ -408,9 +413,9 @@ void WebPageSerializerImpl::buildContentForNode(Node* node, |
} |
} |
-WebPageSerializerImpl::WebPageSerializerImpl( |
+WebFrameSerializerImpl::WebFrameSerializerImpl( |
WebLocalFrame* frame, |
- WebPageSerializerClient* client, |
+ WebFrameSerializerClient* client, |
const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths) |
: m_client(client) |
, m_htmlEntities(false) |
@@ -431,7 +436,7 @@ WebPageSerializerImpl::WebPageSerializerImpl( |
ASSERT(m_dataBuffer.isEmpty()); |
} |
-bool WebPageSerializerImpl::serialize() |
+bool WebFrameSerializerImpl::serialize() |
{ |
bool didSerialization = false; |
@@ -453,15 +458,15 @@ bool WebPageSerializerImpl::serialize() |
if (documentElement) |
buildContentForNode(documentElement, ¶m); |
- encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, ¶m, ForceFlush); |
+ encodeAndFlushBuffer(WebFrameSerializerClient::CurrentFrameIsFinished, ¶m, ForceFlush); |
} else { |
// Report empty contents for invalid URLs. |
m_client->didSerializeDataForFrame( |
- WebCString(), WebPageSerializerClient::CurrentFrameIsFinished); |
+ WebCString(), WebFrameSerializerClient::CurrentFrameIsFinished); |
} |
ASSERT(m_dataBuffer.isEmpty()); |
return didSerialization; |
} |
-} // namespace blink |
+} // namespace blink |