2011-02-15 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Sam Weinig.

        Fix scrollbar rendering crash when rendered into a layer
        https://bugs.webkit.org/show_bug.cgi?id=54494

        The scroller delegate was failing to return a layer in a case
        where the scroller was still rendering into a GraphicsLayer, because
        even though WebCore had switched out of compositing mode, the
        DrawingAreaImpl was still rendering into its nonCompositedContent
        layer. This happens when the m_exitCompositingTimer timer hasn't fired
        yet.

        The fix is to track whether we're drawing into a layer via the
        GraphicsContext, rather than asking about compositing layers.

        * platform/graphics/GraphicsContext.h:
        * platform/graphics/cg/GraphicsContextCG.cpp:
        (WebCore::GraphicsContext::setIsCALayerContext):
        (WebCore::GraphicsContext::isCALayerContext):
        Getter and setter for the bit that says if we're rendering into a CALayer.

        * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
        Store a bool for whether this context targets a layer.

        * platform/graphics/mac/WebLayer.mm:
        (drawLayerContents): Call setIsCALayerContext(true).

        * platform/mac/ScrollAnimatorMac.h:
        (WebCore::ScrollAnimatorMac::setIsDrawingIntoLayer):
        (WebCore::ScrollAnimatorMac::isDrawingIntoLayer):
        New methods to get and set a flag that says when we're
        drawing into a layer, so that the delegate can get at this state.

        * platform/mac/ScrollAnimatorMac.mm:
        (-[ScrollbarPainterDelegate layer]): Use isDrawingIntoLayer()
        (WebCore::ScrollAnimatorMac::ScrollAnimatorMac): Init the flag.

        * platform/mac/ScrollbarThemeMac.mm:
        (WebCore::ScrollbarThemeMac::unregisterScrollbar): Whitespace.
        (WebCore::ScrollbarThemeMac::paint): Push the "isDrawingIntoLayer"
        state down onto ScrollAnimatorMac, getting it from the GraphicsContext.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 32804e07
