Changeset 188510 in webkit
- Timestamp:
- Aug 15, 2015 10:50:04 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r188508 r188510 1 2015-08-15 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Search fields should scale when rendering while zoomed 4 https://bugs.webkit.org/show_bug.cgi?id=147867 5 6 Reviewed by Daniel Bates. 7 8 When rendering zoomed search fields, draw to an image buffer instead of drawing directly into the context. This 9 allows us to scale the image buffer up before rendering. Also refactors common logic used to draw both selects 10 (paintMenuList) and search fields into the new private method paintCellAndSetFocusedElementNeedsRepaintIfNecessary. 11 12 * rendering/RenderThemeMac.h: Changed drawCellOrFocusRingWithViewIntoContext to take a raw pointer. 13 * rendering/RenderThemeMac.mm: 14 (WebCore::paintToggleButton): Passes a raw pointer to drawCellOrFocusRingWithViewIntoContext. 15 (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext): Changed to take a raw pointer. 16 * rendering/RenderThemeMac.h: 17 * rendering/RenderThemeMac.mm: 18 (WebCore::RenderThemeMac::paintMenuList): Refactored to use paintCellAndSetFocusedElementNeedsRepaintIfNecessary. 19 (WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Contains logic common to painting 20 both selects and search fields. 21 (WebCore::RenderThemeMac::paintSearchField): Use ThemeMac::drawCellOrFocusRingWithViewIntoContext 22 to render search fields, utilizing an offscreen image buffer only when necessary. 23 1 24 2015-08-14 Chris Dumez <cdumez@apple.com> 2 25 -
trunk/Source/WebCore/platform/mac/ThemeMac.h
r187961 r188510 59 59 static NSView* ensuredView(ScrollView*, const ControlStates&, bool useUnparentedView = false); 60 60 static void setFocusRingClipRect(const FloatRect&); 61 static bool drawCellOrFocusRingWithViewIntoContext( RetainPtr<NSCell>, GraphicsContext*, const FloatRect&, NSView*, bool /* drawButtonCell */, bool /* drawFocusRing */, bool /* useImageBuffer */, float /* deviceScaleFactor */);61 static bool drawCellOrFocusRingWithViewIntoContext(NSCell*, GraphicsContext*, const FloatRect&, NSView*, bool /* drawButtonCell */, bool /* drawFocusRing */, bool /* useImageBuffer */, float /* deviceScaleFactor */); 62 62 }; 63 63 -
trunk/Source/WebCore/platform/mac/ThemeMac.mm
r187963 r188510 438 438 [toggleButtonCell _renderCurrentAnimationFrameInContext:context->platformContext() atLocation:NSMakePoint(0, 0)]; 439 439 if (![toggleButtonCell _stateAnimationRunning] && isCellFocused) 440 needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell , context, inflatedRect, view, false, true, useImageBuffer, deviceScaleFactor);440 needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, false, true, useImageBuffer, deviceScaleFactor); 441 441 } else 442 needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell , context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor);442 needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell.get(), context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor); 443 443 #else 444 444 needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell, context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor); … … 665 665 const float buttonFocusRectOutlineWidth = 3.0f; 666 666 667 bool ThemeMac::drawCellOrFocusRingWithViewIntoContext( RetainPtr<NSCell>cell, GraphicsContext* context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)667 bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell* cell, GraphicsContext* context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor) 668 668 { 669 669 ASSERT(drawButtonCell || drawFocusRing); … … 678 678 679 679 if (drawFocusRing) 680 needsRepaint = drawCellFocusRing(cell .get(), imageBufferDrawRect, view);680 needsRepaint = drawCellFocusRing(cell, imageBufferDrawRect, view); 681 681 } 682 682 context->drawImageBuffer(imageBuffer.get(), ColorSpaceSRGB, inflatedRect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth)); … … 687 687 688 688 if (drawFocusRing) 689 needsRepaint = drawCellFocusRing(cell .get(), NSRect(inflatedRect), view);689 needsRepaint = drawCellFocusRing(cell, NSRect(inflatedRect), view); 690 690 691 691 return needsRepaint; -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r188183 r188510 197 197 // Helpers for adjusting appearance and for painting 198 198 199 void paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell*, const RenderObject&, const PaintInfo&, const FloatRect&); 199 200 void setPopupButtonCellState(const RenderObject&, const IntSize&); 200 201 const IntSize* popupButtonSizes() const; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r188433 r188510 947 947 } 948 948 949 NSView *view = documentViewFor(renderer); 950 Page* page = renderer.document().page(); 951 float pageScaleFactor = page->pageScaleFactor(); 952 float deviceScaleFactor = page->deviceScaleFactor(); 953 bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto(); 954 bool shouldUseImageBuffer = zoomLevel != 1.0f || pageScaleFactor != 1.0f; 955 bool shouldDrawCell = true; 956 if (ThemeMac::drawCellOrFocusRingWithViewIntoContext(popupButton, paintInfo.context, inflatedRect, view, shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, deviceScaleFactor)) 957 page->focusController().setFocusedElementNeedsRepaint(); 958 949 paintCellAndSetFocusedElementNeedsRepaintIfNecessary(popupButton, renderer, paintInfo, inflatedRect); 959 950 [popupButton setControlView:nil]; 960 951 … … 1465 1456 } 1466 1457 1458 void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell* cell, const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect) 1459 { 1460 Page* page = renderer.document().page(); 1461 bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto(); 1462 bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || page->pageScaleFactor() != 1; 1463 bool shouldDrawCell = true; 1464 if (ThemeMac::drawCellOrFocusRingWithViewIntoContext(cell, paintInfo.context, rect, documentViewFor(renderer), shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, page->deviceScaleFactor())) 1465 page->focusController().setFocusedElementNeedsRepaint(); 1466 } 1467 1467 1468 const IntSize* RenderThemeMac::menuListSizes() const 1468 1469 { … … 1617 1618 [search setSearchButtonCell:nil]; 1618 1619 1619 NSView *documentView = documentViewFor(o); 1620 [search drawWithFrame:NSRect(unzoomedRect) inView:documentView]; 1621 1620 paintCellAndSetFocusedElementNeedsRepaintIfNecessary(search, o, paintInfo, unzoomedRect); 1622 1621 [search setControlView:nil]; 1623 1622 [search resetSearchButtonCell]; 1624 1623 1625 if (isFocused(o) && o.style().outlineStyleIsAuto()) {1626 if (wkDrawCellFocusRingWithFrameAtTime(search, NSRect(unzoomedRect), documentView, std::numeric_limits<double>::max()))1627 o.document().page()->focusController().setFocusedElementNeedsRepaint();1628 }1629 1630 1624 return false; 1631 1625 }
Note: See TracChangeset
for help on using the changeset viewer.