Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: Source/core/layout/LayoutImage.cpp

Issue 930833003: Move and rename RenderReplaced and RenderHTMLCanvas to Layout{Replaced,HTMLCanvas}. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: No need to declare renderName() at all. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/layout/LayoutImage.h ('k') | Source/core/layout/LayoutReplaced.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/rendering/RenderView.h" 47 #include "core/rendering/RenderView.h"
48 #include "core/svg/graphics/SVGImage.h" 48 #include "core/svg/graphics/SVGImage.h"
49 #include "platform/fonts/Font.h" 49 #include "platform/fonts/Font.h"
50 #include "platform/fonts/FontCache.h" 50 #include "platform/fonts/FontCache.h"
51 51
52 namespace blink { 52 namespace blink {
53 53
54 using namespace HTMLNames; 54 using namespace HTMLNames;
55 55
56 LayoutImage::LayoutImage(Element* element) 56 LayoutImage::LayoutImage(Element* element)
57 : RenderReplaced(element, LayoutSize()) 57 : LayoutReplaced(element, LayoutSize())
58 , m_didIncrementVisuallyNonEmptyPixelCount(false) 58 , m_didIncrementVisuallyNonEmptyPixelCount(false)
59 , m_isGeneratedContent(false) 59 , m_isGeneratedContent(false)
60 , m_imageDevicePixelRatio(1.0f) 60 , m_imageDevicePixelRatio(1.0f)
61 { 61 {
62 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayoutObj ect(this); 62 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayoutObj ect(this);
63 } 63 }
64 64
65 LayoutImage* LayoutImage::createAnonymous(Document* document) 65 LayoutImage* LayoutImage::createAnonymous(Document* document)
66 { 66 {
67 LayoutImage* image = new LayoutImage(0); 67 LayoutImage* image = new LayoutImage(0);
68 image->setDocumentForAnonymous(document); 68 image->setDocumentForAnonymous(document);
69 return image; 69 return image;
70 } 70 }
71 71
72 LayoutImage::~LayoutImage() 72 LayoutImage::~LayoutImage()
73 { 73 {
74 } 74 }
75 75
76 void LayoutImage::destroy() 76 void LayoutImage::destroy()
77 { 77 {
78 ASSERT(m_imageResource); 78 ASSERT(m_imageResource);
79 m_imageResource->shutdown(); 79 m_imageResource->shutdown();
80 RenderReplaced::destroy(); 80 LayoutReplaced::destroy();
81 } 81 }
82 82
83 void LayoutImage::setImageResource(PassOwnPtr<LayoutImageResource> imageResource ) 83 void LayoutImage::setImageResource(PassOwnPtr<LayoutImageResource> imageResource )
84 { 84 {
85 ASSERT(!m_imageResource); 85 ASSERT(!m_imageResource);
86 m_imageResource = imageResource; 86 m_imageResource = imageResource;
87 m_imageResource->initialize(this); 87 m_imageResource->initialize(this);
88 } 88 }
89 89
90 void LayoutImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect) 90 void LayoutImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
91 { 91 {
92 if (documentBeingDestroyed()) 92 if (documentBeingDestroyed())
93 return; 93 return;
94 94
95 if (hasBoxDecorationBackground() || hasMask() || hasShapeOutside()) 95 if (hasBoxDecorationBackground() || hasMask() || hasShapeOutside())
96 RenderReplaced::imageChanged(newImage, rect); 96 LayoutReplaced::imageChanged(newImage, rect);
97 97
98 if (!m_imageResource) 98 if (!m_imageResource)
99 return; 99 return;
100 100
101 if (newImage != m_imageResource->imagePtr()) 101 if (newImage != m_imageResource->imagePtr())
102 return; 102 return;
103 103
104 // Per the spec, we let the server-sent header override srcset/other sources of dpr. 104 // Per the spec, we let the server-sent header override srcset/other sources of dpr.
105 // https://github.com/igrigorik/http-client-hints/blob/master/draft-grigorik -http-client-hints-01.txt#L255 105 // https://github.com/igrigorik/http-client-hints/blob/master/draft-grigorik -http-client-hints-01.txt#L255
106 if (m_imageResource->cachedImage() && m_imageResource->cachedImage()->hasDev icePixelRatioHeaderValue()) 106 if (m_imageResource->cachedImage() && m_imageResource->cachedImage()->hasDev icePixelRatioHeaderValue())
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 HTMLMapElement* LayoutImage::imageMap() const 267 HTMLMapElement* LayoutImage::imageMap() const
268 { 268 {
269 HTMLImageElement* i = isHTMLImageElement(node()) ? toHTMLImageElement(node() ) : 0; 269 HTMLImageElement* i = isHTMLImageElement(node()) ? toHTMLImageElement(node() ) : 0;
270 return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0; 270 return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0;
271 } 271 }
272 272
273 bool LayoutImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu lt, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf fset, HitTestAction hitTestAction) 273 bool LayoutImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu lt, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf fset, HitTestAction hitTestAction)
274 { 274 {
275 HitTestResult tempResult(result.hitTestLocation()); 275 HitTestResult tempResult(result.hitTestLocation());
276 bool inside = RenderReplaced::nodeAtPoint(request, tempResult, locationInCon tainer, accumulatedOffset, hitTestAction); 276 bool inside = LayoutReplaced::nodeAtPoint(request, tempResult, locationInCon tainer, accumulatedOffset, hitTestAction);
277 277
278 if (tempResult.innerNode() && node()) { 278 if (tempResult.innerNode() && node()) {
279 if (HTMLMapElement* map = imageMap()) { 279 if (HTMLMapElement* map = imageMap()) {
280 LayoutRect contentBox = contentBoxRect(); 280 LayoutRect contentBox = contentBoxRect();
281 float scaleFactor = 1 / style()->effectiveZoom(); 281 float scaleFactor = 1 / style()->effectiveZoom();
282 LayoutPoint mapLocation = locationInContainer.point() - toLayoutSize (accumulatedOffset) - locationOffset() - toLayoutSize(contentBox.location()); 282 LayoutPoint mapLocation = locationInContainer.point() - toLayoutSize (accumulatedOffset) - locationOffset() - toLayoutSize(contentBox.location());
283 mapLocation.scale(scaleFactor, scaleFactor); 283 mapLocation.scale(scaleFactor, scaleFactor);
284 284
285 if (map->mapMouseEvent(mapLocation, contentBox.size(), tempResult)) 285 if (map->mapMouseEvent(mapLocation, contentBox.size(), tempResult))
286 tempResult.setInnerNonSharedNode(node()); 286 tempResult.setInnerNonSharedNode(node());
287 } 287 }
288 } 288 }
289 289
290 if (!inside && result.isRectBasedTest()) 290 if (!inside && result.isRectBasedTest())
291 result.append(tempResult); 291 result.append(tempResult);
292 if (inside) 292 if (inside)
293 result = tempResult; 293 result = tempResult;
294 return inside; 294 return inside;
295 } 295 }
296 296
297 void LayoutImage::layout() 297 void LayoutImage::layout()
298 { 298 {
299 RenderReplaced::layout(); 299 LayoutReplaced::layout();
300 updateInnerContentRect(); 300 updateInnerContentRect();
301 } 301 }
302 302
303 bool LayoutImage::updateImageLoadingPriorities() 303 bool LayoutImage::updateImageLoadingPriorities()
304 { 304 {
305 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource-> cachedImage()->isLoaded()) 305 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource-> cachedImage()->isLoaded())
306 return false; 306 return false;
307 307
308 LayoutRect viewBounds = viewRect(); 308 LayoutRect viewBounds = viewRect();
309 LayoutRect objectBounds = absoluteContentBox(); 309 LayoutRect objectBounds = absoluteContentBox();
(...skipping 15 matching lines...) Expand all
325 screenArea.intersect(objectBounds); 325 screenArea.intersect(objectBounds);
326 } 326 }
327 327
328 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyImageR esourceVisibility(m_imageResource->cachedImage(), status, screenArea); 328 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyImageR esourceVisibility(m_imageResource->cachedImage(), status, screenArea);
329 329
330 return true; 330 return true;
331 } 331 }
332 332
333 void LayoutImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio) const 333 void LayoutImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, dou ble& intrinsicRatio) const
334 { 334 {
335 RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io); 335 LayoutReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRat io);
336 336
337 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use. 337 // Our intrinsicSize is empty if we're rendering generated images with relat ive width/height. Figure out the right intrinsic size to use.
338 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) { 338 if (intrinsicSize.isEmpty() && (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight())) {
339 LayoutObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock(); 339 LayoutObject* containingBlock = isOutOfFlowPositioned() ? container() : this->containingBlock();
340 if (containingBlock->isBox()) { 340 if (containingBlock->isBox()) {
341 RenderBox* box = toRenderBox(containingBlock); 341 RenderBox* box = toRenderBox(containingBlock);
342 intrinsicSize.setWidth(box->availableLogicalWidth().toFloat()); 342 intrinsicSize.setWidth(box->availableLogicalWidth().toFloat());
343 intrinsicSize.setHeight(box->availableLogicalHeight(IncludeMarginBor derPadding).toFloat()); 343 intrinsicSize.setHeight(box->availableLogicalHeight(IncludeMarginBor derPadding).toFloat());
344 } 344 }
345 } 345 }
346 // Don't compute an intrinsic ratio to preserve historical WebKit behavior i f we're painting alt text and/or a broken image. 346 // Don't compute an intrinsic ratio to preserve historical WebKit behavior i f we're painting alt text and/or a broken image.
347 // Video is excluded from this behavior because video elements have a defaul t aspect ratio that a failed poster image load should not override. 347 // Video is excluded from this behavior because video elements have a defaul t aspect ratio that a failed poster image load should not override.
348 if (m_imageResource && m_imageResource->errorOccurred() && !isVideo()) { 348 if (m_imageResource && m_imageResource->errorOccurred() && !isVideo()) {
349 intrinsicRatio = 1; 349 intrinsicRatio = 1;
350 return; 350 return;
351 } 351 }
352 } 352 }
353 353
354 bool LayoutImage::needsPreferredWidthsRecalculation() const 354 bool LayoutImage::needsPreferredWidthsRecalculation() const
355 { 355 {
356 if (RenderReplaced::needsPreferredWidthsRecalculation()) 356 if (LayoutReplaced::needsPreferredWidthsRecalculation())
357 return true; 357 return true;
358 return embeddedContentBox(); 358 return embeddedContentBox();
359 } 359 }
360 360
361 RenderBox* LayoutImage::embeddedContentBox() const 361 RenderBox* LayoutImage::embeddedContentBox() const
362 { 362 {
363 if (!m_imageResource) 363 if (!m_imageResource)
364 return 0; 364 return 0;
365 365
366 ImageResource* cachedImage = m_imageResource->cachedImage(); 366 ImageResource* cachedImage = m_imageResource->cachedImage();
367 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 367 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
368 return toSVGImage(cachedImage->image())->embeddedContentBox(); 368 return toSVGImage(cachedImage->image())->embeddedContentBox();
369 369
370 return 0; 370 return 0;
371 } 371 }
372 372
373 } // namespace blink 373 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutImage.h ('k') | Source/core/layout/LayoutReplaced.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698