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/layout/LayoutImage.h" | 29 #include "core/layout/LayoutImage.h" |
30 | 30 |
31 #include "core/HTMLNames.h" | 31 #include "core/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/fetch/ResourceLoader.h" |
36 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
37 #include "core/html/HTMLAreaElement.h" | 36 #include "core/html/HTMLAreaElement.h" |
38 #include "core/html/HTMLImageElement.h" | 37 #include "core/html/HTMLImageElement.h" |
39 #include "core/html/HTMLInputElement.h" | 38 #include "core/html/HTMLInputElement.h" |
40 #include "core/html/HTMLMapElement.h" | 39 #include "core/html/HTMLMapElement.h" |
41 #include "core/layout/HitTestResult.h" | 40 #include "core/layout/HitTestResult.h" |
42 #include "core/layout/LayoutView.h" | 41 #include "core/layout/LayoutView.h" |
43 #include "core/layout/TextRunConstructor.h" | 42 #include "core/layout/TextRunConstructor.h" |
44 #include "core/page/Page.h" | 43 #include "core/page/Page.h" |
45 #include "core/paint/ImagePainter.h" | 44 #include "core/paint/ImagePainter.h" |
46 #include "core/svg/graphics/SVGImage.h" | 45 #include "core/svg/graphics/SVGImage.h" |
47 #include "platform/fonts/Font.h" | 46 #include "platform/fonts/Font.h" |
48 #include "platform/fonts/FontCache.h" | 47 #include "platform/fonts/FontCache.h" |
49 | 48 |
50 namespace blink { | 49 namespace blink { |
51 | 50 |
52 using namespace HTMLNames; | 51 using namespace HTMLNames; |
53 | 52 |
54 LayoutImage::LayoutImage(Element* element) | 53 LayoutImage::LayoutImage(Element* element) |
55 : LayoutReplaced(element, LayoutSize()) | 54 : LayoutReplaced(element, LayoutSize()) |
56 , m_didIncrementVisuallyNonEmptyPixelCount(false) | 55 , m_didIncrementVisuallyNonEmptyPixelCount(false) |
57 , m_isGeneratedContent(false) | 56 , m_isGeneratedContent(false) |
58 , m_imageDevicePixelRatio(1.0f) | 57 , m_imageDevicePixelRatio(1.0f) |
59 { | 58 { |
60 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayoutObj
ect(this); | |
61 } | 59 } |
62 | 60 |
63 LayoutImage* LayoutImage::createAnonymous(Document* document) | 61 LayoutImage* LayoutImage::createAnonymous(Document* document) |
64 { | 62 { |
65 LayoutImage* image = new LayoutImage(nullptr); | 63 LayoutImage* image = new LayoutImage(nullptr); |
66 image->setDocumentForAnonymous(document); | 64 image->setDocumentForAnonymous(document); |
67 return image; | 65 return image; |
68 } | 66 } |
69 | 67 |
70 LayoutImage::~LayoutImage() | 68 LayoutImage::~LayoutImage() |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 result = tempResult; | 298 result = tempResult; |
301 return inside; | 299 return inside; |
302 } | 300 } |
303 | 301 |
304 void LayoutImage::layout() | 302 void LayoutImage::layout() |
305 { | 303 { |
306 LayoutReplaced::layout(); | 304 LayoutReplaced::layout(); |
307 updateInnerContentRect(); | 305 updateInnerContentRect(); |
308 } | 306 } |
309 | 307 |
310 bool LayoutImage::updateImageLoadingPriorities() | |
311 { | |
312 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource->
cachedImage()->isLoaded()) | |
313 return false; | |
314 | |
315 LayoutRect viewBounds = viewRect(); | |
316 LayoutRect objectBounds = LayoutRect(absoluteContentBox()); | |
317 | |
318 // The object bounds might be empty right now, so intersects will fail since
it doesn't deal | |
319 // with empty rects. Use LayoutRect::contains in that case. | |
320 bool isVisible; | |
321 if (!objectBounds.isEmpty()) | |
322 isVisible = viewBounds.intersects(objectBounds); | |
323 else | |
324 isVisible = viewBounds.contains(objectBounds); | |
325 | |
326 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | |
327 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::
NotVisible; | |
328 | |
329 LayoutRect screenArea; | |
330 if (!objectBounds.isEmpty()) { | |
331 screenArea = viewBounds; | |
332 screenArea.intersect(objectBounds); | |
333 } | |
334 | |
335 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyImageR
esourceVisibility(m_imageResource->cachedImage(), status, screenArea); | |
336 | |
337 return true; | |
338 } | |
339 | |
340 void LayoutImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou
ble& intrinsicRatio) const | 308 void LayoutImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou
ble& intrinsicRatio) const |
341 { | 309 { |
342 LayoutReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat
io); | 310 LayoutReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat
io); |
343 | 311 |
344 // Our intrinsicSize is empty if we're laying out generated images with rela
tive width/height. Figure out the right intrinsic size to use. | 312 // Our intrinsicSize is empty if we're laying out generated images with rela
tive width/height. Figure out the right intrinsic size to use. |
345 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() ||
m_imageResource->imageHasRelativeHeight())) { | 313 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() ||
m_imageResource->imageHasRelativeHeight())) { |
346 LayoutObject* containingBlock = isOutOfFlowPositioned() ? container() :
this->containingBlock(); | 314 LayoutObject* containingBlock = isOutOfFlowPositioned() ? container() :
this->containingBlock(); |
347 if (containingBlock->isBox()) { | 315 if (containingBlock->isBox()) { |
348 LayoutBox* box = toLayoutBox(containingBlock); | 316 LayoutBox* box = toLayoutBox(containingBlock); |
349 intrinsicSize.setWidth(box->availableLogicalWidth().toFloat()); | 317 intrinsicSize.setWidth(box->availableLogicalWidth().toFloat()); |
(...skipping 21 matching lines...) Expand all Loading... |
371 return nullptr; | 339 return nullptr; |
372 | 340 |
373 ImageResource* cachedImage = m_imageResource->cachedImage(); | 341 ImageResource* cachedImage = m_imageResource->cachedImage(); |
374 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 342 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
375 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 343 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
376 | 344 |
377 return nullptr; | 345 return nullptr; |
378 } | 346 } |
379 | 347 |
380 } // namespace blink | 348 } // namespace blink |
OLD | NEW |