Bug 112015

Summary: [EFL] accessibility/textarea-line-for-index.html is failing
Product: WebKit Reporter: Krzysztof Czech <k.czech>
Component: WebKit EFLAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cfleizach, commit-queue, lucas.de.marchi, mario, r.plociennik
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Linux   
Bug Depends on:    
Bug Blocks: 111985    
Attachments:
Description Flags
Proposed patch
none
Rebased patch for a change
mario: review-
Corrected patch none

Description Krzysztof Czech 2013-03-11 08:12:25 PDT
accessibility/textarea-line-for-index.html is failing on all EFL platforms.
Comment 1 Rob Płóciennik 2013-10-31 06:11:41 PDT
Created attachment 215646 [details]
Proposed patch
Comment 2 Rob Płóciennik 2013-10-31 06:20:48 PDT
Created attachment 215648 [details]
Rebased patch for a change
Comment 3 Mario Sanchez Prada 2013-11-01 03:29:21 PDT
Comment on attachment 215648 [details]
Rebased patch for a change

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

> Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:995
> +    if (!ATK_IS_TEXT(m_element))
> +        return -1;

We normally put this check at the beginning of the function. Could you please move it there?

> Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:998
> +    if (index > atk_text_get_character_count(ATK_TEXT(m_element)))
> +        return -1;

Maybe you could join this check with the index < 0 in a single if condition.

Also, you probably want to check index >= atk_text_get_character_count(ATK_TEXT(m_element)) here (opposite to just >)

> Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:1003
> +    GOwnPtr<gchar> text(atk_text_get_text(ATK_TEXT(m_element), 0, index));
> +
> +    int lineNo = 0;
> +

You don't need these two extra blank lines here

> Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:1006
> +    for (gchar* offset = text.get(); *offset; ++offset)
> +        if (*offset == '\n')
> +            ++lineNo;

Please add braces to this for loop. Even if it only has the if statement inside, it's multiline content and adding braces will make it clearer

> Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:1035
>  int AccessibilityUIElement::lineForIndex(int index)

Same considerations here.
Comment 4 Rob Płóciennik 2013-11-04 00:37:22 PST
(In reply to comment #3)
> Also, you probably want to check index >= atk_text_get_character_count(ATK_TEXT(m_element)) here (opposite to just >)

If I understand correctly, the index equal to the string's length corresponds to a situation where the caret is placed right after the last character. Wouldn't that cause additional failures in cases where the string in question ended with a newline?
Comment 5 Mario Sanchez Prada 2013-11-04 06:49:08 PST
(In reply to comment #4)
> (In reply to comment #3)
> > Also, you probably want to check index >= atk_text_get_character_count(ATK_TEXT(m_element)) here (opposite to just >)
> 
> If I understand correctly, the index equal to the string's length corresponds 
> to a situation where the caret is placed right after the last character. 
> Wouldn't that cause additional failures in cases where the string in question 
> ended with a newline?

I'm not sure I understand what you mean? What kind of failures are you considering? Do you have an specific example/failing test case that we can use to discuss about this?
Comment 6 Rob Płóciennik 2013-11-04 07:02:21 PST
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > Also, you probably want to check index >= atk_text_get_character_count(ATK_TEXT(m_element)) here (opposite to just >)
> > 
> > If I understand correctly, the index equal to the string's length corresponds 
> > to a situation where the caret is placed right after the last character. 
> > Wouldn't that cause additional failures in cases where the string in question 
> > ended with a newline?
> 
> I'm not sure I understand what you mean? What kind of failures are you considering? Do you have an specific example/failing test case that we can use to discuss about this?

Let's consider a test string of "\n". Wouldn't a valid index range in this case be [0,1], with 0 corresponding to a caret placed just before the newline and 1 right after it, resulting in returned line numbers of 0 and 1 respectively? If so, shouldn't the index validity check accept ranges up to and including the length of the input string?
Comment 7 Mario Sanchez Prada 2013-11-04 07:15:09 PST
(In reply to comment #6)
> [...]
> Let's consider a test string of "\n". Wouldn't a valid index range in this
> case be [0,1], with 0 corresponding to a caret placed just before the newline
> and 1 right after it, resulting in returned line numbers of 0 and 1
> respectively? If so, shouldn't the index validity check accept ranges up to
> and including the length of the input string?

I see. The thing that confuses me a bit is that in this case the 'index' parameter actually acts more like a 'count'/'len' than as a 'index'/'position' in the text.

From that point of view, then obviously the text length is a valid value for that, and so my previous comment is non-sense. Sorry about that and thanks for the clarification.
Comment 8 Rob Płóciennik 2013-11-04 07:28:31 PST
Created attachment 215918 [details]
Corrected patch
Comment 9 Mario Sanchez Prada 2013-11-04 07:39:06 PST
Comment on attachment 215918 [details]
Corrected patch

Thanks
Comment 10 WebKit Commit Bot 2013-11-04 08:02:16 PST
Comment on attachment 215918 [details]
Corrected patch

Clearing flags on attachment: 215918

Committed r158576: <http://trac.webkit.org/changeset/158576>
Comment 11 WebKit Commit Bot 2013-11-04 08:02:20 PST
All reviewed patches have been landed.  Closing bug.