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 * 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 Loading... |
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 Loading... |
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 { |
347 HTMLElement::attach(context); | 349 HTMLElement::attach(context); |
348 | 350 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 const KURL& HTMLImageElement::sourceURL() const | 694 const KURL& HTMLImageElement::sourceURL() const |
693 { | 695 { |
694 return cachedImage()->response().url(); | 696 return cachedImage()->response().url(); |
695 } | 697 } |
696 | 698 |
697 void HTMLImageElement::didAddUserAgentShadowRoot(ShadowRoot&) | 699 void HTMLImageElement::didAddUserAgentShadowRoot(ShadowRoot&) |
698 { | 700 { |
699 HTMLImageFallbackHelper::createAltTextShadowTree(*this); | 701 HTMLImageFallbackHelper::createAltTextShadowTree(*this); |
700 } | 702 } |
701 | 703 |
| 704 void HTMLImageElement::ensureFallbackForGeneratedContent() |
| 705 { |
| 706 setUseFallbackContent(); |
| 707 reattachFallbackContent(); |
| 708 } |
| 709 |
702 void HTMLImageElement::ensureFallbackContent() | 710 void HTMLImageElement::ensureFallbackContent() |
703 { | 711 { |
704 if (m_useFallbackContent || m_isFallbackImage) | 712 if (m_useFallbackContent || m_isFallbackImage) |
705 return; | 713 return; |
706 setUseFallbackContent(); | 714 setUseFallbackContent(); |
707 reattachFallbackContent(); | 715 reattachFallbackContent(); |
708 } | 716 } |
709 | 717 |
710 void HTMLImageElement::ensurePrimaryContent() | 718 void HTMLImageElement::ensurePrimaryContent() |
711 { | 719 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 ensureUserAgentShadowRoot(); | 753 ensureUserAgentShadowRoot(); |
746 } | 754 } |
747 | 755 |
748 bool HTMLImageElement::isOpaque() const | 756 bool HTMLImageElement::isOpaque() const |
749 { | 757 { |
750 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 758 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
751 return image && image->currentFrameKnownToBeOpaque(); | 759 return image && image->currentFrameKnownToBeOpaque(); |
752 } | 760 } |
753 | 761 |
754 } | 762 } |
OLD | NEW |