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

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

Issue 1024473004: Do not treat '0' as 'none' for font-size-adjust (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 9 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
« no previous file with comments | « Source/core/css/resolver/FontBuilder.h ('k') | Source/core/layout/style/LayoutStyle.cpp » ('j') | 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * Copyright (C) 2015 Collabora Ltd. All rights reserved. 5 * Copyright (C) 2015 Collabora Ltd. 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (!specifiedSize && fontDescription.keywordSize()) 322 if (!specifiedSize && fontDescription.keywordSize())
323 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio n.keywordSize(), fontDescription.fixedPitchFontType()); 323 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio n.keywordSize(), fontDescription.fixedPitchFontType());
324 324
325 fontDescription.setSpecifiedSize(specifiedSize); 325 fontDescription.setSpecifiedSize(specifiedSize);
326 326
327 checkForGenericFamilyChange(style.fontDescription(), fontDescription); 327 checkForGenericFamilyChange(style.fontDescription(), fontDescription);
328 } 328 }
329 329
330 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Lay outStyle& style, FontSelector* fontSelector) 330 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Lay outStyle& style, FontSelector* fontSelector)
331 { 331 {
332 const float sizeAdjust = fontDescription.sizeAdjust();
333 const float specifiedSize = fontDescription.specifiedSize(); 332 const float specifiedSize = fontDescription.specifiedSize();
334 if (!sizeAdjust || !specifiedSize) 333 if (!fontDescription.hasSizeAdjust() || !specifiedSize)
335 return; 334 return;
336 335
337 // We need to create a temporal Font to get xHeight of a primary font. 336 // We need to create a temporal Font to get xHeight of a primary font.
338 // The aspect value is based on the xHeight of the font for the computed fon t size, 337 // The aspect value is based on the xHeight of the font for the computed fon t size,
339 // so we need to reset the adjustment. 338 // so we need to reset the adjustedSize to computedSize. See FontDescription ::effectiveFontSize.
340 fontDescription.setAdjustedSize(0); 339 fontDescription.setAdjustedSize(fontDescription.computedSize());
341 340
342 Font font(fontDescription); 341 Font font(fontDescription);
343 font.update(fontSelector); 342 font.update(fontSelector);
344 if (!font.fontMetrics().hasXHeight()) 343 if (!font.fontMetrics().hasXHeight())
345 return; 344 return;
346 345
346 const float sizeAdjust = fontDescription.sizeAdjust();
347 float aspectValue = font.fontMetrics().xHeight() / specifiedSize; 347 float aspectValue = font.fontMetrics().xHeight() / specifiedSize;
348 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; 348 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
349 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec tiveZoom(), adjustedSize); 349 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec tiveZoom(), adjustedSize);
350 350
351 float multiplier = style.textAutosizingMultiplier(); 351 float multiplier = style.textAutosizingMultiplier();
352 if (multiplier > 1) 352 if (multiplier > 1)
353 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul tiplier); 353 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul tiplier);
354 fontDescription.setAdjustedSize(adjustedSize); 354 fontDescription.setAdjustedSize(adjustedSize);
355 } 355 }
356 356
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 FontOrientation fontOrientation; 429 FontOrientation fontOrientation;
430 NonCJKGlyphOrientation glyphOrientation; 430 NonCJKGlyphOrientation glyphOrientation;
431 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ; 431 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ;
432 fontDescription.setOrientation(fontOrientation); 432 fontDescription.setOrientation(fontOrientation);
433 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); 433 fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
434 documentStyle.setFontDescription(fontDescription); 434 documentStyle.setFontDescription(fontDescription);
435 documentStyle.font().update(fontSelector); 435 documentStyle.font().update(fontSelector);
436 } 436 }
437 437
438 } 438 }
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FontBuilder.h ('k') | Source/core/layout/style/LayoutStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698