Bug 104832 - [BlackBerry] Ensure InRegionScrollableArea is valid before using.
Summary: [BlackBerry] Ensure InRegionScrollableArea is valid before using.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit BlackBerry (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-12 12:10 PST by Mike Lattanzio
Modified: 2012-12-12 16:14 PST (History)
5 users (show)

See Also:


Attachments
Patch (7.00 KB, patch)
2012-12-12 12:13 PST, Mike Lattanzio
no flags Details | Formatted Diff | Diff
Patch (7.02 KB, patch)
2012-12-12 14:14 PST, Mike Lattanzio
no flags Details | Formatted Diff | Diff
Patch (7.02 KB, patch)
2012-12-12 14:53 PST, Mike Lattanzio
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.