diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-25 13:02:02 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-25 13:02:02 +0200 |
commit | 715be629d51174233403237bfc563cf150087dc8 (patch) | |
tree | 4cff72df808db977624338b0a38d8b6d1bd73c57 /Source/WebKit/chromium/src/WebPageSerializerImpl.cpp | |
parent | dc6262b587c71c14e30d93e57ed812e36a79a33e (diff) | |
download | qtwebkit-715be629d51174233403237bfc563cf150087dc8.tar.gz |
Imported WebKit commit ce614b0924ba46f78d4435e28ff93c8525fbb7cc (http://svn.webkit.org/repository/webkit/trunk@129485)
New snapshot that includes MingW build fixes
Diffstat (limited to 'Source/WebKit/chromium/src/WebPageSerializerImpl.cpp')
-rw-r--r-- | Source/WebKit/chromium/src/WebPageSerializerImpl.cpp | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp b/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp index 793ca8b83..02a665a11 100644 --- a/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp +++ b/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp @@ -75,8 +75,6 @@ // override the incorrect base URL and make sure we alway load correct local // saved resource files. -#define WTF_DEPRECATED_STRING_OPERATORS - #include "config.h" #include "WebPageSerializerImpl.h" @@ -300,23 +298,24 @@ void WebPageSerializerImpl::encodeAndFlushBuffer( void WebPageSerializerImpl::openTagToString(Element* element, SerializeDomParam* param) { - // FIXME: use StringBuilder instead of String. bool needSkip; + StringBuilder result; // Do pre action for open tag. - String result = preActionBeforeSerializeOpenTag(element, param, &needSkip); + result.append(preActionBeforeSerializeOpenTag(element, param, &needSkip)); if (needSkip) return; // Add open tag - result += "<" + element->nodeName().lower(); + result.append('<'); + result.append(element->nodeName().lower()); // Go through all attributes and serialize them. if (element->hasAttributes()) { unsigned numAttrs = element->attributeCount(); for (unsigned i = 0; i < numAttrs; i++) { - result += " "; + result.append(' '); // Add attribute pair const Attribute *attribute = element->attributeItem(i); - result += attribute->name().toString(); - result += "=\""; + result.append(attribute->name().toString()); + result.appendLiteral("=\""); if (!attribute->value().isEmpty()) { const String& attrValue = attribute->value(); @@ -326,7 +325,7 @@ void WebPageSerializerImpl::openTagToString(Element* element, if (elementHasLegalLinkAttribute(element, attrName)) { // For links start with "javascript:", we do not change it. if (attrValue.startsWith("javascript:", false)) - result += attrValue; + result.append(attrValue); else { // Get the absolute link WebFrameImpl* subFrame = WebFrameImpl::fromFrameOwnerElement(element); @@ -334,20 +333,23 @@ void WebPageSerializerImpl::openTagToString(Element* element, param->document->completeURL(attrValue); // Check whether we have local files for those link. if (m_localLinks.contains(completeURL)) { - if (!param->directoryName.isEmpty()) - result += "./" + param->directoryName + "/"; - result += m_localLinks.get(completeURL); + if (!param->directoryName.isEmpty()) { + result.appendLiteral("./"); + result.append(param->directoryName); + result.append('/'); + } + result.append(m_localLinks.get(completeURL)); } else - result += completeURL; + result.append(completeURL); } } else { if (param->isHTMLDocument) - result += m_htmlEntities.convertEntitiesInString(attrValue); + result.append(m_htmlEntities.convertEntitiesInString(attrValue)); else - result += m_xmlEntities.convertEntitiesInString(attrValue); + result.append(m_xmlEntities.convertEntitiesInString(attrValue)); } } - result += "\""; + result.append('\"'); } } @@ -355,11 +357,11 @@ void WebPageSerializerImpl::openTagToString(Element* element, String addedContents = postActionAfterSerializeOpenTag(element, param); // Complete the open tag for element when it has child/children. if (element->hasChildNodes() || param->haveAddedContentsBeforeEnd) - result += ">"; + result.append('>'); // Append the added contents generate in post action of open tag. - result += addedContents; + result.append(addedContents); // Save the result to data buffer. - saveHTMLContentToBuffer(result, param); + saveHTMLContentToBuffer(result.toString(), param); } // Serialize end tag of an specified element. @@ -367,37 +369,36 @@ void WebPageSerializerImpl::endTagToString(Element* element, SerializeDomParam* param) { bool needSkip; + StringBuilder result; // Do pre action for end tag. - String result = preActionBeforeSerializeEndTag(element, - param, - &needSkip); + result.append(preActionBeforeSerializeEndTag(element, param, &needSkip)); if (needSkip) return; // Write end tag when element has child/children. if (element->hasChildNodes() || param->haveAddedContentsBeforeEnd) { - result += "</"; - result += element->nodeName().lower(); - result += ">"; + result.appendLiteral("</"); + result.append(element->nodeName().lower()); + result.append('>'); } else { // Check whether we have to write end tag for empty element. if (param->isHTMLDocument) { - result += ">"; + result.append('>'); // FIXME: This code is horribly wrong. WebPageSerializerImpl must die. if (!static_cast<const HTMLElement*>(element)->ieForbidsInsertHTML()) { // We need to write end tag when it is required. - result += "</"; - result += element->nodeName().lower(); - result += ">"; + result.appendLiteral("</"); + result.append(element->nodeName().lower()); + result.append('>'); } } else { // For xml base document. - result += " />"; + result.appendLiteral(" />"); } } // Do post action for end tag. - result += postActionAfterSerializeEndTag(element, param); + result.append(postActionAfterSerializeEndTag(element, param)); // Save the result to data buffer. - saveHTMLContentToBuffer(result, param); + saveHTMLContentToBuffer(result.toString(), param); } void WebPageSerializerImpl::buildContentForNode(Node* node, |