Changeset 92431 in webkit


Ignore:
Timestamp:
Aug 4, 2011, 4:56:24 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

A few purely stylistic modifications to visible_units.cpp
https://bugs.webkit.org/show_bug.cgi?id=65723

Patch by Van Lam <vanlam@google.com> on 2011-08-04
Reviewed by Ryosuke Niwa.

Renamed greatestValueUnder to greatestOffsetUnder, positionIsInsideBox
to positionIsInBoxButNotOnBoundary (to avoid confusion with
positionIsInBox, which is just a getInlineBoxAndOffset check).
Removed use of invalidOffset as an error value in greatestOffsetUnder
and smallestOffsetAbove since semantically it should only be used to
check if it makes sense to compare offsets in a single box.

  • editing/visible_units.cpp:

(WebCore::greatestOffsetUnder):
(WebCore::smallestOffsetAbove):
(WebCore::positionIsInBoxButNotOnBoundary):
(WebCore::leftWordPositionAcrossBoundary):
(WebCore::rightWordPositionAcrossBoundary):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92430 r92431  
     12011-08-04  Van Lam  <vanlam@google.com>
     2
     3        A few purely stylistic modifications to visible_units.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=65723
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Renamed greatestValueUnder to greatestOffsetUnder, positionIsInsideBox
     9        to positionIsInBoxButNotOnBoundary (to avoid confusion with
     10        positionIsInBox, which is just a getInlineBoxAndOffset check).
     11        Removed use of invalidOffset as an error value in greatestOffsetUnder
     12        and smallestOffsetAbove since semantically it should only be used to
     13        check if it makes sense to compare offsets in a single box.
     14
     15        * editing/visible_units.cpp:
     16        (WebCore::greatestOffsetUnder):
     17        (WebCore::smallestOffsetAbove):
     18        (WebCore::positionIsInBoxButNotOnBoundary):
     19        (WebCore::leftWordPositionAcrossBoundary):
     20        (WebCore::rightWordPositionAcrossBoundary):
     21
    1222011-08-04  James Robinson  <jamesr@chromium.org>
    223
  • trunk/Source/WebCore/editing/visible_units.cpp

    r92286 r92431  
    14451445}
    14461446       
    1447 static int greatestValueUnder(int offset, bool boxAndBlockAreInSameDirection, const WordBoundaryVector& orderedWordBoundaries)
     1447static int greatestOffsetUnder(int offset, bool boxAndBlockAreInSameDirection, const WordBoundaryVector& orderedWordBoundaries)
    14481448{
    14491449    if (!orderedWordBoundaries.size())
    1450         return invalidOffset;
     1450        return -1;
    14511451    // FIXME: binary search.
    14521452    if (boxAndBlockAreInSameDirection) {
     
    14551455                return i;
    14561456        }
    1457         return invalidOffset;
     1457        return -1;
    14581458    }
    14591459    for (int i = orderedWordBoundaries.size() - 1; i >= 0; --i) {
     
    14611461            return i;
    14621462    }
    1463     return invalidOffset;
     1463    return -1;
    14641464}
    14651465
     
    14671467{
    14681468    if (!orderedWordBoundaries.size())
    1469         return invalidOffset;
     1469        return -1;
    14701470    // FIXME: binary search.
    14711471    if (boxAndBlockAreInSameDirection) {
     
    14741474                return i;
    14751475        }
    1476         return invalidOffset;
     1476        return -1;
    14771477    }
    14781478    for (unsigned i = 0; i < orderedWordBoundaries.size(); ++i) {
     
    14801480            return i;
    14811481    }
    1482     return invalidOffset;
     1482    return -1;
    14831483}
    14841484
     
    16001600}
    16011601   
    1602 static bool positionIsInsideBox(const VisiblePosition& wordBreak, const InlineBox* box)
     1602static bool positionIsInBoxButNotOnBoundary(const VisiblePosition& wordBreak, const InlineBox* box)
    16031603{
    16041604    int offsetOfWordBreak;
     
    16341634            wordBreak = nextBoundary(visiblePosition, nextWordPositionBoundary);
    16351635    }
    1636     if (wordBreak.isNotNull() && positionIsInsideBox(wordBreak, box))
     1636    if (wordBreak.isNotNull() && positionIsInBoxButNotOnBoundary(wordBreak, box))
    16371637        return wordBreak;
    16381638   
     
    16401640    collectWordBreaksInBox(box, orderedWordBoundaries, blockDirection);
    16411641
    1642     int index = box->isLeftToRightDirection() ? greatestValueUnder(offset, blockDirection == LTR, orderedWordBoundaries) :
    1643         smallestOffsetAbove(offset, blockDirection == RTL, orderedWordBoundaries);
    1644     if (index != invalidOffset)
     1642    int index = box->isLeftToRightDirection() ? greatestOffsetUnder(offset, blockDirection == LTR, orderedWordBoundaries)
     1643        : smallestOffsetAbove(offset, blockDirection == RTL, orderedWordBoundaries);
     1644    if (index >= 0)
    16451645        return orderedWordBoundaries[index].visiblePosition;
    16461646   
     
    16711671            wordBreak = nextBoundary(visiblePosition, nextWordPositionBoundary);
    16721672    }
    1673     if (wordBreak.isNotNull() && positionIsInsideBox(wordBreak, box))
     1673    if (wordBreak.isNotNull() && positionIsInBoxButNotOnBoundary(wordBreak, box))
    16741674        return wordBreak;
    16751675   
     
    16771677    collectWordBreaksInBox(box, orderedWordBoundaries, blockDirection);
    16781678   
    1679     int index = box->isLeftToRightDirection() ? smallestOffsetAbove(offset, blockDirection == LTR, orderedWordBoundaries) :
    1680         greatestValueUnder(offset, blockDirection == RTL, orderedWordBoundaries);
    1681     if (index != invalidOffset)
     1679    int index = box->isLeftToRightDirection() ? smallestOffsetAbove(offset, blockDirection == LTR, orderedWordBoundaries)
     1680        : greatestOffsetUnder(offset, blockDirection == RTL, orderedWordBoundaries);
     1681    if (index >= 0)
    16821682        return orderedWordBoundaries[index].visiblePosition;
    16831683   
Note: See TracChangeset for help on using the changeset viewer.