Changeset 209001 in webkit
- Timestamp:
- Nov 28, 2016 11:11:38 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r208948 r209001 3003 3003 3004 3004 set(WebCore_CSS_PROPERTY_NAMES 3005 ${WEBCORE_DIR}/css/CSSPropert yNames.in3005 ${WEBCORE_DIR}/css/CSSProperties.json 3006 3006 ) 3007 3007 … … 3603 3603 # Generate CSS property names 3604 3604 add_custom_command( 3605 OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropert yNames.in ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.h ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.gperf ${DERIVED_SOURCES_WEBCORE_DIR}/StyleBuilder.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/StylePropertyShorthandFunctions.h ${DERIVED_SOURCES_WEBCORE_DIR}/StylePropertyShorthandFunctions.cpp3605 OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/CSSProperties.json ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.h ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.gperf ${DERIVED_SOURCES_WEBCORE_DIR}/StyleBuilder.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/StylePropertyShorthandFunctions.h ${DERIVED_SOURCES_WEBCORE_DIR}/StylePropertyShorthandFunctions.cpp 3606 3606 MAIN_DEPENDENCY ${WEBCORE_DIR}/css/makeprop.pl 3607 3607 DEPENDS ${WebCore_CSS_PROPERTY_NAMES} 3608 3608 WORKING_DIRECTORY ${DERIVED_SOURCES_WEBCORE_DIR} 3609 COMMAND ${PERL_EXECUTABLE} -ne "print" ${WebCore_CSS_PROPERTY_NAMES} > ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropert yNames.in3610 COMMAND ${PERL_EXECUTABLE} ${WEBCORE_DIR}/css/makeprop.pl --defines "${FEATURE_DEFINES_WITH_SPACE_SEPARATOR}" -- preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --gperf-executable "${GPERF_EXECUTABLE}"3609 COMMAND ${PERL_EXECUTABLE} -ne "print" ${WebCore_CSS_PROPERTY_NAMES} > ${DERIVED_SOURCES_WEBCORE_DIR}/CSSProperties.json 3610 COMMAND ${PERL_EXECUTABLE} ${WEBCORE_DIR}/css/makeprop.pl --defines "${FEATURE_DEFINES_WITH_SPACE_SEPARATOR}" --gperf-executable "${GPERF_EXECUTABLE}" 3611 3611 VERBATIM) 3612 3612 list(APPEND WebCore_DERIVED_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/CSSPropertyNames.cpp) -
trunk/Source/WebCore/ChangeLog
r209000 r209001 1 2016-11-28 Daniel Bates <dabates@apple.com> 2 3 Replace CSSPropertyNames.in with a JSON file 4 https://bugs.webkit.org/show_bug.cgi?id=164691 5 6 Reviewed by Simon Fraser. 7 8 Convert CSSPropertyNames.in to a structured JSON file. This is the first step towards 9 exposing a CSS feature status dashboard and generating more of the boilerplate code 10 for a CSS property. 11 12 A side effect of this change is that makeprop.pl no longer detects duplicate CSS property 13 definitions. We will look to bring such duplication detection back in a subsequent 14 commit. 15 16 * CMakeLists.txt: Substitute CSSProperties.json for CSSPropertyNames.in and update the 17 invocation of makeprop.pl as we no longer need to pass the bindings/scripts/preprocessor.pm 18 Perl module. Makeprop.pl supports conditional CSS properties and values without the need 19 to preprocess CSSProperties.json using the C preprocessor. 20 * DerivedSources.make: Ditto. Pass WTF_PLATFORM_IOS to makeprop.pl when building for iOS 21 as we no longer make use of bindings/scripts/preprocessor.pm. 22 * css/CSSProperties.json: Added. 23 * css/CSSPropertyNames.in: Removed. 24 * css/StyleResolver.cpp: Remove variable lastHighPriorityProperty as we now generate it. 25 * css/makeprop.pl: Extracted the input file name, now CSSProperties.json, into a global variable 26 and referenced this variable throughout this script instead of hardcoding the input file name at 27 each call site. Updated code to handle CSS longhand names being encoded in a JSON array as opposed 28 to a string of '|'-separated values. I added a FIXME comment to do the same for the codegen property 29 "custom". Fixed Perl uninitialized variable warnings when die()-ing with error "Unknown CSS property 30 used in all shorthand ..." or "Unknown CSS property used in longhands ...". 31 (isPropertyEnabled): Added. Determine whether code should be generated for a property. 32 (addProperty): Added. 33 (sortByDescendingPriorityAndName): Added. 34 (getScopeForFunction): Lowercase option names so that we can use a consistent case throughout 35 the JSON file. 36 (getNameForMethods): Ditto. 37 (generateColorValueSetter): 38 (generateAnimationPropertyInitialValueSetter): Ditto. 39 (generateAnimationPropertyInheritValueSetter): Ditto. 40 (generateFillLayerPropertyInitialValueSetter): Ditto. 41 (generateFillLayerPropertyInheritValueSetter): Ditto. 42 (generateSetValueStatement): Ditto. 43 (generateInitialValueSetter): Ditto. 44 (generateInheritValueSetter): Ditto. 45 (generateValueSetter): Ditto. 46 1 47 2016-11-28 Dave Hyatt <hyatt@apple.com> 2 48 -
trunk/Source/WebCore/DerivedSources.make
r208914 r209001 933 933 # -------- 934 934 935 ADDITIONAL_CSS_PROPERTIES_DEFINES := 936 937 ifeq ($(WTF_PLATFORM_IOS), 1) 938 ADDITIONAL_CSS_PROPERTIES_DEFINES := WTF_PLATFORM_IOS 939 endif 940 941 # -------- 942 935 943 # CSS property names and value keywords 936 944 937 WEBCORE_CSS_PROPERTY_NAMES := $(WebCore)/css/CSSPropert yNames.in945 WEBCORE_CSS_PROPERTY_NAMES := $(WebCore)/css/CSSProperties.json 938 946 WEBCORE_CSS_VALUE_KEYWORDS := $(WebCore)/css/CSSValueKeywords.in 939 947 WEBCORE_CSS_VALUE_KEYWORDS := $(WEBCORE_CSS_VALUE_KEYWORDS) $(WebCore)/css/SVGCSSValueKeywords.in 940 948 WEBCORE_CSS_VALUE_KEYWORDS_DEFINES := $(FEATURE_DEFINES) $(ADDITIONAL_CSS_VALUE_KEYWORDS_DEFINES) 949 WEBCORE_CSS_PROPERTIES_DEFINES := $(FEATURE_DEFINES) $(ADDITIONAL_CSS_PROPERTIES_DEFINES) 941 950 942 951 CSSPropertyNames.h CSSPropertyNames.cpp StyleBuilder.cpp StylePropertyShorthandFunctions.h StylePropertyShorthandFunctions.cpp : makeprop.intermediate 943 952 .INTERMEDIATE : makeprop.intermediate 944 makeprop.intermediate : $(WEBCORE_CSS_PROPERTY_NAMES) css/makeprop.pl bindings/scripts/preprocessor.pm$(PLATFORM_FEATURE_DEFINES)945 $(PERL) -pe '' $(WEBCORE_CSS_PROPERTY_NAMES) > CSSPropert yNames.in946 $(PERL) "$(WebCore)/css/makeprop.pl" --defines "$( FEATURE_DEFINES)"953 makeprop.intermediate : $(WEBCORE_CSS_PROPERTY_NAMES) css/makeprop.pl $(PLATFORM_FEATURE_DEFINES) 954 $(PERL) -pe '' $(WEBCORE_CSS_PROPERTY_NAMES) > CSSProperties.json 955 $(PERL) "$(WebCore)/css/makeprop.pl" --defines "$(WEBCORE_CSS_PROPERTIES_DEFINES)" 947 956 948 957 CSSValueKeywords.h CSSValueKeywords.cpp : makevalues.intermediate -
trunk/Source/WebCore/css/StyleResolver.cpp
r208915 r209001 165 165 using namespace HTMLNames; 166 166 167 static const CSSPropertyID lastHighPriorityProperty = CSSPropertyFontSynthesis;168 167 static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1); 169 168 -
trunk/Source/WebCore/css/makeprop.pl
r208668 r209001 4 4 # 5 5 # Copyright (C) 1999 Waldo Bastian (bastian@kde.org) 6 # Copyright (C) 2007 , 2008, 2012, 2014, 2015Apple Inc. All rights reserved.6 # Copyright (C) 2007-2016 Apple Inc. All rights reserved. 7 7 # Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 8 8 # Copyright (C) 2010 Andras Becsi (abecsi@inf.u-szeged.hu), University of Szeged … … 23 23 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 24 # Boston, MA 02110-1301, USA. 25 use FindBin; 26 use lib "$FindBin::Bin/../bindings/scripts"; 27 28 use Getopt::Long; 29 use preprocessor; 25 30 26 use strict; 31 27 use warnings; 32 28 33 my $defines; 34 my $preprocessor; 29 use English; 30 use File::Spec; 31 use Getopt::Long; 32 use JSON::PP; 33 34 sub addProperty($$); 35 sub isPropertyEnabled($); 36 37 my $inputFile = "CSSProperties.json"; 38 39 my $defines = ""; 35 40 my $gperf; 36 41 GetOptions('defines=s' => \$defines, 37 'preprocessor=s' => \$preprocessor,38 42 'gperf-executable=s' => \$gperf); 39 43 40 my @NAMES = applyPreprocessor("CSSPropertyNames.in", $defines, $preprocessor); 41 die "We've reached more than 1024 CSS properties, please make sure to update CSSProperty/StylePropertyMetadata accordingly" if (scalar(@NAMES) > 1024); 42 43 my %namesHash; 44 my @duplicates = (); 45 44 my $input; 45 { 46 local $INPUT_RECORD_SEPARATOR; # No separator; read through until end-of-file. 47 open(JSON, "<", $inputFile) or die "Cannot open $inputFile.\n"; 48 $input = <JSON>; 49 close(JSON); 50 } 51 52 my $jsonDecoder = JSON::PP->new->utf8; 53 my $jsonHashRef = $jsonDecoder->decode($input); 54 my $propertiesHashRef = $jsonHashRef->{properties}; 55 my @allNames = keys(%$propertiesHashRef); 56 die "We've reached more than 1024 CSS properties, please make sure to update CSSProperty/StylePropertyMetadata accordingly" if @allNames > 1024; 57 58 my %defines = map { $_ => 1 } split(/ /, $defines); 59 60 my @names; 46 61 my $numPredefinedProperties = 2; 47 my @names = ();48 62 my %nameIsInherited; 63 my %nameIsHighPriority; 49 64 my %propertiesWithStyleBuilderOptions; 50 65 my %styleBuilderOptions = ( 51 AnimationProperty=> 1, # Defined in Source/WebCore/css/StyleBuilderConverter.h52 AutoFunctions=> 1,53 ConditionalConverter=> 1,54 Converter=> 1,55 Custom=> 1,56 FillLayerProperty=> 1,57 FontProperty=> 1,58 Getter=> 1,59 Initial=> 1,60 Longhands=> 1,61 NameForMethods=> 1,62 NoDefaultColor=> 1,63 SVG=> 1,64 SkipBuilder=> 1,65 Setter=> 1,66 VisitedLinkColorSupport=> 1,66 "animatable" => 1, # Defined in Source/WebCore/css/StyleBuilderConverter.h 67 "auto-functions" => 1, 68 "conditional-converter" => 1, 69 "converter" => 1, 70 "custom" => 1, 71 "fill-layer-property" => 1, 72 "font-property" => 1, 73 "getter" => 1, 74 "initial" => 1, 75 "longhands" => 1, 76 "name-for-methods" => 1, 77 "no-default-color" => 1, 78 "svg" => 1, 79 "skip-builder" => 1, 80 "setter" => 1, 81 "visited-link-color-support" => 1, 67 82 ); 68 83 my %nameToId; 69 my @aliases = (); 70 foreach (@NAMES) { 71 next if (m/(^\s*$)/); 72 next if (/^#/); 73 74 # Input may use a different EOL sequence than $/, so avoid chomp. 75 $_ =~ s/\s*\[(.+?)\]\r?$//; 76 my @options = (); 77 if ($1) { 78 @options = split(/\s*,\s*/, $1); 79 } 80 81 $_ =~ s/[\r\n]+$//g; 82 if (exists $namesHash{$_}) { 83 push @duplicates, $_; 84 } else { 85 $namesHash{$_} = 1; 86 } 87 if ($_ =~ /=/) { 88 if (@options) { 89 die "Options are specified on an alias $_: ", join(", ", @options) . "\n"; 90 } 91 push @aliases, $_; 92 } else { 93 $nameIsInherited{$_} = 0; 94 $propertiesWithStyleBuilderOptions{$_} = {}; 95 foreach my $option (@options) { 96 my ($optionName, $optionValue) = split(/=/, $option); 97 if ($optionName eq "Inherited") { 98 $nameIsInherited{$_} = 1; 99 } elsif ($styleBuilderOptions{$optionName}) { 100 $propertiesWithStyleBuilderOptions{$_}{$optionName} = $optionValue; 101 } else { 102 die "Unrecognized \"" . $optionName . "\" option for " . $_ . " property."; 103 } 104 } 105 106 my $id = $_; 84 my %nameToAliases; 85 86 for my $name (@allNames) { 87 my $value = $propertiesHashRef->{$name}; 88 my $valueType = ref($value); 89 if ($valueType eq "HASH") { 90 if (isPropertyEnabled($value)) { 91 addProperty($name, $value); 92 } 93 } elsif ($valueType eq "ARRAY") { 94 for my $v (@$value) { 95 if (isPropertyEnabled($v)) { 96 addProperty($name, $v); 97 last; 98 } 99 } 100 } else { 101 die "$name does not have a supported value type. Only dictionary and array types are supported."; 102 } 103 } 104 105 sub isPropertyEnabled($) 106 { 107 my ($optionsHashRef) = @_; 108 if (!$optionsHashRef->{"codegen-properties"} || !$optionsHashRef->{"codegen-properties"}{"enable-if"}) { 109 return 1; 110 } 111 if (exists($defines{$optionsHashRef->{"codegen-properties"}{"enable-if"}})) { 112 return 1; 113 } 114 if (substr($optionsHashRef->{"codegen-properties"}{"enable-if"}, 0, 1) eq "!" && !exists($defines{substr($optionsHashRef->{"codegen-properties"}{"enable-if"}, 1)})) { 115 return 1; 116 } 117 return 0; 118 } 119 120 sub addProperty($$) 121 { 122 my ($name, $optionsHashRef) = @_; 123 124 push @names, $name; 125 126 my $id = $name; 107 127 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge; 108 $nameToId{$_} = $id; 109 110 push @names, $_; 111 } 112 } 113 114 if (@duplicates > 0) { 115 die 'Duplicate CSS property names: ', join(', ', @duplicates) . "\n"; 116 } 128 $nameToId{$name} = $id; 129 130 for my $optionName (keys %{$optionsHashRef}) { 131 if ($optionName eq "codegen-properties") { 132 my $codegenProperties = $optionsHashRef->{"codegen-properties"}; 133 for my $codegenOptionName (keys %$codegenProperties) { 134 if ($codegenOptionName eq "enable-if") { 135 next; 136 } elsif ($codegenOptionName eq "high-priority") { 137 $nameIsHighPriority{$name} = 1; 138 } elsif ($codegenOptionName eq "aliases") { 139 $nameToAliases{$name} = $codegenProperties->{"aliases"}; 140 } elsif ($styleBuilderOptions{$codegenOptionName}) { 141 $propertiesWithStyleBuilderOptions{$name}{$codegenOptionName} = $codegenProperties->{$codegenOptionName}; 142 } else { 143 die "Unrecognized codegen property \"$optionName\" for $name property."; 144 } 145 } 146 } elsif ($optionName eq "animatable") { 147 $propertiesWithStyleBuilderOptions{$name}{"animatable"} = $optionsHashRef->{"animatable"}; 148 } elsif ($optionName eq "inherited") { 149 $nameIsInherited{$name} = 1; 150 } elsif ($optionName eq "values") { 151 # FIXME: Implement. 152 } 153 # We allow unrecognized options to pass through without error to support annotation. 154 } 155 } 156 157 sub sortByDescendingPriorityAndName 158 { 159 # Sort names with high priority to the front 160 if (!!$nameIsHighPriority{$a} < !!$nameIsHighPriority{$b}) { 161 return 1; 162 } 163 if (!!$nameIsHighPriority{$a} > !!$nameIsHighPriority{$b}) { 164 return -1; 165 } 166 # Sort names without leading '-' to the front 167 if (substr($a, 0, 1) eq "-" && substr($b, 0, 1) ne "-") { 168 return 1; 169 } 170 if (substr($a, 0, 1) ne "-" && substr($b, 0, 1) eq "-") { 171 return -1; 172 } 173 return $a cmp $b; 174 } 175 176 @names = sort sortByDescendingPriorityAndName @names; 117 177 118 178 open GPERF, ">CSSPropertyNames.gperf" || die "Could not open CSSPropertyNames.gperf for writing"; 119 179 print GPERF << "EOF"; 120 180 %{ 121 /* This file is automatically generated from CSSPropertyNames.inby makeprop, do not edit */181 /* This file is automatically generated from $inputFile by makeprop, do not edit */ 122 182 #include "config.h" 123 183 #include \"CSSProperty.h\" … … 172 232 } 173 233 174 foreach my $alias (@aliases) { 175 $alias =~ /^([^\s]*)[\s]*=[\s]*([^\s]*)/; 176 my $name = $1; 177 print GPERF $name . ", CSSProperty" . $nameToId{$2} . "\n"; 234 for my $name (@names) { 235 if (!$nameToAliases{$name}) { 236 next; 237 } 238 for my $alias (@{$nameToAliases{$name}}) { 239 print GPERF $alias . ", CSSProperty" . $nameToId{$name} . "\n"; 240 } 178 241 } 179 242 … … 272 335 open HEADER, ">CSSPropertyNames.h" || die "Could not open CSSPropertyNames.h for writing"; 273 336 print HEADER << "EOF"; 274 /* This file is automatically generated from CSSPropertyNames.inby makeprop, do not edit */337 /* This file is automatically generated from $inputFile by makeprop, do not edit */ 275 338 276 339 #pragma once … … 295 358 my $i = $numPredefinedProperties; 296 359 my $maxLen = 0; 360 my $lastHighPriorityPropertyName; 297 361 foreach my $name (@names) { 362 $lastHighPriorityPropertyName = $name if $nameIsHighPriority{$name}; # Assumes that @names is sorted by descending priorities. 298 363 print HEADER " CSSProperty" . $nameToId{$name} . " = " . $i . ",\n"; 299 364 $i = $i + 1; … … 310 375 print HEADER "const int lastCSSProperty = $last;\n"; 311 376 print HEADER "const size_t maxCSSPropertyNameLength = $maxLen;\n"; 377 print HEADER "const CSSPropertyID lastHighPriorityProperty = CSSProperty" . $nameToId{$lastHighPriorityPropertyName} . ";\n"; 312 378 313 379 print HEADER << "EOF"; … … 348 414 my $builderFunction = shift; 349 415 350 return $propertiesWithStyleBuilderOptions{$name}{" Custom"}{$builderFunction} ? "StyleBuilderCustom" : "StyleBuilderFunctions";416 return $propertiesWithStyleBuilderOptions{$name}{"custom"}{$builderFunction} ? "StyleBuilderCustom" : "StyleBuilderFunctions"; 351 417 } 352 418 … … 356 422 my $nameForMethods = $nameToId{$name}; 357 423 $nameForMethods =~ s/Webkit//g; 358 if (exists($propertiesWithStyleBuilderOptions{$name}{" NameForMethods"})) {359 $nameForMethods = $propertiesWithStyleBuilderOptions{$name}{" NameForMethods"};424 if (exists($propertiesWithStyleBuilderOptions{$name}{"name-for-methods"})) { 425 $nameForMethods = $propertiesWithStyleBuilderOptions{$name}{"name-for-methods"}; 360 426 } 361 427 return $nameForMethods; … … 450 516 my $nameForMethods = getNameForMethods($name); 451 517 $nameForMethods =~ s/Webkit//g; 452 if (exists($propertiesWithStyleBuilderOptions{$name}{" NameForMethods"})) {453 $nameForMethods = $propertiesWithStyleBuilderOptions{$name}{" NameForMethods"};454 } 455 456 if (!exists($propertiesWithStyleBuilderOptions{$name}{" Getter"})) {457 $propertiesWithStyleBuilderOptions{$name}{" Getter"} = lcfirst($nameForMethods);458 } 459 if (!exists($propertiesWithStyleBuilderOptions{$name}{" Setter"})) {460 $propertiesWithStyleBuilderOptions{$name}{" Setter"} = "set" . $nameForMethods;461 } 462 if (!exists($propertiesWithStyleBuilderOptions{$name}{" Initial"})) {463 if (exists($propertiesWithStyleBuilderOptions{$name}{" FillLayerProperty"})) {464 $propertiesWithStyleBuilderOptions{$name}{" Initial"} = "initialFill" . $nameForMethods;518 if (exists($propertiesWithStyleBuilderOptions{$name}{"name-for-methods"})) { 519 $nameForMethods = $propertiesWithStyleBuilderOptions{$name}{"name-for-methods"}; 520 } 521 522 if (!exists($propertiesWithStyleBuilderOptions{$name}{"getter"})) { 523 $propertiesWithStyleBuilderOptions{$name}{"getter"} = lcfirst($nameForMethods); 524 } 525 if (!exists($propertiesWithStyleBuilderOptions{$name}{"setter"})) { 526 $propertiesWithStyleBuilderOptions{$name}{"setter"} = "set" . $nameForMethods; 527 } 528 if (!exists($propertiesWithStyleBuilderOptions{$name}{"initial"})) { 529 if (exists($propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"})) { 530 $propertiesWithStyleBuilderOptions{$name}{"initial"} = "initialFill" . $nameForMethods; 465 531 } else { 466 $propertiesWithStyleBuilderOptions{$name}{"Initial"} = "initial" . $nameForMethods; 467 } 468 } 469 if (!exists($propertiesWithStyleBuilderOptions{$name}{"Custom"})) { 470 $propertiesWithStyleBuilderOptions{$name}{"Custom"} = ""; 471 } elsif ($propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All") { 472 $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "Initial|Inherit|Value"; 473 } 474 my %customValues = map { $_ => 1 } split(/\|/, $propertiesWithStyleBuilderOptions{$name}{"Custom"}); 475 $propertiesWithStyleBuilderOptions{$name}{"Custom"} = \%customValues; 532 $propertiesWithStyleBuilderOptions{$name}{"initial"} = "initial" . $nameForMethods; 533 } 534 } 535 # FIXME: Convert option custom from a string to an array. 536 if (!exists($propertiesWithStyleBuilderOptions{$name}{"custom"})) { 537 $propertiesWithStyleBuilderOptions{$name}{"custom"} = ""; 538 } elsif ($propertiesWithStyleBuilderOptions{$name}{"custom"} eq "All") { 539 $propertiesWithStyleBuilderOptions{$name}{"custom"} = "Initial|Inherit|Value"; 540 } 541 my %customValues = map { $_ => 1 } split(/\|/, $propertiesWithStyleBuilderOptions{$name}{"custom"}); 542 $propertiesWithStyleBuilderOptions{$name}{"custom"} = \%customValues; 476 543 } 477 544 … … 501 568 my $style = "styleResolver.style()"; 502 569 my $setterContent .= $indent . "if (styleResolver.applyPropertyToRegularStyle())\n"; 503 my $setValue = $style . "->" . $propertiesWithStyleBuilderOptions{$name}{" Setter"};570 my $setValue = $style . "->" . $propertiesWithStyleBuilderOptions{$name}{"setter"}; 504 571 my $color = $valueIsPrimitive ? colorFromPrimitiveValue($value) : $value; 505 572 $setterContent .= $indent . " " . $setValue . "(" . $color . ");\n"; … … 531 598 $setterContent .= $indent . "if (list.isEmpty())\n"; 532 599 $setterContent .= $indent . " list.append(Animation::create());\n"; 533 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};534 my $initial = $propertiesWithStyleBuilderOptions{$name}{" Initial"};600 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 601 my $initial = $propertiesWithStyleBuilderOptions{$name}{"initial"}; 535 602 $setterContent .= $indent . "list.animation(0)." . $setter . "(Animation::" . $initial . "());\n"; 536 603 if ($name eq "-webkit-transition-property") { … … 554 621 $setterContent .= $indent . " if (list.size() <= i)\n"; 555 622 $setterContent .= $indent . " list.append(Animation::create());\n"; 556 my $getter = $propertiesWithStyleBuilderOptions{$name}{" Getter"};557 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};623 my $getter = $propertiesWithStyleBuilderOptions{$name}{"getter"}; 624 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 558 625 $setterContent .= $indent . " list.animation(i)." . $setter . "(parentList->animation(i)." . $getter . "());\n"; 559 626 $setterContent .= $indent . " list.animation(i).setAnimationMode(parentList->animation(i).animationMode());\n"; … … 600 667 my $indent = shift; 601 668 602 my $getter = $propertiesWithStyleBuilderOptions{$name}{" Getter"};603 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};669 my $getter = $propertiesWithStyleBuilderOptions{$name}{"getter"}; 670 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 604 671 my $clearFunction = getClearFunction($name); 605 672 my $testFunction = getTestFunction($name); 606 my $initial = "FillLayer::" . $propertiesWithStyleBuilderOptions{$name}{" Initial"} . "(" . getFillLayerType($name) . ")";673 my $initial = "FillLayer::" . $propertiesWithStyleBuilderOptions{$name}{"initial"} . "(" . getFillLayerType($name) . ")"; 607 674 608 675 my $setterContent = ""; … … 624 691 my $indent = shift; 625 692 626 my $getter = $propertiesWithStyleBuilderOptions{$name}{" Getter"};627 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};693 my $getter = $propertiesWithStyleBuilderOptions{$name}{"getter"}; 694 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 628 695 my $clearFunction = getClearFunction($name); 629 696 my $testFunction = getTestFunction($name); … … 686 753 my $value = shift; 687 754 688 my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{" SVG"};689 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};755 my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{"svg"}; 756 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 690 757 return "styleResolver.style()->" . ($isSVG ? "accessSVGStyle()." : "") . $setter . "(" . $value . ")"; 691 758 } … … 695 762 my $indent = shift; 696 763 697 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};698 my $initial = $propertiesWithStyleBuilderOptions{$name}{" Initial"};699 my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{" SVG"};764 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 765 my $initial = $propertiesWithStyleBuilderOptions{$name}{"initial"}; 766 my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{"svg"}; 700 767 my $setterContent = ""; 701 768 $setterContent .= $indent . "static void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n"; 702 769 $setterContent .= $indent . "{\n"; 703 770 my $style = "styleResolver.style()"; 704 if (exists $propertiesWithStyleBuilderOptions{$name}{" AutoFunctions"}) {771 if (exists $propertiesWithStyleBuilderOptions{$name}{"auto-functions"}) { 705 772 $setterContent .= $indent . " " . getAutoSetter($name, $style) . ";\n"; 706 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" VisitedLinkColorSupport"}) {773 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"visited-link-color-support"}) { 707 774 my $initialColor = "RenderStyle::" . $initial . "()"; 708 775 $setterContent .= generateColorValueSetter($name, $initialColor, $indent . " "); 709 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" AnimationProperty"}) {776 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"animatable"}) { 710 777 $setterContent .= generateAnimationPropertyInitialValueSetter($name, $indent . " "); 711 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" FontProperty"}) {778 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"font-property"}) { 712 779 $setterContent .= $indent . " auto fontDescription = styleResolver.fontDescription();\n"; 713 780 $setterContent .= $indent . " fontDescription." . $setter . "(FontCascadeDescription::" . $initial . "());\n"; 714 781 $setterContent .= $indent . " styleResolver.setFontDescription(fontDescription);\n"; 715 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" FillLayerProperty"}) {782 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"}) { 716 783 $setterContent .= generateFillLayerPropertyInitialValueSetter($name, $indent . " "); 717 784 } else { … … 731 798 $setterContent .= $indent . "static void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n"; 732 799 $setterContent .= $indent . "{\n"; 733 my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{" SVG"};800 my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{"svg"}; 734 801 my $parentStyle = "styleResolver.parentStyle()"; 735 802 my $style = "styleResolver.style()"; 736 my $getter = $propertiesWithStyleBuilderOptions{$name}{" Getter"};737 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};803 my $getter = $propertiesWithStyleBuilderOptions{$name}{"getter"}; 804 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 738 805 my $didCallSetValue = 0; 739 if (exists $propertiesWithStyleBuilderOptions{$name}{" AutoFunctions"}) {806 if (exists $propertiesWithStyleBuilderOptions{$name}{"auto-functions"}) { 740 807 $setterContent .= $indent . " if (" . getAutoGetter($name, $parentStyle) . ") {\n"; 741 808 $setterContent .= $indent . " " . getAutoSetter($name, $style) . ";\n"; 742 809 $setterContent .= $indent . " return;\n"; 743 810 $setterContent .= $indent . " }\n"; 744 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" VisitedLinkColorSupport"}) {811 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"visited-link-color-support"}) { 745 812 $setterContent .= $indent . " Color color = " . $parentStyle . "->" . $getter . "();\n"; 746 if (!exists($propertiesWithStyleBuilderOptions{$name}{" NoDefaultColor"})) {813 if (!exists($propertiesWithStyleBuilderOptions{$name}{"no-default-color"})) { 747 814 $setterContent .= $indent . " if (!color.isValid())\n"; 748 815 $setterContent .= $indent . " color = " . $parentStyle . "->color();\n"; … … 750 817 $setterContent .= generateColorValueSetter($name, "color", $indent . " "); 751 818 $didCallSetValue = 1; 752 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" AnimationProperty"}) {819 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"animatable"}) { 753 820 $setterContent .= generateAnimationPropertyInheritValueSetter($name, $indent . " "); 754 821 $didCallSetValue = 1; 755 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" FontProperty"}) {822 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"font-property"}) { 756 823 $setterContent .= $indent . " auto fontDescription = styleResolver.fontDescription();\n"; 757 824 $setterContent .= $indent . " fontDescription." . $setter . "(styleResolver.parentFontDescription()." . $getter . "());\n"; 758 825 $setterContent .= $indent . " styleResolver.setFontDescription(fontDescription);\n"; 759 826 $didCallSetValue = 1; 760 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" FillLayerProperty"}) {827 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"}) { 761 828 $setterContent .= generateFillLayerPropertyInheritValueSetter($name, $indent . " "); 762 829 $didCallSetValue = 1; … … 779 846 $setterContent .= $indent . "{\n"; 780 847 my $convertedValue; 781 if (exists($propertiesWithStyleBuilderOptions{$name}{" Converter"})) {782 $convertedValue = "StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{" Converter"} . "(styleResolver, value)";783 } elsif (exists($propertiesWithStyleBuilderOptions{$name}{" ConditionalConverter"})) {784 $setterContent .= $indent . " auto convertedValue = StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{" ConditionalConverter"} . "(styleResolver, value);\n";848 if (exists($propertiesWithStyleBuilderOptions{$name}{"converter"})) { 849 $convertedValue = "StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"converter"} . "(styleResolver, value)"; 850 } elsif (exists($propertiesWithStyleBuilderOptions{$name}{"conditional-converter"})) { 851 $setterContent .= $indent . " auto convertedValue = StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"conditional-converter"} . "(styleResolver, value);\n"; 785 852 $convertedValue = "convertedValue.value()"; 786 853 } else { … … 788 855 } 789 856 790 my $setter = $propertiesWithStyleBuilderOptions{$name}{" Setter"};857 my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"}; 791 858 my $style = "styleResolver.style()"; 792 859 my $didCallSetValue = 0; 793 if (exists $propertiesWithStyleBuilderOptions{$name}{" AutoFunctions"}) {860 if (exists $propertiesWithStyleBuilderOptions{$name}{"auto-functions"}) { 794 861 $setterContent .= $indent . " if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto) {\n"; 795 862 $setterContent .= $indent . " ". getAutoSetter($name, $style) . ";\n"; 796 863 $setterContent .= $indent . " return;\n"; 797 864 $setterContent .= $indent . " }\n"; 798 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" VisitedLinkColorSupport"}) {865 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"visited-link-color-support"}) { 799 866 $setterContent .= $indent . " auto& primitiveValue = downcast<CSSPrimitiveValue>(value);\n"; 800 867 if ($name eq "color") { … … 804 871 $setterContent .= generateColorValueSetter($name, "primitiveValue", $indent . " ", VALUE_IS_PRIMITIVE); 805 872 $didCallSetValue = 1; 806 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" AnimationProperty"}) {873 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"animatable"}) { 807 874 $setterContent .= generateAnimationPropertyValueSetter($name, $indent . " "); 808 875 $didCallSetValue = 1; 809 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" FontProperty"}) {876 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"font-property"}) { 810 877 $setterContent .= $indent . " auto fontDescription = styleResolver.fontDescription();\n"; 811 878 $setterContent .= $indent . " fontDescription." . $setter . "(" . $convertedValue . ");\n"; 812 879 $setterContent .= $indent . " styleResolver.setFontDescription(fontDescription);\n"; 813 880 $didCallSetValue = 1; 814 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{" FillLayerProperty"}) {881 } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"}) { 815 882 $setterContent .= generateFillLayerPropertyValueSetter($name, $indent . " "); 816 883 $didCallSetValue = 1; 817 884 } 818 885 if (!$didCallSetValue) { 819 if (exists($propertiesWithStyleBuilderOptions{$name}{" ConditionalConverter"})) {886 if (exists($propertiesWithStyleBuilderOptions{$name}{"conditional-converter"})) { 820 887 $setterContent .= $indent . " if (convertedValue)\n"; 821 888 $setterContent .= " "; … … 830 897 open STYLEBUILDER, ">StyleBuilder.cpp" || die "Could not open StyleBuilder.cpp for writing"; 831 898 print STYLEBUILDER << "EOF"; 832 /* This file is automatically generated from CSSPropertyNames.inby makeprop, do not edit */899 /* This file is automatically generated from $inputFile by makeprop, do not edit */ 833 900 834 901 #include "config.h" … … 851 918 foreach my $name (@names) { 852 919 # Skip Shorthand properties and properties that do not use the StyleBuilder. 853 next if (exists $propertiesWithStyleBuilderOptions{$name}{" Longhands"});854 next if (exists $propertiesWithStyleBuilderOptions{$name}{" SkipBuilder"});920 next if (exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}); 921 next if (exists $propertiesWithStyleBuilderOptions{$name}{"skip-builder"}); 855 922 856 923 my $indent = " "; 857 if (!$propertiesWithStyleBuilderOptions{$name}{" Custom"}{"Initial"}) {924 if (!$propertiesWithStyleBuilderOptions{$name}{"custom"}{"Initial"}) { 858 925 print STYLEBUILDER generateInitialValueSetter($name, $indent); 859 926 } 860 if (!$propertiesWithStyleBuilderOptions{$name}{" Custom"}{"Inherit"}) {927 if (!$propertiesWithStyleBuilderOptions{$name}{"custom"}{"Inherit"}) { 861 928 print STYLEBUILDER generateInheritValueSetter($name, $indent); 862 929 } 863 if (!$propertiesWithStyleBuilderOptions{$name}{" Custom"}{"Value"}) {930 if (!$propertiesWithStyleBuilderOptions{$name}{"custom"}{"Value"}) { 864 931 print STYLEBUILDER generateValueSetter($name, $indent); 865 932 } … … 879 946 foreach my $name (@names) { 880 947 print STYLEBUILDER " case CSSProperty" . $nameToId{$name} . ":\n"; 881 if (exists $propertiesWithStyleBuilderOptions{$name}{" Longhands"}) {948 if (exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}) { 882 949 print STYLEBUILDER " ASSERT(isShorthandCSSProperty(property));\n"; 883 950 print STYLEBUILDER " ASSERT_NOT_REACHED();\n"; 884 } elsif (!exists $propertiesWithStyleBuilderOptions{$name}{" SkipBuilder"}) {951 } elsif (!exists $propertiesWithStyleBuilderOptions{$name}{"skip-builder"}) { 885 952 print STYLEBUILDER " if (isInitial)\n"; 886 953 print STYLEBUILDER " " . getScopeForFunction($name, "Initial") . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n"; … … 905 972 open SHORTHANDS_H, ">StylePropertyShorthandFunctions.h" || die "Could not open StylePropertyShorthandFunctions.h for writing"; 906 973 print SHORTHANDS_H << "EOF"; 907 /* This file is automatically generated from CSSPropertyNames.inby makeprop, do not edit */974 /* This file is automatically generated from $inputFile by makeprop, do not edit */ 908 975 909 976 #pragma once … … 917 984 foreach my $name (@names) { 918 985 # Skip non-Shorthand properties. 919 next if (!exists $propertiesWithStyleBuilderOptions{$name}{" Longhands"});986 next if (!exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}); 920 987 921 988 print SHORTHANDS_H "StylePropertyShorthand " . lcfirst($nameToId{$name}) . "Shorthand();\n"; … … 931 998 open SHORTHANDS_CPP, ">StylePropertyShorthandFunctions.cpp" || die "Could not open StylePropertyShorthandFunctions.cpp for writing"; 932 999 print SHORTHANDS_CPP << "EOF"; 933 /* This file is automatically generated from CSSPropertyNames.inby makeprop, do not edit */1000 /* This file is automatically generated from $inputFile by makeprop, do not edit */ 934 1001 935 1002 #include "config.h" … … 947 1014 foreach my $name (@names) { 948 1015 # Skip non-Shorthand properties. 949 next if (!exists $propertiesWithStyleBuilderOptions{$name}{" Longhands"});1016 next if (!exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}); 950 1017 951 1018 my $lowercaseId = lcfirst($nameToId{$name}); 952 my @longhands = split(/\|/, $propertiesWithStyleBuilderOptions{$name}{"Longhands"});1019 my @longhands = @{$propertiesWithStyleBuilderOptions{$name}{"longhands"}}; 953 1020 954 1021 print SHORTHANDS_CPP "StylePropertyShorthand " . $lowercaseId . "Shorthand()\n"; … … 958 1025 if ($_ eq "all") { 959 1026 foreach my $propname (@names) { 960 next if (exists $propertiesWithStyleBuilderOptions{$propname}{" Longhands"});1027 next if (exists $propertiesWithStyleBuilderOptions{$propname}{"longhands"}); 961 1028 next if ($propname eq "direction" || $propname eq "unicode-bidi"); 962 die "Unknown CSS property used in all shorthand: " . $nameToId{$propname}if !exists($nameToId{$propname});1029 die "Unknown CSS property used in all shorthand: $propname" if !exists($nameToId{$propname}); 963 1030 push(@{$longhandToShorthands{$propname}}, $name); 964 1031 print SHORTHANDS_CPP " CSSProperty" . $nameToId{$propname} . ",\n"; 965 1032 } 966 1033 } else { 967 die "Unknown CSS property used in Longhands: " . $nameToId{$_}if !exists($nameToId{$_});1034 die "Unknown CSS property used in longhands: $_" if !exists($nameToId{$_}); 968 1035 push(@{$longhandToShorthands{$_}}, $name); 969 1036 print SHORTHANDS_CPP " CSSProperty" . $nameToId{$_} . ",\n"; … … 985 1052 foreach my $name (@names) { 986 1053 # Skip non-Shorthand properties. 987 next if (!exists $propertiesWithStyleBuilderOptions{$name}{" Longhands"});1054 next if (!exists $propertiesWithStyleBuilderOptions{$name}{"longhands"}); 988 1055 989 1056 print SHORTHANDS_CPP " case CSSProperty" . $nameToId{$name} . ":\n";
Note: See TracChangeset
for help on using the changeset viewer.