OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "core/svg/SVGURIReference.h" | 84 #include "core/svg/SVGURIReference.h" |
85 #include "platform/fonts/FontDescription.h" | 85 #include "platform/fonts/FontDescription.h" |
86 #include "wtf/MathExtras.h" | 86 #include "wtf/MathExtras.h" |
87 #include "wtf/StdLibExtras.h" | 87 #include "wtf/StdLibExtras.h" |
88 #include "wtf/Vector.h" | 88 #include "wtf/Vector.h" |
89 | 89 |
90 namespace WebCore { | 90 namespace WebCore { |
91 | 91 |
92 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue*
value) | 92 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue*
value) |
93 { | 93 { |
94 return value->convertToLength<FixedIntegerConversion | PercentConversion | A
utoConversion>(state.style(), state.rootElementStyle(), state.style()->effective
Zoom()); | 94 return value->convertToLength<FixedConversion | PercentConversion | AutoConv
ersion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())
; |
95 } | 95 } |
96 | 96 |
97 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& stat
e) | 97 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& stat
e) |
98 { | 98 { |
99 state.style()->setClip(Length(), Length(), Length(), Length()); | 99 state.style()->setClip(Length(), Length(), Length(), Length()); |
100 state.style()->setHasClip(false); | 100 state.style()->setHasClip(false); |
101 } | 101 } |
102 | 102 |
103 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& stat
e) | 103 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& stat
e) |
104 { | 104 { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 { | 534 { |
535 if (!value->isValueList()) | 535 if (!value->isValueList()) |
536 return; | 536 return; |
537 | 537 |
538 // [ <length> | <percentage> ] each-line | 538 // [ <length> | <percentage> ] each-line |
539 // The order is guaranteed. See CSSParser::parseTextIndent. | 539 // The order is guaranteed. See CSSParser::parseTextIndent. |
540 // The second value, each-line is handled only when css3TextEnabled() return
s true. | 540 // The second value, each-line is handled only when css3TextEnabled() return
s true. |
541 | 541 |
542 CSSValueList* valueList = toCSSValueList(value); | 542 CSSValueList* valueList = toCSSValueList(value); |
543 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho
utBoundsCheck(0)); | 543 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho
utBoundsCheck(0)); |
544 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntege
rConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.
style()->effectiveZoom()); | 544 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedConver
sion | PercentConversion>(state.style(), state.rootElementStyle(), state.style()
->effectiveZoom()); |
545 ASSERT(!lengthOrPercentageValue.isUndefined()); | 545 ASSERT(!lengthOrPercentageValue.isUndefined()); |
546 state.style()->setTextIndent(lengthOrPercentageValue); | 546 state.style()->setTextIndent(lengthOrPercentageValue); |
547 | 547 |
548 ASSERT(valueList->length() <= 2); | 548 ASSERT(valueList->length() <= 2); |
549 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); | 549 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); |
550 if (eachLineValue) { | 550 if (eachLineValue) { |
551 ASSERT(eachLineValue->getValueID() == CSSValueEachLine); | 551 ASSERT(eachLineValue->getValueID() == CSSValueEachLine); |
552 state.style()->setTextIndentLine(TextIndentEachLine); | 552 state.style()->setTextIndentLine(TextIndentEachLine); |
553 } else | 553 } else |
554 state.style()->setTextIndentLine(TextIndentFirstLine); | 554 state.style()->setTextIndentLine(TextIndentFirstLine); |
555 } | 555 } |
556 | 556 |
557 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverStat
e& state, CSSValue* value) | 557 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverStat
e& state, CSSValue* value) |
558 { | 558 { |
559 if (!value->isPrimitiveValue()) | 559 if (!value->isPrimitiveValue()) |
560 return; | 560 return; |
561 | 561 |
562 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 562 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
563 | 563 |
564 if (primitiveValue->getValueID()) | 564 if (primitiveValue->getValueID()) |
565 return state.style()->setVerticalAlign(*primitiveValue); | 565 return state.style()->setVerticalAlign(*primitiveValue); |
566 | 566 |
567 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedI
ntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), s
tate.style()->effectiveZoom())); | 567 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedC
onversion | PercentConversion>(state.style(), state.rootElementStyle(), state.st
yle()->effectiveZoom())); |
568 } | 568 } |
569 | 569 |
570 static void resetEffectiveZoom(StyleResolverState& state) | 570 static void resetEffectiveZoom(StyleResolverState& state) |
571 { | 571 { |
572 // Reset the zoom in effect. This allows the setZoom method to accurately co
mpute a new zoom in effect. | 572 // 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()); | 573 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ
oom() : RenderStyle::initialZoom()); |
574 } | 574 } |
575 | 575 |
576 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& stat
e) | 576 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& stat
e) |
577 { | 577 { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 case CSSValueNormal: | 685 case CSSValueNormal: |
686 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi
nIE default. | 686 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi
nIE default. |
687 break; | 687 break; |
688 case CSSValueLarge: | 688 case CSSValueLarge: |
689 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. | 689 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. |
690 break; | 690 break; |
691 default: | 691 default: |
692 break; | 692 break; |
693 } | 693 } |
694 } else { | 694 } else { |
695 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength<
FixedIntegerConversion | PercentConversion>(state.style(), state.rootElementStyl
e()) : Length(Undefined); | 695 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength<
FixedConversion | PercentConversion>(state.style(), state.rootElementStyle()) :
Length(Undefined); |
696 if (!marqueeLength.isUndefined()) | 696 if (!marqueeLength.isUndefined()) |
697 state.style()->setMarqueeIncrement(marqueeLength); | 697 state.style()->setMarqueeIncrement(marqueeLength); |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeSpeed(StyleResol
verState& state, CSSValue* value) | 701 void StyleBuilderFunctions::applyValueCSSPropertyInternalMarqueeSpeed(StyleResol
verState& state, CSSValue* value) |
702 { | 702 { |
703 if (!value->isPrimitiveValue()) | 703 if (!value->isPrimitiveValue()) |
704 return; | 704 return; |
705 | 705 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 { | 824 { |
825 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 825 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
826 if (primitiveValue->isURI()) | 826 if (primitiveValue->isURI()) |
827 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->
getStringValue(), state.document()); | 827 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->
getStringValue(), state.document()); |
828 return String(); | 828 return String(); |
829 } | 829 } |
830 | 830 |
831 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue*
value) | 831 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue*
value) |
832 { | 832 { |
833 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 833 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
834 Length result = primitiveValue->convertToLength<FixedIntegerConversion | Per
centConversion>(state.style(), state.rootElementStyle(), state.style()->effectiv
eZoom()); | 834 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon
version>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()
); |
835 ASSERT(!result.isUndefined()); | 835 ASSERT(!result.isUndefined()); |
836 result.setQuirk(primitiveValue->isQuirkValue()); | 836 result.setQuirk(primitiveValue->isQuirkValue()); |
837 return result; | 837 return result; |
838 } | 838 } |
839 | 839 |
840 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS
Value* value) | 840 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS
Value* value) |
841 { | 841 { |
842 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 842 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
843 Length result = primitiveValue->convertToLength<FixedIntegerConversion | Per
centConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.
style()->effectiveZoom()); | 843 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon
version | AutoConversion>(state.style(), state.rootElementStyle(), state.style()
->effectiveZoom()); |
844 ASSERT(!result.isUndefined()); | 844 ASSERT(!result.isUndefined()); |
845 result.setQuirk(primitiveValue->isQuirkValue()); | 845 result.setQuirk(primitiveValue->isQuirkValue()); |
846 return result; | 846 return result; |
847 } | 847 } |
848 | 848 |
849 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS
Value* value) | 849 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS
Value* value) |
850 { | 850 { |
851 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 851 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
852 switch (primitiveValue->getValueID()) { | 852 switch (primitiveValue->getValueID()) { |
853 case CSSValueInvalid: | 853 case CSSValueInvalid: |
(...skipping 23 matching lines...) Expand all Loading... |
877 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 877 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
878 if (primitiveValue->getValueID() == CSSValueNone) | 878 if (primitiveValue->getValueID() == CSSValueNone) |
879 return Length(Undefined); | 879 return Length(Undefined); |
880 return convertLengthSizing(state, value); | 880 return convertLengthSizing(state, value); |
881 } | 881 } |
882 | 882 |
883 LengthPoint StyleBuilderConverter::convertLengthPoint(StyleResolverState& state,
CSSValue* value) | 883 LengthPoint StyleBuilderConverter::convertLengthPoint(StyleResolverState& state,
CSSValue* value) |
884 { | 884 { |
885 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 885 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
886 Pair* pair = primitiveValue->getPairValue(); | 886 Pair* pair = primitiveValue->getPairValue(); |
887 Length x = pair->first()->convertToLength<FixedIntegerConversion | PercentCo
nversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom(
)); | 887 Length x = pair->first()->convertToLength<FixedConversion | PercentConversio
n>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); |
888 Length y = pair->second()->convertToLength<FixedIntegerConversion | PercentC
onversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom
()); | 888 Length y = pair->second()->convertToLength<FixedConversion | PercentConversi
on>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); |
889 return LengthPoint(x, y); | 889 return LengthPoint(x, y); |
890 } | 890 } |
891 | 891 |
892 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, CSSValue* value) | 892 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, CSSValue* value) |
893 { | 893 { |
894 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 894 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
895 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); | 895 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); |
896 if (primitiveValue->isNumber()) | 896 if (primitiveValue->isNumber()) |
897 return primitiveValue->getFloatValue(); | 897 return primitiveValue->getFloatValue(); |
898 return primitiveValue->getFloatValue() / 100.0f; | 898 return primitiveValue->getFloatValue() / 100.0f; |
899 } | 899 } |
900 | 900 |
901 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa
lue* value) | 901 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa
lue* value) |
902 { | 902 { |
903 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 903 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
904 Pair* pair = primitiveValue->getPairValue(); | 904 Pair* pair = primitiveValue->getPairValue(); |
905 Length radiusWidth = pair->first()->convertToLength<FixedIntegerConversion |
PercentConversion>(state.style(), state.rootElementStyle(), state.style()->effe
ctiveZoom()); | 905 Length radiusWidth = pair->first()->convertToLength<FixedConversion | Percen
tConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZo
om()); |
906 Length radiusHeight = pair->second()->convertToLength<FixedIntegerConversion
| PercentConversion>(state.style(), state.rootElementStyle(), state.style()->ef
fectiveZoom()); | 906 Length radiusHeight = pair->second()->convertToLength<FixedConversion | Perc
entConversion>(state.style(), state.rootElementStyle(), state.style()->effective
Zoom()); |
907 float width = radiusWidth.value(); | 907 float width = radiusWidth.value(); |
908 float height = radiusHeight.value(); | 908 float height = radiusHeight.value(); |
909 ASSERT(width >= 0 && height >= 0); | 909 ASSERT(width >= 0 && height >= 0); |
910 if (width <= 0 || height <= 0) | 910 if (width <= 0 || height <= 0) |
911 return LengthSize(Length(0, Fixed), Length(0, Fixed)); | 911 return LengthSize(Length(0, Fixed), Length(0, Fixed)); |
912 return LengthSize(radiusWidth, radiusHeight); | 912 return LengthSize(radiusWidth, radiusHeight); |
913 } | 913 } |
914 | 914 |
915 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, CSSValue* value) | 915 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, CSSValue* value) |
916 { | 916 { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 workingLength = Length(MaxContent); | 998 workingLength = Length(MaxContent); |
999 return true; | 999 return true; |
1000 } | 1000 } |
1001 | 1001 |
1002 if (primitiveValue->isFlex()) { | 1002 if (primitiveValue->isFlex()) { |
1003 // Fractional unit. | 1003 // Fractional unit. |
1004 workingLength.setFlex(primitiveValue->getDoubleValue()); | 1004 workingLength.setFlex(primitiveValue->getDoubleValue()); |
1005 return true; | 1005 return true; |
1006 } | 1006 } |
1007 | 1007 |
1008 workingLength = primitiveValue->convertToLength<FixedIntegerConversion | Per
centConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.
style()->effectiveZoom()); | 1008 workingLength = primitiveValue->convertToLength<FixedConversion | PercentCon
version | AutoConversion>(state.style(), state.rootElementStyle(), state.style()
->effectiveZoom()); |
1009 if (workingLength.length().isUndefined()) | 1009 if (workingLength.length().isUndefined()) |
1010 return false; | 1010 return false; |
1011 | 1011 |
1012 if (primitiveValue->isLength()) | 1012 if (primitiveValue->isLength()) |
1013 workingLength.length().setQuirk(primitiveValue->isQuirkValue()); | 1013 workingLength.length().setQuirk(primitiveValue->isQuirkValue()); |
1014 | 1014 |
1015 return true; | 1015 return true; |
1016 } | 1016 } |
1017 | 1017 |
1018 static bool createGridTrackSize(CSSValue* value, GridTrackSize& trackSize, const
StyleResolverState& state) | 1018 static bool createGridTrackSize(CSSValue* value, GridTrackSize& trackSize, const
StyleResolverState& state) |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 return; | 1517 return; |
1518 } | 1518 } |
1519 | 1519 |
1520 if (!value->isReflectValue()) | 1520 if (!value->isReflectValue()) |
1521 return; | 1521 return; |
1522 | 1522 |
1523 CSSReflectValue* reflectValue = toCSSReflectValue(value); | 1523 CSSReflectValue* reflectValue = toCSSReflectValue(value); |
1524 RefPtr<StyleReflection> reflection = StyleReflection::create(); | 1524 RefPtr<StyleReflection> reflection = StyleReflection::create(); |
1525 reflection->setDirection(*reflectValue->direction()); | 1525 reflection->setDirection(*reflectValue->direction()); |
1526 if (reflectValue->offset()) | 1526 if (reflectValue->offset()) |
1527 reflection->setOffset(reflectValue->offset()->convertToLength<FixedI
ntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), z
oomFactor)); | 1527 reflection->setOffset(reflectValue->offset()->convertToLength<FixedC
onversion | PercentConversion>(state.style(), state.rootElementStyle(), zoomFact
or)); |
1528 NinePieceImage mask; | 1528 NinePieceImage mask; |
1529 mask.setMaskDefaults(); | 1529 mask.setMaskDefaults(); |
1530 state.styleMap().mapNinePieceImage(state.style(), id, reflectValue->mask
(), mask); | 1530 state.styleMap().mapNinePieceImage(state.style(), id, reflectValue->mask
(), mask); |
1531 reflection->setMask(mask); | 1531 reflection->setMask(mask); |
1532 | 1532 |
1533 state.style()->setBoxReflect(reflection.release()); | 1533 state.style()->setBoxReflect(reflection.release()); |
1534 return; | 1534 return; |
1535 } | 1535 } |
1536 case CSSPropertySrc: // Only used in @font-face rules. | 1536 case CSSPropertySrc: // Only used in @font-face rules. |
1537 return; | 1537 return; |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 break; | 2306 break; |
2307 } | 2307 } |
2308 case CSSPropertyEnableBackground: | 2308 case CSSPropertyEnableBackground: |
2309 // Silently ignoring this property for now | 2309 // Silently ignoring this property for now |
2310 // http://bugs.webkit.org/show_bug.cgi?id=6022 | 2310 // http://bugs.webkit.org/show_bug.cgi?id=6022 |
2311 break; | 2311 break; |
2312 } | 2312 } |
2313 } | 2313 } |
2314 | 2314 |
2315 } // namespace WebCore | 2315 } // namespace WebCore |
OLD | NEW |