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

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

Issue 64293008: Wrap CSS length conversion arguments in an object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: erm.. use DEFINE_STATIC_REF Created 7 years 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) 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "StyleBuilderFunctions.h" 44 #include "StyleBuilderFunctions.h"
45 #include "StylePropertyShorthand.h" 45 #include "StylePropertyShorthand.h"
46 #include "core/css/BasicShapeFunctions.h" 46 #include "core/css/BasicShapeFunctions.h"
47 #include "core/css/CSSAspectRatioValue.h" 47 #include "core/css/CSSAspectRatioValue.h"
48 #include "core/css/CSSCursorImageValue.h" 48 #include "core/css/CSSCursorImageValue.h"
49 #include "core/css/CSSFontValue.h" 49 #include "core/css/CSSFontValue.h"
50 #include "core/css/CSSFunctionValue.h" 50 #include "core/css/CSSFunctionValue.h"
51 #include "core/css/CSSGradientValue.h" 51 #include "core/css/CSSGradientValue.h"
52 #include "core/css/CSSGridLineNamesValue.h" 52 #include "core/css/CSSGridLineNamesValue.h"
53 #include "core/css/CSSGridTemplateValue.h" 53 #include "core/css/CSSGridTemplateValue.h"
54 #include "core/css/CSSHelper.h"
54 #include "core/css/CSSImageSetValue.h" 55 #include "core/css/CSSImageSetValue.h"
55 #include "core/css/CSSLineBoxContainValue.h" 56 #include "core/css/CSSLineBoxContainValue.h"
56 #include "core/css/CSSParser.h" 57 #include "core/css/CSSParser.h"
57 #include "core/css/CSSPrimitiveValueMappings.h" 58 #include "core/css/CSSPrimitiveValueMappings.h"
58 #include "core/css/CSSProperty.h" 59 #include "core/css/CSSProperty.h"
59 #include "core/css/CSSReflectValue.h" 60 #include "core/css/CSSReflectValue.h"
60 #include "core/css/CSSShadowValue.h" 61 #include "core/css/CSSShadowValue.h"
61 #include "core/css/CSSVariableValue.h" 62 #include "core/css/CSSVariableValue.h"
62 #include "core/css/Counter.h" 63 #include "core/css/Counter.h"
63 #include "core/css/Pair.h" 64 #include "core/css/Pair.h"
(...skipping 21 matching lines...) Expand all
85 #include "core/svg/SVGURIReference.h" 86 #include "core/svg/SVGURIReference.h"
86 #include "platform/fonts/FontDescription.h" 87 #include "platform/fonts/FontDescription.h"
87 #include "wtf/MathExtras.h" 88 #include "wtf/MathExtras.h"
88 #include "wtf/StdLibExtras.h" 89 #include "wtf/StdLibExtras.h"
89 #include "wtf/Vector.h" 90 #include "wtf/Vector.h"
90 91
91 namespace WebCore { 92 namespace WebCore {
92 93
93 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue* value) 94 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue* value)
94 { 95 {
95 return value->convertToLength<FixedConversion | PercentConversion | AutoConv ersion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()) ; 96 return value->convertToLength<FixedConversion | PercentConversion | AutoConv ersion>(state.cssToLengthConversionData());
96 } 97 }
97 98
98 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& stat e) 99 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& stat e)
99 { 100 {
100 state.style()->setClip(Length(), Length(), Length(), Length()); 101 state.style()->setClip(Length(), Length(), Length(), Length());
101 state.style()->setHasClip(false); 102 state.style()->setHasClip(false);
102 } 103 }
103 104
104 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& stat e) 105 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& stat e)
105 { 106 {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 { 270 {
270 if (!value->isPrimitiveValue()) 271 if (!value->isPrimitiveValue())
271 return; 272 return;
272 273
273 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 274 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
274 Length lineHeight; 275 Length lineHeight;
275 276
276 if (primitiveValue->getValueID() == CSSValueNormal) { 277 if (primitiveValue->getValueID() == CSSValueNormal) {
277 lineHeight = RenderStyle::initialLineHeight(); 278 lineHeight = RenderStyle::initialLineHeight();
278 } else if (primitiveValue->isLength()) { 279 } else if (primitiveValue->isLength()) {
279 double multiplier = state.style()->effectiveZoom(); 280 float multiplier = state.style()->effectiveZoom();
280 if (Frame* frame = state.document().frame()) 281 if (Frame* frame = state.document().frame())
281 multiplier *= frame->textZoomFactor(); 282 multiplier *= frame->textZoomFactor();
282 lineHeight = primitiveValue->computeLength<Length>(state.style(), state. rootElementStyle(), multiplier); 283 lineHeight = primitiveValue->computeLength<Length>(state.cssToLengthConv ersionData().copyWithAdjustedZoom(multiplier));
283 } else if (primitiveValue->isPercentage()) { 284 } else if (primitiveValue->isPercentage()) {
284 lineHeight = Length((state.style()->computedFontSize() * primitiveValue- >getIntValue()) / 100.0, Fixed); 285 lineHeight = Length((state.style()->computedFontSize() * primitiveValue- >getIntValue()) / 100.0, Fixed);
285 } else if (primitiveValue->isNumber()) { 286 } else if (primitiveValue->isNumber()) {
286 lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent); 287 lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
287 } else if (primitiveValue->isViewportPercentageLength()) { 288 } else if (primitiveValue->isViewportPercentageLength()) {
288 lineHeight = primitiveValue->viewportPercentageLength(); 289 lineHeight = primitiveValue->viewportPercentageLength();
289 } else if (primitiveValue->isCalculated()) { 290 } else if (primitiveValue->isCalculated()) {
290 double multiplier = state.style()->effectiveZoom(); 291 double multiplier = state.style()->effectiveZoom();
291 if (Frame* frame = state.document().frame()) 292 if (Frame* frame = state.document().frame())
292 multiplier *= frame->textZoomFactor(); 293 multiplier *= frame->textZoomFactor();
293 Length zoomedLength = Length(primitiveValue->cssCalcValue()->toCalcValue (state.style(), state.rootElementStyle(), multiplier)); 294 Length zoomedLength = Length(primitiveValue->cssCalcValue()->toCalcValue (state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier)));
294 lineHeight = Length(valueForLength(zoomedLength, state.style()->fontSize ()), Fixed); 295 lineHeight = Length(valueForLength(zoomedLength, state.style()->fontSize ()), Fixed);
295 } else { 296 } else {
296 return; 297 return;
297 } 298 }
298 state.style()->setLineHeight(lineHeight); 299 state.style()->setLineHeight(lineHeight);
299 } 300 }
300 301
301 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverSta te& state, CSSValue* value) 302 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverSta te& state, CSSValue* value)
302 { 303 {
303 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage, value)); 304 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage, value));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 case CSSValueAuto: 337 case CSSValueAuto:
337 if (Settings* settings = state.document().settings()) 338 if (Settings* settings = state.document().settings())
338 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; 339 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
339 break; 340 break;
340 default: 341 default:
341 r = *primitiveValue; 342 r = *primitiveValue;
342 } 343 }
343 state.style()->setResize(r); 344 state.style()->setResize(r);
344 } 345 }
345 346
346 static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrim itiveValue::CSS_MM)->computeLength<Length>(0, 0); } 347 static Length mmLength(double mm) { return Length(mm * cssPixelsPerInch / 25.4, Fixed); }
Julien - ping for review 2013/11/26 05:31:07 25.4 == another magic constant!
Timothy Loh 2013/11/27 05:44:51 Fixed
347 static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, C SSPrimitiveValue::CSS_IN)->computeLength<Length>(0, 0); } 348 static Length inchLength(double inch) { return Length(inch * cssPixelsPerInch, F ixed); }
348 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveVal ue* pageOrientation, Length& width, Length& height) 349 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveVal ue* pageOrientation, Length& width, Length& height)
349 { 350 {
350 DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148))); 351 DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148)));
351 DEFINE_STATIC_LOCAL(Length, a5Height, (mmLength(210))); 352 DEFINE_STATIC_LOCAL(Length, a5Height, (mmLength(210)));
352 DEFINE_STATIC_LOCAL(Length, a4Width, (mmLength(210))); 353 DEFINE_STATIC_LOCAL(Length, a4Width, (mmLength(210)));
353 DEFINE_STATIC_LOCAL(Length, a4Height, (mmLength(297))); 354 DEFINE_STATIC_LOCAL(Length, a4Height, (mmLength(297)));
354 DEFINE_STATIC_LOCAL(Length, a3Width, (mmLength(297))); 355 DEFINE_STATIC_LOCAL(Length, a3Width, (mmLength(297)));
355 DEFINE_STATIC_LOCAL(Length, a3Height, (mmLength(420))); 356 DEFINE_STATIC_LOCAL(Length, a3Height, (mmLength(420)));
356 DEFINE_STATIC_LOCAL(Length, b5Width, (mmLength(176))); 357 DEFINE_STATIC_LOCAL(Length, b5Width, (mmLength(176)));
357 DEFINE_STATIC_LOCAL(Length, b5Height, (mmLength(250))); 358 DEFINE_STATIC_LOCAL(Length, b5Height, (mmLength(250)));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 case 2: { 433 case 2: {
433 // <length>{2} | <page-size> <orientation> 434 // <length>{2} | <page-size> <orientation>
434 if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPri mitiveValue()) 435 if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPri mitiveValue())
435 return; 436 return;
436 CSSPrimitiveValue* first = toCSSPrimitiveValue(inspector.first()); 437 CSSPrimitiveValue* first = toCSSPrimitiveValue(inspector.first());
437 CSSPrimitiveValue* second = toCSSPrimitiveValue(inspector.second()); 438 CSSPrimitiveValue* second = toCSSPrimitiveValue(inspector.second());
438 if (first->isLength()) { 439 if (first->isLength()) {
439 // <length>{2} 440 // <length>{2}
440 if (!second->isLength()) 441 if (!second->isLength())
441 return; 442 return;
442 width = first->computeLength<Length>(state.style(), state.rootElemen tStyle()); 443 width = first->computeLength<Length>(state.cssToLengthConversionData ().copyWithAdjustedZoom(1.0));
443 height = second->computeLength<Length>(state.style(), state.rootElem entStyle()); 444 height = second->computeLength<Length>(state.cssToLengthConversionDa ta().copyWithAdjustedZoom(1.0));
444 } else { 445 } else {
445 // <page-size> <orientation> 446 // <page-size> <orientation>
446 // The value order is guaranteed. See CSSParser::parseSizeParameter. 447 // The value order is guaranteed. See CSSParser::parseSizeParameter.
447 if (!getPageSizeFromName(first, second, width, height)) 448 if (!getPageSizeFromName(first, second, width, height))
448 return; 449 return;
449 } 450 }
450 pageSizeType = PAGE_SIZE_RESOLVED; 451 pageSizeType = PAGE_SIZE_RESOLVED;
451 break; 452 break;
452 } 453 }
453 case 1: { 454 case 1: {
454 // <length> | auto | <page-size> | [ portrait | landscape] 455 // <length> | auto | <page-size> | [ portrait | landscape]
455 if (!inspector.first()->isPrimitiveValue()) 456 if (!inspector.first()->isPrimitiveValue())
456 return; 457 return;
457 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inspector.first( )); 458 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inspector.first( ));
458 if (primitiveValue->isLength()) { 459 if (primitiveValue->isLength()) {
459 // <length> 460 // <length>
460 pageSizeType = PAGE_SIZE_RESOLVED; 461 pageSizeType = PAGE_SIZE_RESOLVED;
461 width = height = primitiveValue->computeLength<Length>(state.style() , state.rootElementStyle()); 462 width = height = primitiveValue->computeLength<Length>(state.cssToLe ngthConversionData().copyWithAdjustedZoom(1.0));
462 } else { 463 } else {
463 switch (primitiveValue->getValueID()) { 464 switch (primitiveValue->getValueID()) {
464 case 0: 465 case 0:
465 return; 466 return;
466 case CSSValueAuto: 467 case CSSValueAuto:
467 pageSizeType = PAGE_SIZE_AUTO; 468 pageSizeType = PAGE_SIZE_AUTO;
468 break; 469 break;
469 case CSSValuePortrait: 470 case CSSValuePortrait:
470 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT; 471 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT;
471 break; 472 break;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 { 536 {
536 if (!value->isValueList()) 537 if (!value->isValueList())
537 return; 538 return;
538 539
539 // [ <length> | <percentage> ] each-line 540 // [ <length> | <percentage> ] each-line
540 // The order is guaranteed. See CSSParser::parseTextIndent. 541 // The order is guaranteed. See CSSParser::parseTextIndent.
541 // The second value, each-line is handled only when css3TextEnabled() return s true. 542 // The second value, each-line is handled only when css3TextEnabled() return s true.
542 543
543 CSSValueList* valueList = toCSSValueList(value); 544 CSSValueList* valueList = toCSSValueList(value);
544 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho utBoundsCheck(0)); 545 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho utBoundsCheck(0));
545 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedConver sion | PercentConversion>(state.style(), state.rootElementStyle(), state.style() ->effectiveZoom()); 546 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedConver sion | PercentConversion>(state.cssToLengthConversionData());
546 ASSERT(!lengthOrPercentageValue.isUndefined()); 547 ASSERT(!lengthOrPercentageValue.isUndefined());
547 state.style()->setTextIndent(lengthOrPercentageValue); 548 state.style()->setTextIndent(lengthOrPercentageValue);
548 549
549 ASSERT(valueList->length() <= 2); 550 ASSERT(valueList->length() <= 2);
550 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); 551 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1));
551 if (eachLineValue) { 552 if (eachLineValue) {
552 ASSERT(eachLineValue->getValueID() == CSSValueEachLine); 553 ASSERT(eachLineValue->getValueID() == CSSValueEachLine);
553 state.style()->setTextIndentLine(TextIndentEachLine); 554 state.style()->setTextIndentLine(TextIndentEachLine);
554 } else 555 } else
555 state.style()->setTextIndentLine(TextIndentFirstLine); 556 state.style()->setTextIndentLine(TextIndentFirstLine);
556 } 557 }
557 558
558 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverStat e& state, CSSValue* value) 559 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverStat e& state, CSSValue* value)
559 { 560 {
560 if (!value->isPrimitiveValue()) 561 if (!value->isPrimitiveValue())
561 return; 562 return;
562 563
563 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 564 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
564 565
565 if (primitiveValue->getValueID()) 566 if (primitiveValue->getValueID())
566 return state.style()->setVerticalAlign(*primitiveValue); 567 return state.style()->setVerticalAlign(*primitiveValue);
567 568
568 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedC onversion | PercentConversion>(state.style(), state.rootElementStyle(), state.st yle()->effectiveZoom())); 569 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedC onversion | PercentConversion>(state.cssToLengthConversionData()));
569 } 570 }
570 571
571 static void resetEffectiveZoom(StyleResolverState& state) 572 static void resetEffectiveZoom(StyleResolverState& state)
572 { 573 {
573 // Reset the zoom in effect. This allows the setZoom method to accurately co mpute a new zoom in effect. 574 // Reset the zoom in effect. This allows the setZoom method to accurately co mpute a new zoom in effect.
574 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ oom() : RenderStyle::initialZoom()); 575 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ oom() : RenderStyle::initialZoom());
575 } 576 }
576 577
577 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& stat e) 578 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& stat e)
578 { 579 {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 case CSSValueNormal: 687 case CSSValueNormal:
687 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi nIE default. 688 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi nIE default.
688 break; 689 break;
689 case CSSValueLarge: 690 case CSSValueLarge:
690 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. 691 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px.
691 break; 692 break;
692 default: 693 default:
693 break; 694 break;
694 } 695 }
695 } else { 696 } else {
696 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength< FixedConversion | PercentConversion>(state.style(), state.rootElementStyle()) : Length(Undefined); 697 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength< FixedConversion | PercentConversion>(state.cssToLengthConversionData()) : Length (Undefined);
697 if (!marqueeLength.isUndefined()) 698 if (!marqueeLength.isUndefined())
698 state.style()->setMarqueeIncrement(marqueeLength); 699 state.style()->setMarqueeIncrement(marqueeLength);
699 } 700 }
700 } 701 }
701 702
702 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeSpeed(StyleResol verState& state, CSSValue* value) 703 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeSpeed(StyleResol verState& state, CSSValue* value)
703 { 704 {
704 if (!value->isPrimitiveValue()) 705 if (!value->isPrimitiveValue())
705 return; 706 return;
706 707
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 { 826 {
826 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 827 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
827 if (primitiveValue->isURI()) 828 if (primitiveValue->isURI())
828 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue-> getStringValue(), state.document()); 829 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue-> getStringValue(), state.document());
829 return String(); 830 return String();
830 } 831 }
831 832
832 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue* value) 833 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue* value)
833 { 834 {
834 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 835 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
835 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom() ); 836 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version>(state.cssToLengthConversionData());
836 ASSERT(!result.isUndefined()); 837 ASSERT(!result.isUndefined());
837 result.setQuirk(primitiveValue->isQuirkValue()); 838 result.setQuirk(primitiveValue->isQuirkValue());
838 return result; 839 return result;
839 } 840 }
840 841
841 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS Value* value) 842 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS Value* value)
842 { 843 {
843 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 844 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
844 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version | AutoConversion>(state.style(), state.rootElementStyle(), state.style() ->effectiveZoom()); 845 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version | AutoConversion>(state.cssToLengthConversionData());
845 ASSERT(!result.isUndefined()); 846 ASSERT(!result.isUndefined());
846 result.setQuirk(primitiveValue->isQuirkValue()); 847 result.setQuirk(primitiveValue->isQuirkValue());
847 return result; 848 return result;
848 } 849 }
849 850
850 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS Value* value) 851 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS Value* value)
851 { 852 {
852 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 853 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
853 switch (primitiveValue->getValueID()) { 854 switch (primitiveValue->getValueID()) {
854 case CSSValueInvalid: 855 case CSSValueInvalid:
(...skipping 23 matching lines...) Expand all
878 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 879 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
879 if (primitiveValue->getValueID() == CSSValueNone) 880 if (primitiveValue->getValueID() == CSSValueNone)
880 return Length(Undefined); 881 return Length(Undefined);
881 return convertLengthSizing(state, value); 882 return convertLengthSizing(state, value);
882 } 883 }
883 884
884 LengthPoint StyleBuilderConverter::convertLengthPoint(StyleResolverState& state, CSSValue* value) 885 LengthPoint StyleBuilderConverter::convertLengthPoint(StyleResolverState& state, CSSValue* value)
885 { 886 {
886 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 887 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
887 Pair* pair = primitiveValue->getPairValue(); 888 Pair* pair = primitiveValue->getPairValue();
888 Length x = pair->first()->convertToLength<FixedConversion | PercentConversio n>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 889 Length x = pair->first()->convertToLength<FixedConversion | PercentConversio n>(state.cssToLengthConversionData());
889 Length y = pair->second()->convertToLength<FixedConversion | PercentConversi on>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 890 Length y = pair->second()->convertToLength<FixedConversion | PercentConversi on>(state.cssToLengthConversionData());
890 return LengthPoint(x, y); 891 return LengthPoint(x, y);
891 } 892 }
892 893
893 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value) 894 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value)
894 { 895 {
895 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 896 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
896 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); 897 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage());
897 if (primitiveValue->isNumber()) 898 if (primitiveValue->isNumber())
898 return primitiveValue->getFloatValue(); 899 return primitiveValue->getFloatValue();
899 return primitiveValue->getFloatValue() / 100.0f; 900 return primitiveValue->getFloatValue() / 100.0f;
900 } 901 }
901 902
902 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) 903 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value)
903 { 904 {
904 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 905 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
905 Pair* pair = primitiveValue->getPairValue(); 906 Pair* pair = primitiveValue->getPairValue();
906 Length radiusWidth = pair->first()->convertToLength<FixedConversion | Percen tConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZo om()); 907 Length radiusWidth = pair->first()->convertToLength<FixedConversion | Percen tConversion>(state.cssToLengthConversionData());
907 Length radiusHeight = pair->second()->convertToLength<FixedConversion | Perc entConversion>(state.style(), state.rootElementStyle(), state.style()->effective Zoom()); 908 Length radiusHeight = pair->second()->convertToLength<FixedConversion | Perc entConversion>(state.cssToLengthConversionData());
908 float width = radiusWidth.value(); 909 float width = radiusWidth.value();
909 float height = radiusHeight.value(); 910 float height = radiusHeight.value();
910 ASSERT(width >= 0 && height >= 0); 911 ASSERT(width >= 0 && height >= 0);
911 if (width <= 0 || height <= 0) 912 if (width <= 0 || height <= 0)
912 return LengthSize(Length(0, Fixed), Length(0, Fixed)); 913 return LengthSize(Length(0, Fixed), Length(0, Fixed));
913 return LengthSize(radiusWidth, radiusHeight); 914 return LengthSize(radiusWidth, radiusHeight);
914 } 915 }
915 916
916 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue* value) 917 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue* value)
917 { 918 {
918 if (value->isPrimitiveValue()) { 919 if (value->isPrimitiveValue()) {
919 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); 920 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
920 return PassRefPtr<ShadowList>(); 921 return PassRefPtr<ShadowList>();
921 } 922 }
922 923
923 const CSSValueList* valueList = toCSSValueList(value); 924 const CSSValueList* valueList = toCSSValueList(value);
924 size_t shadowCount = valueList->length(); 925 size_t shadowCount = valueList->length();
925 float zoom = state.style()->effectiveZoom();
926 ShadowDataVector shadows; 926 ShadowDataVector shadows;
927 for (size_t i = 0; i < shadowCount; ++i) { 927 for (size_t i = 0; i < shadowCount; ++i) {
928 const CSSShadowValue* item = toCSSShadowValue(valueList->item(i)); 928 const CSSShadowValue* item = toCSSShadowValue(valueList->item(i));
929 int x = item->x->computeLength<int>(state.style(), state.rootElementStyl e(), zoom); 929 int x = item->x->computeLength<int>(state.cssToLengthConversionData());
930 int y = item->y->computeLength<int>(state.style(), state.rootElementStyl e(), zoom); 930 int y = item->y->computeLength<int>(state.cssToLengthConversionData());
931 int blur = item->blur ? item->blur->computeLength<int>(state.style(), st ate.rootElementStyle(), zoom) : 0; 931 int blur = item->blur ? item->blur->computeLength<int>(state.cssToLength ConversionData()) : 0;
932 int spread = item->spread ? item->spread->computeLength<int>(state.style (), state.rootElementStyle(), zoom) : 0; 932 int spread = item->spread ? item->spread->computeLength<int>(state.cssTo LengthConversionData()) : 0;
933 ShadowStyle shadowStyle = item->style && item->style->getValueID() == CS SValueInset ? Inset : Normal; 933 ShadowStyle shadowStyle = item->style && item->style->getValueID() == CS SValueInset ? Inset : Normal;
934 Color color; 934 Color color;
935 if (item->color) 935 if (item->color)
936 color = state.document().textLinkColors().colorFromPrimitiveValue(it em->color.get(), state.style()->visitedDependentColor(CSSPropertyColor)); 936 color = state.document().textLinkColors().colorFromPrimitiveValue(it em->color.get(), state.style()->visitedDependentColor(CSSPropertyColor));
937 else 937 else
938 color = state.style()->color(); 938 color = state.style()->color();
939 939
940 if (!color.isValid()) 940 if (!color.isValid())
941 color = Color::transparent; 941 color = Color::transparent;
942 shadows.append(ShadowData(IntPoint(x, y), blur, spread, shadowStyle, col or)); 942 shadows.append(ShadowData(IntPoint(x, y), blur, spread, shadowStyle, col or));
943 } 943 }
944 return ShadowList::adopt(shadows); 944 return ShadowList::adopt(shadows);
945 } 945 }
946 946
947 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, CSSValue* value) 947 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, CSSValue* value)
948 { 948 {
949 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 949 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
950 if (primitiveValue->getValueID() == CSSValueNormal) 950 if (primitiveValue->getValueID() == CSSValueNormal)
951 return 0; 951 return 0;
952 float zoom = state.useSVGZoomRules() ? 1.0f : state.style()->effectiveZoom() ; 952 if (state.useSVGZoomRules())
953 return primitiveValue->computeLength<float>(state.style(), state.rootElement Style(), zoom); 953 return primitiveValue->computeLength<float>(state.cssToLengthConversionD ata().copyWithAdjustedZoom(1));
954 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( ));
954 } 955 }
955 956
956 SVGLength StyleBuilderConverter::convertSVGLength(StyleResolverState&, CSSValue* value) 957 SVGLength StyleBuilderConverter::convertSVGLength(StyleResolverState&, CSSValue* value)
957 { 958 {
958 return SVGLength::fromCSSPrimitiveValue(toCSSPrimitiveValue(value)); 959 return SVGLength::fromCSSPrimitiveValue(toCSSPrimitiveValue(value));
959 } 960 }
960 961
961 962
962 // Everything below this line is from the old StyleResolver::applyProperty 963 // Everything below this line is from the old StyleResolver::applyProperty
963 // and eventually needs to move into new StyleBuilderFunctions calls intead. 964 // and eventually needs to move into new StyleBuilderFunctions calls intead.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 workingLength = Length(MaxContent); 1000 workingLength = Length(MaxContent);
1000 return true; 1001 return true;
1001 } 1002 }
1002 1003
1003 if (primitiveValue->isFlex()) { 1004 if (primitiveValue->isFlex()) {
1004 // Fractional unit. 1005 // Fractional unit.
1005 workingLength.setFlex(primitiveValue->getDoubleValue()); 1006 workingLength.setFlex(primitiveValue->getDoubleValue());
1006 return true; 1007 return true;
1007 } 1008 }
1008 1009
1009 workingLength = primitiveValue->convertToLength<FixedConversion | PercentCon version | AutoConversion>(state.style(), state.rootElementStyle(), state.style() ->effectiveZoom()); 1010 workingLength = primitiveValue->convertToLength<FixedConversion | PercentCon version | AutoConversion>(state.cssToLengthConversionData());
1010 if (workingLength.length().isUndefined()) 1011 if (workingLength.length().isUndefined())
1011 return false; 1012 return false;
1012 1013
1013 if (primitiveValue->isLength()) 1014 if (primitiveValue->isLength())
1014 workingLength.length().setQuirk(primitiveValue->isQuirkValue()); 1015 workingLength.length().setQuirk(primitiveValue->isQuirkValue());
1015 1016
1016 return true; 1017 return true;
1017 } 1018 }
1018 1019
1019 static bool createGridTrackSize(CSSValue* value, GridTrackSize& trackSize, const StyleResolverState& state) 1020 static bool createGridTrackSize(CSSValue* value, GridTrackSize& trackSize, const StyleResolverState& state)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 1324
1324 // Fall back to the old switch statement, which is now in StyleBuilderCustom .cpp 1325 // Fall back to the old switch statement, which is now in StyleBuilderCustom .cpp
1325 StyleBuilder::oldApplyProperty(id, state, value, isInitial, isInherit); 1326 StyleBuilder::oldApplyProperty(id, state, value, isInitial, isInherit);
1326 } 1327 }
1327 1328
1328 1329
1329 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit) 1330 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit)
1330 { 1331 {
1331 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0; 1332 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0;
1332 1333
1333 float zoomFactor = state.style()->effectiveZoom();
1334
1335 // What follows is a list that maps the CSS properties into their correspond ing front-end 1334 // What follows is a list that maps the CSS properties into their correspond ing front-end
1336 // RenderStyle values. 1335 // RenderStyle values.
1337 switch (id) { 1336 switch (id) {
1338 case CSSPropertyContent: 1337 case CSSPropertyContent:
1339 // list of string, uri, counter, attr, i 1338 // list of string, uri, counter, attr, i
1340 { 1339 {
1341 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 i t is not. This 1340 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 i t is not. This
1342 // note is a reminder that eventually "inherit" needs to be supporte d. 1341 // note is a reminder that eventually "inherit" needs to be supporte d.
1343 1342
1344 if (isInitial) { 1343 if (isInitial) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 return; 1517 return;
1519 } 1518 }
1520 1519
1521 if (!value->isReflectValue()) 1520 if (!value->isReflectValue())
1522 return; 1521 return;
1523 1522
1524 CSSReflectValue* reflectValue = toCSSReflectValue(value); 1523 CSSReflectValue* reflectValue = toCSSReflectValue(value);
1525 RefPtr<StyleReflection> reflection = StyleReflection::create(); 1524 RefPtr<StyleReflection> reflection = StyleReflection::create();
1526 reflection->setDirection(*reflectValue->direction()); 1525 reflection->setDirection(*reflectValue->direction());
1527 if (reflectValue->offset()) 1526 if (reflectValue->offset())
1528 reflection->setOffset(reflectValue->offset()->convertToLength<FixedC onversion | PercentConversion>(state.style(), state.rootElementStyle(), zoomFact or)); 1527 reflection->setOffset(reflectValue->offset()->convertToLength<FixedC onversion | PercentConversion>(state.cssToLengthConversionData()));
1529 NinePieceImage mask; 1528 NinePieceImage mask;
1530 mask.setMaskDefaults(); 1529 mask.setMaskDefaults();
1531 state.styleMap().mapNinePieceImage(state.style(), id, reflectValue->mask (), mask); 1530 state.styleMap().mapNinePieceImage(state.style(), id, reflectValue->mask (), mask);
1532 reflection->setMask(mask); 1531 reflection->setMask(mask);
1533 1532
1534 state.style()->setBoxReflect(reflection.release()); 1533 state.style()->setBoxReflect(reflection.release());
1535 return; 1534 return;
1536 } 1535 }
1537 case CSSPropertySrc: // Only used in @font-face rules. 1536 case CSSPropertySrc: // Only used in @font-face rules.
1538 return; 1537 return;
(...skipping 22 matching lines...) Expand all
1561 float width = 0; 1560 float width = 0;
1562 switch (primitiveValue->getValueID()) { 1561 switch (primitiveValue->getValueID()) {
1563 case CSSValueThin: 1562 case CSSValueThin:
1564 case CSSValueMedium: 1563 case CSSValueMedium:
1565 case CSSValueThick: { 1564 case CSSValueThick: {
1566 double result = 1.0 / 48; 1565 double result = 1.0 / 48;
1567 if (primitiveValue->getValueID() == CSSValueMedium) 1566 if (primitiveValue->getValueID() == CSSValueMedium)
1568 result *= 3; 1567 result *= 3;
1569 else if (primitiveValue->getValueID() == CSSValueThick) 1568 else if (primitiveValue->getValueID() == CSSValueThick)
1570 result *= 5; 1569 result *= 5;
1571 width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS )->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor); 1570 width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS )->computeLength<float>(state.cssToLengthConversionData());
1572 break; 1571 break;
1573 } 1572 }
1574 default: 1573 default:
1575 width = primitiveValue->computeLength<float>(state.style(), state.ro otElementStyle(), zoomFactor); 1574 width = primitiveValue->computeLength<float>(state.cssToLengthConver sionData());
1576 break; 1575 break;
1577 } 1576 }
1578 state.style()->setTextStrokeWidth(width); 1577 state.style()->setTextStrokeWidth(width);
1579 return; 1578 return;
1580 } 1579 }
1581 case CSSPropertyWebkitTransform: { 1580 case CSSPropertyWebkitTransform: {
1582 HANDLE_INHERIT_AND_INITIAL(transform, Transform); 1581 HANDLE_INHERIT_AND_INITIAL(transform, Transform);
1583 TransformOperations operations; 1582 TransformOperations operations;
1584 TransformBuilder::createTransformOperations(value, state.style(), state. rootElementStyle(), operations); 1583 TransformBuilder::createTransformOperations(value, state.cssToLengthConv ersionData(), operations);
1585 state.style()->setTransform(operations); 1584 state.style()->setTransform(operations);
1586 return; 1585 return;
1587 } 1586 }
1588 case CSSPropertyWebkitPerspective: { 1587 case CSSPropertyWebkitPerspective: {
1589 HANDLE_INHERIT_AND_INITIAL(perspective, Perspective) 1588 HANDLE_INHERIT_AND_INITIAL(perspective, Perspective)
1590 1589
1591 if (!primitiveValue) 1590 if (!primitiveValue)
1592 return; 1591 return;
1593 1592
1594 if (primitiveValue->getValueID() == CSSValueNone) { 1593 if (primitiveValue->getValueID() == CSSValueNone) {
1595 state.style()->setPerspective(0); 1594 state.style()->setPerspective(0);
1596 return; 1595 return;
1597 } 1596 }
1598 1597
1599 float perspectiveValue; 1598 float perspectiveValue;
1600 if (primitiveValue->isLength()) { 1599 if (primitiveValue->isLength()) {
1601 perspectiveValue = primitiveValue->computeLength<float>(state.style( ), state.rootElementStyle(), zoomFactor); 1600 perspectiveValue = primitiveValue->computeLength<float>(state.cssToL engthConversionData());
1602 } else if (primitiveValue->isNumber()) { 1601 } else if (primitiveValue->isNumber()) {
1603 // For backward compatibility, treat valueless numbers as px. 1602 // For backward compatibility, treat valueless numbers as px.
1604 perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoub leValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.style(), state .rootElementStyle(), zoomFactor); 1603 perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoub leValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.cssToLengthCon versionData());
1605 } else { 1604 } else {
1606 return; 1605 return;
1607 } 1606 }
1608 1607
1609 if (perspectiveValue >= 0.0f) 1608 if (perspectiveValue >= 0.0f)
1610 state.style()->setPerspective(perspectiveValue); 1609 state.style()->setPerspective(perspectiveValue);
1611 return; 1610 return;
1612 } 1611 }
1613 case CSSPropertyWebkitTapHighlightColor: { 1612 case CSSPropertyWebkitTapHighlightColor: {
1614 HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor); 1613 HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 if (!value->isValueList()) 1729 if (!value->isValueList())
1731 return; 1730 return;
1732 1731
1733 state.fontBuilder().setFeatureSettingsValue(value); 1732 state.fontBuilder().setFeatureSettingsValue(value);
1734 return; 1733 return;
1735 } 1734 }
1736 1735
1737 case CSSPropertyWebkitFilter: { 1736 case CSSPropertyWebkitFilter: {
1738 HANDLE_INHERIT_AND_INITIAL(filter, Filter); 1737 HANDLE_INHERIT_AND_INITIAL(filter, Filter);
1739 FilterOperations operations; 1738 FilterOperations operations;
1740 if (FilterOperationResolver::createFilterOperations(value, state.style() , state.rootElementStyle(), operations, state)) 1739 if (FilterOperationResolver::createFilterOperations(value, state.cssToLe ngthConversionData(), operations, state))
1741 state.style()->setFilter(operations); 1740 state.style()->setFilter(operations);
1742 return; 1741 return;
1743 } 1742 }
1744 case CSSPropertyGridAutoColumns: { 1743 case CSSPropertyGridAutoColumns: {
1745 HANDLE_INHERIT_AND_INITIAL(gridAutoColumns, GridAutoColumns); 1744 HANDLE_INHERIT_AND_INITIAL(gridAutoColumns, GridAutoColumns);
1746 GridTrackSize trackSize; 1745 GridTrackSize trackSize;
1747 if (!createGridTrackSize(value, trackSize, state)) 1746 if (!createGridTrackSize(value, trackSize, state))
1748 return; 1747 return;
1749 state.style()->setGridAutoColumns(trackSize); 1748 state.style()->setGridAutoColumns(trackSize);
1750 return; 1749 return;
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 break; 2306 break;
2308 } 2307 }
2309 case CSSPropertyEnableBackground: 2308 case CSSPropertyEnableBackground:
2310 // Silently ignoring this property for now 2309 // Silently ignoring this property for now
2311 // http://bugs.webkit.org/show_bug.cgi?id=6022 2310 // http://bugs.webkit.org/show_bug.cgi?id=6022
2312 break; 2311 break;
2313 } 2312 }
2314 } 2313 }
2315 2314
2316 } // namespace WebCore 2315 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698