Changeset 69675 in webkit
- Timestamp:
- Oct 13, 2010 11:12:42 AM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r69673 r69675 1 2010-10-13 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Tony Chang. 4 5 [Chromium] Clean up WebPageSerializerImpl::serialize 6 https://bugs.webkit.org/show_bug.cgi?id=47577 7 8 This patch shouldn't have any behavior change. I'm just trying to 9 understand what this code does. 10 11 * src/WebPageSerializerImpl.cpp: 12 (WebKit::WebPageSerializerImpl::saveHTMLContentToBuffer): 13 (WebKit::WebPageSerializerImpl::encodeAndFlushBuffer): 14 (WebKit::WebPageSerializerImpl::serialize): 15 * src/WebPageSerializerImpl.h: 16 1 17 2010-10-13 John Knottenbelt <jknotten@chromium.org> 2 18 -
trunk/WebKit/chromium/src/WebPageSerializerImpl.cpp
r69668 r69675 270 270 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsNotFinished, 271 271 param, 272 0);272 DoNotForceFlush); 273 273 } 274 274 … … 276 276 WebPageSerializerClient::PageSerializationStatus status, 277 277 SerializeDomParam* param, 278 bool force)278 FlushOption flushOption) 279 279 { 280 280 // Data buffer is not full nor do we want to force flush. 281 if ( !force&& m_dataBuffer.size() <= dataBufferCapacity)281 if (flushOption != ForceFlush && m_dataBuffer.size() <= dataBufferCapacity) 282 282 return; 283 283 … … 490 490 bool WebPageSerializerImpl::serialize() 491 491 { 492 // Collect target frames.493 492 if (!m_framesCollected) 494 493 collectTargetFrames(); 494 495 495 bool didSerialization = false; 496 // Get KURL for main frame. 497 KURL mainPageURL = m_specifiedWebFrameImpl->frame()->loader()->url(); 498 499 // Go through all frames for serializing DOM for whole page, include 500 // sub-frames. 501 for (int i = 0; i < static_cast<int>(m_frames.size()); ++i) { 502 // Get current serializing frame. 503 WebFrameImpl* currentFrame = m_frames[i]; 504 // Get current using document. 505 Document* currentDoc = currentFrame->frame()->document(); 506 // Get current frame's URL. 507 const KURL& currentFrameURL = currentFrame->frame()->loader()->url(); 508 509 // Check whether we have done this document. 510 if (currentFrameURL.isValid() && m_localLinks.contains(currentFrameURL.string())) { 511 // A new document, we will serialize it. 512 didSerialization = true; 513 // Get target encoding for current document. 514 String encoding = currentFrame->frame()->loader()->writer()->encoding(); 515 // Create the text encoding object with target encoding. 516 TextEncoding textEncoding(encoding); 517 // Construct serialize parameter for late processing document. 518 SerializeDomParam param(currentFrameURL, 519 encoding.length() ? textEncoding : UTF8Encoding(), 520 currentDoc, 521 currentFrameURL == mainPageURL ? m_localDirectoryName : ""); 522 523 // Process current document. 524 Element* rootElement = currentDoc->documentElement(); 525 if (rootElement) 526 buildContentForNode(rootElement, ¶m); 527 528 // Flush the remainder data and finish serializing current frame. 529 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, 530 ¶m, 531 1); 532 } 533 } 534 535 // We have done call frames, so we send message to embedder to tell it that 536 // frames are finished serializing. 496 KURL mainURL = m_specifiedWebFrameImpl->frame()->document()->url(); 497 498 for (unsigned i = 0; i < m_frames.size(); ++i) { 499 WebFrameImpl* webFrame = m_frames[i]; 500 Document* document = webFrame->frame()->document(); 501 const KURL& url = document->url(); 502 503 if (!url.isValid() || !m_localLinks.contains(url.string())) 504 continue; 505 506 didSerialization = true; 507 508 String encoding = webFrame->frame()->loader()->writer()->encoding(); 509 const TextEncoding& textEncoding = encoding.isEmpty() ? UTF8Encoding() : TextEncoding(encoding); 510 String directoryName = url == mainURL ? m_localDirectoryName : ""; 511 512 SerializeDomParam param(url, textEncoding, document, directoryName); 513 514 Element* documentElement = document->documentElement(); 515 if (documentElement) 516 buildContentForNode(documentElement, ¶m); 517 518 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, ¶m, ForceFlush); 519 } 520 537 521 ASSERT(m_dataBuffer.isEmpty()); 538 m_client->didSerializeDataForFrame(KURL(), 539 WebCString("", 0), 540 WebPageSerializerClient::AllFramesAreFinished); 522 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSerializerClient::AllFramesAreFinished); 541 523 return didSerialization; 542 524 } -
trunk/WebKit/chromium/src/WebPageSerializerImpl.h
r69668 r69675 162 162 void saveHTMLContentToBuffer(const WTF::String& content, 163 163 SerializeDomParam* param); 164 165 enum FlushOption { 166 ForceFlush, 167 DoNotForceFlush, 168 }; 169 164 170 // Flushes the content buffer by encoding and sending the content to the 165 171 // WebPageSerializerClient. Content is not flushed if the buffer is not full … … 167 173 void encodeAndFlushBuffer(WebPageSerializerClient::PageSerializationStatus status, 168 174 SerializeDomParam* param, 169 bool force);175 FlushOption); 170 176 // Serialize open tag of an specified element. 171 177 void openTagToString(const WebCore::Element* element,
Note: See TracChangeset
for help on using the changeset viewer.