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

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.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 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 || rareInheritedData->hyphenationString != other.rareInheritedData-> hyphenationString 580 || rareInheritedData->hyphenationString != other.rareInheritedData-> hyphenationString
581 || rareInheritedData->m_respectImageOrientation != other.rareInherit edData->m_respectImageOrientation 581 || rareInheritedData->m_respectImageOrientation != other.rareInherit edData->m_respectImageOrientation
582 || rareInheritedData->m_rubyPosition != other.rareInheritedData->m_r ubyPosition 582 || rareInheritedData->m_rubyPosition != other.rareInheritedData->m_r ubyPosition
583 || rareInheritedData->textEmphasisMark != other.rareInheritedData->t extEmphasisMark 583 || rareInheritedData->textEmphasisMark != other.rareInheritedData->t extEmphasisMark
584 || rareInheritedData->textEmphasisPosition != other.rareInheritedDat a->textEmphasisPosition 584 || rareInheritedData->textEmphasisPosition != other.rareInheritedDat a->textEmphasisPosition
585 || rareInheritedData->textEmphasisCustomMark != other.rareInheritedD ata->textEmphasisCustomMark 585 || rareInheritedData->textEmphasisCustomMark != other.rareInheritedD ata->textEmphasisCustomMark
586 || rareInheritedData->m_textJustify != other.rareInheritedData->m_te xtJustify 586 || rareInheritedData->m_textJustify != other.rareInheritedData->m_te xtJustify
587 || rareInheritedData->m_textOrientation != other.rareInheritedData-> m_textOrientation 587 || rareInheritedData->m_textOrientation != other.rareInheritedData-> m_textOrientation
588 || rareInheritedData->m_textCombine != other.rareInheritedData->m_te xtCombine 588 || rareInheritedData->m_textCombine != other.rareInheritedData->m_te xtCombine
589 || rareInheritedData->m_tabSize != other.rareInheritedData->m_tabSiz e 589 || rareInheritedData->m_tabSize != other.rareInheritedData->m_tabSiz e
590 || rareInheritedData->m_textSizeAdjust != other.rareInheritedData->m _textSizeAdjust
590 || rareInheritedData->listStyleImage != other.rareInheritedData->lis tStyleImage 591 || rareInheritedData->listStyleImage != other.rareInheritedData->lis tStyleImage
591 || rareInheritedData->m_snapHeightUnit != other.rareInheritedData->m _snapHeightUnit 592 || rareInheritedData->m_snapHeightUnit != other.rareInheritedData->m _snapHeightUnit
592 || rareInheritedData->m_snapHeightPosition != other.rareInheritedDat a->m_snapHeightPosition 593 || rareInheritedData->m_snapHeightPosition != other.rareInheritedDat a->m_snapHeightPosition
593 || rareInheritedData->textStrokeWidth != other.rareInheritedData->te xtStrokeWidth) 594 || rareInheritedData->textStrokeWidth != other.rareInheritedData->te xtStrokeWidth)
594 return true; 595 return true;
595 596
596 if (!rareInheritedData->shadowDataEquivalent(*other.rareInheritedData.ge t())) 597 if (!rareInheritedData->shadowDataEquivalent(*other.rareInheritedData.ge t()))
597 return true; 598 return true;
598 599
599 if (!rareInheritedData->quotesDataEquivalent(*other.rareInheritedData.ge t())) 600 if (!rareInheritedData->quotesDataEquivalent(*other.rareInheritedData.ge t()))
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 } 1342 }
1342 1343
1343 const Length& ComputedStyle::specifiedLineHeight() const { return inherited->lin e_height; } 1344 const Length& ComputedStyle::specifiedLineHeight() const { return inherited->lin e_height; }
1344 Length ComputedStyle::lineHeight() const 1345 Length ComputedStyle::lineHeight() const
1345 { 1346 {
1346 const Length& lh = inherited->line_height; 1347 const Length& lh = inherited->line_height;
1347 // Unlike getFontDescription().computedSize() and hence fontSize(), this is 1348 // Unlike getFontDescription().computedSize() and hence fontSize(), this is
1348 // recalculated on demand as we only store the specified line height. 1349 // recalculated on demand as we only store the specified line height.
1349 // FIXME: Should consider scaling the fixed part of any calc expressions 1350 // FIXME: Should consider scaling the fixed part of any calc expressions
1350 // too, though this involves messily poking into CalcExpressionLength. 1351 // too, though this involves messily poking into CalcExpressionLength.
1351 float multiplier = textAutosizingMultiplier(); 1352 if (lh.isFixed()) {
1352 if (multiplier > 1 && lh.isFixed()) 1353 float multiplier = textAutosizingMultiplier();
1353 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multip lier), Fixed); 1354 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multip lier), Fixed);
1355 }
1354 1356
1355 return lh; 1357 return lh;
1356 } 1358 }
1357 1359
1358 void ComputedStyle::setLineHeight(const Length& specifiedLineHeight) { SET_VAR(i nherited, line_height, specifiedLineHeight); } 1360 void ComputedStyle::setLineHeight(const Length& specifiedLineHeight) { SET_VAR(i nherited, line_height, specifiedLineHeight); }
1359 1361
1360 int ComputedStyle::computedLineHeight() const 1362 int ComputedStyle::computedLineHeight() const
1361 { 1363 {
1362 const Length& lh = lineHeight(); 1364 const Length& lh = lineHeight();
1363 1365
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 if (!std::isfinite(size) || size < 0) 1402 if (!std::isfinite(size) || size < 0)
1401 size = 0; 1403 size = 0;
1402 else 1404 else
1403 size = std::min(maximumAllowedFontSize, size); 1405 size = std::min(maximumAllowedFontSize, size);
1404 1406
1405 FontSelector* currentFontSelector = font().getFontSelector(); 1407 FontSelector* currentFontSelector = font().getFontSelector();
1406 FontDescription desc(getFontDescription()); 1408 FontDescription desc(getFontDescription());
1407 desc.setSpecifiedSize(size); 1409 desc.setSpecifiedSize(size);
1408 desc.setComputedSize(size); 1410 desc.setComputedSize(size);
1409 1411
1410 if (multiplier > 1) { 1412 float autosizedFontSize = TextAutosizer::computeAutosizedFontSize(size, mult iplier);
1411 float autosizedFontSize = TextAutosizer::computeAutosizedFontSize(size, multiplier); 1413 desc.setComputedSize(std::min(maximumAllowedFontSize, autosizedFontSize));
1412 desc.setComputedSize(std::min(maximumAllowedFontSize, autosizedFontSize) );
1413 }
1414 1414
1415 setFontDescription(desc); 1415 setFontDescription(desc);
1416 font().update(currentFontSelector); 1416 font().update(currentFontSelector);
1417 } 1417 }
1418 1418
1419 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion) 1419 void ComputedStyle::addAppliedTextDecoration(const AppliedTextDecoration& decora tion)
1420 { 1420 {
1421 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations; 1421 RefPtr<AppliedTextDecorationList>& list = rareInheritedData.access()->applie dTextDecorations;
1422 1422
1423 if (!list) 1423 if (!list)
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 if (value < 0) 1874 if (value < 0)
1875 fvalue -= 0.5f; 1875 fvalue -= 0.5f;
1876 else 1876 else
1877 fvalue += 0.5f; 1877 fvalue += 0.5f;
1878 } 1878 }
1879 1879
1880 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 1880 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
1881 } 1881 }
1882 1882
1883 } // namespace blink 1883 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698