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

Unified Diff: Source/core/html/ImageDocument.cpp

Issue 262053005: Allow zoom/restore in a zoomed document. It is a regression from an earlier fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased code Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/ImageDocument.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/ImageDocument.cpp
diff --git a/Source/core/html/ImageDocument.cpp b/Source/core/html/ImageDocument.cpp
index 417332d4d7b9dbc56dd798c70d5bb89392691ab8..eef84394aa9402bfd3dfad2b50ccf5de8f9caf8d 100644
--- a/Source/core/html/ImageDocument.cpp
+++ b/Source/core/html/ImageDocument.cpp
@@ -233,9 +233,9 @@ float ImageDocument::scale() const
return min(widthScale, heightScale);
}
-void ImageDocument::resizeImageToFit()
+void ImageDocument::resizeImageToFit(ScaleType type)
{
- if (!m_imageElement || m_imageElement->document() != this || pageZoomFactor(this) > 1)
+ if (!m_imageElement || m_imageElement->document() != this || (pageZoomFactor(this) > 1 && type == ScaleOnlyUnzoomedDocument))
return;
LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
@@ -255,9 +255,9 @@ void ImageDocument::imageClicked(int x, int y)
m_shouldShrinkImage = !m_shouldShrinkImage;
if (m_shouldShrinkImage)
- windowSizeChanged();
+ windowSizeChanged(ScaleZoomedDocument);
else {
- restoreImageSize();
+ restoreImageSize(ScaleZoomedDocument);
updateLayout();
@@ -284,13 +284,13 @@ void ImageDocument::imageUpdated()
if (shouldShrinkToFit()) {
// Force resizing of the image
- windowSizeChanged();
+ windowSizeChanged(ScaleOnlyUnzoomedDocument);
}
}
-void ImageDocument::restoreImageSize()
+void ImageDocument::restoreImageSize(ScaleType type)
{
- if (!m_imageElement || !m_imageSizeIsKnown || m_imageElement->document() != this || pageZoomFactor(this) < 1)
+ if (!m_imageElement || !m_imageSizeIsKnown || m_imageElement->document() != this || (pageZoomFactor(this) < 1 && type == ScaleOnlyUnzoomedDocument))
return;
LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), 1.0f);
@@ -320,7 +320,7 @@ bool ImageDocument::imageFitsInWindow() const
return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
}
-void ImageDocument::windowSizeChanged()
+void ImageDocument::windowSizeChanged(ScaleType type)
{
if (!m_imageElement || !m_imageSizeIsKnown || m_imageElement->document() != this)
return;
@@ -341,13 +341,13 @@ void ImageDocument::windowSizeChanged()
// If the window has been resized so that the image fits, restore the image size
// otherwise update the restored image size.
if (fitsInWindow)
- restoreImageSize();
+ restoreImageSize(type);
else
- resizeImageToFit();
+ resizeImageToFit(type);
} else {
// If the image isn't resized but needs to be, then resize it.
if (!fitsInWindow) {
- resizeImageToFit();
+ resizeImageToFit(type);
m_didShrinkImage = true;
}
}
@@ -385,7 +385,7 @@ void ImageDocument::trace(Visitor* visitor)
void ImageEventListener::handleEvent(ExecutionContext*, Event* event)
{
if (event->type() == EventTypeNames::resize)
- m_doc->windowSizeChanged();
+ m_doc->windowSizeChanged(ImageDocument::ScaleOnlyUnzoomedDocument);
else if (event->type() == EventTypeNames::click && event->isMouseEvent()) {
MouseEvent* mouseEvent = toMouseEvent(event);
m_doc->imageClicked(mouseEvent->x(), mouseEvent->y());
« no previous file with comments | « Source/core/html/ImageDocument.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698