WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 209129
Move most of TextIterator off of live ranges
https://bugs.webkit.org/show_bug.cgi?id=209129
Summary
Move most of TextIterator off of live ranges
Darin Adler
Reported
2020-03-15 15:56:31 PDT
Move most of TextIterator off of live ranges
Attachments
Patch
(104.80 KB, patch)
2020-03-15 16:45 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(104.73 KB, patch)
2020-03-15 22:35 PDT
,
Darin Adler
koivisto
: review+
Details
Formatted Diff
Diff
Crash Log from ews122
(114.11 KB, patch)
2020-03-16 10:24 PDT
,
Aakash Jain
no flags
Details
Formatted Diff
Diff
Patch
(121.01 KB, patch)
2020-03-16 12:01 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(113.42 KB, patch)
2020-03-16 12:08 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2020-03-15 16:45:52 PDT
Comment hidden (obsolete)
Created
attachment 393628
[details]
Patch
Darin Adler
Comment 2
2020-03-15 16:52:13 PDT
Comment hidden (obsolete)
This is ready for Mac and iOS, but I’ll let EWS run now to tell me if there are compilation issues on other platforms, or in Release builds, or catch if there was some configuration where I didn’t run tests. Before I ask anyone to review.
Darin Adler
Comment 3
2020-03-15 22:35:38 PDT
Created
attachment 393633
[details]
Patch
Antti Koivisto
Comment 4
2020-03-16 00:13:28 PDT
Comment on
attachment 393633
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393633&action=review
> Source/WebCore/ChangeLog:17 > + - Re-remove the include of SimpleRange.h from TextIterator.h. Instead, files that > + use TextIterator.h will include SimpleRange.h as needed. This probably re-breaks > + unified builds, but the fix will be to add includes of SimpleRange.h elsewhere, > + not to TextIterator.h itself.
Does this lead to fewer includes somewhere? Presumably at least every cpp file using TextIterator directly is going to need SimpleRange anyway. If not, this might add unnecessary maintenance burden.
> Source/WebCore/accessibility/AXObjectCache.cpp:1905 > + for (TextIterator it(*range); !it.atEnd(); it.advance()) {
Not sure if it is worth the effort but it would be nice to eventually be able to do something like for (auto& textItem : textIteratorRange(*range))
> Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:52 > - _textIterator = makeUnique<WebCore::TextIterator>(WebKit::toWebCoreRange(range)); > + if (!range) > + return self; > + > + _textIterator = makeUnique<WebCore::TextIterator>(*WebKit::toWebCoreRange(range));
I suppose an alternative in these cased would be to construct a TextIterator with empty range? That would lead to fewer null checks in other parts of the code and maybe fewer chances to get things wrong.
Antti Koivisto
Comment 5
2020-03-16 00:15:13 PDT
Comment on
attachment 393633
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393633&action=review
> Source/WebCore/dom/Range.h:46 > +// FIXME: Rename to LiveRange, while leaving the DOM-exposed name as Range.
Good idea!
Darin Adler
Comment 6
2020-03-16 08:43:31 PDT
Comment on
attachment 393633
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393633&action=review
Need to fix the iOS test failure before landing.
>> Source/WebCore/ChangeLog:17 >> + not to TextIterator.h itself. > > Does this lead to fewer includes somewhere? Presumably at least every cpp file using TextIterator directly is going to need SimpleRange anyway. > > If not, this might add unnecessary maintenance burden.
There are functions in TextIterator.h that you can use without SimpleRange; like using an iterator created elsewhere and passed to you, for example. But, yes, still not 100% sure this is better. Would be willing to do the reverse and add it here and remove all the unnecessary places it’s included elsewhere.
>> Source/WebCore/accessibility/AXObjectCache.cpp:1905 >> + for (TextIterator it(*range); !it.atEnd(); it.advance()) { > > Not sure if it is worth the effort but it would be nice to eventually be able to do something like > > for (auto& textItem : textIteratorRange(*range))
I like that idea. I think it’s worth it. It’s how I would design the text iterator if I was creating it now. I will eventually come back and do that.
>> Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:52 >> + _textIterator = makeUnique<WebCore::TextIterator>(*WebKit::toWebCoreRange(range)); > > I suppose an alternative in these cased would be to construct a TextIterator with empty range? That would lead to fewer null checks in other parts of the code and maybe fewer chances to get things wrong.
Even an empty SimoleRange requires at least one node, which I don’t have here. But I could add a default constructor to TextIterator that makes an empty iterator. I chose this approach because the class is so small (only 5 null checks needed) and was already heap-allocating the TextIterator. But I would happily consider an alternative.
Antti Koivisto
Comment 7
2020-03-16 09:38:02 PDT
> There are functions in TextIterator.h that you can use without SimpleRange; > like using an iterator created elsewhere and passed to you, for example. > But, yes, still not 100% sure this is better. Would be willing to do the > reverse and add it here and remove all the unnecessary places it’s included > elsewhere.
I'd prefer that.
> Even an empty SimoleRange requires at least one node, which I don’t have > here. But I could add a default constructor to TextIterator that makes an > empty iterator. I chose this approach because the class is so small (only 5 > null checks needed) and was already heap-allocating the TextIterator. But I > would happily consider an alternative.
Note that there is another similar class in WebKitLegacy following this pattern. I'm ok with the current approach too if you prefer it.
Aakash Jain
Comment 8
2020-03-16 10:24:49 PDT
Created
attachment 393658
[details]
Crash Log from ews122 Manually copied crash log from ews122 from
https://ews-build.webkit.org/#/builders/24/builds/13112
Darin Adler
Comment 9
2020-03-16 11:36:43 PDT
(In reply to Antti Koivisto from
comment #7
)
> > There are functions in TextIterator.h that you can use without SimpleRange; > > like using an iterator created elsewhere and passed to you, for example. > > But, yes, still not 100% sure this is better. Would be willing to do the > > reverse and add it here and remove all the unnecessary places it’s included > > elsewhere. > > I'd prefer that.
Sure thing. I came to that conclusion already and was already working on it.
> > Even an empty SimoleRange requires at least one node, which I don’t have > > here. But I could add a default constructor to TextIterator that makes an > > empty iterator. I chose this approach because the class is so small (only 5 > > null checks needed) and was already heap-allocating the TextIterator. But I > > would happily consider an alternative. > > Note that there is another similar class in WebKitLegacy following this > pattern. I'm ok with the current approach too if you prefer it.
Yes, it’s the same class, just copied and pasted for Legacy vs. Modern WebKit. I will stick with this approach for now. Could always come back later.
Darin Adler
Comment 10
2020-03-16 12:01:15 PDT
Comment hidden (obsolete)
Created
attachment 393668
[details]
Patch
Darin Adler
Comment 11
2020-03-16 12:08:02 PDT
Created
attachment 393670
[details]
Patch
Darin Adler
Comment 12
2020-03-16 16:02:16 PDT
Committed
r258525
: <
https://trac.webkit.org/changeset/258525
>
Radar WebKit Bug Importer
Comment 13
2020-03-16 16:03:15 PDT
<
rdar://problem/60514402
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug