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

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

Powered by Google App Engine
This is Rietveld 408576698