Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
| 10 * | 10 * |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 using namespace HTMLNames; | 56 using namespace HTMLNames; |
| 57 | 57 |
| 58 RenderImage::RenderImage(Element* element) | 58 RenderImage::RenderImage(Element* element) |
| 59 : RenderReplaced(element, IntSize()) | 59 : RenderReplaced(element, IntSize()) |
| 60 , m_needsToSetSizeForAltText(false) | 60 , m_needsToSetSizeForAltText(false) |
| 61 , m_didIncrementVisuallyNonEmptyPixelCount(false) | 61 , m_didIncrementVisuallyNonEmptyPixelCount(false) |
| 62 , m_isGeneratedContent(false) | 62 , m_isGeneratedContent(false) |
| 63 , m_imageDevicePixelRatio(1.0f) | 63 , m_imageDevicePixelRatio(1.0f) |
| 64 { | 64 { |
| 65 updateAltText(); | 65 updateAltText(); |
| 66 resourceLoadPriorityOptimizer()->addRenderObject(this); | |
| 66 } | 67 } |
| 67 | 68 |
| 68 RenderImage* RenderImage::createAnonymous(Document* document) | 69 RenderImage* RenderImage::createAnonymous(Document* document) |
| 69 { | 70 { |
| 70 RenderImage* image = new RenderImage(0); | 71 RenderImage* image = new RenderImage(0); |
| 71 image->setDocumentForAnonymous(document); | 72 image->setDocumentForAnonymous(document); |
| 72 return image; | 73 return image; |
| 73 } | 74 } |
| 74 | 75 |
| 75 RenderImage::~RenderImage() | 76 RenderImage::~RenderImage() |
| 76 { | 77 { |
| 78 resourceLoadPriorityOptimizer()->removeRenderObject(this); | |
|
esprehn
2014/01/15 01:27:45
This should be in ~RenderObject and you should jus
shatch
2014/01/15 19:28:52
Done.
| |
| 77 ASSERT(m_imageResource); | 79 ASSERT(m_imageResource); |
| 78 m_imageResource->shutdown(); | 80 m_imageResource->shutdown(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void RenderImage::setImageResource(PassOwnPtr<RenderImageResource> imageResource ) | 83 void RenderImage::setImageResource(PassOwnPtr<RenderImageResource> imageResource ) |
| 82 { | 84 { |
| 83 ASSERT(!m_imageResource); | 85 ASSERT(!m_imageResource); |
| 84 m_imageResource = imageResource; | 86 m_imageResource = imageResource; |
| 85 m_imageResource->initialize(this); | 87 m_imageResource->initialize(this); |
| 86 } | 88 } |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 m_altText = toHTMLImageElement(node())->altText(); | 573 m_altText = toHTMLImageElement(node())->altText(); |
| 572 } | 574 } |
| 573 | 575 |
| 574 void RenderImage::layout() | 576 void RenderImage::layout() |
| 575 { | 577 { |
| 576 LayoutRectRecorder recorder(*this); | 578 LayoutRectRecorder recorder(*this); |
| 577 RenderReplaced::layout(); | 579 RenderReplaced::layout(); |
| 578 updateInnerContentRect(); | 580 updateInnerContentRect(); |
| 579 } | 581 } |
| 580 | 582 |
| 581 void RenderImage::didLayout(ResourceLoadPriorityOptimizer& optimizer) | 583 bool RenderImage::updateImageLoadingPriorities() |
| 582 { | |
| 583 RenderReplaced::didLayout(optimizer); | |
| 584 updateImageLoadingPriority(optimizer); | |
| 585 } | |
| 586 | |
| 587 void RenderImage::didScroll(ResourceLoadPriorityOptimizer& optimizer) | |
| 588 { | |
| 589 RenderReplaced::didScroll(optimizer); | |
| 590 updateImageLoadingPriority(optimizer); | |
| 591 } | |
| 592 | |
| 593 void RenderImage::updateImageLoadingPriority(ResourceLoadPriorityOptimizer& opti mizer) | |
| 594 { | 584 { |
| 595 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource-> cachedImage()->isLoaded()) | 585 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource-> cachedImage()->isLoaded()) |
| 596 return; | 586 return false; |
| 597 | 587 |
| 598 LayoutRect viewBounds = viewRect(); | 588 LayoutRect viewBounds = viewRect(); |
| 599 LayoutRect objectBounds = absoluteContentBox(); | 589 LayoutRect objectBounds = absoluteContentBox(); |
| 600 | 590 |
| 601 // The object bounds might be empty right now, so intersects will fail since it doesn't deal | 591 // The object bounds might be empty right now, so intersects will fail since it doesn't deal |
| 602 // with empty rects. Use LayoutRect::contains in that case. | 592 // with empty rects. Use LayoutRect::contains in that case. |
| 603 bool isVisible; | 593 bool isVisible; |
| 604 if (!objectBounds.isEmpty()) | 594 if (!objectBounds.isEmpty()) |
| 605 isVisible = viewBounds.intersects(objectBounds); | 595 isVisible = viewBounds.intersects(objectBounds); |
| 606 else | 596 else |
| 607 isVisible = viewBounds.contains(objectBounds); | 597 isVisible = viewBounds.contains(objectBounds); |
| 608 | 598 |
| 609 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | 599 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? |
| 610 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; | 600 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; |
| 611 | 601 |
| 612 optimizer.notifyImageResourceVisibility(m_imageResource->cachedImage(), stat us); | 602 resourceLoadPriorityOptimizer()->notifyImageResourceVisibility(m_imageResour ce->cachedImage(), status); |
| 603 | |
| 604 return true; | |
| 613 } | 605 } |
| 614 | 606 |
| 615 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const | 607 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const |
| 616 { | 608 { |
| 617 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io, isPercentageIntrinsicSize); | 609 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io, isPercentageIntrinsicSize); |
| 618 | 610 |
| 619 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use. | 611 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use. |
| 620 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) { | 612 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) { |
| 621 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); | 613 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); |
| 622 if (containingBlock->isBox()) { | 614 if (containingBlock->isBox()) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 646 return 0; | 638 return 0; |
| 647 | 639 |
| 648 ImageResource* cachedImage = m_imageResource->cachedImage(); | 640 ImageResource* cachedImage = m_imageResource->cachedImage(); |
| 649 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) | 641 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) |
| 650 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 642 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
| 651 | 643 |
| 652 return 0; | 644 return 0; |
| 653 } | 645 } |
| 654 | 646 |
| 655 } // namespace WebCore | 647 } // namespace WebCore |
| OLD | NEW |