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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp

Issue 2686693002: Don't keep a static copy of a font's ellipsis character. (Closed)
Patch Set: bug 663855 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All right reserved. 4 * All right reserved.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 2347
2348 void LayoutBlockFlow::checkLinesForTextOverflow() { 2348 void LayoutBlockFlow::checkLinesForTextOverflow() {
2349 // Determine the width of the ellipsis using the current font. 2349 // Determine the width of the ellipsis using the current font.
2350 const Font& font = style()->font(); 2350 const Font& font = style()->font();
2351 2351
2352 const size_t fullStopStringLength = 3; 2352 const size_t fullStopStringLength = 3;
2353 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, 2353 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter,
2354 fullstopCharacter}; 2354 fullstopCharacter};
2355 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, 2355 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr,
2356 (fullStopString, fullStopStringLength)); 2356 (fullStopString, fullStopStringLength));
2357 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, 2357 AtomicString selectedEllipsisStr(&horizontalEllipsisCharacter, 1);
2358 (&horizontalEllipsisCharacter, 1));
2359 AtomicString& selectedEllipsisStr = ellipsisStr;
2360 2358
2361 const Font& firstLineFont = firstLineStyle()->font(); 2359 const Font& firstLineFont = firstLineStyle()->font();
2362 // FIXME: We should probably not hard-code the direction here. 2360 // FIXME: We should probably not hard-code the direction here.
2363 // https://crbug.com/333004 2361 // https://crbug.com/333004
2364 TextDirection ellipsisDirection = TextDirection::kLtr; 2362 TextDirection ellipsisDirection = TextDirection::kLtr;
2365 float firstLineEllipsisWidth = 0; 2363 float firstLineEllipsisWidth = 0;
2366 float ellipsisWidth = 0; 2364 float ellipsisWidth = 0;
2367 2365
2368 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of 2366 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of
2369 // three Full Stops (002E) can be used. 2367 // three Full Stops (002E) can be used.
2370 const SimpleFontData* fontData = firstLineFont.primaryFont(); 2368 const SimpleFontData* fontData = firstLineFont.primaryFont();
2371 DCHECK(fontData); 2369 DCHECK(fontData);
2372 if (fontData && fontData->glyphForCharacter(horizontalEllipsisCharacter)) { 2370 if (fontData && fontData->glyphForCharacter(horizontalEllipsisCharacter)) {
2373 firstLineEllipsisWidth = firstLineFont.width( 2371 firstLineEllipsisWidth = firstLineFont.width(
2374 constructTextRun(firstLineFont, &horizontalEllipsisCharacter, 1, 2372 constructTextRun(firstLineFont, &horizontalEllipsisCharacter, 1,
2375 *firstLineStyle(), ellipsisDirection)); 2373 *firstLineStyle(), ellipsisDirection));
2376 } else { 2374 } else {
2377 selectedEllipsisStr = fullstopCharacterStr; 2375 selectedEllipsisStr = fullstopCharacterStr;
2378 firstLineEllipsisWidth = firstLineFont.width( 2376 firstLineEllipsisWidth = firstLineFont.width(
2379 constructTextRun(firstLineFont, fullStopString, fullStopStringLength, 2377 constructTextRun(firstLineFont, fullStopString, fullStopStringLength,
2380 *firstLineStyle(), ellipsisDirection)); 2378 *firstLineStyle(), ellipsisDirection));
2381 } 2379 }
2382 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0; 2380 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0;
2383 2381
2384 if (!ellipsisWidth) { 2382 if (!ellipsisWidth) {
2385 ASSERT(font.primaryFont()); 2383 ASSERT(font.primaryFont());
2386 if (font.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter)) { 2384 if (font.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter)) {
2387 selectedEllipsisStr = ellipsisStr;
2388 ellipsisWidth = 2385 ellipsisWidth =
2389 font.width(constructTextRun(font, &horizontalEllipsisCharacter, 1, 2386 font.width(constructTextRun(font, &horizontalEllipsisCharacter, 1,
2390 styleRef(), ellipsisDirection)); 2387 styleRef(), ellipsisDirection));
2391 } else { 2388 } else {
2392 selectedEllipsisStr = fullstopCharacterStr; 2389 selectedEllipsisStr = fullstopCharacterStr;
2393 ellipsisWidth = font.width( 2390 ellipsisWidth = font.width(
2394 constructTextRun(font, fullStopString, fullStopStringLength, 2391 constructTextRun(font, fullStopString, fullStopStringLength,
2395 styleRef(), ellipsisDirection)); 2392 styleRef(), ellipsisDirection));
2396 } 2393 }
2397 } 2394 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 2512
2516 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { 2513 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const {
2517 // LayoutBlockFlow is in charge of paint invalidation of the first line. 2514 // LayoutBlockFlow is in charge of paint invalidation of the first line.
2518 if (firstLineBox()) 2515 if (firstLineBox())
2519 return false; 2516 return false;
2520 2517
2521 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); 2518 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize();
2522 } 2519 }
2523 2520
2524 } // namespace blink 2521 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/linux/fast/text/ellipsis-rtl-text-in-rtl-flow-underline-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698