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

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 684213002: Return correct length for firstLetterLength. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | « LayoutTests/fast/css/first-letter-wbr-first-character-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index 2604be6e70be9b2c8f0059ad47f3d9cd4ea90254..b1ee0e6eb70355229bb1b7df602f130c3eb0d683 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -3634,6 +3634,9 @@ static inline unsigned firstLetterLength(const String& text)
unsigned length = 0;
unsigned textLength = text.length();
+ if (textLength == 0)
+ return length;
+
// Account for leading spaces first.
while (length < textLength && isSpaceForFirstLetter(text[length]))
length++;
@@ -3643,7 +3646,7 @@ static inline unsigned firstLetterLength(const String& text)
length++;
// Bail if we didn't find a letter before the end of the text or before a space.
- if (isSpaceForFirstLetter(text[length]) || (textLength && length == textLength))
+ if (isSpaceForFirstLetter(text[length]) || length == textLength)
return 0;
// Account the next character for first letter.
@@ -3658,8 +3661,6 @@ static inline unsigned firstLetterLength(const String& text)
length = scanLength + 1;
}
-
- // FIXME: If textLength is 0, length may still be 1!
return length;
}
@@ -3732,7 +3733,7 @@ void RenderBlock::updateFirstLetter()
// FIXME: If there is leading punctuation in a different RenderText than
// the first letter, we'll not apply the correct style to it.
length = firstLetterLength(toRenderText(currChild)->originalText());
- if (length)
+ if (length || (currChild->isBR() || (currChild->isText() && toRenderText(currChild)->isWordBreak())))
leviw_travelin_and_unemployed 2014/10/29 20:26:52 Can you extract these cases into a static named fu
dsinclair 2014/10/30 14:07:27 Done.
break;
currChild = currChild->nextSibling();
} else if (currChild->isListMarker()) {
« no previous file with comments | « LayoutTests/fast/css/first-letter-wbr-first-character-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698