| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 TRACE_EVENT0("page-serialization", "FrameSerializer::serializeFrame HTML"); | 289 TRACE_EVENT0("page-serialization", "FrameSerializer::serializeFrame HTML"); |
| 290 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( | 290 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( |
| 291 "PageSerialization.SerializationTime.Html"); | 291 "PageSerialization.SerializationTime.Html"); |
| 292 SerializerMarkupAccumulator accumulator(m_delegate, document, | 292 SerializerMarkupAccumulator accumulator(m_delegate, document, |
| 293 serializedNodes); | 293 serializedNodes); |
| 294 String text = | 294 String text = |
| 295 serializeNodes<EditingStrategy>(accumulator, document, IncludeNode); | 295 serializeNodes<EditingStrategy>(accumulator, document, IncludeNode); |
| 296 | 296 |
| 297 CString frameHTML = | 297 CString frameHTML = |
| 298 document.encoding().encode(text, WTF::EntitiesForUnencodables); | 298 document.encoding().encode(text, WTF::EntitiesForUnencodables); |
| 299 m_resources->append(SerializedResource( | 299 m_resources->push_back(SerializedResource( |
| 300 url, document.suggestedMIMEType(), | 300 url, document.suggestedMIMEType(), |
| 301 SharedBuffer::create(frameHTML.data(), frameHTML.length()))); | 301 SharedBuffer::create(frameHTML.data(), frameHTML.length()))); |
| 302 } | 302 } |
| 303 | 303 |
| 304 for (Node* node : serializedNodes) { | 304 for (Node* node : serializedNodes) { |
| 305 ASSERT(node); | 305 ASSERT(node); |
| 306 if (!node->isElementNode()) | 306 if (!node->isElementNode()) |
| 307 continue; | 307 continue; |
| 308 | 308 |
| 309 Element& element = toElement(*node); | 309 Element& element = toElement(*node); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (i < styleSheet.length() - 1) | 381 if (i < styleSheet.length() - 1) |
| 382 cssText.append("\n\n"); | 382 cssText.append("\n\n"); |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 WTF::TextEncoding textEncoding(styleSheet.contents()->charset()); | 386 WTF::TextEncoding textEncoding(styleSheet.contents()->charset()); |
| 387 ASSERT(textEncoding.isValid()); | 387 ASSERT(textEncoding.isValid()); |
| 388 String textString = cssText.toString(); | 388 String textString = cssText.toString(); |
| 389 CString text = | 389 CString text = |
| 390 textEncoding.encode(textString, WTF::CSSEncodedEntitiesForUnencodables); | 390 textEncoding.encode(textString, WTF::CSSEncodedEntitiesForUnencodables); |
| 391 m_resources->append( | 391 m_resources->push_back( |
| 392 SerializedResource(url, String("text/css"), | 392 SerializedResource(url, String("text/css"), |
| 393 SharedBuffer::create(text.data(), text.length()))); | 393 SharedBuffer::create(text.data(), text.length()))); |
| 394 m_resourceURLs.insert(url); | 394 m_resourceURLs.insert(url); |
| 395 } | 395 } |
| 396 | 396 |
| 397 // Sub resources need to be serialized even if the CSS definition doesn't | 397 // Sub resources need to be serialized even if the CSS definition doesn't |
| 398 // need to be. | 398 // need to be. |
| 399 for (unsigned i = 0; i < styleSheet.length(); ++i) | 399 for (unsigned i = 0; i < styleSheet.length(); ++i) |
| 400 serializeCSSRule(styleSheet.item(i)); | 400 serializeCSSRule(styleSheet.item(i)); |
| 401 | 401 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 PassRefPtr<const SharedBuffer> data, | 466 PassRefPtr<const SharedBuffer> data, |
| 467 const KURL& url) { | 467 const KURL& url) { |
| 468 if (m_delegate.shouldSkipResource(hasCacheControlNoStoreHeader)) | 468 if (m_delegate.shouldSkipResource(hasCacheControlNoStoreHeader)) |
| 469 return; | 469 return; |
| 470 | 470 |
| 471 if (!data) { | 471 if (!data) { |
| 472 DLOG(ERROR) << "No data for resource " << url.getString(); | 472 DLOG(ERROR) << "No data for resource " << url.getString(); |
| 473 return; | 473 return; |
| 474 } | 474 } |
| 475 | 475 |
| 476 m_resources->append(SerializedResource(url, mimeType, std::move(data))); | 476 m_resources->push_back(SerializedResource(url, mimeType, std::move(data))); |
| 477 m_resourceURLs.insert(url); | 477 m_resourceURLs.insert(url); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void FrameSerializer::addImageToResources(ImageResourceContent* image, | 480 void FrameSerializer::addImageToResources(ImageResourceContent* image, |
| 481 const KURL& url) { | 481 const KURL& url) { |
| 482 if (!image || !image->hasImage() || image->errorOccurred() || | 482 if (!image || !image->hasImage() || image->errorOccurred() || |
| 483 !shouldAddURL(url)) | 483 !shouldAddURL(url)) |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 TRACE_EVENT2("page-serialization", "FrameSerializer::addImageToResources", | 486 TRACE_EVENT2("page-serialization", "FrameSerializer::addImageToResources", |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 emitsMinus = ch == '-'; | 580 emitsMinus = ch == '-'; |
| 581 builder.append(ch); | 581 builder.append(ch); |
| 582 } | 582 } |
| 583 CString escapedUrl = builder.toString().ascii(); | 583 CString escapedUrl = builder.toString().ascii(); |
| 584 return String::format("saved from url=(%04d)%s", | 584 return String::format("saved from url=(%04d)%s", |
| 585 static_cast<int>(escapedUrl.length()), | 585 static_cast<int>(escapedUrl.length()), |
| 586 escapedUrl.data()); | 586 escapedUrl.data()); |
| 587 } | 587 } |
| 588 | 588 |
| 589 } // namespace blink | 589 } // namespace blink |
| OLD | NEW |