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/platform/graphics/Font.h" | 42 #include "core/platform/graphics/Font.h" |
41 #include "core/platform/graphics/FontCache.h" | 43 #include "core/platform/graphics/FontCache.h" |
42 #include "core/platform/graphics/GraphicsContext.h" | 44 #include "core/platform/graphics/GraphicsContext.h" |
43 #include "core/platform/graphics/GraphicsContextStateSaver.h" | 45 #include "core/platform/graphics/GraphicsContextStateSaver.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->cachedImage() && !m_imageResource->cachedImage()->isLoa ded()) { | |
eseidel
2013/11/27 20:58:35
nit: Early returns are preferred over long if bloc
shatch
2013/12/02 22:32:46
Done. Also changed that in RenderBlock.
| |
593 LayoutRect objectBounds = absoluteContentBox(); | |
594 LayoutRect viewBounds = viewRect(); | |
595 | |
596 ResourceLoadPriorityOptimizer::VisibilityStatus status = viewBounds.inte rsects(objectBounds) ? | |
597 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimiz er::NotVisible; | |
598 optimizer.notifyImageResourceVisibility(m_imageResource->cachedImage(), status); | |
599 } | |
600 } | |
601 | |
576 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const | 602 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio, bool& isPercentageIntrinsicSize) const |
577 { | 603 { |
578 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io, isPercentageIntrinsicSize); | 604 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io, isPercentageIntrinsicSize); |
579 | 605 |
580 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use. | 606 // 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())) { | 607 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) { |
582 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); | 608 RenderObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); |
583 if (containingBlock->isBox()) { | 609 if (containingBlock->isBox()) { |
584 RenderBox* box = toRenderBox(containingBlock); | 610 RenderBox* box = toRenderBox(containingBlock); |
585 intrinsicSize.setWidth(box->availableLogicalWidth()); | 611 intrinsicSize.setWidth(box->availableLogicalWidth()); |
(...skipping 20 matching lines...) Expand all Loading... | |
606 return 0; | 632 return 0; |
607 | 633 |
608 ImageResource* cachedImage = m_imageResource->cachedImage(); | 634 ImageResource* cachedImage = m_imageResource->cachedImage(); |
609 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) | 635 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) |
610 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 636 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
611 | 637 |
612 return 0; | 638 return 0; |
613 } | 639 } |
614 | 640 |
615 } // namespace WebCore | 641 } // namespace WebCore |
OLD | NEW |