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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp

Issue 2416033003: Remove unsafe getFontMetrics methods (Closed)
Patch Set: Address wkroman suggestions Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2013 Google Inc. All rights reserved. 5 * Copyright (C) 2013 Google Inc. All rights reserved.
6 * Copyright (C) 2015 Collabora Ltd. All rights reserved. 6 * Copyright (C) 2015 Collabora Ltd. 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return; 312 return;
313 313
314 // We need to create a temporal Font to get xHeight of a primary font. 314 // We need to create a temporal Font to get xHeight of a primary font.
315 // The aspect value is based on the xHeight of the font for the computed font 315 // The aspect value is based on the xHeight of the font for the computed font
316 // size, so we need to reset the adjustedSize to computedSize. See 316 // size, so we need to reset the adjustedSize to computedSize. See
317 // FontDescription::effectiveFontSize. 317 // FontDescription::effectiveFontSize.
318 fontDescription.setAdjustedSize(fontDescription.computedSize()); 318 fontDescription.setAdjustedSize(fontDescription.computedSize());
319 319
320 Font font(fontDescription); 320 Font font(fontDescription);
321 font.update(fontSelector); 321 font.update(fontSelector);
322 if (!font.getFontMetrics().hasXHeight()) 322
323 const SimpleFontData* fontData = font.primaryFont();
324
325 if (!fontData || !fontData->getFontMetrics().hasXHeight())
323 return; 326 return;
324 327
325 const float sizeAdjust = fontDescription.sizeAdjust(); 328 const float sizeAdjust = fontDescription.sizeAdjust();
326 float aspectValue = font.getFontMetrics().xHeight() / specifiedSize; 329 float aspectValue = fontData->getFontMetrics().xHeight() / specifiedSize;
327 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; 330 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
328 adjustedSize = getComputedSizeFromSpecifiedSize( 331 adjustedSize = getComputedSizeFromSpecifiedSize(
329 fontDescription, style.effectiveZoom(), adjustedSize); 332 fontDescription, style.effectiveZoom(), adjustedSize);
330 333
331 float multiplier = style.textAutosizingMultiplier(); 334 float multiplier = style.textAutosizingMultiplier();
332 adjustedSize = 335 adjustedSize =
333 TextAutosizer::computeAutosizedFontSize(adjustedSize, multiplier); 336 TextAutosizer::computeAutosizedFontSize(adjustedSize, multiplier);
334 fontDescription.setAdjustedSize(adjustedSize); 337 fontDescription.setAdjustedSize(adjustedSize);
335 } 338 }
336 339
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false)); 410 FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false));
408 updateSpecifiedSize(fontDescription, documentStyle); 411 updateSpecifiedSize(fontDescription, documentStyle);
409 updateComputedSize(fontDescription, documentStyle); 412 updateComputedSize(fontDescription, documentStyle);
410 413
411 updateOrientation(fontDescription, documentStyle); 414 updateOrientation(fontDescription, documentStyle);
412 documentStyle.setFontDescription(fontDescription); 415 documentStyle.setFontDescription(fontDescription);
413 documentStyle.font().update(fontSelector); 416 documentStyle.font().update(fontSelector);
414 } 417 }
415 418
416 } // namespace blink 419 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698