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

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

Issue 748073002: Use a StyleBuilderConverter function for line-height. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/resolver/StyleBuilderConverter.cpp ('k') | no next file » | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(newNamedGrid Areas, namedGridColumnLines, ForColumns); 297 StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(newNamedGrid Areas, namedGridColumnLines, ForColumns);
298 StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(newNamedGrid Areas, namedGridRowLines, ForRows); 298 StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(newNamedGrid Areas, namedGridRowLines, ForRows);
299 state.style()->setNamedGridColumnLines(namedGridColumnLines); 299 state.style()->setNamedGridColumnLines(namedGridColumnLines);
300 state.style()->setNamedGridRowLines(namedGridRowLines); 300 state.style()->setNamedGridRowLines(namedGridRowLines);
301 301
302 state.style()->setNamedGridArea(newNamedGridAreas); 302 state.style()->setNamedGridArea(newNamedGridAreas);
303 state.style()->setNamedGridAreaRowCount(gridTemplateAreasValue->rowCount()); 303 state.style()->setNamedGridAreaRowCount(gridTemplateAreasValue->rowCount());
304 state.style()->setNamedGridAreaColumnCount(gridTemplateAreasValue->columnCou nt()); 304 state.style()->setNamedGridAreaColumnCount(gridTemplateAreasValue->columnCou nt());
305 } 305 }
306 306
307 void StyleBuilderFunctions::applyValueCSSPropertyLineHeight(StyleResolverState& state, CSSValue* value)
308 {
309 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
310 Length lineHeight;
311
312 if (primitiveValue->getValueID() == CSSValueNormal) {
313 lineHeight = RenderStyle::initialLineHeight();
314 } else if (primitiveValue->isLength()) {
315 float multiplier = state.style()->effectiveZoom();
316 if (LocalFrame* frame = state.document().frame())
317 multiplier *= frame->textZoomFactor();
318 lineHeight = primitiveValue->computeLength<Length>(state.cssToLengthConv ersionData().copyWithAdjustedZoom(multiplier));
319 } else if (primitiveValue->isPercentage()) {
320 lineHeight = Length((state.style()->computedFontSize() * primitiveValue- >getIntValue()) / 100.0, Fixed);
321 } else if (primitiveValue->isNumber()) {
322 lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
323 } else if (primitiveValue->isCalculated()) {
324 double multiplier = state.style()->effectiveZoom();
325 if (LocalFrame* frame = state.document().frame())
326 multiplier *= frame->textZoomFactor();
327 Length zoomedLength = Length(primitiveValue->cssCalcValue()->toCalcValue (state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier)));
328 lineHeight = Length(valueForLength(zoomedLength, state.style()->fontSize ()), Fixed);
andersr 2014/11/21 16:29:15 Calc resolves against RenderStyle::fontSize, but p
Timothy Loh 2014/11/21 17:13:02 Sounds wrong, but I wouldn't fix it in this patch.
329 } else {
330 return;
331 }
332 state.style()->setLineHeight(lineHeight);
333 }
334
335 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverSta te& state, CSSValue* value) 307 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverSta te& state, CSSValue* value)
336 { 308 {
337 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage, value)); 309 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage, value));
338 } 310 }
339 311
340 void StyleBuilderFunctions::applyInitialCSSPropertyOutlineStyle(StyleResolverSta te& state) 312 void StyleBuilderFunctions::applyInitialCSSPropertyOutlineStyle(StyleResolverSta te& state)
341 { 313 {
342 state.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto( )); 314 state.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto( ));
343 state.style()->setOutlineStyle(RenderStyle::initialBorderStyle()); 315 state.style()->setOutlineStyle(RenderStyle::initialBorderStyle());
344 } 316 }
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 return; 916 return;
945 case CSSValueSuper: 917 case CSSValueSuper:
946 svgStyle.setBaselineShift(BS_SUPER); 918 svgStyle.setBaselineShift(BS_SUPER);
947 return; 919 return;
948 default: 920 default:
949 ASSERT_NOT_REACHED(); 921 ASSERT_NOT_REACHED();
950 } 922 }
951 } 923 }
952 924
953 } // namespace blink 925 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleBuilderConverter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698