2011-02-15 Simon Fraser <simon.fraser@apple.com>
Reviewed by Sam Weinig.
Fix scrollbar rendering crash when rendered into a layer
https://bugs.webkit.org/show_bug.cgi?id=54494
The scroller delegate was failing to return a layer in a case
where the scroller was still rendering into a GraphicsLayer, because
even though WebCore had switched out of compositing mode, the
DrawingAreaImpl was still rendering into its nonCompositedContent
layer. This happens when the m_exitCompositingTimer timer hasn't fired
yet.
The fix is to track whether we're drawing into a layer via the
GraphicsContext, rather than asking about compositing layers.
* platform/graphics/GraphicsContext.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::setIsCALayerContext):
(WebCore::GraphicsContext::isCALayerContext):
Getter and setter for the bit that says if we're rendering into a CALayer.
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
Store a bool for whether this context targets a layer.
* platform/graphics/mac/WebLayer.mm:
(drawLayerContents): Call setIsCALayerContext(true).
* platform/mac/ScrollAnimatorMac.h:
(WebCore::ScrollAnimatorMac::setIsDrawingIntoLayer):
(WebCore::ScrollAnimatorMac::isDrawingIntoLayer):
New methods to get and set a flag that says when we're
drawing into a layer, so that the delegate can get at this state.
* platform/mac/ScrollAnimatorMac.mm:
(-[ScrollbarPainterDelegate layer]): Use isDrawingIntoLayer()
(WebCore::ScrollAnimatorMac::ScrollAnimatorMac): Init the flag.
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::ScrollbarThemeMac::unregisterScrollbar): Whitespace.
(WebCore::ScrollbarThemeMac::paint): Push the "isDrawingIntoLayer"
state down onto ScrollAnimatorMac, getting it from the GraphicsContext.
2011-02-15 Anders Carlsson <andersca@apple.com>
Reviewed by Darin Adler.
......@@ -268,6 +268,9 @@ namespace WebCore {
// Allow font smoothing (LCD antialiasing). Not part of the graphics state.
void setAllowsFontSmoothing(bool);
void setIsCALayerContext(bool);
bool isCALayerContext() const;
#endif
void save();
......
......@@ -1269,6 +1269,16 @@ void GraphicsContext::setAllowsFontSmoothing(bool allowsFontSmoothing)
#endif
}
void GraphicsContext::setIsCALayerContext(bool)
{
m_data->m_isCALayerContext = true;
}
bool GraphicsContext::isCALayerContext() const
{
return m_data->m_isCALayerContext;
}
void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
{
if (paintingDisabled())
......
......@@ -33,7 +33,7 @@ namespace WebCore {
class GraphicsContextPlatformPrivate {
public:
GraphicsContextPlatformPrivate(CGContextRef cgContext)
GraphicsContextPlatformPrivate(CGContextRef cgContext, bool isLayerContext = false)
: m_cgContext(cgContext)
#if PLATFORM(WIN)
, m_hdc(0)
......@@ -41,6 +41,7 @@ public:
, m_shouldIncludeChildWindows(false)
#endif
, m_userToDeviceTransformKnownToBeIdentity(false)
, m_isCALayerContext(isLayerContext)
{
}
......@@ -84,6 +85,7 @@ public:
RetainPtr<CGContextRef> m_cgContext;
bool m_userToDeviceTransformKnownToBeIdentity;
bool m_isCALayerContext;
};
}
......
......@@ -61,6 +61,7 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCA
[NSGraphicsContext setCurrentContext:layerContext];
GraphicsContext graphicsContext(context);
graphicsContext.setIsCALayerContext(true);
if (!layerContents->platformCALayerContentsOpaque()) {
// Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
......
......@@ -70,7 +70,10 @@ public:
void immediateScrollToPoint(const FloatPoint& newPosition);
void immediateScrollByDeltaX(float deltaX);
void immediateScrollByDeltaY(float deltaY);
void setIsDrawingIntoLayer(bool b) { m_drawingIntoLayer = b; }
bool isDrawingIntoLayer() const { return m_drawingIntoLayer; }
private:
RetainPtr<id> m_scrollAnimationHelper;
RetainPtr<ScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate;
......@@ -114,6 +117,8 @@ private:
bool m_inScrollGesture;
bool m_momentumScrollInProgress;
bool m_ignoreMomentumScrolls;
bool m_drawingIntoLayer;
CFTimeInterval m_lastMomemtumScrollTimestamp;
FloatSize m_overflowScrollDelta;
FloatSize m_stretchScrollForce;
......
......@@ -357,7 +357,7 @@ static NSSize abs(NSSize size)
{
if (!_animator)
return nil;
if (!_animator->scrollableArea()->scrollbarWillRenderIntoCompositingLayer())
if (!_animator->isDrawingIntoLayer())
return nil;
// FIXME: This should attempt to return an actual layer.
......@@ -455,6 +455,7 @@ ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea)
, m_inScrollGesture(false)
, m_momentumScrollInProgress(false)
, m_ignoreMomentumScrolls(false)
, m_drawingIntoLayer(false)
, m_lastMomemtumScrollTimestamp(0)
, m_startTime(0)
, m_snapRubberBandTimer(this, &ScrollAnimatorMac::snapRubberBandTimerFired)
......
......@@ -59,7 +59,6 @@ static ScrollbarPainterMap* scrollbarMap()
@interface ScrollbarPrefsObserver : NSObject
{
}
+ (void)registerAsObserver;
......@@ -167,7 +166,6 @@ void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar)
{
scrollbarMap()->remove(scrollbar);
}
......@@ -446,6 +444,9 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co
totalSize = scrollbar->totalSize();
}
ScrollAnimatorMac* scrollAnimator = static_cast<ScrollAnimatorMac*>(scrollbar->scrollableArea()->scrollAnimator());
scrollAnimator->setIsDrawingIntoLayer(context->isCALayerContext());
context->save();
context->clip(damageRect);
context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
......@@ -455,6 +456,9 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co
value,
static_cast<CGFloat>(scrollbar->visibleSize()) / totalSize,
scrollbar->frameRect());
scrollAnimator->setIsDrawingIntoLayer(false);
context->restore();
return true;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment