OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 m_data.clear(); | 351 m_data.clear(); |
352 setEncodedSize(0); | 352 setEncodedSize(0); |
353 } | 353 } |
354 | 354 |
355 inline void ImageResource::createImage() | 355 inline void ImageResource::createImage() |
356 { | 356 { |
357 // Create the image if it doesn't yet exist. | 357 // Create the image if it doesn't yet exist. |
358 if (m_image) | 358 if (m_image) |
359 return; | 359 return; |
360 | 360 |
361 if (m_response.mimeType() == "image/svg+xml") { | 361 if (response().mimeType() == "image/svg+xml") { |
362 m_image = SVGImage::create(this); | 362 m_image = SVGImage::create(this); |
363 } else { | 363 } else { |
364 m_image = BitmapImage::create(this); | 364 m_image = BitmapImage::create(this); |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 inline void ImageResource::clearImage() | 368 inline void ImageResource::clearImage() |
369 { | 369 { |
370 if (!m_image) | 370 if (!m_image) |
371 return; | 371 return; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 void ImageResource::responseReceived(const ResourceResponse& response, std::uniq
ue_ptr<WebDataConsumerHandle> handle) | 450 void ImageResource::responseReceived(const ResourceResponse& response, std::uniq
ue_ptr<WebDataConsumerHandle> handle) |
451 { | 451 { |
452 ASSERT(!handle); | 452 ASSERT(!handle); |
453 ASSERT(!m_multipartParser); | 453 ASSERT(!m_multipartParser); |
454 // If there's no boundary, just handle the request normally. | 454 // If there's no boundary, just handle the request normally. |
455 if (response.isMultipart() && !response.multipartBoundary().isEmpty()) | 455 if (response.isMultipart() && !response.multipartBoundary().isEmpty()) |
456 m_multipartParser = new MultipartImageResourceParser(response, response.
multipartBoundary(), this); | 456 m_multipartParser = new MultipartImageResourceParser(response, response.
multipartBoundary(), this); |
457 Resource::responseReceived(response, std::move(handle)); | 457 Resource::responseReceived(response, std::move(handle)); |
458 if (RuntimeEnabledFeatures::clientHintsEnabled()) { | 458 if (RuntimeEnabledFeatures::clientHintsEnabled()) { |
459 m_devicePixelRatioHeaderValue = m_response.httpHeaderField(HTTPNames::Co
ntent_DPR).toFloat(&m_hasDevicePixelRatioHeaderValue); | 459 m_devicePixelRatioHeaderValue = this->response().httpHeaderField(HTTPNam
es::Content_DPR).toFloat(&m_hasDevicePixelRatioHeaderValue); |
460 if (!m_hasDevicePixelRatioHeaderValue || m_devicePixelRatioHeaderValue <
= 0.0) { | 460 if (!m_hasDevicePixelRatioHeaderValue || m_devicePixelRatioHeaderValue <
= 0.0) { |
461 m_devicePixelRatioHeaderValue = 1.0; | 461 m_devicePixelRatioHeaderValue = 1.0; |
462 m_hasDevicePixelRatioHeaderValue = false; | 462 m_hasDevicePixelRatioHeaderValue = false; |
463 } | 463 } |
464 | 464 |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 void ImageResource::decodedSizeChangedTo(const blink::Image* image, size_t newSi
ze) | 468 void ImageResource::decodedSizeChangedTo(const blink::Image* image, size_t newSi
ze) |
469 { | 469 { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (m_image->animationPolicy() != newPolicy) { | 533 if (m_image->animationPolicy() != newPolicy) { |
534 m_image->resetAnimation(); | 534 m_image->resetAnimation(); |
535 m_image->setAnimationPolicy(newPolicy); | 535 m_image->setAnimationPolicy(newPolicy); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 void ImageResource::reloadIfLoFi(ResourceFetcher* fetcher) | 539 void ImageResource::reloadIfLoFi(ResourceFetcher* fetcher) |
540 { | 540 { |
541 if (m_resourceRequest.loFiState() != WebURLRequest::LoFiOn) | 541 if (m_resourceRequest.loFiState() != WebURLRequest::LoFiOn) |
542 return; | 542 return; |
543 if (isLoaded() && !m_response.httpHeaderField("chrome-proxy").contains("q=lo
w")) | 543 if (isLoaded() && !response().httpHeaderField("chrome-proxy").contains("q=lo
w")) |
544 return; | 544 return; |
545 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); | 545 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
546 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); | 546 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
547 if (isLoading()) | 547 if (isLoading()) |
548 m_loader->cancel(); | 548 m_loader->cancel(); |
549 clear(); | 549 clear(); |
550 notifyObservers(); | 550 notifyObservers(); |
551 | 551 |
552 setStatus(NotStarted); | 552 setStatus(NotStarted); |
553 fetcher->startLoad(this); | 553 fetcher->startLoad(this); |
554 } | 554 } |
555 | 555 |
556 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect
) | 556 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect
) |
557 { | 557 { |
558 if (!image || image != m_image) | 558 if (!image || image != m_image) |
559 return; | 559 return; |
560 notifyObservers(&rect); | 560 notifyObservers(&rect); |
561 } | 561 } |
562 | 562 |
563 void ImageResource::onePartInMultipartReceived(const ResourceResponse& response) | 563 void ImageResource::onePartInMultipartReceived(const ResourceResponse& response) |
564 { | 564 { |
565 ASSERT(m_multipartParser); | 565 ASSERT(m_multipartParser); |
566 | 566 |
567 m_response = response; | 567 setResponse(response); |
568 if (m_multipartParsingState == MultipartParsingState::WaitingForFirstPart) { | 568 if (m_multipartParsingState == MultipartParsingState::WaitingForFirstPart) { |
569 // We have nothing to do because we don't have any data. | 569 // We have nothing to do because we don't have any data. |
570 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; | 570 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; |
571 return; | 571 return; |
572 } | 572 } |
573 updateImageAndClearBuffer(); | 573 updateImageAndClearBuffer(); |
574 | 574 |
575 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { | 575 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { |
576 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPar
t; | 576 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPar
t; |
577 // Notify finished when the first part ends. | 577 // Notify finished when the first part ends. |
(...skipping 16 matching lines...) Expand all Loading... |
594 if (response().wasFetchedViaServiceWorker()) | 594 if (response().wasFetchedViaServiceWorker()) |
595 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; | 595 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; |
596 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 596 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
597 return false; | 597 return false; |
598 if (passesAccessControlCheck(securityOrigin)) | 598 if (passesAccessControlCheck(securityOrigin)) |
599 return true; | 599 return true; |
600 return !securityOrigin->taintsCanvas(response().url()); | 600 return !securityOrigin->taintsCanvas(response().url()); |
601 } | 601 } |
602 | 602 |
603 } // namespace blink | 603 } // namespace blink |
OLD | NEW |