Chromium Code Reviews

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

Issue 227043007: CSS Length calculation with MediaValues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sizes_parser3
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 580 matching lines...)
591 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa ta& conversionData) 591 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa ta& conversionData)
592 { 592 {
593 return computeLengthDouble(conversionData); 593 return computeLengthDouble(conversionData);
594 } 594 }
595 595
596 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c onversionData) 596 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c onversionData)
597 { 597 {
598 if (m_primitiveUnitType == CSS_CALC) 598 if (m_primitiveUnitType == CSS_CALC)
599 return m_value.calc->computeLengthPx(conversionData); 599 return m_value.calc->computeLengthPx(conversionData);
600 600
601 const RenderStyle& style = conversionData.style();
602 const RenderStyle* rootStyle = conversionData.rootStyle();
603 bool computingFontSize = conversionData.computingFontSize(); 601 bool computingFontSize = conversionData.computingFontSize();
604 602
605 double factor; 603 double factor;
606 604
607 switch (primitiveType()) { 605 switch (primitiveType()) {
608 case CSS_EMS: 606 case CSS_EMS:
609 factor = computingFontSize ? style.fontDescription().specifiedSize() : style.fontDescription().computedSize(); 607 factor = computingFontSize ? conversionData.fontSpecifiedSize() : co nversionData.fontComputedSize();
610 break; 608 break;
611 case CSS_EXS: 609 case CSS_EXS:
612 // FIXME: We have a bug right now where the zoom will be applied twi ce to EX units. 610 // FIXME: We have a bug right now where the zoom will be applied twi ce to EX units.
613 // We really need to compute EX using fontMetrics for the original s pecifiedSize and not use 611 // We really need to compute EX using fontMetrics for the original s pecifiedSize and not use
614 // our actual constructed rendering font. 612 // our actual constructed rendering font.
615 if (style.fontMetrics().hasXHeight()) 613 if (conversionData.hasXHeight())
616 factor = style.fontMetrics().xHeight(); 614 factor = conversionData.xHeight();
617 else 615 else
618 factor = (computingFontSize ? style.fontDescription().specifiedS ize() : style.fontDescription().computedSize()) / 2.0; 616 factor = (computingFontSize ? conversionData.fontSpecifiedSize() : conversionData.fontComputedSize()) / 2.0;
619 break; 617 break;
620 case CSS_REMS: 618 case CSS_REMS:
621 if (rootStyle) 619 if (conversionData.hasRoot())
622 factor = computingFontSize ? rootStyle->fontDescription().specif iedSize() : rootStyle->fontDescription().computedSize(); 620 factor = computingFontSize ? conversionData.rootFontSpecifiedSiz e() : conversionData.rootFontComputedSize();
623 else 621 else
624 factor = 1.0; 622 factor = 1.0;
625 break; 623 break;
626 case CSS_CHS: 624 case CSS_CHS:
627 factor = style.fontMetrics().zeroWidth(); 625 factor = conversionData.zeroWidth();
628 break; 626 break;
629 case CSS_PX: 627 case CSS_PX:
630 factor = 1.0; 628 factor = 1.0;
631 break; 629 break;
632 case CSS_CM: 630 case CSS_CM:
633 factor = cssPixelsPerCentimeter; 631 factor = cssPixelsPerCentimeter;
634 break; 632 break;
635 case CSS_MM: 633 case CSS_MM:
636 factor = cssPixelsPerMillimeter; 634 factor = cssPixelsPerMillimeter;
637 break; 635 break;
(...skipping 679 matching lines...)
1317 case CSS_SHAPE: 1315 case CSS_SHAPE:
1318 visitor->trace(m_value.shape); 1316 visitor->trace(m_value.shape);
1319 break; 1317 break;
1320 default: 1318 default:
1321 break; 1319 break;
1322 } 1320 }
1323 CSSValue::traceAfterDispatch(visitor); 1321 CSSValue::traceAfterDispatch(visitor);
1324 } 1322 }
1325 1323
1326 } // namespace WebCore 1324 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/CSSToLengthConversionData.h » ('j') | Source/core/css/CSSToLengthConversionData.h » ('J')

Powered by Google App Engine