| Index: Source/core/rendering/RenderThemeChromiumMac.mm
|
| ===================================================================
|
| --- Source/core/rendering/RenderThemeChromiumMac.mm (revision 181329)
|
| +++ Source/core/rendering/RenderThemeChromiumMac.mm (working copy)
|
| @@ -151,6 +151,20 @@
|
|
|
| using namespace HTMLNames;
|
|
|
| +enum {
|
| + topMargin,
|
| + rightMargin,
|
| + bottomMargin,
|
| + leftMargin
|
| +};
|
| +
|
| +enum {
|
| + topPadding,
|
| + rightPadding,
|
| + bottomPadding,
|
| + leftPadding
|
| +};
|
| +
|
| RenderThemeChromiumMac::RenderThemeChromiumMac()
|
| : m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver alloc] initWithTheme:this])
|
| {
|
| @@ -540,12 +554,30 @@
|
| IntSize size = popupButtonSizes()[[popupButton() controlSize]];
|
| size.setHeight(size.height() * zoomLevel);
|
| size.setWidth(r.width());
|
| - r = ThemeMac::inflateRect(r, size, popupButtonMargins(), zoomLevel);
|
| + r = inflateRect(r, size, popupButtonMargins(), zoomLevel);
|
| } else if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
|
| r.setHeight(r.height() + sliderThumbShadowBlur);
|
| }
|
| }
|
|
|
| +IntRect RenderThemeChromiumMac::inflateRect(const IntRect& r, const IntSize& size, const int* margins, float zoomLevel) const
|
| +{
|
| + // Only do the inflation if the available width/height are too small. Otherwise try to
|
| + // fit the glow/check space into the available box's width/height.
|
| + int widthDelta = r.width() - (size.width() + margins[leftMargin] * zoomLevel + margins[rightMargin] * zoomLevel);
|
| + int heightDelta = r.height() - (size.height() + margins[topMargin] * zoomLevel + margins[bottomMargin] * zoomLevel);
|
| + IntRect result(r);
|
| + if (widthDelta < 0) {
|
| + result.setX(result.x() - margins[leftMargin] * zoomLevel);
|
| + result.setWidth(result.width() - widthDelta);
|
| + }
|
| + if (heightDelta < 0) {
|
| + result.setY(result.y() - margins[topMargin] * zoomLevel);
|
| + result.setHeight(result.height() - heightDelta);
|
| + }
|
| + return result;
|
| +}
|
| +
|
| FloatRect RenderThemeChromiumMac::convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const
|
| {
|
| FloatRect partRect(inputRect);
|
| @@ -707,7 +739,7 @@
|
|
|
| bool RenderThemeChromiumMac::paintTextField(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| {
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
|
|
| #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
|
| bool useNSTextFieldCell = o->style()->hasAppearance()
|
| @@ -739,7 +771,7 @@
|
| bool RenderThemeChromiumMac::paintCapsLockIndicator(RenderObject*, const PaintInfo& paintInfo, const IntRect& r)
|
| {
|
| // This draws the caps lock indicator as it was done by WKDrawCapsLockIndicator.
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
| CGContextRef c = localContext.cgContext();
|
| CGMutablePathRef shape = CGPathCreateMutable();
|
|
|
| @@ -797,7 +829,7 @@
|
|
|
| bool RenderThemeChromiumMac::paintTextArea(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| {
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
| _NSDrawCarbonThemeListBox(r, isEnabled(o) && !isReadOnlyControl(o), YES, YES);
|
| return false;
|
| }
|
| @@ -832,6 +864,7 @@
|
|
|
| bool RenderThemeChromiumMac::paintMenuList(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| {
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
| setPopupButtonCellState(o, r);
|
|
|
| NSPopUpButtonCell* popupButton = this->popupButton();
|
| @@ -844,9 +877,8 @@
|
| // Now inflate it to account for the shadow.
|
| IntRect inflatedRect = r;
|
| if (r.width() >= minimumMenuListSize(o->style()))
|
| - inflatedRect = ThemeMac::inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel);
|
| + inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel);
|
|
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, ThemeMac::inflateRectForFocusRing(inflatedRect));
|
| GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
|
|
| // On Leopard, the cell will draw outside of the given rect, so we have to clip to the rect
|
| @@ -888,7 +920,7 @@
|
| if (!renderObject->isMeter())
|
| return true;
|
|
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, rect);
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
|
|
| NSLevelIndicatorCell* cell = levelIndicatorFor(toRenderMeter(renderObject));
|
| GraphicsContextStateSaver stateSaver(*paintInfo.context);
|
| @@ -1017,7 +1049,7 @@
|
| // Now inflate it to account for the shadow.
|
| IntRect inflatedRect = rect;
|
| if (rect.height() <= minimumProgressBarHeight(renderObject->style()))
|
| - inflatedRect = ThemeMac::inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel);
|
| + inflatedRect = inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel);
|
|
|
| RenderProgress* renderProgress = toRenderProgress(renderObject);
|
| HIThemeTrackDrawInfo trackInfo;
|
| @@ -1153,7 +1185,7 @@
|
| return autofillPopupHorizontalPadding;
|
|
|
| if (style->appearance() == MenulistPart)
|
| - return popupButtonPadding(controlSizeForFont(style))[ThemeMac::LeftMargin] * style->effectiveZoom();
|
| + return popupButtonPadding(controlSizeForFont(style))[leftPadding] * style->effectiveZoom();
|
| if (style->appearance() == MenulistButtonPart)
|
| return styledPopupPaddingLeft * style->effectiveZoom();
|
| return 0;
|
| @@ -1165,7 +1197,7 @@
|
| return autofillPopupHorizontalPadding;
|
|
|
| if (style->appearance() == MenulistPart)
|
| - return popupButtonPadding(controlSizeForFont(style))[ThemeMac::RightMargin] * style->effectiveZoom();
|
| + return popupButtonPadding(controlSizeForFont(style))[rightPadding] * style->effectiveZoom();
|
| if (style->appearance() == MenulistButtonPart) {
|
| float fontScale = style->fontSize() / baseFontSize;
|
| float arrowWidth = baseArrowWidth * fontScale;
|
| @@ -1177,7 +1209,7 @@
|
| int RenderThemeChromiumMac::popupInternalPaddingTop(RenderStyle* style) const
|
| {
|
| if (style->appearance() == MenulistPart)
|
| - return popupButtonPadding(controlSizeForFont(style))[ThemeMac::TopMargin] * style->effectiveZoom();
|
| + return popupButtonPadding(controlSizeForFont(style))[topPadding] * style->effectiveZoom();
|
| if (style->appearance() == MenulistButtonPart)
|
| return styledPopupPaddingTop * style->effectiveZoom();
|
| return 0;
|
| @@ -1186,7 +1218,7 @@
|
| int RenderThemeChromiumMac::popupInternalPaddingBottom(RenderStyle* style) const
|
| {
|
| if (style->appearance() == MenulistPart)
|
| - return popupButtonPadding(controlSizeForFont(style))[ThemeMac::BottomMargin] * style->effectiveZoom();
|
| + return popupButtonPadding(controlSizeForFont(style))[bottomPadding] * style->effectiveZoom();
|
| if (style->appearance() == MenulistButtonPart)
|
| return styledPopupPaddingBottom * style->effectiveZoom();
|
| return 0;
|
| @@ -1393,7 +1425,7 @@
|
|
|
| bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
|
| {
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
|
|
| NSSearchFieldCell* search = this->search();
|
| setSearchCellState(o, r);
|
| @@ -1612,7 +1644,7 @@
|
| paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
|
| }
|
|
|
| - LocalCurrentGraphicsContext localContext(paintInfo.context, r);
|
| + LocalCurrentGraphicsContext localContext(paintInfo.context);
|
|
|
| NSSearchFieldCell* search = this->search();
|
| setSearchCellState(input->renderer(), r);
|
|
|