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

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 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 ImageResource* cachedImage() const { return imageLoader().image(); } 62 ImageResource* cachedImage() const { return imageLoader().image(); }
62 void setImageResource(ImageResource* i) { imageLoader().setImage(i); }; 63 void setImageResource(ImageResource* i) { imageLoader().setImage(i); };
63 64
64 void setLoadingImageDocument() { imageLoader().setLoadingImageDocument(); } 65 void setLoadingImageDocument() { imageLoader().setLoadingImageDocument(); }
65 66
66 void setHeight(int); 67 void setHeight(int);
67 68
68 KURL src() const; 69 KURL src() const;
69 void setSrc(const String&); 70 void setSrc(const String&);
70 71
71 void setWidth(int); 72 void setWidth(int);
72 73
73 int x() const; 74 int x() const;
74 int y() const; 75 int y() const;
75 76
76 bool complete() const; 77 bool complete() const;
77 78
78 bool hasPendingActivity() const { return imageLoader().hasPendingActivity(); } 79 bool hasPendingActivity() const { return imageLoader().hasPendingActivity(); }
79 80
80 virtual bool canContainRangeEndPoint() const override { return false; } 81 virtual bool canContainRangeEndPoint() const override { return false; }
81 82
82 void addClient(ImageLoaderClient* client) { imageLoader().addClient(client); } 83 void addClient(ImageLoaderClient* client) { imageLoader().addClient(client); }
83 void removeClient(ImageLoaderClient* client) { imageLoader().removeClient(cl ient); } 84 void removeClient(ImageLoaderClient* client) { imageLoader().removeClient(cl ient); }
84 85
85 virtual const AtomicString imageSourceURL() const override; 86 virtual const AtomicString imageSourceURL() const override;
86 87
87 virtual HTMLFormElement* formOwner() const override; 88 virtual HTMLFormElement* formOwner() const override;
88 void formRemovedFromTree(const Node& formRoot); 89 void formRemovedFromTree(const Node& formRoot);
90 virtual void ensureFallbackContent();
91 virtual void ensurePrimaryContent();
89 92
90 // CanvasImageSourceImplementations 93 // CanvasImageSourceImplementations
91 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma geStatus*) const override; 94 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma geStatus*) const override;
92 virtual bool wouldTaintOrigin(SecurityOrigin*) const override; 95 virtual bool wouldTaintOrigin(SecurityOrigin*) const override;
93 virtual FloatSize sourceSize() const override; 96 virtual FloatSize sourceSize() const override;
94 virtual FloatSize defaultDestinationSize() const override; 97 virtual FloatSize defaultDestinationSize() const override;
95 virtual const KURL& sourceURL() const override; 98 virtual const KURL& sourceURL() const override;
96 99
97 // public so that HTMLPictureElement can call this as well. 100 // public so that HTMLPictureElement can call this as well.
98 void selectSourceURL(ImageLoader::UpdateFromElementBehavior); 101 void selectSourceURL(ImageLoader::UpdateFromElementBehavior);
102 void reattachFallbackContent();
103 void setUseFallbackContent();
104 void setIsFallbackImage() { m_isFallbackImage = true; }
105
99 protected: 106 protected:
100 explicit HTMLImageElement(Document&, HTMLFormElement* = 0, bool createdByPar ser = false); 107 explicit HTMLImageElement(Document&, HTMLFormElement* = 0, bool createdByPar ser = false);
101 108
102 virtual void didMoveToNewDocument(Document& oldDocument) override; 109 virtual void didMoveToNewDocument(Document& oldDocument) override;
110 virtual bool useFallbackContent() const { return m_useFallbackContent; }
103 111
112 virtual void didAddUserAgentShadowRoot(ShadowRoot&) override;
113 virtual PassRefPtr<RenderStyle> customStyleForRenderer() override;
104 private: 114 private:
105 virtual bool areAuthorShadowsAllowed() const override { return false; } 115 virtual bool areAuthorShadowsAllowed() const override { return false; }
106 116
107 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr ide; 117 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr ide;
108 virtual bool isPresentationAttribute(const QualifiedName&) const override; 118 virtual bool isPresentationAttribute(const QualifiedName&) const override;
109 virtual void collectStyleForPresentationAttribute(const QualifiedName&, cons t AtomicString&, MutableStylePropertySet*) override; 119 virtual void collectStyleForPresentationAttribute(const QualifiedName&, cons t AtomicString&, MutableStylePropertySet*) override;
110 120
111 virtual void attach(const AttachContext& = AttachContext()) override; 121 virtual void attach(const AttachContext& = AttachContext()) override;
112 virtual RenderObject* createRenderer(RenderStyle*) override; 122 virtual RenderObject* createRenderer(RenderStyle*) override;
113 123
(...skipping 25 matching lines...) Expand all
139 Member<HTMLFormElement> m_form; 149 Member<HTMLFormElement> m_form;
140 #else 150 #else
141 WeakPtr<HTMLFormElement> m_form; 151 WeakPtr<HTMLFormElement> m_form;
142 #endif 152 #endif
143 AtomicString m_bestFitImageURL; 153 AtomicString m_bestFitImageURL;
144 float m_imageDevicePixelRatio; 154 float m_imageDevicePixelRatio;
145 unsigned m_formWasSetByParser : 1; 155 unsigned m_formWasSetByParser : 1;
146 unsigned m_elementCreatedByParser : 1; 156 unsigned m_elementCreatedByParser : 1;
147 // Intrinsic sizing is viewport dependant if the 'w' descriptor was used for the picked resource. 157 // Intrinsic sizing is viewport dependant if the 'w' descriptor was used for the picked resource.
148 unsigned m_intrinsicSizingViewportDependant : 1; 158 unsigned m_intrinsicSizingViewportDependant : 1;
159 unsigned m_useFallbackContent : 1;
160 unsigned m_isFallbackImage : 1;
149 }; 161 };
150 162
151 } // namespace blink 163 } // namespace blink
152 164
153 #endif // HTMLImageElement_h 165 #endif // HTMLImageElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698