| 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::resourceLoadPriorityOptimizer()->addRenderObj
ect(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() |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 m_altText = toHTMLImageElement(node())->altText(); | 572 m_altText = toHTMLImageElement(node())->altText(); |
| 572 } | 573 } |
| 573 | 574 |
| 574 void RenderImage::layout() | 575 void RenderImage::layout() |
| 575 { | 576 { |
| 576 LayoutRectRecorder recorder(*this); | 577 LayoutRectRecorder recorder(*this); |
| 577 RenderReplaced::layout(); | 578 RenderReplaced::layout(); |
| 578 updateInnerContentRect(); | 579 updateInnerContentRect(); |
| 579 } | 580 } |
| 580 | 581 |
| 581 void RenderImage::didLayout(ResourceLoadPriorityOptimizer& optimizer) | 582 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 { | 583 { |
| 595 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource->
cachedImage()->isLoaded()) | 584 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource->
cachedImage()->isLoaded()) |
| 596 return; | 585 return false; |
| 597 | 586 |
| 598 LayoutRect viewBounds = viewRect(); | 587 LayoutRect viewBounds = viewRect(); |
| 599 LayoutRect objectBounds = absoluteContentBox(); | 588 LayoutRect objectBounds = absoluteContentBox(); |
| 600 | 589 |
| 601 // The object bounds might be empty right now, so intersects will fail since
it doesn't deal | 590 // 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. | 591 // with empty rects. Use LayoutRect::contains in that case. |
| 603 bool isVisible; | 592 bool isVisible; |
| 604 if (!objectBounds.isEmpty()) | 593 if (!objectBounds.isEmpty()) |
| 605 isVisible = viewBounds.intersects(objectBounds); | 594 isVisible = viewBounds.intersects(objectBounds); |
| 606 else | 595 else |
| 607 isVisible = viewBounds.contains(objectBounds); | 596 isVisible = viewBounds.contains(objectBounds); |
| 608 | 597 |
| 609 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | 598 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? |
| 610 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::
NotVisible; | 599 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::
NotVisible; |
| 611 | 600 |
| 612 optimizer.notifyImageResourceVisibility(m_imageResource->cachedImage(), stat
us); | 601 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyImageR
esourceVisibility(m_imageResource->cachedImage(), status); |
| 602 |
| 603 return true; |
| 613 } | 604 } |
| 614 | 605 |
| 615 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou
ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const | 606 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou
ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const |
| 616 { | 607 { |
| 617 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat
io, isPercentageIntrinsicSize); | 608 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat
io, isPercentageIntrinsicSize); |
| 618 | 609 |
| 619 // Our intrinsicSize is empty if we're rendering generated images with relat
ive width/height. Figure out the right intrinsic size to use. | 610 // 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())) { | 611 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() ||
m_imageResource->imageHasRelativeHeight())) { |
| 621 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() :
this->containingBlock(); | 612 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() :
this->containingBlock(); |
| 622 if (containingBlock->isBox()) { | 613 if (containingBlock->isBox()) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 646 return 0; | 637 return 0; |
| 647 | 638 |
| 648 ImageResource* cachedImage = m_imageResource->cachedImage(); | 639 ImageResource* cachedImage = m_imageResource->cachedImage(); |
| 649 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 640 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
| 650 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 641 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
| 651 | 642 |
| 652 return 0; | 643 return 0; |
| 653 } | 644 } |
| 654 | 645 |
| 655 } // namespace WebCore | 646 } // namespace WebCore |
| OLD | NEW |