Bug 104832

Summary: [BlackBerry] Ensure InRegionScrollableArea is valid before using.
Product: WebKit Reporter: Mike Lattanzio <mlattanzio>
Component: WebKit BlackBerryAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mifenton, rwlbuis, tonikitoo, webkit.review.bot, yong.li.webkit
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Mike Lattanzio 2012-12-12 12:10:37 PST
Make sure we still have a RefPtr to pointer before using it. 
Otherwise it might have been deleted.
Comment 1 Mike Lattanzio 2012-12-12 12:13:59 PST
Created attachment 179099 [details]
Patch
Comment 2 Antonio Gomes 2012-12-12 13:31:01 PST
Comment on attachment 179099 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=179099&action=review

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:420
> +bool InRegionScrollerPrivate::isValidScrollableLayerWebKitThread(WebCore::LayerWebKitThread* layerWebKitThread)

const

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:432
> +bool InRegionScrollerPrivate::isValidScrollableNode(WebCore::Node* node)

const

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:437
> +    for (unsigned i = 0; i < m_activeInRegionScrollableAreas.size(); i++)

IIRC calculateActiveAndShrinkCachedScrollableAreas shrink this vector. Does it need to be a for loop?
Comment 3 Mike Lattanzio 2012-12-12 13:48:01 PST
(In reply to comment #2)
> (From update of attachment 179099 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=179099&action=review
> 
> > Source/WebKit/blackberry/Api/InRegionScroller.cpp:420
> > +bool InRegionScrollerPrivate::isValidScrollableLayerWebKitThread(WebCore::LayerWebKitThread* layerWebKitThread)
> 
> const
> 
> > Source/WebKit/blackberry/Api/InRegionScroller.cpp:432
> > +bool InRegionScrollerPrivate::isValidScrollableNode(WebCore::Node* node)
> 
> const
>

Fixing those. Good eye.
 
> > Source/WebKit/blackberry/Api/InRegionScroller.cpp:437
> > +    for (unsigned i = 0; i < m_activeInRegionScrollableAreas.size(); i++)
> 
> IIRC calculateActiveAndShrinkCachedScrollableAreas shrink this vector. Does it need to be a for loop?

I think so. That shrinking is performed after we cast and use the layer, but we need to know if the layer still exists first.
Comment 4 Mike Lattanzio 2012-12-12 14:14:51 PST
Created attachment 179123 [details]
Patch
Comment 5 Antonio Gomes 2012-12-12 14:29:47 PST
Comment on attachment 179123 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=179123&action=review

Please reupload with "Reviewed by antonio Gomes" and just request cq to land it.

r+, some nits though.

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:420
> +bool InRegionScrollerPrivate::isValidScrollableLayerWebKitThread(WebCore::LayerWebKitThread* layerWebKitThread) const

WebCore:: is needed?

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:428
> +    for (unsigned i = 0; i < m_activeInRegionScrollableAreas.size(); i++)
> +        if (static_cast<InRegionScrollableArea*>(m_activeInRegionScrollableAreas[i])->cachedScrollableLayer() == layerWebKitThread)
> +            return true;
> +

for need {}

++i is preferred.

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:432
> +bool InRegionScrollerPrivate::isValidScrollableNode(WebCore::Node* node) const

WebCore is needed?

> Source/WebKit/blackberry/Api/InRegionScroller.cpp:439
> +    for (unsigned i = 0; i < m_activeInRegionScrollableAreas.size(); i++)
> +        if (static_cast<InRegionScrollableArea*>(m_activeInRegionScrollableAreas[i])->cachedScrollableNode() == node)
> +            return true;

ditto

++i is preferred.
Comment 6 Mike Lattanzio 2012-12-12 14:53:45 PST
Created attachment 179130 [details]
Patch
Comment 7 Rob Buis 2012-12-12 15:48:57 PST
Comment on attachment 179130 [details]
Patch

LGTM.
Comment 8 WebKit Review Bot 2012-12-12 16:14:55 PST
Comment on attachment 179130 [details]
Patch

Clearing flags on attachment: 179130

Committed r137532: <http://trac.webkit.org/changeset/137532>
Comment 9 WebKit Review Bot 2012-12-12 16:14:59 PST
All reviewed patches have been landed.  Closing bug.