Changeset 188510 in webkit


Ignore:
Timestamp:
Aug 15, 2015 10:50:04 AM (9 years ago)
Author:
Wenson Hsieh
Message:

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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r188508 r188510  
     12015-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
    1242015-08-14  Chris Dumez  <cdumez@apple.com>
    225
  • trunk/Source/WebCore/platform/mac/ThemeMac.h

    r187961 r188510  
    5959    static NSView* ensuredView(ScrollView*, const ControlStates&, bool useUnparentedView = false);
    6060    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 */);
    6262};
    6363
  • trunk/Source/WebCore/platform/mac/ThemeMac.mm

    r187963 r188510  
    438438        [toggleButtonCell _renderCurrentAnimationFrameInContext:context->platformContext() atLocation:NSMakePoint(0, 0)];
    439439        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);
    441441    } 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);
    443443#else
    444444    needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(toggleButtonCell, context, inflatedRect, view, true, isCellFocused, useImageBuffer, deviceScaleFactor);
     
    665665const float buttonFocusRectOutlineWidth = 3.0f;
    666666
    667 bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(RetainPtr<NSCell> cell, GraphicsContext* context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)
     667bool ThemeMac::drawCellOrFocusRingWithViewIntoContext(NSCell* cell, GraphicsContext* context, const FloatRect& inflatedRect, NSView* view, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor)
    668668{
    669669    ASSERT(drawButtonCell || drawFocusRing);
     
    678678           
    679679            if (drawFocusRing)
    680                 needsRepaint = drawCellFocusRing(cell.get(), imageBufferDrawRect, view);
     680                needsRepaint = drawCellFocusRing(cell, imageBufferDrawRect, view);
    681681        }
    682682        context->drawImageBuffer(imageBuffer.get(), ColorSpaceSRGB, inflatedRect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth));
     
    687687   
    688688    if (drawFocusRing)
    689         needsRepaint = drawCellFocusRing(cell.get(), NSRect(inflatedRect), view);
     689        needsRepaint = drawCellFocusRing(cell, NSRect(inflatedRect), view);
    690690   
    691691    return needsRepaint;
  • trunk/Source/WebCore/rendering/RenderThemeMac.h

    r188183 r188510  
    197197    // Helpers for adjusting appearance and for painting
    198198
     199    void paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell*, const RenderObject&, const PaintInfo&, const FloatRect&);
    199200    void setPopupButtonCellState(const RenderObject&, const IntSize&);
    200201    const IntSize* popupButtonSizes() const;
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r188433 r188510  
    947947    }
    948948
    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);
    959950    [popupButton setControlView:nil];
    960951
     
    14651456}
    14661457
     1458void 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
    14671468const IntSize* RenderThemeMac::menuListSizes() const
    14681469{
     
    16171618    [search setSearchButtonCell:nil];
    16181619
    1619     NSView *documentView = documentViewFor(o);
    1620     [search drawWithFrame:NSRect(unzoomedRect) inView:documentView];
    1621 
     1620    paintCellAndSetFocusedElementNeedsRepaintIfNecessary(search, o, paintInfo, unzoomedRect);
    16221621    [search setControlView:nil];
    16231622    [search resetSearchButtonCell];
    16241623
    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    
    16301624    return false;
    16311625}
Note: See TracChangeset for help on using the changeset viewer.