Changeset 57603 in webkit


Ignore:
Timestamp:
Apr 14, 2010 1:39:31 PM (14 years ago)
Author:
andersca@apple.com
Message:

2010-04-14 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Add ThemeMac::ensuredView and get rid of a workaround in ThemeMac::paintButton.
https://bugs.webkit.org/show_bug.cgi?id=37601

  • platform/mac/ThemeMac.h:
  • platform/mac/ThemeMac.mm: (-[WebCoreFlippedView isFlipped]): (WebCore::paintButton): (WebCore::ThemeMac::ensuredView):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57599 r57603  
     12010-04-14  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Add ThemeMac::ensuredView and get rid of a workaround in ThemeMac::paintButton.
     6        https://bugs.webkit.org/show_bug.cgi?id=37601
     7
     8        * platform/mac/ThemeMac.h:
     9        * platform/mac/ThemeMac.mm:
     10        (-[WebCoreFlippedView isFlipped]):
     11        (WebCore::paintButton):
     12        (WebCore::ThemeMac::ensuredView):
     13
    1142010-04-14  Jay Civelli  <jcivelli@chromium.org>
    215 
  • trunk/WebCore/platform/mac/ThemeMac.h

    r37790 r57603  
    5050    virtual void paint(ControlPart, ControlStates, GraphicsContext*, const IntRect&, float zoomFactor, ScrollView*) const;
    5151    virtual void inflateControlPaintRect(ControlPart, ControlStates, IntRect&, float zoomFactor) const;
     52
     53    // FIXME: Once RenderThemeMac is converted over to use Theme then this can be internal to ThemeMac.
     54    static NSView* ensuredView(ScrollView*);
    5255};
    5356
  • trunk/WebCore/platform/mac/ThemeMac.mm

    r54299 r57603  
    3636using namespace std;
    3737
     38// This is a view whose sole purpose is to tell AppKit that it's flipped.
     39@interface WebCoreFlippedView : NSView
     40@end
     41
     42@implementation WebCoreFlippedView
     43
     44- (BOOL)isFlipped
     45{
     46    return YES;
     47}
     48
     49@end
     50
    3851// FIXME: Default buttons really should be more like push buttons and not like buttons.
    3952
     
    406419    }
    407420
    408     NSView *view = scrollView->documentView();
     421    NSView *view = ThemeMac::ensuredView(scrollView);
    409422    NSWindow *window = [view window];
    410423    NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
     
    416429        [window setDefaultButtonCell:nil];
    417430
    418     if (!view) {
    419         context->save();
    420         context->translate(inflatedRect.x(), inflatedRect.y());
    421         context->scale(FloatSize(1, -1));
    422         context->translate(0, -inflatedRect.height());
    423         inflatedRect.setLocation(IntPoint());
    424     }
    425 
    426431    [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
    427432    [buttonCell setControlView:nil];
    428433
    429     if (!view)
    430         context->restore();
    431 
    432434    if (![previousDefaultButtonCell isEqual:buttonCell])
    433435        [window setDefaultButtonCell:previousDefaultButtonCell];
     
    436438}
    437439
     440// This will ensure that we always return a valid NSView, even if ScrollView doesn't have an associated document NSView.
     441// If the ScrollView doesn't have an NSView, we will return a fake NSView whose sole purpose is to tell AppKit that it's flipped.
     442NSView *ThemeMac::ensuredView(ScrollView* scrollView)
     443{
     444    if (NSView *documentView = scrollView->documentView())
     445        return documentView;
     446   
     447    // Use a fake flipped view.
     448    static NSView *flippedView = [[WebCoreFlippedView alloc] init];
     449   
     450    return flippedView;
     451}
     452   
    438453// Theme overrides
    439454
Note: See TracChangeset for help on using the changeset viewer.