update-iexploder-cssproperties 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/usr/bin/perl
  2. # Copyright (C) 2007 Apple Inc. All rights reserved.
  3. # Copyright (C) 2010 Holger Hans Peter Freyther
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. #
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. # 3. Neither the name of Apple Inc. ("Apple") nor the names of
  15. # its contributors may be used to endorse or promote products derived
  16. # from this software without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  19. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  22. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. # This script updates Tools/iExploder/iExploder-1.3.2/htdocs/*.in based on
  29. # WebCore/css/CSSPropertyNames.in, WebCore/html/HTMLTagNames.in
  30. # and WebCore/html/HTMLAttributeNames.in
  31. use warnings;
  32. use strict;
  33. use FindBin;
  34. use lib $FindBin::Bin;
  35. use VCSUtils;
  36. use webkitdirs;
  37. use File::Spec;
  38. sub generateEntityListFromFile($);
  39. sub readiExploderFile($);
  40. sub update($$);
  41. sub writeiExploderFile($@);
  42. update("cssproperties.in", "css/CSSPropertyNames.in");
  43. update("htmlattrs.in", "html/HTMLAttributeNames.in");
  44. update("htmltags.in", "html/HTMLTagNames.in");
  45. print "Successfully updated!\n";
  46. exit 0;
  47. sub generateEntityListFromFile($)
  48. {
  49. my ($filename) = @_;
  50. my $revision = svnRevisionForDirectory(dirname($filename));
  51. my $path = File::Spec->abs2rel($filename, sourceDir());
  52. my $result = "# From WebKit svn r" . $revision . " (" . $path . ")\n";
  53. my @entities = ();
  54. my $in_namespace = 0;
  55. open(IN, $filename) || die "$!";
  56. while (my $l = <IN>) {
  57. chomp $l;
  58. if ($l =~ m/^namespace=\"/) {
  59. $in_namespace = 1;
  60. } elsif ($in_namespace && $l =~ m/^$/) {
  61. $in_namespace = 0;
  62. }
  63. next if $in_namespace;
  64. next if $l =~ m/^\s*#/ || $l =~ m/^\s*$/;
  65. # For HTML Tags that can have additional information
  66. if ($l =~ m/ /) {
  67. my @split = split / /, $l;
  68. $l = $split[0]
  69. }
  70. push(@entities, $l);
  71. }
  72. close(IN);
  73. $result .= join("\n", sort { $a cmp $b } @entities) . "\n\n";
  74. return $result;
  75. }
  76. sub readiExploderFile($)
  77. {
  78. my ($filename) = @_;
  79. my @sections = ();
  80. local $/ = "\n\n";
  81. open(IN, $filename) || die "$!";
  82. @sections = <IN>;
  83. close(IN);
  84. return @sections;
  85. }
  86. sub update($$)
  87. {
  88. my ($iexploderPath, $webcorePath) = @_;
  89. $iexploderPath = File::Spec->catfile(sourceDir(), "Tools", "iExploder", "iExploder-1.3.2", "htdocs", split("/", $iexploderPath));
  90. $webcorePath = File::Spec->catfile(sourceDir(), "Source", "WebCore", split("/", $webcorePath));
  91. my @sections = readiExploderFile($iexploderPath);
  92. $sections[0] = generateEntityListFromFile($webcorePath);
  93. writeiExploderFile($iexploderPath, @sections);
  94. }
  95. sub writeiExploderFile($@)
  96. {
  97. my ($filename, @sections) = @_;
  98. open(OUT, "> $filename") || die "$!";
  99. print OUT join("", @sections);
  100. close(OUT);
  101. }