From 1a7f7cb197d087a725b2200049344dcc24545af9 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 4 Sep 2014 13:42:25 -0700 Subject: [PATCH] Fixed: CSS style background-size doesn't change its value when changing frameSize Previously, when changing the frameSize of a CPView, the style background-size wasn't changed with. This raised issue with threePartImage. Fixed #2187 --- AppKit/CPView.j | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index e16b0427a..d5adb6c43 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -1024,7 +1024,8 @@ var CPViewFlags = { }, else { var images = [[_backgroundColor patternImage] imageSlices], - partIndex = 0; + partIndex = 0, + frameSize = aSize; if (_backgroundType === BackgroundVerticalThreePartImage) { @@ -1034,16 +1035,21 @@ var CPViewFlags = { }, // Make sure to repeat the top and bottom pieces horizontally if they're not the exact width needed. if (top) { + CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", top + "px"); CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, top); partIndex++; } if (_DOMImageSizes[1]) { + var height = frameSize.height - top - bottom; + + CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", height + "px"); CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, size.height - top - bottom); partIndex++; } if (bottom) { + CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", bottom + "px"); CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, bottom); } } @@ -1055,16 +1061,21 @@ var CPViewFlags = { }, // Make sure to repeat the left and right pieces vertically if they're not the exact height needed. if (left) { + CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], left + "px", frameSize.height + "px"); CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], left, size.height); partIndex++; } if (_DOMImageSizes[1]) { + var width = (frameSize.width - left - right); + + CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], width + "px", frameSize.height + "px"); CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width - left - right, size.height); partIndex++; } if (right) { + CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], right + "px", frameSize.height + "px"); CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], right, size.height); } }