2011-04-07 Magnus Danielsson <public@fuzzac.com>

        Reviewed by Darin Fisher.

        [chromium] WebPageSerializerImpl doesn't serialize sub-frames correctly
        https://bugs.webkit.org/show_bug.cgi?id=53897

        When serializing a web page using 'save page as', sub-frames and resources gets
        saved in a sub-directory. However, frame elements didn't get updated to reference
        these saved sub-frames, but were still referencing the original url. So when opening
        a saved web page, any sub-frames would get pulled in from the original url rather than
        what was saved.

        In addition to this, sub-frames in the sub-directory erroneously had the name of the
        sub-directory prepended to the path of resources located in the same sub-directory.

        * src/WebPageSerializerImpl.cpp:
        (WebKit::WebPageSerializerImpl::openTagToStrne: Fixed resource paths in sub-frames.
        Also made sure sub-frames are referenced correctly from parent frame.
        (WebKit::WebPageSerializerImpl::endTagToString): Removed constness from argument.
        (WebKit::WebPageSerializerImpl::buildContentForNode): Ditto.
        * src/WebPageSerializerImpl.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@83252 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent a430ef05
2011-04-07 Magnus Danielsson <public@fuzzac.com>
Reviewed by Darin Fisher.
[chromium] WebPageSerializerImpl doesn't serialize sub-frames correctly
https://bugs.webkit.org/show_bug.cgi?id=53897
When serializing a web page using 'save page as', sub-frames and resources gets
saved in a sub-directory. However, frame elements didn't get updated to reference
these saved sub-frames, but were still referencing the original url. So when opening
a saved web page, any sub-frames would get pulled in from the original url rather than
what was saved.
In addition to this, sub-frames in the sub-directory erroneously had the name of the
sub-directory prepended to the path of resources located in the same sub-directory.
* src/WebPageSerializerImpl.cpp:
(WebKit::WebPageSerializerImpl::openTagToStrne: Fixed resource paths in sub-frames.
Also made sure sub-frames are referenced correctly from parent frame.
(WebKit::WebPageSerializerImpl::endTagToString): Removed constness from argument.
(WebKit::WebPageSerializerImpl::buildContentForNode): Ditto.
* src/WebPageSerializerImpl.h:
2011-04-07 Nat Duca <nduca@chromium.org> 2011-04-07 Nat Duca <nduca@chromium.org>
Reviewed by David Levin. Reviewed by David Levin.
......
...@@ -295,7 +295,7 @@ void WebPageSerializerImpl::encodeAndFlushBuffer( ...@@ -295,7 +295,7 @@ void WebPageSerializerImpl::encodeAndFlushBuffer(
status); status);
} }
void WebPageSerializerImpl::openTagToString(const Element* element, void WebPageSerializerImpl::openTagToString(Element* element,
SerializeDomParam* param) SerializeDomParam* param)
{ {
// FIXME: use StringBuilder instead of String. // FIXME: use StringBuilder instead of String.
...@@ -328,11 +328,13 @@ void WebPageSerializerImpl::openTagToString(const Element* element, ...@@ -328,11 +328,13 @@ void WebPageSerializerImpl::openTagToString(const Element* element,
result += attrValue; result += attrValue;
else { else {
// Get the absolute link // Get the absolute link
String completeURL = param->document->completeURL(attrValue); WebFrameImpl* subFrame = WebFrameImpl::fromFrameOwnerElement(element);
String completeURL = subFrame ? subFrame->frame()->document()->url() :
param->document->completeURL(attrValue);
// Check whether we have local files for those link. // Check whether we have local files for those link.
if (m_localLinks.contains(completeURL)) { if (m_localLinks.contains(completeURL)) {
if (!m_localDirectoryName.isEmpty()) if (!param->directoryName.isEmpty())
result += "./" + m_localDirectoryName + "/"; result += "./" + param->directoryName + "/";
result += m_localLinks.get(completeURL); result += m_localLinks.get(completeURL);
} else } else
result += completeURL; result += completeURL;
...@@ -360,7 +362,7 @@ void WebPageSerializerImpl::openTagToString(const Element* element, ...@@ -360,7 +362,7 @@ void WebPageSerializerImpl::openTagToString(const Element* element,
} }
// Serialize end tag of an specified element. // Serialize end tag of an specified element.
void WebPageSerializerImpl::endTagToString(const Element* element, void WebPageSerializerImpl::endTagToString(Element* element,
SerializeDomParam* param) SerializeDomParam* param)
{ {
bool needSkip; bool needSkip;
...@@ -397,18 +399,18 @@ void WebPageSerializerImpl::endTagToString(const Element* element, ...@@ -397,18 +399,18 @@ void WebPageSerializerImpl::endTagToString(const Element* element,
saveHTMLContentToBuffer(result, param); saveHTMLContentToBuffer(result, param);
} }
void WebPageSerializerImpl::buildContentForNode(const Node* node, void WebPageSerializerImpl::buildContentForNode(Node* node,
SerializeDomParam* param) SerializeDomParam* param)
{ {
switch (node->nodeType()) { switch (node->nodeType()) {
case Node::ELEMENT_NODE: case Node::ELEMENT_NODE:
// Process open tag of element. // Process open tag of element.
openTagToString(static_cast<const Element*>(node), param); openTagToString(static_cast<Element*>(node), param);
// Walk through the children nodes and process it. // Walk through the children nodes and process it.
for (const Node *child = node->firstChild(); child; child = child->nextSibling()) for (Node *child = node->firstChild(); child; child = child->nextSibling())
buildContentForNode(child, param); buildContentForNode(child, param);
// Process end tag of element. // Process end tag of element.
endTagToString(static_cast<const Element*>(node), param); endTagToString(static_cast<Element*>(node), param);
break; break;
case Node::TEXT_NODE: case Node::TEXT_NODE:
saveHTMLContentToBuffer(createMarkup(node), param); saveHTMLContentToBuffer(createMarkup(node), param);
......
...@@ -174,13 +174,13 @@ private: ...@@ -174,13 +174,13 @@ private:
SerializeDomParam* param, SerializeDomParam* param,
FlushOption); FlushOption);
// Serialize open tag of an specified element. // Serialize open tag of an specified element.
void openTagToString(const WebCore::Element* element, void openTagToString(WebCore::Element*,
SerializeDomParam* param); SerializeDomParam* param);
// Serialize end tag of an specified element. // Serialize end tag of an specified element.
void endTagToString(const WebCore::Element* element, void endTagToString(WebCore::Element*,
SerializeDomParam* param); SerializeDomParam* param);
// Build content for a specified node // Build content for a specified node
void buildContentForNode(const WebCore::Node* node, void buildContentForNode(WebCore::Node*,
SerializeDomParam* param); SerializeDomParam* param);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment