Modified: trunk/Source/WebCore/platform/Theme.h (186816 => 186817)
--- trunk/Source/WebCore/platform/Theme.h 2015-07-14 21:19:50 UTC (rev 186816)
+++ trunk/Source/WebCore/platform/Theme.h 2015-07-14 21:39:34 UTC (rev 186817)
@@ -100,7 +100,7 @@
virtual bool controlRequiresPreWhiteSpace(ControlPart) const { return false; }
// Method for painting a control. The rect is in zoomed coordinates.
- virtual void paint(ControlPart, ControlStates*, GraphicsContext*, const FloatRect& /*zoomedRect*/, float /*zoomFactor*/, ScrollView*) { }
+ virtual void paint(ControlPart, ControlStates*, GraphicsContext*, const FloatRect& /*zoomedRect*/, float /*zoomFactor*/, ScrollView*, float /*deviceScaleFactor*/, float /*pageScaleFactor*/) { }
// Some controls may spill out of their containers (e.g., the check on an OS X checkbox). When these controls repaint,
// the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
Modified: trunk/Source/WebCore/platform/mac/ThemeMac.h (186816 => 186817)
--- trunk/Source/WebCore/platform/mac/ThemeMac.h 2015-07-14 21:19:50 UTC (rev 186816)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.h 2015-07-14 21:39:34 UTC (rev 186817)
@@ -52,7 +52,7 @@
virtual bool controlRequiresPreWhiteSpace(ControlPart part) const override { return part == PushButtonPart; }
- virtual void paint(ControlPart, ControlStates*, GraphicsContext*, const FloatRect&, float zoomFactor, ScrollView*) override;
+ virtual void paint(ControlPart, ControlStates*, GraphicsContext*, const FloatRect&, float zoomFactor, ScrollView*, float deviceScaleFactor, float pageScaleFactor) override;
virtual void inflateControlPaintRect(ControlPart, const ControlStates*, FloatRect&, float zoomFactor) const override;
// FIXME: Once RenderThemeMac is converted over to use Theme then this can be internal to ThemeMac.
Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (186816 => 186817)
--- trunk/Source/WebCore/platform/mac/ThemeMac.mm 2015-07-14 21:19:50 UTC (rev 186816)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm 2015-07-14 21:39:34 UTC (rev 186817)
@@ -29,6 +29,7 @@
#import "AXObjectCache.h"
#import "BlockExceptions.h"
#import "GraphicsContext.h"
+#import "ImageBuffer.h"
#import "LocalCurrentGraphicsContext.h"
#import "ScrollView.h"
#import "WebCoreSystemInterface.h"
@@ -530,8 +531,13 @@
return cell;
}
-static void paintButton(ControlPart part, ControlStates* controlStates, GraphicsContext* context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
+static float buttonFocusRectOutlineWidth()
{
+ return 3.0f;
+}
+
+static void paintButton(ControlPart part, ControlStates* controlStates, GraphicsContext* context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor)
+{
BEGIN_BLOCK_OBJC_EXCEPTIONS
// Determine the width and height needed for the control and prepare the cell for painting.
@@ -561,9 +567,19 @@
context->scale(FloatSize(zoomFactor, zoomFactor));
context->translate(-inflatedRect.x(), -inflatedRect.y());
}
- }
-
- LocalCurrentGraphicsContext localContext(context);
+ }
+
+ bool shouldUseImageBuffer = pageScaleFactor != 1.0f || zoomFactor != 1.0f;
+ float focusThickness = buttonFocusRectOutlineWidth();
+
+ std::unique_ptr<ImageBuffer> imageBuffer;
+ GraphicsContext* drawButtonContext = context;
+ if (shouldUseImageBuffer) {
+ imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size() + 2 * FloatSize(focusThickness, focusThickness), deviceScaleFactor, ColorSpaceDeviceRGB, context, false);
+ drawButtonContext = imageBuffer->context();
+ }
+ LocalCurrentGraphicsContext localContext(drawButtonContext);
+
NSView *view = ThemeMac::ensuredView(scrollView, controlStates);
NSWindow *window = [view window];
NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
@@ -576,13 +592,23 @@
} else if ([previousDefaultButtonCell isEqual:buttonCell])
[window setDefaultButtonCell:nil];
- [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
- bool needsRepaint = false;
- if (states & ControlStates::FocusState)
- needsRepaint = drawCellFocusRing(buttonCell, inflatedRect, view);
+ if (shouldUseImageBuffer) {
+ [buttonCell drawWithFrame:CGRectMake(focusThickness, focusThickness, inflatedRect.width(), inflatedRect.height()) inView:view];
+ if (!(states & ControlStates::FocusState))
+ context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, inflatedRect.location() - FloatSize(focusThickness, focusThickness));
+ } else
+ [buttonCell drawWithFrame:CGRect(inflatedRect) inView:view];
+
+ if (states & ControlStates::FocusState) {
+ if (shouldUseImageBuffer) {
+ drawCellFocusRing(buttonCell, CGRectMake(focusThickness, focusThickness, inflatedRect.width(), inflatedRect.height()), view);
+ context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, inflatedRect.location() - FloatSize(focusThickness, focusThickness));
+ } else
+ drawCellFocusRing(buttonCell, inflatedRect, view);
+ }
+
+ controlStates->setNeedsRepaint(false);
- controlStates->setNeedsRepaint(needsRepaint);
-
[buttonCell setControlView:nil];
if (![previousDefaultButtonCell isEqual:buttonCell])
@@ -823,7 +849,7 @@
END_BLOCK_OBJC_EXCEPTIONS
}
-void ThemeMac::paint(ControlPart part, ControlStates* states, GraphicsContext* context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
+void ThemeMac::paint(ControlPart part, ControlStates* states, GraphicsContext* context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor)
{
switch (part) {
case CheckboxPart:
@@ -836,7 +862,7 @@
case DefaultButtonPart:
case ButtonPart:
case SquareButtonPart:
- paintButton(part, states, context, zoomedRect, zoomFactor, scrollView);
+ paintButton(part, states, context, zoomedRect, zoomFactor, scrollView, deviceScaleFactor, pageScaleFactor);
break;
case InnerSpinButtonPart:
paintStepper(states, context, zoomedRect, zoomFactor, scrollView);
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (186816 => 186817)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2015-07-14 21:19:50 UTC (rev 186816)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2015-07-14 21:39:34 UTC (rev 186817)
@@ -277,9 +277,12 @@
ControlPart part = o.style().appearance();
IntRect integralSnappedRect = snappedIntRect(r);
- FloatRect devicePixelSnappedRect = snapRectToDevicePixels(r, o.document().deviceScaleFactor());
+ float deviceScaleFactor = o.document().deviceScaleFactor();
+ FloatRect devicePixelSnappedRect = snapRectToDevicePixels(r, deviceScaleFactor);
#if USE(NEW_THEME)
+ float pageScaleFactor = o.document().page() ? o.document().page()->pageScaleFactor() : 1.0f;
+
switch (part) {
case CheckboxPart:
case RadioPart:
@@ -289,7 +292,7 @@
case ButtonPart:
case InnerSpinButtonPart:
updateControlStatesForRenderer(o, controlStates);
- m_theme->paint(part, controlStates, const_cast<GraphicsContext*>(paintInfo.context), devicePixelSnappedRect, o.style().effectiveZoom(), &o.view().frameView());
+ m_theme->paint(part, controlStates, const_cast<GraphicsContext*>(paintInfo.context), devicePixelSnappedRect, o.style().effectiveZoom(), &o.view().frameView(), deviceScaleFactor, pageScaleFactor);
return false;
default:
break;