Bug 52644 - Stop instantiating legacy editing positions in DeleteSelectionCommand, IndentOudentCommand, InsertLineBreakCommand, InsertListCOmmand.cpp, InsertParagraphSeparatorCommand, and htmlediting.cpp
Summary: Stop instantiating legacy editing positions in DeleteSelectionCommand, Indent...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks: 52099
  Show dependency treegraph
 
Reported: 2011-01-18 11:39 PST by Ryosuke Niwa
Modified: 2011-01-18 13:33 PST (History)
4 users (show)

See Also:


Attachments
cleanup (19.98 KB, patch)
2011-01-18 11:49 PST, Ryosuke Niwa
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2011-01-18 11:39:21 PST
Cleanup in the following files:
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/IndentOutdentCommand.cpp
Source/WebCore/editing/InsertLineBreakCommand.cpp
Source/WebCore/editing/InsertListCommand.cpp
Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
Source/WebCore/editing/htmlediting.cpp
Comment 1 Ryosuke Niwa 2011-01-18 11:49:16 PST
Created attachment 79302 [details]
cleanup
Comment 2 Eric Seidel (no email) 2011-01-18 12:26:55 PST
Comment on attachment 79302 [details]
cleanup

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

OK.

> Source/WebCore/editing/DeleteSelectionCommand.cpp:111
>      // For HRs, we'll get a position at (HR,1) when hitting delete from the beginning of the previous line, or (HR,0) when forward deleting,

Seems we need to update this comment?

> Source/WebCore/editing/DeleteSelectionCommand.cpp:321
> +    switch (position.anchorType()) {
> +    case Position::PositionIsOffsetInAnchor:
> +        if (position.containerNode() == node->parentNode() && static_cast<unsigned>(position.offsetInContainerNode()) > node->nodeIndex())
> +            position.moveToOffset(position.offsetInContainerNode() - 1);

I wonder if this method should move onto the Position class.

I also wonder if DeleteSelectionCommand wants to be using RangeEndPoint intsead of Position, since don't ranges do this sort of thing automatically?

> Source/WebCore/editing/DeleteSelectionCommand.cpp:489
> +                    m_downstreamEnd.moveToOffset(m_downstreamEnd.deprecatedEditingOffset() - 1);

I guess moveToOffset does not ASSERT that the offset is valid?

Can we use something other than deprecatedEditingOffset() here? or is that a separate change?
Comment 3 Ryosuke Niwa 2011-01-18 12:55:19 PST
Comment on attachment 79302 [details]
cleanup

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

Thanks for the review, Eric.  Unfortunately, I can't make further changes because of the chicken or the egg dilemma.

>> Source/WebCore/editing/DeleteSelectionCommand.cpp:111
>>      // For HRs, we'll get a position at (HR,1) when hitting delete from the beginning of the previous line, or (HR,0) when forward deleting,
> 
> Seems we need to update this comment?

This comment is about start/end passed onto DeleteSelectionCommand, which is probably generated by upstream/downstream, and not about the positions we're expanding to.  So I will not remove.

>> Source/WebCore/editing/DeleteSelectionCommand.cpp:321
>> +            position.moveToOffset(position.offsetInContainerNode() - 1);
> 
> I wonder if this method should move onto the Position class.
> 
> I also wonder if DeleteSelectionCommand wants to be using RangeEndPoint intsead of Position, since don't ranges do this sort of thing automatically?

You're right.  DeleteSelectionCommand should be using a Range but I guess that refactoring can only be done after we got rid of legacy editing positions because ranges aren't compatible with legacy editing positions.

>> Source/WebCore/editing/DeleteSelectionCommand.cpp:489
>> +                    m_downstreamEnd.moveToOffset(m_downstreamEnd.deprecatedEditingOffset() - 1);
> 
> I guess moveToOffset does not ASSERT that the offset is valid?
> 
> Can we use something other than deprecatedEditingOffset() here? or is that a separate change?

I can call offsetInContainerNode but that isn't really correct in the sense that the code around it doesn't really consider positions before/after node, and they also call .node() all over the place.  I'm planning to remove all calls to Position::node(), and not calling deprecatedEditingOffset() here should be a part of that change.
Comment 4 Ryosuke Niwa 2011-01-18 13:33:51 PST
Committed r76057: <http://trac.webkit.org/changeset/76057>