2011-04-07 Magnus Danielsson <public@fuzzac.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 04:59:33 +0000 (04:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 04:59:33 +0000 (04:59 +0000)
        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: https://svn.webkit.org/repository/webkit/trunk@83252 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebPageSerializerImpl.cpp
Source/WebKit/chromium/src/WebPageSerializerImpl.h

index 7b94480..b4f9803 100644 (file)
@@ -1,3 +1,26 @@
+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>
 
         Reviewed by David Levin.
index 4b65b9e..280747f 100644 (file)
@@ -295,7 +295,7 @@ void WebPageSerializerImpl::encodeAndFlushBuffer(
                                        status);
 }
 
-void WebPageSerializerImpl::openTagToString(const Element* element,
+void WebPageSerializerImpl::openTagToString(Element* element,
                                             SerializeDomParam* param)
 {
     // FIXME: use StringBuilder instead of String.
@@ -328,11 +328,13 @@ void WebPageSerializerImpl::openTagToString(const Element* element,
                         result += attrValue;
                     else {
                         // 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.
                         if (m_localLinks.contains(completeURL)) {
-                            if (!m_localDirectoryName.isEmpty())
-                                result += "./" + m_localDirectoryName + "/";
+                            if (!param->directoryName.isEmpty())
+                                result += "./" + param->directoryName + "/";
                             result += m_localLinks.get(completeURL);
                         } else
                             result += completeURL;
@@ -360,7 +362,7 @@ void WebPageSerializerImpl::openTagToString(const Element* element,
 }
 
 // Serialize end tag of an specified element.
-void WebPageSerializerImpl::endTagToString(const Element* element,
+void WebPageSerializerImpl::endTagToString(Element* element,
                                            SerializeDomParam* param)
 {
     bool needSkip;
@@ -397,18 +399,18 @@ void WebPageSerializerImpl::endTagToString(const Element* element,
     saveHTMLContentToBuffer(result, param);
 }
 
-void WebPageSerializerImpl::buildContentForNode(const Node* node,
+void WebPageSerializerImpl::buildContentForNode(Node* node,
                                                 SerializeDomParam* param)
 {
     switch (node->nodeType()) {
     case Node::ELEMENT_NODE:
         // 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.
-        for (const Node *child = node->firstChild(); child; child = child->nextSibling())
+        for (Node *child = node->firstChild(); child; child = child->nextSibling())
             buildContentForNode(child, param);
         // Process end tag of element.
-        endTagToString(static_cast<const Element*>(node), param);
+        endTagToString(static_cast<Element*>(node), param);
         break;
     case Node::TEXT_NODE:
         saveHTMLContentToBuffer(createMarkup(node), param);
index 5ee8805..b53bd66 100644 (file)
@@ -174,13 +174,13 @@ private:
                               SerializeDomParam* param,
                               FlushOption);
     // Serialize open tag of an specified element.
-    void openTagToString(const WebCore::Element* element,
+    void openTagToString(WebCore::Element*,
                          SerializeDomParam* param);
     // Serialize end tag of an specified element.
-    void endTagToString(const WebCore::Element* element,
+    void endTagToString(WebCore::Element*,
                         SerializeDomParam* param);
     // Build content for a specified node
-    void buildContentForNode(const WebCore::Node* node,
+    void buildContentForNode(WebCore::Node*,
                              SerializeDomParam* param);
 };