Modified: trunk/Source/WebCore/ChangeLog (92430 => 92431)
--- trunk/Source/WebCore/ChangeLog 2011-08-04 23:46:59 UTC (rev 92430)
+++ trunk/Source/WebCore/ChangeLog 2011-08-04 23:56:24 UTC (rev 92431)
@@ -1,3 +1,24 @@
+2011-08-04 Van Lam <van...@google.com>
+
+ A few purely stylistic modifications to visible_units.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=65723
+
+ 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):
+
2011-08-04 James Robinson <jam...@chromium.org>
[chromium] Implement a global resource limit for DrawingBuffer to limit the amount of GPU memory used by 2d canvas backing stores
Modified: trunk/Source/WebCore/editing/visible_units.cpp (92430 => 92431)
--- trunk/Source/WebCore/editing/visible_units.cpp 2011-08-04 23:46:59 UTC (rev 92430)
+++ trunk/Source/WebCore/editing/visible_units.cpp 2011-08-04 23:56:24 UTC (rev 92431)
@@ -1444,42 +1444,42 @@
return VisiblePosition();
}
-static int greatestValueUnder(int offset, bool boxAndBlockAreInSameDirection, const WordBoundaryVector& orderedWordBoundaries)
+static int greatestOffsetUnder(int offset, bool boxAndBlockAreInSameDirection, const WordBoundaryVector& orderedWordBoundaries)
{
if (!orderedWordBoundaries.size())
- return invalidOffset;
+ return -1;
// FIXME: binary search.
if (boxAndBlockAreInSameDirection) {
for (unsigned i = 0; i < orderedWordBoundaries.size(); ++i) {
if (orderedWordBoundaries[i].offsetInInlineBox < offset)
return i;
}
- return invalidOffset;
+ return -1;
}
for (int i = orderedWordBoundaries.size() - 1; i >= 0; --i) {
if (orderedWordBoundaries[i].offsetInInlineBox < offset)
return i;
}
- return invalidOffset;
+ return -1;
}
static int smallestOffsetAbove(int offset, bool boxAndBlockAreInSameDirection, const WordBoundaryVector& orderedWordBoundaries)
{
if (!orderedWordBoundaries.size())
- return invalidOffset;
+ return -1;
// FIXME: binary search.
if (boxAndBlockAreInSameDirection) {
for (int i = orderedWordBoundaries.size() - 1; i >= 0; --i) {
if (orderedWordBoundaries[i].offsetInInlineBox > offset)
return i;
}
- return invalidOffset;
+ return -1;
}
for (unsigned i = 0; i < orderedWordBoundaries.size(); ++i) {
if (orderedWordBoundaries[i].offsetInInlineBox > offset)
return i;
}
- return invalidOffset;
+ return -1;
}
static const RenderBlock* blockWithPreviousLineBox(const RenderBlock* startingBlock)
@@ -1599,7 +1599,7 @@
return VisiblePosition();
}
-static bool positionIsInsideBox(const VisiblePosition& wordBreak, const InlineBox* box)
+static bool positionIsInBoxButNotOnBoundary(const VisiblePosition& wordBreak, const InlineBox* box)
{
int offsetOfWordBreak;
return positionIsInBox(wordBreak, box, offsetOfWordBreak)
@@ -1633,15 +1633,15 @@
else
wordBreak = nextBoundary(visiblePosition, nextWordPositionBoundary);
}
- if (wordBreak.isNotNull() && positionIsInsideBox(wordBreak, box))
+ if (wordBreak.isNotNull() && positionIsInBoxButNotOnBoundary(wordBreak, box))
return wordBreak;
WordBoundaryVector orderedWordBoundaries;
collectWordBreaksInBox(box, orderedWordBoundaries, blockDirection);
- int index = box->isLeftToRightDirection() ? greatestValueUnder(offset, blockDirection == LTR, orderedWordBoundaries) :
- smallestOffsetAbove(offset, blockDirection == RTL, orderedWordBoundaries);
- if (index != invalidOffset)
+ int index = box->isLeftToRightDirection() ? greatestOffsetUnder(offset, blockDirection == LTR, orderedWordBoundaries)
+ : smallestOffsetAbove(offset, blockDirection == RTL, orderedWordBoundaries);
+ if (index >= 0)
return orderedWordBoundaries[index].visiblePosition;
return leftWordBoundary(leftInlineBox(box, blockDirection), invalidOffset, blockDirection);
@@ -1670,15 +1670,15 @@
else
wordBreak = nextBoundary(visiblePosition, nextWordPositionBoundary);
}
- if (wordBreak.isNotNull() && positionIsInsideBox(wordBreak, box))
+ if (wordBreak.isNotNull() && positionIsInBoxButNotOnBoundary(wordBreak, box))
return wordBreak;
WordBoundaryVector orderedWordBoundaries;
collectWordBreaksInBox(box, orderedWordBoundaries, blockDirection);
- int index = box->isLeftToRightDirection() ? smallestOffsetAbove(offset, blockDirection == LTR, orderedWordBoundaries) :
- greatestValueUnder(offset, blockDirection == RTL, orderedWordBoundaries);
- if (index != invalidOffset)
+ int index = box->isLeftToRightDirection() ? smallestOffsetAbove(offset, blockDirection == LTR, orderedWordBoundaries)
+ : greatestOffsetUnder(offset, blockDirection == RTL, orderedWordBoundaries);
+ if (index >= 0)
return orderedWordBoundaries[index].visiblePosition;
return rightWordBoundary(rightInlineBox(box, blockDirection), invalidOffset, blockDirection);