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

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 820093005: [TextBlob] Recompute blob bounds when empty. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) { 249 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) {
250 cacheEntry->glyphBounds = glyphBounds; 250 cacheEntry->glyphBounds = glyphBounds;
251 cacheEntry->width = result; 251 cacheEntry->width = result;
252 } 252 }
253 253
254 if (glyphOverflow) 254 if (glyphOverflow)
255 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ; 255 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ;
256 return result; 256 return result;
257 } 257 }
258 258
259 static bool requiresRecomputingBounds(const Font& font) 259 static bool requiresRecomputingBounds(const Font& font, const FloatRect& bounds)
260 { 260 {
261 // Blobs should never have empty bounds, but see http://crbug.com/445527
262 if (bounds.isEmpty())
263 return true;
264
261 const FontDescription& fontDescription = font.fontDescription(); 265 const FontDescription& fontDescription = font.fontDescription();
262 return fontDescription.letterSpacing() < 0 || fontDescription.wordSpacing() < 0; 266 return fontDescription.letterSpacing() < 0 || fontDescription.wordSpacing() < 0;
263 } 267 }
264 268
265 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR ect& bounds, 269 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR ect& bounds,
266 bool couldUseLCD) const 270 bool couldUseLCD) const
267 { 271 {
268 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); 272 ASSERT(RuntimeEnabledFeatures::textBlobEnabled());
269 273
270 SkTextBlobBuilder builder; 274 SkTextBlobBuilder builder;
271 SkRect skBounds = bounds; 275 SkRect skBounds = bounds;
272 // FIXME: Identify these cases earlier on and avoid using bounds that are 276 // FIXME: Identify these cases earlier on and avoid using bounds that are
273 // not visually correct in other places. 277 // not visually correct in other places.
274 const SkRect* skBoundsPtr = requiresRecomputingBounds(*this) ? nullptr : &sk Bounds; 278 const SkRect* skBoundsPtr = requiresRecomputingBounds(*this, bounds) ? nullp tr : &skBounds;
275 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets(); 279 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets();
276 280
277 unsigned i = 0; 281 unsigned i = 0;
278 while (i < glyphBuffer.size()) { 282 while (i < glyphBuffer.size()) {
279 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); 283 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i);
280 284
281 // FIXME: Handle vertical text. 285 // FIXME: Handle vertical text.
282 if (fontData->platformData().orientation() == Vertical) 286 if (fontData->platformData().orientation() == Vertical)
283 return nullptr; 287 return nullptr;
284 288
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 if (delta <= 0) 964 if (delta <= 0)
961 break; 965 break;
962 } 966 }
963 } 967 }
964 } 968 }
965 969
966 return offset; 970 return offset;
967 } 971 }
968 972
969 } // namespace blink 973 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698