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 13 matching lines...) Expand all Loading... | |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/rendering/RenderImage.h" | 29 #include "core/rendering/RenderImage.h" |
30 | 30 |
31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
32 #include "core/editing/FrameSelection.h" | 32 #include "core/editing/FrameSelection.h" |
33 #include "core/fetch/ImageResource.h" | 33 #include "core/fetch/ImageResource.h" |
34 #include "core/fetch/ResourceLoadPriorityOptimizer.h" | |
35 #include "core/fetch/ResourceLoader.h" | |
34 #include "core/html/HTMLAreaElement.h" | 36 #include "core/html/HTMLAreaElement.h" |
35 #include "core/html/HTMLImageElement.h" | 37 #include "core/html/HTMLImageElement.h" |
36 #include "core/html/HTMLInputElement.h" | 38 #include "core/html/HTMLInputElement.h" |
37 #include "core/html/HTMLMapElement.h" | 39 #include "core/html/HTMLMapElement.h" |
38 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
39 #include "core/frame/Frame.h" | 41 #include "core/frame/Frame.h" |
40 #include "core/rendering/HitTestResult.h" | 42 #include "core/rendering/HitTestResult.h" |
41 #include "core/rendering/LayoutRectRecorder.h" | 43 #include "core/rendering/LayoutRectRecorder.h" |
42 #include "core/rendering/PaintInfo.h" | 44 #include "core/rendering/PaintInfo.h" |
43 #include "core/rendering/RenderView.h" | 45 #include "core/rendering/RenderView.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 m_altText = toHTMLImageElement(node())->altText(); | 568 m_altText = toHTMLImageElement(node())->altText(); |
567 } | 569 } |
568 | 570 |
569 void RenderImage::layout() | 571 void RenderImage::layout() |
570 { | 572 { |
571 LayoutRectRecorder recorder(*this); | 573 LayoutRectRecorder recorder(*this); |
572 RenderReplaced::layout(); | 574 RenderReplaced::layout(); |
573 updateInnerContentRect(); | 575 updateInnerContentRect(); |
574 } | 576 } |
575 | 577 |
578 void RenderImage::didLayout(ResourceLoadPriorityOptimizer& optimizer) | |
579 { | |
580 RenderReplaced::didLayout(optimizer); | |
581 updateImageLoadingPriority(optimizer); | |
582 } | |
583 | |
584 void RenderImage::didScroll(ResourceLoadPriorityOptimizer& optimizer) | |
585 { | |
586 RenderReplaced::didScroll(optimizer); | |
587 updateImageLoadingPriority(optimizer); | |
588 } | |
589 | |
590 void RenderImage::updateImageLoadingPriority(ResourceLoadPriorityOptimizer& opti mizer) | |
591 { | |
592 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource-> cachedImage()->isLoaded()) | |
593 return; | |
594 | |
595 LayoutRect viewBounds = viewRect(); | |
596 LayoutRect objectBounds = absoluteContentBox(); | |
597 | |
598 // The object bounds might be empty right now, so intersects will fail since it doesn't deal | |
599 // with empty rects. Use LayoutRect::contains in that case. | |
600 bool isVisible; | |
eseidel
2013/12/10 17:15:30
Same problem. I wouldn't bother making empty rect
shatch
2013/12/10 18:56:19
Per offline discussion: I don't have any data on t
| |
601 if (!objectBounds.isEmpty()) | |
602 isVisible = viewBounds.intersects(objectBounds); | |
603 else | |
604 isVisible = viewBounds.contains(objectBounds); | |
605 | |
606 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | |
607 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible; | |
608 | |
609 optimizer.notifyImageResourceVisibility(m_imageResource->cachedImage(), stat us); | |
610 } | |
611 | |
576 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const | 612 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const |
577 { | 613 { |
578 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io, isPercentageIntrinsicSize); | 614 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io, isPercentageIntrinsicSize); |
579 | 615 |
580 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use. | 616 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use. |
581 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) { | 617 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) { |
582 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); | 618 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); |
583 if (containingBlock->isBox()) { | 619 if (containingBlock->isBox()) { |
584 RenderBox* box = toRenderBox(containingBlock); | 620 RenderBox* box = toRenderBox(containingBlock); |
585 intrinsicSize.setWidth(box->availableLogicalWidth()); | 621 intrinsicSize.setWidth(box->availableLogicalWidth()); |
(...skipping 20 matching lines...) Expand all Loading... | |
606 return 0; | 642 return 0; |
607 | 643 |
608 ImageResource* cachedImage = m_imageResource->cachedImage(); | 644 ImageResource* cachedImage = m_imageResource->cachedImage(); |
609 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) | 645 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) |
610 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 646 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
611 | 647 |
612 return 0; | 648 return 0; |
613 } | 649 } |
614 | 650 |
615 } // namespace WebCore | 651 } // namespace WebCore |
OLD | NEW |