| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 class ImageResource; | 34 class ImageResource; |
| 35 | 35 |
| 36 class CORE_EXPORT ImageDocument final : public HTMLDocument { | 36 class CORE_EXPORT ImageDocument final : public HTMLDocument { |
| 37 public: | 37 public: |
| 38 static ImageDocument* create(const DocumentInit& initializer = DocumentInit(
)) | 38 static ImageDocument* create(const DocumentInit& initializer = DocumentInit(
)) |
| 39 { | 39 { |
| 40 return new ImageDocument(initializer); | 40 return new ImageDocument(initializer); |
| 41 } | 41 } |
| 42 | 42 |
| 43 enum ScaleType { | |
| 44 ScaleZoomedDocument, | |
| 45 ScaleOnlyUnzoomedDocument | |
| 46 }; | |
| 47 | |
| 48 ImageResource* cachedImage(); | 43 ImageResource* cachedImage(); |
| 49 HTMLImageElement* imageElement() const { return m_imageElement.get(); } | 44 HTMLImageElement* imageElement() const { return m_imageElement.get(); } |
| 50 | 45 |
| 51 void windowSizeChanged(ScaleType); | 46 void windowSizeChanged(); |
| 52 void imageUpdated(); | 47 void imageUpdated(); |
| 53 void imageClicked(int x, int y); | 48 void imageClicked(int x, int y); |
| 54 | 49 |
| 55 DECLARE_VIRTUAL_TRACE(); | 50 DECLARE_VIRTUAL_TRACE(); |
| 56 | 51 |
| 57 private: | 52 private: |
| 58 explicit ImageDocument(const DocumentInit&); | 53 explicit ImageDocument(const DocumentInit&); |
| 59 | 54 |
| 60 DocumentParser* createParser() override; | 55 DocumentParser* createParser() override; |
| 61 | 56 |
| 62 void createDocumentStructure(); | 57 void createDocumentStructure(); |
| 63 | 58 |
| 64 // These methods are for m_shrinkToFitMode == Desktop. | 59 // These methods are for m_shrinkToFitMode == Desktop. |
| 65 void resizeImageToFit(ScaleType); | 60 void resizeImageToFit(); |
| 66 void restoreImageSize(ScaleType); | 61 void restoreImageSize(); |
| 67 bool imageFitsInWindow() const; | 62 bool imageFitsInWindow() const; |
| 68 bool shouldShrinkToFit() const; | 63 bool shouldShrinkToFit() const; |
| 64 // Calculates the image size multiplier that's needed to fit the image to |
| 65 // the window, taking into account page zoom and device scale. |
| 69 float scale() const; | 66 float scale() const; |
| 70 | 67 |
| 71 Member<HTMLImageElement> m_imageElement; | 68 Member<HTMLImageElement> m_imageElement; |
| 72 | 69 |
| 73 // Whether enough of the image has been loaded to determine its size | 70 // Whether enough of the image has been loaded to determine its size |
| 74 bool m_imageSizeIsKnown; | 71 bool m_imageSizeIsKnown; |
| 75 | 72 |
| 76 // Whether the image is shrunk to fit or not | 73 // Whether the image is shrunk to fit or not |
| 77 bool m_didShrinkImage; | 74 bool m_didShrinkImage; |
| 78 | 75 |
| 79 // Whether the image should be shrunk or not | 76 // Whether the image should be shrunk or not |
| 80 bool m_shouldShrinkImage; | 77 bool m_shouldShrinkImage; |
| 81 | 78 |
| 82 enum ShrinkToFitMode { | 79 enum ShrinkToFitMode { |
| 83 Viewport, | 80 Viewport, |
| 84 Desktop | 81 Desktop |
| 85 }; | 82 }; |
| 86 ShrinkToFitMode m_shrinkToFitMode; | 83 ShrinkToFitMode m_shrinkToFitMode; |
| 87 }; | 84 }; |
| 88 | 85 |
| 89 DEFINE_DOCUMENT_TYPE_CASTS(ImageDocument); | 86 DEFINE_DOCUMENT_TYPE_CASTS(ImageDocument); |
| 90 | 87 |
| 91 } // namespace blink | 88 } // namespace blink |
| 92 | 89 |
| 93 #endif // ImageDocument_h | 90 #endif // ImageDocument_h |
| OLD | NEW |