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