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

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

Issue 2100013002: Implement the new text-size-adjust CSS property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup convertTextSizeAdjust and add a test that better covers it Created 4 years, 5 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. 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 font.update(fontSelector); 325 font.update(fontSelector);
326 if (!font.getFontMetrics().hasXHeight()) 326 if (!font.getFontMetrics().hasXHeight())
327 return; 327 return;
328 328
329 const float sizeAdjust = fontDescription.sizeAdjust(); 329 const float sizeAdjust = fontDescription.sizeAdjust();
330 float aspectValue = font.getFontMetrics().xHeight() / specifiedSize; 330 float aspectValue = font.getFontMetrics().xHeight() / specifiedSize;
331 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; 331 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
332 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec tiveZoom(), adjustedSize); 332 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec tiveZoom(), adjustedSize);
333 333
334 float multiplier = style.textAutosizingMultiplier(); 334 float multiplier = style.textAutosizingMultiplier();
335 if (multiplier > 1) 335 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, multipl ier);
336 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul tiplier);
337 fontDescription.setAdjustedSize(adjustedSize); 336 fontDescription.setAdjustedSize(adjustedSize);
338 } 337 }
339 338
340 void FontBuilder::updateComputedSize(FontDescription& fontDescription, const Com putedStyle& style) 339 void FontBuilder::updateComputedSize(FontDescription& fontDescription, const Com putedStyle& style)
341 { 340 {
342 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style .effectiveZoom(), fontDescription.specifiedSize()); 341 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style .effectiveZoom(), fontDescription.specifiedSize());
343 float multiplier = style.textAutosizingMultiplier(); 342 float multiplier = style.textAutosizingMultiplier();
344 if (multiplier > 1) 343 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, multipl ier);
345 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul tiplier);
346 fontDescription.setComputedSize(computedSize); 344 fontDescription.setComputedSize(computedSize);
347 } 345 }
348 346
349 void FontBuilder::createFont(FontSelector* fontSelector, ComputedStyle& style) 347 void FontBuilder::createFont(FontSelector* fontSelector, ComputedStyle& style)
350 { 348 {
351 if (!m_flags) 349 if (!m_flags)
352 return; 350 return;
353 351
354 FontDescription description = style.getFontDescription(); 352 FontDescription description = style.getFontDescription();
355 353
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false)); 405 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false));
408 updateSpecifiedSize(fontDescription, documentStyle); 406 updateSpecifiedSize(fontDescription, documentStyle);
409 updateComputedSize(fontDescription, documentStyle); 407 updateComputedSize(fontDescription, documentStyle);
410 408
411 updateOrientation(fontDescription, documentStyle); 409 updateOrientation(fontDescription, documentStyle);
412 documentStyle.setFontDescription(fontDescription); 410 documentStyle.setFontDescription(fontDescription);
413 documentStyle.font().update(fontSelector); 411 documentStyle.font().update(fontSelector);
414 } 412 }
415 413
416 } // namespace blink 414 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698