2011-02-28 Ryosuke Niwa <rniwa@webkit.org>
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Feb 2011 13:24:25 +0000 (13:24 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Feb 2011 13:24:25 +0000 (13:24 +0000)
commit4dd02f9eafdb0bdb12f2218cd3c7113dd9c7b994
tree4434cca06c1096bafbef427d4e9f201aaa0005df
parentdd71a9834f1078b422ff8e1caec1c031aebf54cc
2011-02-28  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Kent Tamura.

        Range::processContents needs cleanup
        https://bugs.webkit.org/show_bug.cgi?id=51006

        Refactored Range::processContents.  Extracted childOfCommonRootBeforeOffset from processContents
        which is used to find processStart and processEnd respectively.  In the case of processStart,
        we use the next sibling of the node returned by childOfCommonRootBeforeOffset when m_start is not
        the common root because copying m_start's ancestors will result in processing too much contents.

        Also extracted processNodes and deleteCharacterData from processContents and processContentsBetweenOffsets.

        In addition, lengthOfContentsInNode was modified to return the correct length instead of
        numeric_limits<unsigned>::max() because the convention that processContentsBetweenOffsets automatically
        corrects the length when endOffset is numeric_limits<unsigned>::max() seemed more confusing than
        having two switch statements that need to be consistent.

        Historically, lengthOfContentsInNode was introduced in r78413 as a build fix because unsigned const
        LengthOfContentsInNode added in r78409 violated WebKit C++ rules and caused build failures on Mac and
        other ports.

        * dom/Range.cpp:
        (WebCore::childOfCommonRootBeforeOffset): Extracted from processContents.
        (WebCore::lengthOfContentsInNode): Added.
        (WebCore::Range::processContents): Calls childOfCommonRootBeforeOffset, lengthOfContentsInNode,
        and processNodes.
        (WebCore::deleteCharacterData): Added.
        (WebCore::Range::processContentsBetweenOffsets): Calls deleteCharacterData and processNodes.
        (WebCore::Range::processNodes): Extracted from processContents and processContentsBetweenOffsets.
        (WebCore::Range::processAncestorsAndTheirSiblings):
        * dom/Range.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/Range.h