Bug 68875 - Encapsulate m_firstNodeInserted and m_lastLeafInserted in node insertion logic
Summary: Encapsulate m_firstNodeInserted and m_lastLeafInserted in node insertion logic
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks: 68874
  Show dependency treegraph
 
Reported: 2011-09-27 00:26 PDT by Ryosuke Niwa
Modified: 2011-09-27 01:59 PDT (History)
7 users (show)

See Also:


Attachments
refactoring (13.48 KB, patch)
2011-09-27 00:39 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Added the forgotten DeleteSelectionCommand change (16.11 KB, patch)
2011-09-27 00:40 PDT, Ryosuke Niwa
tkent: review+
Details | Formatted Diff | Diff
patch for landing (16.46 KB, patch)
2011-09-27 01:40 PDT, Ryosuke Niwa
no flags 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-09-27 00:26:58 PDT
As the first part of the bug 68874, we need to encapsulate m_firstNodeInserted and m_lastLeafInserted in ReplaceSelectionCommand's node insertion logic.
Comment 1 Ryosuke Niwa 2011-09-27 00:39:02 PDT
Created attachment 108800 [details]
refactoring
Comment 2 WebKit Review Bot 2011-09-27 00:40:32 PDT
Attachment 108800 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/editing/ReplaceSelectionCommand.cpp:557:  Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side.  [whitespace/operators] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Ryosuke Niwa 2011-09-27 00:40:44 PDT
Created attachment 108802 [details]
Added the forgotten DeleteSelectionCommand change
Comment 4 WebKit Review Bot 2011-09-27 00:43:01 PDT
Attachment 108802 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/editing/ReplaceSelectionCommand.cpp:557:  Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side.  [whitespace/operators] [4]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Ryosuke Niwa 2011-09-27 00:43:24 PDT
Comment on attachment 108802 [details]
Added the forgotten DeleteSelectionCommand change

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

> Source/WebCore/editing/ReplaceSelectionCommand.cpp:558
> -    if (!m_firstNodeInserted->renderer() && 
> +    if (!m_firstNodeInserted->renderer() &&
>          m_firstNodeInserted->isTextNode()) {

Style bot is complaining about this existing line. I'll revert this whitespace change or fix the style if the reviewer is so inclined.
Comment 6 Kent Tamura 2011-09-27 01:20:06 PDT
Comment on attachment 108802 [details]
Added the forgotten DeleteSelectionCommand change

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

> Source/WebCore/editing/ReplaceSelectionCommand.h:82
> +        void respondToNodeInsertion(Node* node)
> +        {
> +            if (!node)
> +                return;
> +            
> +            if (!m_firstNodeInserted)
> +                m_firstNodeInserted = node;
> +            
> +            m_lastNodeInserted = node;
> +        }
> +        void willRemoveNode(Node* node)
> +        {
> +            if (m_firstNodeInserted == node)
> +                m_firstNodeInserted = node->traverseNextNode();
> +            if (m_lastNodeInserted == node)
> +                m_lastNodeInserted = node->lastChild() ? node->lastChild() : node->traverseNextSibling();
> +        }

nit: I'd like to move these function definitions to ReplaceSelectionCommand.cpp in order to reduce the header size.

> Source/WebCore/editing/ReplaceSelectionCommand.h:85
> +        Node* firstNodeInserted() { return m_firstNodeInserted.get(); }
> +        Node* lastLeafInserted() { return m_lastNodeInserted->lastDescendant(); }
> +        Node* pastLastLeaf() { return m_firstNodeInserted ? lastLeafInserted()->traverseNextNode() : 0; }

nit: These function should be "const".

> Source/WebCore/editing/ReplaceSelectionCommand.h:86
> +    private:

Need a blank line before the private: label.
Comment 7 Ryosuke Niwa 2011-09-27 01:38:37 PDT
Thanks for the review! Will land safely after addressing your comments.
Comment 8 Ryosuke Niwa 2011-09-27 01:40:23 PDT
Created attachment 108809 [details]
patch for landing
Comment 9 WebKit Review Bot 2011-09-27 01:59:15 PDT
Comment on attachment 108809 [details]
patch for landing

Clearing flags on attachment: 108809

Committed r96084: <http://trac.webkit.org/changeset/96084>
Comment 10 WebKit Review Bot 2011-09-27 01:59:20 PDT
All reviewed patches have been landed.  Closing bug.