Bug 156805

Summary: Drop [UsePointersEvenForNonNullableObjectArguments] from Range
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: BindingsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, youennf
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

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>