void WebPageSerializerImpl::saveHTMLContentToBuffer( const String& result, SerializeDomParam* param) { m_dataBuffer.append(result); encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsNotFinished, param, DoNotForceFlush); }
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(); // 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, ¶m); // Flush the remainder data and finish serializing current frame. encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, ¶m, 1); } } // 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); return didSerialization; }