[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 14:34:58 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9ec4307049f2bb05694d23abcffbeba5627d3daf
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 13 18:12:42 2010 +0000

    2010-10-13  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Tony Chang.
    
            [Chromium] Clean up WebPageSerializerImpl::serialize
            https://bugs.webkit.org/show_bug.cgi?id=47577
    
            This patch shouldn't have any behavior change.  I'm just trying to
            understand what this code does.
    
            * src/WebPageSerializerImpl.cpp:
            (WebKit::WebPageSerializerImpl::saveHTMLContentToBuffer):
            (WebKit::WebPageSerializerImpl::encodeAndFlushBuffer):
            (WebKit::WebPageSerializerImpl::serialize):
            * src/WebPageSerializerImpl.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69675 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 44c8855..e56db06 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-13  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Tony Chang.
+
+        [Chromium] Clean up WebPageSerializerImpl::serialize
+        https://bugs.webkit.org/show_bug.cgi?id=47577
+
+        This patch shouldn't have any behavior change.  I'm just trying to
+        understand what this code does.
+
+        * src/WebPageSerializerImpl.cpp:
+        (WebKit::WebPageSerializerImpl::saveHTMLContentToBuffer):
+        (WebKit::WebPageSerializerImpl::encodeAndFlushBuffer):
+        (WebKit::WebPageSerializerImpl::serialize):
+        * src/WebPageSerializerImpl.h:
+
 2010-10-13  John Knottenbelt  <jknotten at chromium.org>
 
         Reviewed by Steve Block.
diff --git a/WebKit/chromium/src/WebPageSerializerImpl.cpp b/WebKit/chromium/src/WebPageSerializerImpl.cpp
index ced0821..7e7f27c 100644
--- a/WebKit/chromium/src/WebPageSerializerImpl.cpp
+++ b/WebKit/chromium/src/WebPageSerializerImpl.cpp
@@ -269,16 +269,16 @@ void WebPageSerializerImpl::saveHTMLContentToBuffer(
     m_dataBuffer.append(result);
     encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsNotFinished,
                          param,
-                         0);
+                         DoNotForceFlush);
 }
 
 void WebPageSerializerImpl::encodeAndFlushBuffer(
     WebPageSerializerClient::PageSerializationStatus status,
     SerializeDomParam* param,
-    bool force)
+    FlushOption flushOption)
 {
     // Data buffer is not full nor do we want to force flush.
-    if (!force && m_dataBuffer.size() <= dataBufferCapacity)
+    if (flushOption != ForceFlush && m_dataBuffer.size() <= dataBufferCapacity)
         return;
 
     String content = m_dataBuffer.toString();
@@ -489,55 +489,37 @@ void WebPageSerializerImpl::collectTargetFrames()
 
 bool WebPageSerializerImpl::serialize()
 {
-    // Collect target frames.
     if (!m_framesCollected)
         collectTargetFrames();
+
     bool didSerialization = false;
-    // Get KURL for main frame.
-    KURL mainPageURL = m_specifiedWebFrameImpl->frame()->loader()->url();
+    KURL mainURL = m_specifiedWebFrameImpl->frame()->document()->url();
 
-    // Go through all frames for serializing DOM for whole page, include
-    // sub-frames.
-    for (int i = 0; i < static_cast<int>(m_frames.size()); ++i) {
-        // Get current serializing frame.
-        WebFrameImpl* currentFrame = m_frames[i];
-        // Get current using document.
-        Document* currentDoc = currentFrame->frame()->document();
-        // Get current frame's URL.
-        const KURL& currentFrameURL = currentFrame->frame()->loader()->url();
-
-        // Check whether we have done this document.
-        if (currentFrameURL.isValid() && m_localLinks.contains(currentFrameURL.string())) {
-            // A new document, we will serialize it.
-            didSerialization = true;
-            // Get target encoding for current document.
-            String encoding = currentFrame->frame()->loader()->writer()->encoding();
-            // Create the text encoding object with target encoding.
-            TextEncoding textEncoding(encoding);
-            // Construct serialize parameter for late processing document.
-            SerializeDomParam param(currentFrameURL,
-                                    encoding.length() ? textEncoding : UTF8Encoding(),
-                                    currentDoc,
-                                    currentFrameURL == mainPageURL ? m_localDirectoryName : "");
-
-            // Process current document.
-            Element* rootElement = currentDoc->documentElement();
-            if (rootElement)
-                buildContentForNode(rootElement, &param);
-
-            // Flush the remainder data and finish serializing current frame.
-            encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished,
-                                 &param,
-                                 1);
-        }
+    for (unsigned i = 0; i < m_frames.size(); ++i) {
+        WebFrameImpl* webFrame = m_frames[i];
+        Document* document = webFrame->frame()->document();
+        const KURL& url = document->url();
+
+        if (!url.isValid() || !m_localLinks.contains(url.string()))
+            continue;
+
+        didSerialization = true;
+
+        String encoding = webFrame->frame()->loader()->writer()->encoding();
+        const TextEncoding& textEncoding = encoding.isEmpty() ? UTF8Encoding() : TextEncoding(encoding);
+        String directoryName = url == mainURL ? m_localDirectoryName : "";
+
+        SerializeDomParam param(url, textEncoding, document, directoryName);
+
+        Element* documentElement = document->documentElement();
+        if (documentElement)
+            buildContentForNode(documentElement, &param);
+
+        encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &param, ForceFlush);
     }
 
-    // We have done call frames, so we send message to embedder to tell it that
-    // frames are finished serializing.
     ASSERT(m_dataBuffer.isEmpty());
-    m_client->didSerializeDataForFrame(KURL(),
-                                       WebCString("", 0),
-                                       WebPageSerializerClient::AllFramesAreFinished);
+    m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSerializerClient::AllFramesAreFinished);
     return didSerialization;
 }
 
diff --git a/WebKit/chromium/src/WebPageSerializerImpl.h b/WebKit/chromium/src/WebPageSerializerImpl.h
index fe94b84..5ee8805 100644
--- a/WebKit/chromium/src/WebPageSerializerImpl.h
+++ b/WebKit/chromium/src/WebPageSerializerImpl.h
@@ -161,12 +161,18 @@ private:
     // Save generated html content to data buffer.
     void saveHTMLContentToBuffer(const WTF::String& content,
                                  SerializeDomParam* param);
+
+    enum FlushOption {
+        ForceFlush,
+        DoNotForceFlush,
+    };
+
     // Flushes the content buffer by encoding and sending the content to the
     // WebPageSerializerClient. Content is not flushed if the buffer is not full
     // unless force is 1.
     void encodeAndFlushBuffer(WebPageSerializerClient::PageSerializationStatus status,
                               SerializeDomParam* param,
-                              bool force);
+                              FlushOption);
     // Serialize open tag of an specified element.
     void openTagToString(const WebCore::Element* element,
                          SerializeDomParam* param);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list