Changeset 190623 in webkit
- Timestamp:
- Oct 6, 2015 10:28:02 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r190621 r190623 1 2015-10-05 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Slider knobs should scale when rendering while zoomed 4 https://bugs.webkit.org/show_bug.cgi?id=149835 5 <rdar://problem/22897080> 6 7 Reviewed by Darin Adler. 8 9 Make slider knobs follow suit with the rest of the unscaled form controls 10 by rendering to an offscreen buffer when the page is zoomed or scaled and 11 then rendering a scaled version of the offscreen buffer onto the page. 12 13 * platform/mac/ThemeMac.mm: 14 (WebCore::drawCellOrFocusRingIntoRectWithView): Helper function for drawing 15 cells and/or focus rings. 16 (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext): Refactored to 17 handle drawing slider knobs as well. 18 * rendering/RenderThemeMac.mm: 19 (WebCore::RenderThemeMac::paintSliderThumb): Use scaled rendering when necessary. 20 1 21 2015-10-06 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebCore/platform/mac/ThemeMac.mm
r189830 r190623 665 665 const float buttonFocusRectOutlineWidth = 3.0f; 666 666 667 bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell* cell, GraphicsContext& context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor) 667 static inline bool drawCellOrFocusRingIntoRectWithView(NSCell *cell, NSRect rect, NSView *view, bool drawButtonCell, bool drawFocusRing) 668 { 669 if (drawButtonCell) { 670 if ([cell isKindOfClass:[NSSliderCell class]]) { 671 // For slider cells, draw only the knob. 672 [(NSSliderCell *)cell drawKnob:rect]; 673 } else 674 [cell drawWithFrame:rect inView:view]; 675 } 676 if (drawFocusRing) 677 return drawCellFocusRing(cell, rect, view); 678 679 return false; 680 } 681 682 bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell *cell, GraphicsContext& context, const FloatRect& rect, NSView *view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor) 668 683 { 669 684 ASSERT(drawButtonCell || drawFocusRing); 670 685 bool needsRepaint = false; 671 686 if (useImageBuffer) { 672 NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, inflatedRect.width(), inflatedRect.height()));673 std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor, ColorSpaceSRGB, context, false);687 NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, rect.width(), rect.height())); 688 auto imageBuffer = ImageBuffer::createCompatibleBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor, ColorSpaceSRGB, context, false); 674 689 { 675 690 LocalCurrentGraphicsContext localContext(imageBuffer->context()); 676 if (drawButtonCell) 677 [cell drawWithFrame:imageBufferDrawRect inView:view]; 678 679 if (drawFocusRing) 680 needsRepaint = drawCellFocusRing(cell, imageBufferDrawRect, view); 681 } 682 context.drawImageBuffer(imageBuffer.get(), ColorSpaceSRGB, inflatedRect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth)); 691 needsRepaint = drawCellOrFocusRingIntoRectWithView(cell, imageBufferDrawRect, view, drawButtonCell, drawFocusRing); 692 } 693 context.drawImageBuffer(imageBuffer.get(), ColorSpaceSRGB, rect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth)); 683 694 return needsRepaint; 684 695 } 685 696 if (drawButtonCell) 686 [cell drawWithFrame:NSRect(inflatedRect) inView:view]; 687 688 if (drawFocusRing) 689 needsRepaint = drawCellFocusRing(cell, NSRect(inflatedRect), view); 697 needsRepaint = drawCellOrFocusRingIntoRectWithView(cell, NSRect(rect), view, drawButtonCell, drawFocusRing); 690 698 691 699 return needsRepaint; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r189830 r190623 1582 1582 } 1583 1583 1584 [sliderThumbCell drawKnob:unzoomedRect]; 1584 bool shouldDrawCell = true; 1585 bool shouldDrawFocusRing = false; 1586 float deviceScaleFactor = o.document().page()->deviceScaleFactor(); 1587 bool shouldUseImageBuffer = deviceScaleFactor != 1 || zoomLevel != 1; 1588 ThemeMac::drawCellOrFocusRingWithViewIntoContext(sliderThumbCell, paintInfo.context(), unzoomedRect, view, shouldDrawCell, shouldDrawFocusRing, shouldUseImageBuffer, deviceScaleFactor); 1585 1589 [sliderThumbCell setControlView:nil]; 1586 1590
Note: See TracChangeset
for help on using the changeset viewer.