[webkit-dev] A Range question
Darin Adler
darin at apple.com
Fri Apr 9 10:58:29 PDT 2010
On Apr 9, 2010, at 10:52 AM, Finnur Thorarinsson wrote:
> I need a WebKit "Ranger" for this question:
>
> Imagine I have the word "Foo" inside an edit field (input type=text value="Foo") and the word "bar" outside of it, like so: [Foo]bar
>
> If I try to create a Range of the text Foobar, the range will get collapsed.
>
> It collapses because Range::setEnd has a |start| inside the shadow tree and an |end| outside of it. Specifically, setEnd walks up the parent chain for both |start| and |end| (to see if they share the same root container), but doesn't reach the top for |start| because while walking up the parent list it stops on a shadow node (TextControlInnerTextElement), which has only a shadow parent.
>
> Is this expected? Is this a bug? Is the right fix to have it walk up the shadow parent for shadow nodes?
>
> Best regards,
> Finnur
>
> PS. I believe this is the root cause for https://bugs.webkit.org/show_bug.cgi?id=25868, which was a regression caused by the fix for https://bugs.webkit.org/show_bug.cgi?id=7023.
It’s expected behavior.
A selection needs to be either entirely inside an edit field, or outside the edit field. We don’t support selections that start partway through an edit field and then continue out to the outside document.
From the DOM API’s point of view, selections inside an edit field aren’t really selections at all. The DOM nodes within the shadow DOM tree should never be exposed to JavaScript in a webpage.
The find code in markAllMatchesForText needs to not consider matches that cross the boundary between the inside of an edit field and the rest of the document.
-- Darin
More information about the webkit-dev
mailing list