|
|
DescriptionDispose temporary and not-cached Range in DOMSelection
We can dispose temporary Range in Selection of shadow root because
it is neither cached nor exposed to js but we create it each time
when we call getRangeAt().
BUG=693975
Patch Set 1 #Patch Set 2 : update #
Total comments: 1
Patch Set 3 : update #
Total comments: 4
Messages
Total messages: 19 (10 generated)
The CQ bit was checked by yoichio@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== Dispose temporary and not-cached Range in DOMSelection BUG=693975 ========== to ========== Dispose temporary and not-cached Range in DOMSelection We can dispose temporary Range in Selection of shadow root because it is neither cached nor exposed to js but we create it each time when we call getRangeAt(). BUG=693975 ==========
yoichio@chromium.org changed reviewers: + tkent@chromium.org, yosin@chromium.org
> // However, Selection of shadow root returns copied Range everytime so far This is just a limitation of our current implementation, and we can fix it. Anyway, can we resolve this issue by updating primaryRangeOrNull() like: Range* DOMSelection::primaryRangeOrNull() const { if (rangeCount() <= 0) return nullptr; Range* range = getRangeAt(0, ASSERT_NO_EXCEPTION); if (!isSelectionOfDocument()) range->dispose(); return range; } ?
https://codereview.chromium.org/2783103002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/2783103002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/DOMSelection.cpp:128: class ScopedRange { Please introduce a function acts like primaryRangeOrNull() but returns EphemeralRange, e.g. Optinal<EphemeralRange> compurePrimaryEphemeralRange(). We don't want to introduce |ScopedRange| anywhere. We discussed introducing it on Jun 2014 when [1] was filed. [1] http://crbug.com/388681 Avoid registering temporary Range object for updating on the Document
The CQ bit was checked by yoichio@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
> Range* DOMSelection::primaryRangeOrNull() const { > if (rangeCount() <= 0) > return nullptr; > Range* range = getRangeAt(0, ASSERT_NO_EXCEPTION); > if (!isSelectionOfDocument()) > range->dispose(); > return range; > } > Disposing inside primaryRangeOrNull looks better. Done. PTAL
PTAL
https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/DOMSelection.cpp:544: if (!isSelectionOfDocument()) I'm not a fan of this approach. We still create temporary Range. Disposing it doesn't make execution speed, but we still have temporary object eating GC heap up.
https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/DOMSelection.cpp:544: if (!isSelectionOfDocument()) On 2017/04/04 04:50:07, yosin_UTC9 wrote: > I'm not a fan of this approach. We still create temporary Range. > Disposing it doesn't make execution speed, but we still have temporary object > eating GC heap up. Creating temporary Ranges and Disposing them is different matter. At least disposing Range from document makes tree modification faster though temporary Range is in heap. I will implement somehow there is cached Range for each TreeScope later.
https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/DOMSelection.cpp:544: if (!isSelectionOfDocument()) On 2017/04/04 at 05:32:42, yoichio wrote: > On 2017/04/04 04:50:07, yosin_UTC9 wrote: > > I'm not a fan of this approach. We still create temporary Range. > > Disposing it doesn't make execution speed, but we still have temporary object > > eating GC heap up. > Creating temporary Ranges and Disposing them is different matter. > At least disposing Range from document makes tree modification > faster though temporary Range is in heap. > > I will implement somehow there is cached Range for each TreeScope > later. Calling Range::dispose() is error prone in this case and hacky. Let's make clear code rather hacky code.
https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/2783103002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/DOMSelection.cpp:544: if (!isSelectionOfDocument()) > Calling Range::dispose() is error prone in this case and hacky. > Let's make clear code rather hacky code. I agree that it's a hack :) If we have no reason to be hurry, we should avoid this approach. |