| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
| 4 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved. | |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | |
| 6 * | |
| 7 * This library is free software; you can redistribute it and/or | |
| 8 * modify it under the terms of the GNU Library General Public | |
| 9 * License as published by the Free Software Foundation; either | |
| 10 * version 2 of the License, or (at your option) any later version. | |
| 11 * | |
| 12 * This library is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 * Library General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU Library General Public License | |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 20 * Boston, MA 02110-1301, USA. | |
| 21 * | |
| 22 */ | |
| 23 | |
| 24 #ifndef SKY_ENGINE_CORE_HTML_HTMLIMAGEELEMENT_H_ | |
| 25 #define SKY_ENGINE_CORE_HTML_HTMLIMAGEELEMENT_H_ | |
| 26 | |
| 27 #include "sky/engine/core/html/HTMLElement.h" | |
| 28 #include "sky/engine/core/html/HTMLImageLoader.h" | |
| 29 #include "sky/engine/platform/graphics/GraphicsTypes.h" | |
| 30 #include "sky/engine/wtf/WeakPtr.h" | |
| 31 | |
| 32 namespace blink { | |
| 33 | |
| 34 class ImageCandidate; | |
| 35 class MediaQueryList; | |
| 36 | |
| 37 class HTMLImageElement final : public HTMLElement { | |
| 38 DEFINE_WRAPPERTYPEINFO(); | |
| 39 public: | |
| 40 class ViewportChangeListener; | |
| 41 | |
| 42 static PassRefPtr<HTMLImageElement> create(Document&); | |
| 43 static PassRefPtr<HTMLImageElement> create(Document&, bool createdByParser); | |
| 44 static PassRefPtr<HTMLImageElement> createForJSConstructor(Document&, int wi
dth, int height); | |
| 45 | |
| 46 virtual ~HTMLImageElement(); | |
| 47 | |
| 48 int naturalWidth() const; | |
| 49 int naturalHeight() const; | |
| 50 const String& currentSrc() const; | |
| 51 | |
| 52 ImageResource* cachedImage() const { return imageLoader().image(); } | |
| 53 void setImageResource(ImageResource* i) { imageLoader().setImage(i); }; | |
| 54 | |
| 55 KURL src() const; | |
| 56 void setSrc(const String&); | |
| 57 | |
| 58 bool complete() const; | |
| 59 | |
| 60 bool hasPendingActivity() const { return imageLoader().hasPendingActivity();
} | |
| 61 | |
| 62 virtual bool canContainRangeEndPoint() const override { return false; } | |
| 63 | |
| 64 void addClient(ImageLoaderClient* client) { imageLoader().addClient(client);
} | |
| 65 void removeClient(ImageLoaderClient* client) { imageLoader().removeClient(cl
ient); } | |
| 66 | |
| 67 virtual const AtomicString imageSourceURL() const override; | |
| 68 | |
| 69 protected: | |
| 70 explicit HTMLImageElement(Document&, bool createdByParser = false); | |
| 71 | |
| 72 virtual void didMoveToNewDocument(Document& oldDocument) override; | |
| 73 | |
| 74 private: | |
| 75 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; | |
| 76 | |
| 77 void selectSourceURL(ImageLoader::UpdateFromElementBehavior); | |
| 78 | |
| 79 virtual RenderObject* createRenderer(RenderStyle*) override; | |
| 80 | |
| 81 virtual bool canStartSelection() const override; | |
| 82 | |
| 83 virtual bool isURLAttribute(const Attribute&) const override; | |
| 84 | |
| 85 virtual void insertedInto(ContainerNode*) override; | |
| 86 virtual void removedFrom(ContainerNode*) override; | |
| 87 | |
| 88 void setBestFitURLAndDPRFromImageCandidate(const ImageCandidate&); | |
| 89 HTMLImageLoader& imageLoader() const { return *m_imageLoader; } | |
| 90 void notifyViewportChanged(); | |
| 91 | |
| 92 OwnPtr<HTMLImageLoader> m_imageLoader; | |
| 93 RefPtr<ViewportChangeListener> m_listener; | |
| 94 AtomicString m_bestFitImageURL; | |
| 95 float m_imageDevicePixelRatio; | |
| 96 unsigned m_elementCreatedByParser : 1; | |
| 97 // Intrinsic sizing is viewport dependant if the 'w' descriptor was used for
the picked resource. | |
| 98 unsigned m_intrinsicSizingViewportDependant : 1; | |
| 99 // Effective size is viewport dependant if the sizes attribute's effective s
ize used v* length units. | |
| 100 unsigned m_effectiveSizeViewportDependant : 1; | |
| 101 }; | |
| 102 | |
| 103 } // namespace blink | |
| 104 | |
| 105 #endif // SKY_ENGINE_CORE_HTML_HTMLIMAGEELEMENT_H_ | |
| OLD | NEW |