Bug 156805 - Drop [UsePointersEvenForNonNullableObjectArguments] from Range
Summary: Drop [UsePointersEvenForNonNullableObjectArguments] from Range
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-20 12:17 PDT by Chris Dumez
Modified: 2016-04-21 09:07 PDT (History)
2 users (show)

See Also:


Attachments
Patch (92.52 KB, patch)
2016-04-20 19:13 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (94.49 KB, patch)
2016-04-20 19:41 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (95.20 KB, patch)
2016-04-20 19:47 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (96.01 KB, patch)
2016-04-20 19:53 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (97.76 KB, patch)
2016-04-20 19:57 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (98.70 KB, patch)
2016-04-20 20:03 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (103.12 KB, patch)
2016-04-20 20:50 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (106.10 KB, patch)
2016-04-21 08:54 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-04-20 12:17:42 PDT
Drop [UsePointersEvenForNonNullableObjectArguments] from Range
Comment 1 Chris Dumez 2016-04-20 19:13:38 PDT
Created attachment 276884 [details]
Patch
Comment 2 Chris Dumez 2016-04-20 19:41:18 PDT
Created attachment 276888 [details]
Patch
Comment 3 Chris Dumez 2016-04-20 19:47:59 PDT
Created attachment 276889 [details]
Patch
Comment 4 Chris Dumez 2016-04-20 19:53:24 PDT
Created attachment 276890 [details]
Patch
Comment 5 Chris Dumez 2016-04-20 19:57:09 PDT
Created attachment 276892 [details]
Patch
Comment 6 Chris Dumez 2016-04-20 20:03:49 PDT
Created attachment 276894 [details]
Patch
Comment 7 Chris Dumez 2016-04-20 20:50:25 PDT
Created attachment 276895 [details]
Patch
Comment 8 youenn fablet 2016-04-21 02:15:20 PDT
Comment on attachment 276895 [details]
Patch

r=me, some nits below.

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

> Source/WebCore/accessibility/AXObjectCache.cpp:1639
> +    return !range2 || range1->compareBoundaryPoints(Range::START_TO_START, *range2, IGNORE_EXCEPTION) <= 0;

Do you know what is preventing range1 to be null?
Should we check it/assert it?

> Source/WebCore/accessibility/AXObjectCache.cpp:1758
>          copyRange = Range::create(range->ownerDocument(), &range->startContainer(), range->startOffset(), &range->endContainer(), range->endOffset());

Is it possible to make copyRange a Ref<Range> and/or limit ref count churn here?

> Source/WebCore/accessibility/AXObjectCache.cpp:1761
> +        copyRange->setStart(*node, nodeStartOffset.startIndex);

Why not making node a Node& instead of a Node*?

> Source/WebCore/accessibility/atk/WebKitAccessibleUtil.cpp:162
>      Node* node = coreObject->node();

Add ASSERT(node)?

> Source/WebCore/editing/htmlediting.cpp:1171
>          return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM);

Could visiblePositionForIndexUsingCharacterIterator take a Node& instead of a Node*, like you did for isNodeVisiblyContainedWithin?
Comment 9 Chris Dumez 2016-04-21 08:53:15 PDT
Comment on attachment 276895 [details]
Patch

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

>> Source/WebCore/accessibility/AXObjectCache.cpp:1639
>> +    return !range2 || range1->compareBoundaryPoints(Range::START_TO_START, *range2, IGNORE_EXCEPTION) <= 0;
> 
> Do you know what is preventing range1 to be null?
> Should we check it/assert it?

range1 was already being dereferenced so this is not new. An assertion would not bring much here because we would anyway crash right away when dereferencing range1 if range1 were null.
We would add a null-check for range1 but considering there was not one before and my patch did not change range1 in any way, I decided to leave it alone.

>> Source/WebCore/accessibility/AXObjectCache.cpp:1758
>>          copyRange = Range::create(range->ownerDocument(), &range->startContainer(), range->startOffset(), &range->endContainer(), range->endOffset());
> 
> Is it possible to make copyRange a Ref<Range> and/or limit ref count churn here?

I don't see why not.

>> Source/WebCore/accessibility/AXObjectCache.cpp:1761
>> +        copyRange->setStart(*node, nodeStartOffset.startIndex);
> 
> Why not making node a Node& instead of a Node*?

Ok.

>> Source/WebCore/accessibility/atk/WebKitAccessibleUtil.cpp:162
>>      Node* node = coreObject->node();
> 
> Add ASSERT(node)?

It would anyway crash right away upon dereferencing in the line below.

>> Source/WebCore/editing/htmlediting.cpp:1171
>>          return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM);
> 
> Could visiblePositionForIndexUsingCharacterIterator take a Node& instead of a Node*, like you did for isNodeVisiblyContainedWithin?

Ok.
Comment 10 Chris Dumez 2016-04-21 08:54:25 PDT
Created attachment 276932 [details]
Patch
Comment 11 Chris Dumez 2016-04-21 09:06:59 PDT
Committed r199817: <http://trac.webkit.org/changeset/199817>