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

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

Issue 481753002: Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 2 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, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved.
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 16 matching lines...) Expand all
27 #include "core/html/HTMLElement.h" 27 #include "core/html/HTMLElement.h"
28 #include "core/html/HTMLImageLoader.h" 28 #include "core/html/HTMLImageLoader.h"
29 #include "core/html/canvas/CanvasImageSource.h" 29 #include "core/html/canvas/CanvasImageSource.h"
30 #include "platform/graphics/GraphicsTypes.h" 30 #include "platform/graphics/GraphicsTypes.h"
31 #include "wtf/WeakPtr.h" 31 #include "wtf/WeakPtr.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 class HTMLFormElement; 35 class HTMLFormElement;
36 class ImageCandidate; 36 class ImageCandidate;
37 class ShadowRoot;
37 38
38 class HTMLImageElement FINAL : public HTMLElement, public CanvasImageSource { 39 class HTMLImageElement FINAL : public HTMLElement, public CanvasImageSource {
39 DEFINE_WRAPPERTYPEINFO(); 40 DEFINE_WRAPPERTYPEINFO();
40 public: 41 public:
41 class ViewportChangeListener; 42 class ViewportChangeListener;
42 43
43 static PassRefPtrWillBeRawPtr<HTMLImageElement> create(Document&); 44 static PassRefPtrWillBeRawPtr<HTMLImageElement> create(Document&);
44 static PassRefPtrWillBeRawPtr<HTMLImageElement> create(Document&, HTMLFormEl ement*, bool createdByParser); 45 static PassRefPtrWillBeRawPtr<HTMLImageElement> create(Document&, HTMLFormEl ement*, bool createdByParser);
45 static PassRefPtrWillBeRawPtr<HTMLImageElement> createForJSConstructor(Docum ent&, int width, int height); 46 static PassRefPtrWillBeRawPtr<HTMLImageElement> createForJSConstructor(Docum ent&, int width, int height);
46 47
47 virtual ~HTMLImageElement(); 48 virtual ~HTMLImageElement();
48 virtual void trace(Visitor*) OVERRIDE; 49 virtual void trace(Visitor*) OVERRIDE;
49 50
50 int width(bool ignorePendingStylesheets = false); 51 int width(bool ignorePendingStylesheets = false);
51 int height(bool ignorePendingStylesheets = false); 52 int height(bool ignorePendingStylesheets = false);
52 53
53 int naturalWidth() const; 54 int naturalWidth() const;
54 int naturalHeight() const; 55 int naturalHeight() const;
55 const String& currentSrc() const; 56 const String& currentSrc() const;
56 57
57 bool isServerMap() const; 58 bool isServerMap() const;
58 59
59 const AtomicString& altText() const; 60 virtual String altText() const OVERRIDE FINAL;
60 61
61 CompositeOperator compositeOperator() const { return m_compositeOperator; } 62 CompositeOperator compositeOperator() const { return m_compositeOperator; }
62 63
63 ImageResource* cachedImage() const { return imageLoader().image(); } 64 ImageResource* cachedImage() const { return imageLoader().image(); }
64 void setImageResource(ImageResource* i) { imageLoader().setImage(i); }; 65 void setImageResource(ImageResource* i) { imageLoader().setImage(i); };
65 66
66 void setLoadingImageDocument() { imageLoader().setLoadingImageDocument(); } 67 void setLoadingImageDocument() { imageLoader().setLoadingImageDocument(); }
67 68
68 void setHeight(int); 69 void setHeight(int);
69 70
(...skipping 11 matching lines...) Expand all
81 82
82 virtual bool canContainRangeEndPoint() const OVERRIDE { return false; } 83 virtual bool canContainRangeEndPoint() const OVERRIDE { return false; }
83 84
84 void addClient(ImageLoaderClient* client) { imageLoader().addClient(client); } 85 void addClient(ImageLoaderClient* client) { imageLoader().addClient(client); }
85 void removeClient(ImageLoaderClient* client) { imageLoader().removeClient(cl ient); } 86 void removeClient(ImageLoaderClient* client) { imageLoader().removeClient(cl ient); }
86 87
87 virtual const AtomicString imageSourceURL() const OVERRIDE; 88 virtual const AtomicString imageSourceURL() const OVERRIDE;
88 89
89 virtual HTMLFormElement* formOwner() const OVERRIDE; 90 virtual HTMLFormElement* formOwner() const OVERRIDE;
90 void formRemovedFromTree(const Node& formRoot); 91 void formRemovedFromTree(const Node& formRoot);
92 virtual void ensureFallbackContent() OVERRIDE FINAL;
93 virtual void ensurePrimaryContent() OVERRIDE FINAL;
91 94
92 // CanvasImageSourceImplementations 95 // CanvasImageSourceImplementations
93 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma geStatus*) const; 96 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma geStatus*) const;
94 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; 97 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE;
95 virtual FloatSize sourceSize() const OVERRIDE; 98 virtual FloatSize sourceSize() const OVERRIDE;
96 virtual FloatSize defaultDestinationSize() const OVERRIDE; 99 virtual FloatSize defaultDestinationSize() const OVERRIDE;
97 virtual const KURL& sourceURL() const OVERRIDE; 100 virtual const KURL& sourceURL() const OVERRIDE;
98 101
99 // public so that HTMLPictureElement can call this as well. 102 // public so that HTMLPictureElement can call this as well.
100 void selectSourceURL(ImageLoader::UpdateFromElementBehavior); 103 void selectSourceURL(ImageLoader::UpdateFromElementBehavior);
104 void reattachFallbackContent();
105 void setUseFallbackContent() { m_useFallbackContent = true; ensureUserAgentS hadowRoot(); }
106 void setIsFallbackImage() { m_isFallbackImage = true; }
107
101 protected: 108 protected:
102 explicit HTMLImageElement(Document&, HTMLFormElement* = 0, bool createdByPar ser = false); 109 explicit HTMLImageElement(Document&, HTMLFormElement* = 0, bool createdByPar ser = false);
103 110
104 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; 111 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
112 virtual bool useFallbackContent() const { return m_useFallbackContent; }
105 113
114 virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE;
115 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
106 private: 116 private:
107 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } 117 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
108 118
109 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; 119 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
110 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 120 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
111 virtual void collectStyleForPresentationAttribute(const QualifiedName&, cons t AtomicString&, MutableStylePropertySet*) OVERRIDE; 121 virtual void collectStyleForPresentationAttribute(const QualifiedName&, cons t AtomicString&, MutableStylePropertySet*) OVERRIDE;
112 122
113 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; 123 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
114 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 124 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
115 125
(...skipping 28 matching lines...) Expand all
144 #endif 154 #endif
145 CompositeOperator m_compositeOperator; 155 CompositeOperator m_compositeOperator;
146 AtomicString m_bestFitImageURL; 156 AtomicString m_bestFitImageURL;
147 float m_imageDevicePixelRatio; 157 float m_imageDevicePixelRatio;
148 unsigned m_formWasSetByParser : 1; 158 unsigned m_formWasSetByParser : 1;
149 unsigned m_elementCreatedByParser : 1; 159 unsigned m_elementCreatedByParser : 1;
150 // Intrinsic sizing is viewport dependant if the 'w' descriptor was used for the picked resource. 160 // Intrinsic sizing is viewport dependant if the 'w' descriptor was used for the picked resource.
151 unsigned m_intrinsicSizingViewportDependant : 1; 161 unsigned m_intrinsicSizingViewportDependant : 1;
152 // Effective size is viewport dependant if the sizes attribute's effective s ize used v* length units. 162 // Effective size is viewport dependant if the sizes attribute's effective s ize used v* length units.
153 unsigned m_effectiveSizeViewportDependant : 1; 163 unsigned m_effectiveSizeViewportDependant : 1;
164 unsigned m_useFallbackContent : 1;
165 unsigned m_isFallbackImage : 1;
154 }; 166 };
155 167
156 } // namespace blink 168 } // namespace blink
157 169
158 #endif // HTMLImageElement_h 170 #endif // HTMLImageElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698