Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp

Issue 2699393002: Place ellipsis correctly inside inline-blocks (Closed)
Patch Set: bug 133700 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/RootInlineBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
index 7d7d3e68fa2d03085caf477ac32cd8659c0066ac..6314b189868fc6cab52c10390e96fa3d16362477 100644
--- a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
@@ -111,33 +111,42 @@ LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr,
bool ltr,
LayoutUnit blockLeftEdge,
LayoutUnit blockRightEdge,
- LayoutUnit ellipsisWidth) {
- // Create an ellipsis box.
- EllipsisBox* ellipsisBox = new EllipsisBox(
- getLineLayoutItem(), ellipsisStr, this, ellipsisWidth, logicalHeight(),
- location(), !prevRootBox(), isHorizontal());
-
- if (!gEllipsisBoxMap)
- gEllipsisBoxMap = new EllipsisBoxMap();
- gEllipsisBoxMap->insert(this, ellipsisBox);
- setHasEllipsisBox(true);
+ LayoutUnit ellipsisWidth,
+ LayoutUnit logicalLeftOffset,
+ bool foundBox) {
+ // Create an ellipsis box if we don't already have one. If we already have one
+ // we're just
+ // here to blank out (truncate) the text boxes.
+ if (!foundBox) {
+ EllipsisBox* ellipsisBox = new EllipsisBox(
+ getLineLayoutItem(), ellipsisStr, this, ellipsisWidth, logicalHeight(),
+ location(), !prevRootBox(), isHorizontal());
+
+ if (!gEllipsisBoxMap)
+ gEllipsisBoxMap = new EllipsisBoxMap();
+ gEllipsisBoxMap->insert(this, ellipsisBox);
+ setHasEllipsisBox(true);
+ }
// FIXME: Do we need an RTL version of this?
+ LayoutUnit adjustedLogicalLeft = logicalLeftOffset + logicalLeft();
if (ltr &&
- (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdge) {
- ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth());
+ (adjustedLogicalLeft + logicalWidth() + ellipsisWidth) <=
+ blockRightEdge) {
+ if (hasEllipsisBox())
+ ellipsisBox()->setLogicalLeft(logicalLeft() + logicalWidth());
return logicalWidth() + ellipsisWidth;
}
// Now attempt to find the nearest glyph horizontally and place just to the
// right (or left in RTL) of that glyph. Mark all of the objects that
// intersect the ellipsis box as not painting (as being truncated).
- bool foundBox = false;
LayoutUnit truncatedWidth;
LayoutUnit position =
placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth,
- truncatedWidth, foundBox);
- ellipsisBox->setLogicalLeft(position);
+ truncatedWidth, foundBox, logicalLeftOffset);
+ if (hasEllipsisBox())
+ ellipsisBox()->setLogicalLeft(position);
return truncatedWidth;
}
@@ -146,13 +155,17 @@ LayoutUnit RootInlineBox::placeEllipsisBox(bool ltr,
LayoutUnit blockRightEdge,
LayoutUnit ellipsisWidth,
LayoutUnit& truncatedWidth,
- bool& foundBox) {
- LayoutUnit result =
- InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge,
- ellipsisWidth, truncatedWidth, foundBox);
+ bool& foundBox,
+ LayoutUnit logicalLeftOffset) {
+ LayoutUnit result = InlineFlowBox::placeEllipsisBox(
+ ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth,
+ foundBox, logicalLeftOffset);
if (result == -1) {
- result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge;
- truncatedWidth = blockRightEdge - blockLeftEdge;
+ result = ltr ? std::max<LayoutUnit>(
+ LayoutUnit(),
+ blockRightEdge - ellipsisWidth - logicalLeftOffset)
+ : blockLeftEdge - logicalLeftOffset;
+ truncatedWidth = blockRightEdge - blockLeftEdge - logicalLeftOffset;
}
return result;
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/RootInlineBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698