https://bugs.webkit.org/show_bug.cgi?id=147867
Reviewed by Daniel Bates.
When rendering zoomed search fields, draw to an image buffer instead of drawing directly into the context. This
allows us to scale the image buffer up before rendering. Also refactors common logic used to draw both selects
(paintMenuList) and search fields into the new private method paintCellAndSetFocusedElementNeedsRepaintIfNecessary.
* rendering/RenderThemeMac.h: Changed drawCellOrFocusRingWithViewIntoContext to take a raw pointer.
* rendering/RenderThemeMac.mm:
(WebCore::paintToggleButton): Passes a raw pointer to drawCellOrFocusRingWithViewIntoContext.
(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext): Changed to take a raw pointer.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMenuList): Refactored to use paintCellAndSetFocusedElementNeedsRepaintIfNecessary.
(WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Contains logic common to painting
both selects and search fields.
(WebCore::RenderThemeMac::paintSearchField): Use ThemeMac::drawCellOrFocusRingWithViewIntoContext
to render search fields, utilizing an offscreen image buffer only when necessary.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188510
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-08-15 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Search fields should scale when rendering while zoomed
+ https://bugs.webkit.org/show_bug.cgi?id=147867
+
+ Reviewed by Daniel Bates.
+
+ When rendering zoomed search fields, draw to an image buffer instead of drawing directly into the context. This
+ allows us to scale the image buffer up before rendering. Also refactors common logic used to draw both selects
+ (paintMenuList) and search fields into the new private method paintCellAndSetFocusedElementNeedsRepaintIfNecessary.
+
+ * rendering/RenderThemeMac.h: Changed drawCellOrFocusRingWithViewIntoContext to take a raw pointer.
+ * rendering/RenderThemeMac.mm:
+ (WebCore::paintToggleButton): Passes a raw pointer to drawCellOrFocusRingWithViewIntoContext.
+ (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext): Changed to take a raw pointer.
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::paintMenuList): Refactored to use paintCellAndSetFocusedElementNeedsRepaintIfNecessary.
+ (WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Contains logic common to painting
+ both selects and search fields.
+ (WebCore::RenderThemeMac::paintSearchField): Use ThemeMac::drawCellOrFocusRingWithViewIntoContext
+ to render search fields, utilizing an offscreen image buffer only when necessary.
+
2015-08-14 Chris Dumez <cdumez@apple.com>
Refactor HTMLCollection to be as fast as CachedLiveNodeList
// FIXME: Once RenderThemeMac is converted over to use Theme then this can be internal to ThemeMac.
static NSView* ensuredView(ScrollView*, const ControlStates&, bool useUnparentedView = false);
static void setFocusRingClipRect(const FloatRect&);
- static bool drawCellOrFocusRingWithViewIntoContext(RetainPtr<NSCell>, GraphicsContext*, const FloatRect&, NSView*, bool /* drawButtonCell */, bool /* drawFocusRing */, bool /* useImageBuffer */, float /* deviceScaleFactor */);
+ static bool drawCellOrFocusRingWithViewIntoContext(NSCell*, GraphicsContext*, const FloatRect&, NSView*, bool /* drawButtonCell */, bool /* drawFocusRing */, bool /* useImageBuffer */, float /* deviceScaleFactor */);
};
} // namespace WebCore
[toggleButtonCell _renderCurrentAnimationFrameInContext:context->platformContext() atLocation:NSMakePoint(0, 0)];
if (![toggleButtonCell _stateAnimationRunning] && isCellFocused)
- needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell, context, inflatedRect, view, false, true, useImageBuffer, deviceScaleFactor);
+ needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, false, true, useImageBuffer, deviceScaleFactor);
} else
- needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell, context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor);
+ needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor);
#else
needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell, context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor);
#endif
const float buttonFocusRectOutlineWidth = 3.0f;
-bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(RetainPtr<NSCell> cell, GraphicsContext* context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)
+bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell* cell, GraphicsContext* context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)
{
ASSERT(drawButtonCell || drawFocusRing);
bool needsRepaint = false;
[cell drawWithFrame:imageBufferDrawRect inView:view];
if (drawFocusRing)
- needsRepaint = drawCellFocusRing(cell.get(), imageBufferDrawRect, view);
+ needsRepaint = drawCellFocusRing(cell, imageBufferDrawRect, view);
}
context->drawImageBuffer(imageBuffer.get(), ColorSpaceSRGB, inflatedRect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth));
return needsRepaint;
[cell drawWithFrame:NSRect(inflatedRect) inView:view];
if (drawFocusRing)
- needsRepaint = drawCellFocusRing(cell.get(), NSRect(inflatedRect), view);
+ needsRepaint = drawCellFocusRing(cell, NSRect(inflatedRect), view);
return needsRepaint;
}
// Helpers for adjusting appearance and for painting
+ void paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell*, const RenderObject&, const PaintInfo&, const FloatRect&);
void setPopupButtonCellState(const RenderObject&, const IntSize&);
const IntSize* popupButtonSizes() const;
const int* popupButtonMargins() const;
paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y());
}
- NSView *view = documentViewFor(renderer);
- Page* page = renderer.document().page();
- float pageScaleFactor = page->pageScaleFactor();
- float deviceScaleFactor = page->deviceScaleFactor();
- bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto();
- bool shouldUseImageBuffer = zoomLevel != 1.0f || pageScaleFactor != 1.0f;
- bool shouldDrawCell = true;
- if (ThemeMac::drawCellOrFocusRingWithViewIntoContext(popupButton, paintInfo.context, inflatedRect, view, shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, deviceScaleFactor))
- page->focusController().setFocusedElementNeedsRepaint();
-
+ paintCellAndSetFocusedElementNeedsRepaintIfNecessary(popupButton, renderer, paintInfo, inflatedRect);
[popupButton setControlView:nil];
return false;
updatePressedState(popupButton, o);
}
+void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell* cell, const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect)
+{
+ Page* page = renderer.document().page();
+ bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto();
+ bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || page->pageScaleFactor() != 1;
+ bool shouldDrawCell = true;
+ if (ThemeMac::drawCellOrFocusRingWithViewIntoContext(cell, paintInfo.context, rect, documentViewFor(renderer), shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, page->deviceScaleFactor()))
+ page->focusController().setFocusedElementNeedsRepaint();
+}
+
const IntSize* RenderThemeMac::menuListSizes() const
{
static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0) };
// Set the search button to nil before drawing. Then reset it so we can draw it later.
[search setSearchButtonCell:nil];
- NSView *documentView = documentViewFor(o);
- [search drawWithFrame:NSRect(unzoomedRect) inView:documentView];
-
+ paintCellAndSetFocusedElementNeedsRepaintIfNecessary(search, o, paintInfo, unzoomedRect);
[search setControlView:nil];
[search resetSearchButtonCell];
- if (isFocused(o) && o.style().outlineStyleIsAuto()) {
- if (wkDrawCellFocusRingWithFrameAtTime(search, NSRect(unzoomedRect), documentView, std::numeric_limits<double>::max()))
- o.document().page()->focusController().setFocusedElementNeedsRepaint();
- }
-
return false;
}