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

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

Issue 1277013005: Images from content:url() aren't loading if the alt attribute is present (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 4 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 | Annotate | Revision Log
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 28 matching lines...) Expand all
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/parser/HTMLParserIdioms.h" 43 #include "core/html/parser/HTMLParserIdioms.h"
44 #include "core/html/parser/HTMLSrcsetParser.h" 44 #include "core/html/parser/HTMLSrcsetParser.h"
45 #include "core/inspector/ConsoleMessage.h" 45 #include "core/inspector/ConsoleMessage.h"
46 #include "core/layout/LayoutBlockFlow.h" 46 #include "core/layout/LayoutBlockFlow.h"
47 #include "core/layout/LayoutImage.h" 47 #include "core/layout/LayoutImage.h"
48 #include "core/page/Page.h" 48 #include "core/page/Page.h"
49 #include "core/style/ContentData.h"
49 #include "platform/ContentType.h" 50 #include "platform/ContentType.h"
50 #include "platform/EventDispatchForbiddenScope.h" 51 #include "platform/EventDispatchForbiddenScope.h"
51 #include "platform/MIMETypeRegistry.h" 52 #include "platform/MIMETypeRegistry.h"
52 #include "platform/RuntimeEnabledFeatures.h" 53 #include "platform/RuntimeEnabledFeatures.h"
53 54
54 namespace blink { 55 namespace blink {
55 56
56 using namespace HTMLNames; 57 using namespace HTMLNames;
57 58
58 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener { 59 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ImageCandidate candidate = bestFitSourceForSrcsetAttribute(document().de vicePixelRatio(), sourceSize(*source), source->fastGetAttribute(srcsetAttr), &do cument()); 324 ImageCandidate candidate = bestFitSourceForSrcsetAttribute(document().de vicePixelRatio(), sourceSize(*source), source->fastGetAttribute(srcsetAttr), &do cument());
324 if (candidate.isEmpty()) 325 if (candidate.isEmpty())
325 continue; 326 continue;
326 return candidate; 327 return candidate;
327 } 328 }
328 return ImageCandidate(); 329 return ImageCandidate();
329 } 330 }
330 331
331 LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style) 332 LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style)
332 { 333 {
334 const ContentData* contentData = style.contentData();
335 if (contentData && contentData->isImage() && !toImageContentData(contentData )->image()->cachedImage()->errorOccurred())
336 return LayoutObject::createObject(this, style);
337
333 if (m_useFallbackContent) 338 if (m_useFallbackContent)
334 return new LayoutBlockFlow(this); 339 return new LayoutBlockFlow(this);
335 340
336 if (style.hasContent())
337 return LayoutObject::createObject(this, style);
338
339 LayoutImage* image = new LayoutImage(this); 341 LayoutImage* image = new LayoutImage(this);
340 image->setImageResource(LayoutImageResource::create()); 342 image->setImageResource(LayoutImageResource::create());
341 image->setImageDevicePixelRatio(m_imageDevicePixelRatio); 343 image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
342 return image; 344 return image;
343 } 345 }
344 346
345 void HTMLImageElement::attach(const AttachContext& context) 347 void HTMLImageElement::attach(const AttachContext& context)
346 { 348 {
349
pdr. 2015/08/11 20:48:29 Nit: extra space
347 HTMLElement::attach(context); 350 HTMLElement::attach(context);
348 351
349 if (layoutObject() && layoutObject()->isImage()) { 352 if (layoutObject() && layoutObject()->isImage()) {
350 LayoutImage* layoutImage = toLayoutImage(layoutObject()); 353 LayoutImage* layoutImage = toLayoutImage(layoutObject());
351 LayoutImageResource* layoutImageResource = layoutImage->imageResource(); 354 LayoutImageResource* layoutImageResource = layoutImage->imageResource();
352 if (m_isFallbackImage) { 355 if (m_isFallbackImage) {
353 float deviceScaleFactor = blink::deviceScaleFactor(layoutImage->fram e()); 356 float deviceScaleFactor = blink::deviceScaleFactor(layoutImage->fram e());
354 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource:: brokenImage(deviceScaleFactor); 357 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource:: brokenImage(deviceScaleFactor);
355 ImageResource* newImageResource = new ImageResource(brokenImageAndIm ageScaleFactor.first); 358 ImageResource* newImageResource = new ImageResource(brokenImageAndIm ageScaleFactor.first);
356 layoutImage->imageResource()->setImageResource(newImageResource); 359 layoutImage->imageResource()->setImageResource(newImageResource);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 const KURL& HTMLImageElement::sourceURL() const 695 const KURL& HTMLImageElement::sourceURL() const
693 { 696 {
694 return cachedImage()->response().url(); 697 return cachedImage()->response().url();
695 } 698 }
696 699
697 void HTMLImageElement::didAddUserAgentShadowRoot(ShadowRoot&) 700 void HTMLImageElement::didAddUserAgentShadowRoot(ShadowRoot&)
698 { 701 {
699 HTMLImageFallbackHelper::createAltTextShadowTree(*this); 702 HTMLImageFallbackHelper::createAltTextShadowTree(*this);
700 } 703 }
701 704
705 void HTMLImageElement::ensureFallbackForGeneratedContent()
706 {
707 setUseFallbackContent();
708 reattachFallbackContent();
709 }
710
702 void HTMLImageElement::ensureFallbackContent() 711 void HTMLImageElement::ensureFallbackContent()
703 { 712 {
704 if (m_useFallbackContent || m_isFallbackImage) 713 if (m_useFallbackContent || m_isFallbackImage)
705 return; 714 return;
706 setUseFallbackContent(); 715 setUseFallbackContent();
707 reattachFallbackContent(); 716 reattachFallbackContent();
708 } 717 }
709 718
710 void HTMLImageElement::ensurePrimaryContent() 719 void HTMLImageElement::ensurePrimaryContent()
711 { 720 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 ensureUserAgentShadowRoot(); 754 ensureUserAgentShadowRoot();
746 } 755 }
747 756
748 bool HTMLImageElement::isOpaque() const 757 bool HTMLImageElement::isOpaque() const
749 { 758 {
750 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); 759 Image* image = const_cast<HTMLImageElement*>(this)->imageContents();
751 return image && image->currentFrameKnownToBeOpaque(); 760 return image && image->currentFrameKnownToBeOpaque();
752 } 761 }
753 762
754 } 763 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698