Bug 812899 part 1. Split the "image is overflow" concept in ImageDocument into two separate booleans for vertical and horizontal overflow. r=khuey

This commit is contained in:
Boris Zbarsky 2016-02-05 23:31:09 -05:00
parent 5fd2f2accc
commit f155474462
2 changed files with 11 additions and 10 deletions

View File

@ -413,7 +413,7 @@ ImageDocument::RestoreImage()
imageContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::width, true);
imageContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::height, true);
if (mImageIsOverflowing) {
if (ImageIsOverflowing()) {
SetModeClass(eOverflowing);
}
else {
@ -441,7 +441,7 @@ ImageDocument::ToggleImageSize()
ResetZoomLevel();
RestoreImage();
}
else if (mImageIsOverflowing) {
else if (ImageIsOverflowing()) {
ResetZoomLevel();
ShrinkToFit();
}
@ -579,7 +579,7 @@ ImageDocument::HandleEvent(nsIDOMEvent* aEvent)
mShouldResize = false;
RestoreImageTo(x, y);
}
else if (mImageIsOverflowing) {
else if (ImageIsOverflowing()) {
ShrinkToFit();
}
} else if (eventType.EqualsLiteral("load")) {
@ -681,14 +681,14 @@ ImageDocument::CheckOverflowing(bool changeState)
mVisibleHeight = nsPresContext::AppUnitsToFloatCSSPixels(visibleArea.height);
}
bool imageWasOverflowing = mImageIsOverflowing;
mImageIsOverflowing =
mImageWidth > mVisibleWidth || mImageHeight > mVisibleHeight;
bool windowBecameBigEnough = imageWasOverflowing && !mImageIsOverflowing;
bool imageWasOverflowing = ImageIsOverflowing();
mImageIsOverflowingHorizontally = mImageWidth > mVisibleWidth;
mImageIsOverflowingVertically = mImageHeight > mVisibleHeight;
bool windowBecameBigEnough = imageWasOverflowing && !ImageIsOverflowing();
if (changeState || mShouldResize || mFirstResize ||
windowBecameBigEnough) {
if (mImageIsOverflowing && (changeState || mShouldResize)) {
if (ImageIsOverflowing() && (changeState || mShouldResize)) {
ShrinkToFit();
}
else if (mImageIsResized || mFirstResize || windowBecameBigEnough) {

View File

@ -62,7 +62,7 @@ public:
}
bool ImageIsOverflowing() const
{
return mImageIsOverflowing;
return mImageIsOverflowingHorizontally || mImageIsOverflowingVertically;
}
bool ImageIsResized() const
{
@ -118,7 +118,8 @@ protected:
bool mResizeImageByDefault;
bool mClickResizingEnabled;
bool mImageIsOverflowing;
bool mImageIsOverflowingHorizontally;
bool mImageIsOverflowingVertically;
// mImageIsResized is true if the image is currently resized
bool mImageIsResized;
// mShouldResize is true if the image should be resized when it doesn't fit