| Index: Source/core/html/ImageDocument.cpp
|
| diff --git a/Source/core/html/ImageDocument.cpp b/Source/core/html/ImageDocument.cpp
|
| index 3b046c42b776a96c12f21e8db08b2c3c6cc979f4..31edf2765cf30189816d0b71928f4ec2cad51fcc 100644
|
| --- a/Source/core/html/ImageDocument.cpp
|
| +++ b/Source/core/html/ImageDocument.cpp
|
| @@ -19,7 +19,7 @@
|
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
| * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| #include "config.h"
|
| @@ -75,7 +75,7 @@ private:
|
|
|
| ImageDocument* m_doc;
|
| };
|
| -
|
| +
|
| class ImageDocumentParser : public RawDataDocumentParser {
|
| public:
|
| static PassRefPtr<ImageDocumentParser> create(ImageDocument* document)
|
| @@ -87,7 +87,7 @@ public:
|
| {
|
| return toImageDocument(RawDataDocumentParser::document());
|
| }
|
| -
|
| +
|
| private:
|
| ImageDocumentParser(ImageDocument* document)
|
| : RawDataDocumentParser(document)
|
| @@ -145,7 +145,7 @@ void ImageDocumentParser::finish()
|
|
|
| document()->finishedParsing();
|
| }
|
| -
|
| +
|
| // --------
|
|
|
| ImageDocument::ImageDocument(const DocumentInit& initializer)
|
| @@ -158,7 +158,7 @@ ImageDocument::ImageDocument(const DocumentInit& initializer)
|
| setCompatibilityMode(QuirksMode);
|
| lockCompatibilityMode();
|
| }
|
| -
|
| +
|
| PassRefPtr<DocumentParser> ImageDocument::createParser()
|
| {
|
| return ImageDocumentParser::create(this);
|
| @@ -211,7 +211,7 @@ float ImageDocument::scale() const
|
|
|
| LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
|
| LayoutSize windowSize = LayoutSize(view->width(), view->height());
|
| -
|
| +
|
| float widthScale = (float)windowSize.width() / imageSize.width();
|
| float heightScale = (float)windowSize.height() / imageSize.height();
|
|
|
| @@ -228,7 +228,7 @@ void ImageDocument::resizeImageToFit()
|
| float scale = this->scale();
|
| m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
|
| m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
|
| -
|
| +
|
| m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomIn);
|
| }
|
|
|
| @@ -238,19 +238,19 @@ void ImageDocument::imageClicked(int x, int y)
|
| return;
|
|
|
| m_shouldShrinkImage = !m_shouldShrinkImage;
|
| -
|
| +
|
| if (m_shouldShrinkImage)
|
| windowSizeChanged();
|
| else {
|
| restoreImageSize();
|
| -
|
| +
|
| updateLayout();
|
| -
|
| +
|
| float scale = this->scale();
|
| -
|
| +
|
| int scrollX = static_cast<int>(x / scale - (float)frame()->view()->width() / 2);
|
| int scrollY = static_cast<int>(y / scale - (float)frame()->view()->height() / 2);
|
| -
|
| +
|
| frame()->view()->setScrollPosition(IntPoint(scrollX, scrollY));
|
| }
|
| }
|
| @@ -258,15 +258,15 @@ void ImageDocument::imageClicked(int x, int y)
|
| void ImageDocument::imageUpdated()
|
| {
|
| ASSERT(m_imageElement);
|
| -
|
| +
|
| if (m_imageSizeIsKnown)
|
| return;
|
|
|
| if (m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this)).isEmpty())
|
| return;
|
| -
|
| +
|
| m_imageSizeIsKnown = true;
|
| -
|
| +
|
| if (shouldShrinkToFit()) {
|
| // Force resizing of the image
|
| windowSizeChanged();
|
| @@ -277,16 +277,16 @@ void ImageDocument::restoreImageSize()
|
| {
|
| if (!m_imageElement || !m_imageSizeIsKnown || m_imageElement->document() != this)
|
| return;
|
| -
|
| +
|
| LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), 1.0f);
|
| m_imageElement->setWidth(imageSize.width());
|
| m_imageElement->setHeight(imageSize.height());
|
| -
|
| +
|
| if (imageFitsInWindow())
|
| m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
|
| else
|
| m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomOut);
|
| -
|
| +
|
| m_didShrinkImage = false;
|
| }
|
|
|
| @@ -301,8 +301,8 @@ bool ImageDocument::imageFitsInWindow() const
|
|
|
| LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
|
| LayoutSize windowSize = LayoutSize(view->width(), view->height());
|
| -
|
| - return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
|
| +
|
| + return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
|
| }
|
|
|
| void ImageDocument::windowSizeChanged()
|
| @@ -311,7 +311,7 @@ void ImageDocument::windowSizeChanged()
|
| return;
|
|
|
| bool fitsInWindow = imageFitsInWindow();
|
| -
|
| +
|
| // If the image has been explicitly zoomed in, restore the cursor if the image fits
|
| // and set it to a zoom out cursor if the image doesn't fit
|
| if (!m_shouldShrinkImage) {
|
| @@ -321,7 +321,7 @@ void ImageDocument::windowSizeChanged()
|
| m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomOut);
|
| return;
|
| }
|
| -
|
| +
|
| if (m_didShrinkImage) {
|
| // If the window has been resized so that the image fits, restore the image size
|
| // otherwise update the restored image size.
|
| @@ -339,10 +339,10 @@ void ImageDocument::windowSizeChanged()
|
| }
|
|
|
| CachedImage* ImageDocument::cachedImage()
|
| -{
|
| +{
|
| if (!m_imageElement)
|
| createDocumentStructure();
|
| -
|
| +
|
| return m_imageElement->cachedImage();
|
| }
|
|
|
|
|