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

Side by Side Diff: Source/core/html/HTMLImageElement.cpp

Issue 923953002: Move rendering/RenderImage* to layout/LayoutImage* (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/html/HTMLAreaElement.cpp ('k') | Source/core/html/HTMLImageFallbackHelper.cpp » ('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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 26 matching lines...) Expand all
37 #include "core/frame/UseCounter.h" 37 #include "core/frame/UseCounter.h"
38 #include "core/html/HTMLAnchorElement.h" 38 #include "core/html/HTMLAnchorElement.h"
39 #include "core/html/HTMLCanvasElement.h" 39 #include "core/html/HTMLCanvasElement.h"
40 #include "core/html/HTMLFormElement.h" 40 #include "core/html/HTMLFormElement.h"
41 #include "core/html/HTMLImageFallbackHelper.h" 41 #include "core/html/HTMLImageFallbackHelper.h"
42 #include "core/html/HTMLSourceElement.h" 42 #include "core/html/HTMLSourceElement.h"
43 #include "core/html/canvas/CanvasRenderingContext.h" 43 #include "core/html/canvas/CanvasRenderingContext.h"
44 #include "core/html/parser/HTMLParserIdioms.h" 44 #include "core/html/parser/HTMLParserIdioms.h"
45 #include "core/html/parser/HTMLSrcsetParser.h" 45 #include "core/html/parser/HTMLSrcsetParser.h"
46 #include "core/inspector/ConsoleMessage.h" 46 #include "core/inspector/ConsoleMessage.h"
47 #include "core/layout/LayoutImage.h"
47 #include "core/page/Page.h" 48 #include "core/page/Page.h"
48 #include "core/rendering/RenderBlockFlow.h" 49 #include "core/rendering/RenderBlockFlow.h"
49 #include "core/rendering/RenderImage.h"
50 #include "platform/ContentType.h" 50 #include "platform/ContentType.h"
51 #include "platform/EventDispatchForbiddenScope.h" 51 #include "platform/EventDispatchForbiddenScope.h"
52 #include "platform/MIMETypeRegistry.h" 52 #include "platform/MIMETypeRegistry.h"
53 #include "platform/RuntimeEnabledFeatures.h" 53 #include "platform/RuntimeEnabledFeatures.h"
54 54
55 namespace blink { 55 namespace blink {
56 56
57 using namespace HTMLNames; 57 using namespace HTMLNames;
58 58
59 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener { 59 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 float candidateDensity = candidate.density(); 244 float candidateDensity = candidate.density();
245 if (candidateDensity >= 0) 245 if (candidateDensity >= 0)
246 m_imageDevicePixelRatio = 1.0 / candidateDensity; 246 m_imageDevicePixelRatio = 1.0 / candidateDensity;
247 if (candidate.resourceWidth() > 0) { 247 if (candidate.resourceWidth() > 0) {
248 m_intrinsicSizingViewportDependant = true; 248 m_intrinsicSizingViewportDependant = true;
249 UseCounter::count(document(), UseCounter::SrcsetWDescriptor); 249 UseCounter::count(document(), UseCounter::SrcsetWDescriptor);
250 } else if (!candidate.srcOrigin()) { 250 } else if (!candidate.srcOrigin()) {
251 UseCounter::count(document(), UseCounter::SrcsetXDescriptor); 251 UseCounter::count(document(), UseCounter::SrcsetXDescriptor);
252 } 252 }
253 if (renderer() && renderer()->isImage()) 253 if (renderer() && renderer()->isImage())
254 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio); 254 toLayoutImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio);
255 } 255 }
256 256
257 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 257 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
258 { 258 {
259 if (name == altAttr || name == titleAttr) { 259 if (name == altAttr || name == titleAttr) {
260 if (userAgentShadowRoot()) { 260 if (userAgentShadowRoot()) {
261 Element* text = userAgentShadowRoot()->getElementById("alttext"); 261 Element* text = userAgentShadowRoot()->getElementById("alttext");
262 String value = altText(); 262 String value = altText();
263 if (text && text->textContent() != value) 263 if (text && text->textContent() != value)
264 text->setTextContent(altText()); 264 text->setTextContent(altText());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 335
336 LayoutObject* HTMLImageElement::createRenderer(const LayoutStyle& style) 336 LayoutObject* HTMLImageElement::createRenderer(const LayoutStyle& style)
337 { 337 {
338 if (style.hasContent()) 338 if (style.hasContent())
339 return LayoutObject::createObject(this, style); 339 return LayoutObject::createObject(this, style);
340 340
341 if (m_useFallbackContent) 341 if (m_useFallbackContent)
342 return new RenderBlockFlow(this); 342 return new RenderBlockFlow(this);
343 343
344 RenderImage* image = new RenderImage(this); 344 LayoutImage* image = new LayoutImage(this);
345 image->setImageResource(RenderImageResource::create()); 345 image->setImageResource(LayoutImageResource::create());
346 image->setImageDevicePixelRatio(m_imageDevicePixelRatio); 346 image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
347 return image; 347 return image;
348 } 348 }
349 349
350 void HTMLImageElement::attach(const AttachContext& context) 350 void HTMLImageElement::attach(const AttachContext& context)
351 { 351 {
352 HTMLElement::attach(context); 352 HTMLElement::attach(context);
353 353
354 if (renderer() && renderer()->isImage()) { 354 if (renderer() && renderer()->isImage()) {
355 RenderImage* renderImage = toRenderImage(renderer()); 355 LayoutImage* layoutImage = toLayoutImage(renderer());
356 RenderImageResource* renderImageResource = renderImage->imageResource(); 356 LayoutImageResource* layoutImageResource = layoutImage->imageResource();
357 if (m_isFallbackImage) { 357 if (m_isFallbackImage) {
358 float deviceScaleFactor = blink::deviceScaleFactor(renderImage->fram e()); 358 float deviceScaleFactor = blink::deviceScaleFactor(layoutImage->fram e());
359 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource:: brokenImage(deviceScaleFactor); 359 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource:: brokenImage(deviceScaleFactor);
360 ImageResource* newImageResource = new ImageResource(brokenImageAndIm ageScaleFactor.first); 360 ImageResource* newImageResource = new ImageResource(brokenImageAndIm ageScaleFactor.first);
361 renderImage->imageResource()->setImageResource(newImageResource); 361 layoutImage->imageResource()->setImageResource(newImageResource);
362 } 362 }
363 if (renderImageResource->hasImage()) 363 if (layoutImageResource->hasImage())
364 return; 364 return;
365 365
366 if (!imageLoader().image() && !renderImageResource->cachedImage()) 366 if (!imageLoader().image() && !layoutImageResource->cachedImage())
367 return; 367 return;
368 renderImageResource->setImageResource(imageLoader().image()); 368 layoutImageResource->setImageResource(imageLoader().image());
369 } 369 }
370 } 370 }
371 371
372 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint) 372 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint)
373 { 373 {
374 if (!m_formWasSetByParser || NodeTraversal::highestAncestorOrSelf(*insertion Point) != NodeTraversal::highestAncestorOrSelf(*m_form.get())) 374 if (!m_formWasSetByParser || NodeTraversal::highestAncestorOrSelf(*insertion Point) != NodeTraversal::highestAncestorOrSelf(*m_form.get()))
375 resetFormOwner(); 375 resetFormOwner();
376 if (m_listener) 376 if (m_listener)
377 document().mediaQueryMatcher().addViewportListener(m_listener); 377 document().mediaQueryMatcher().addViewportListener(m_listener);
378 378
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return FloatSize(image->imageSizeForRenderer(renderer(), 1.0f)); 623 return FloatSize(image->imageSizeForRenderer(renderer(), 1.0f));
624 } 624 }
625 625
626 FloatSize HTMLImageElement::defaultDestinationSize() const 626 FloatSize HTMLImageElement::defaultDestinationSize() const
627 { 627 {
628 ImageResource* image = cachedImage(); 628 ImageResource* image = cachedImage();
629 if (!image) 629 if (!image)
630 return FloatSize(); 630 return FloatSize();
631 LayoutSize size; 631 LayoutSize size;
632 size = image->imageSizeForRenderer(renderer(), 1.0f); 632 size = image->imageSizeForRenderer(renderer(), 1.0f);
633 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth()) 633 if (renderer() && renderer()->isLayoutImage() && image->image() && !image->i mage()->hasRelativeWidth())
634 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); 634 size.scale(toLayoutImage(renderer())->imageDevicePixelRatio());
635 return FloatSize(size); 635 return FloatSize(size);
636 } 636 }
637 637
638 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) 638 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior)
639 { 639 {
640 if (!document().isActive()) 640 if (!document().isActive())
641 return; 641 return;
642 642
643 bool foundURL = false; 643 bool foundURL = false;
644 if (RuntimeEnabledFeatures::pictureEnabled()) { 644 if (RuntimeEnabledFeatures::pictureEnabled()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 ensureUserAgentShadowRoot(); 726 ensureUserAgentShadowRoot();
727 } 727 }
728 728
729 bool HTMLImageElement::isOpaque() const 729 bool HTMLImageElement::isOpaque() const
730 { 730 {
731 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); 731 Image* image = const_cast<HTMLImageElement*>(this)->imageContents();
732 return image && image->currentFrameKnownToBeOpaque(); 732 return image && image->currentFrameKnownToBeOpaque();
733 } 733 }
734 734
735 } 735 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLAreaElement.cpp ('k') | Source/core/html/HTMLImageFallbackHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698