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

Side by Side Diff: Source/core/css/CSSPrimitiveValue.cpp

Issue 705783002: Decouple font unit conversion in computeLengthDouble from RenderStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Forgot to remove ASSERT(rootStyle). Created 6 years, 1 month 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/CSSMatrix.cpp ('k') | Source/core/css/CSSToLengthConversionData.h » ('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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 597 }
598 598
599 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c onversionData) 599 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c onversionData)
600 { 600 {
601 // The logic in this function is duplicated in MediaValues::computeLength 601 // The logic in this function is duplicated in MediaValues::computeLength
602 // because MediaValues::computeLength needs nearly identical logic, but we h aven't found a way to make 602 // because MediaValues::computeLength needs nearly identical logic, but we h aven't found a way to make
603 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases) without hurting performance. 603 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases) without hurting performance.
604 if (m_primitiveUnitType == CSS_CALC) 604 if (m_primitiveUnitType == CSS_CALC)
605 return m_value.calc->computeLengthPx(conversionData); 605 return m_value.calc->computeLengthPx(conversionData);
606 606
607 const RenderStyle& style = conversionData.style();
608 const RenderStyle* rootStyle = conversionData.rootStyle();
609 bool computingFontSize = conversionData.computingFontSize();
610
611 double factor; 607 double factor;
612 608
613 switch (primitiveType()) { 609 switch (primitiveType()) {
614 case CSS_EMS: 610 case CSS_EMS:
615 factor = computingFontSize ? style.fontDescription().specifiedSize() : style.fontDescription().computedSize(); 611 factor = conversionData.emFontSize();
616 break; 612 break;
617 case CSS_EXS: 613 case CSS_EXS:
618 // FIXME: We have a bug right now where the zoom will be applied twi ce to EX units. 614 factor = conversionData.exFontSize();
619 // We really need to compute EX using fontMetrics for the original s pecifiedSize and not use
620 // our actual constructed rendering font.
621 if (style.fontMetrics().hasXHeight())
622 factor = style.fontMetrics().xHeight();
623 else
624 factor = (computingFontSize ? style.fontDescription().specifiedS ize() : style.fontDescription().computedSize()) / 2.0;
625 break; 615 break;
626 case CSS_REMS: 616 case CSS_REMS:
627 if (rootStyle) 617 factor = conversionData.remFontSize();
628 factor = computingFontSize ? rootStyle->fontDescription().specif iedSize() : rootStyle->fontDescription().computedSize();
629 else
630 factor = 1.0;
631 break; 618 break;
632 case CSS_CHS: 619 case CSS_CHS:
633 factor = style.fontMetrics().zeroWidth(); 620 factor = conversionData.chFontSize();
634 break; 621 break;
635 case CSS_PX: 622 case CSS_PX:
636 factor = 1.0; 623 factor = 1.0;
637 break; 624 break;
638 case CSS_CM: 625 case CSS_CM:
639 factor = cssPixelsPerCentimeter; 626 factor = cssPixelsPerCentimeter;
640 break; 627 break;
641 case CSS_MM: 628 case CSS_MM:
642 factor = cssPixelsPerMillimeter; 629 factor = cssPixelsPerMillimeter;
643 break; 630 break;
(...skipping 24 matching lines...) Expand all
668 return -1.0; 655 return -1.0;
669 default: 656 default:
670 ASSERT_NOT_REACHED(); 657 ASSERT_NOT_REACHED();
671 return -1.0; 658 return -1.0;
672 } 659 }
673 660
674 // We do not apply the zoom factor when we are computing the value of the fo nt-size property. The zooming 661 // We do not apply the zoom factor when we are computing the value of the fo nt-size property. The zooming
675 // for font sizes is much more complicated, since we have to worry about enf orcing the minimum font size preference 662 // for font sizes is much more complicated, since we have to worry about enf orcing the minimum font size preference
676 // as well as enforcing the implicit "smart minimum." 663 // as well as enforcing the implicit "smart minimum."
677 double result = getDoubleValue() * factor; 664 double result = getDoubleValue() * factor;
678 if (computingFontSize || isFontRelativeLength()) 665 if (isFontRelativeLength())
679 return result; 666 return result;
680 667
681 return result * conversionData.zoom(); 668 return result * conversionData.zoom();
682 } 669 }
683 670
684 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, doubl e multiplier) const 671 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, doubl e multiplier) const
685 { 672 {
686 ASSERT(lengthArray.size() == LengthUnitTypeCount); 673 ASSERT(lengthArray.size() == LengthUnitTypeCount);
687 674
688 if (m_primitiveUnitType == CSS_CALC) { 675 if (m_primitiveUnitType == CSS_CALC) {
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 visitor->trace(m_value.shape); 1412 visitor->trace(m_value.shape);
1426 break; 1413 break;
1427 default: 1414 default:
1428 break; 1415 break;
1429 } 1416 }
1430 #endif 1417 #endif
1431 CSSValue::traceAfterDispatch(visitor); 1418 CSSValue::traceAfterDispatch(visitor);
1432 } 1419 }
1433 1420
1434 } // namespace blink 1421 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSMatrix.cpp ('k') | Source/core/css/CSSToLengthConversionData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698