Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (86935 => 86936)
--- trunk/Source/WebCore/CMakeLists.txt 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-05-20 10:47:56 UTC (rev 86936)
@@ -1952,6 +1952,7 @@
${WEBCORE_DIR}/bindings/scripts/IDLParser.pm
${WEBCORE_DIR}/bindings/scripts/IDLStructure.pm
${WEBCORE_DIR}/bindings/scripts/InFilesParser.pm
+ ${WEBCORE_DIR}/bindings/scripts/preprocessor.pm
)
INCLUDE(${WEBCORE_DIR}/UseJSC.cmake)
@@ -2067,8 +2068,8 @@
ADD_CUSTOM_COMMAND(
OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheetsData.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheets.h
MAIN_DEPENDENCY ${WEBCORE_DIR}/css/make-css-file-arrays.pl
- DEPENDS ${WebCore_USER_AGENT_STYLE_SHEETS}
- COMMAND ${PERL_EXECUTABLE} ${WEBCORE_DIR}/css/make-css-file-arrays.pl ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheets.h ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheetsData.cpp ${WebCore_USER_AGENT_STYLE_SHEETS}
+ DEPENDS ${WebCore_USER_AGENT_STYLE_SHEETS} ${WEBCORE_DIR}/bindings/scripts/preprocessor.pm
+ COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/css/make-css-file-arrays.pl --defines "${FEATURE_DEFINES}" ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheets.h ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheetsData.cpp ${WebCore_USER_AGENT_STYLE_SHEETS}
VERBATIM)
LIST(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/UserAgentStyleSheetsData.cpp)
ADD_SOURCE_WEBCORE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/css/CSSStyleSelector.cpp UserAgentStyleSheetsData.cpp UserAgentStyleSheets.h)
Modified: trunk/Source/WebCore/ChangeLog (86935 => 86936)
--- trunk/Source/WebCore/ChangeLog 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/ChangeLog 2011-05-20 10:47:56 UTC (rev 86936)
@@ -1,3 +1,47 @@
+2011-05-20 Kent Tamura <tk...@chromium.org>
+
+ Reviewed by Hajime Morita.
+
+ Apply feature flags to user-agent style sheets
+ https://bugs.webkit.org/show_bug.cgi?id=52612
+
+ A user-agent style sheet should not have style definitions for disabled
+ features because such definitions makes feature detection harder and
+ causes incorrect behavior (See Bug 52214).
+
+ We have handled such feature-dependent style definitions by providing
+ separated CSS files and selecting them in build files. Adding such style
+ definition was hard because we need to update each of build files. This
+ change simplifies the process to add such style definitions by applying
+ preprocessor to the CSS files.
+
+ Implementation:
+ make-css-file-arrays.pl invokes a preprocessor if it has --defines
+ option. Otherwise, it just remove lines beginning with #.
+ In this change, we pass --defines on Mac, Windows, Chromium, GTK, and
+ CMake platforms. Qt and Android have no behavior change.
+
+ * CMakeLists.txt:
+ - IDL handling depends on preprocessor.pm.
+ - Pass --defines option to make-css-file-arrays.pl
+ - Add WebCore/bindings/scripts to @INC for make-css-file-arrays.pl
+ * CodeGenerators.pri: IDL handling depends on preprocessor.pm.
+ * DerivedSources.make: ditto.
+ * GNUmakefile.am: ditto.
+ * WebCore.gyp/WebCore.gyp: ditto.
+ * WebCore.gyp/scripts/action_useragentstylesheets.py:
+ Change parameter order to support perl modules and options.
+ Many code is taken from rule_bindings.py.
+ * WebCore.vcproj/MigrateScripts: Handles preprocessor.pm.
+ * bindings/scripts/IDLParser.pm:
+ Move the preprocessor code to preprocessor.pm.
+ * bindings/scripts/preprocessor.pm:
+ Added. The code was moved from IDLParser.pm
+ * css/html.css: Enclose some style definitions with #if-#endif.
+ * css/make-css-file-arrays.pl:
+ - Add --defines and --preprocessor options.
+ - Invoke a preprocessor if --defines is specified.
+
2011-05-20 Dirk Schulze <k...@webkit.org>
Rubber-stamped by Nikolas Zimmermann.
Modified: trunk/Source/WebCore/CodeGenerators.pri (86935 => 86936)
--- trunk/Source/WebCore/CodeGenerators.pri 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/CodeGenerators.pri 2011-05-20 10:47:56 UTC (rev 86936)
@@ -625,14 +625,16 @@
$$PWD/bindings/scripts/CodeGeneratorV8.pm \
$$PWD/bindings/scripts/IDLParser.pm \
$$PWD/bindings/scripts/IDLStructure.pm \
- $$PWD/bindings/scripts/InFilesParser.pm
+ $$PWD/bindings/scripts/InFilesParser.pm \
+ $$PWD/bindings/scripts/preprocessor.pm
} else {
idl.output = $${WC_GENERATED_SOURCES_DIR}/JS${QMAKE_FILE_BASE}.cpp
idl.depends = $$PWD/bindings/scripts/CodeGenerator.pm \
$$PWD/bindings/scripts/CodeGeneratorJS.pm \
$$PWD/bindings/scripts/IDLParser.pm \
$$PWD/bindings/scripts/IDLStructure.pm \
- $$PWD/bindings/scripts/InFilesParser.pm
+ $$PWD/bindings/scripts/InFilesParser.pm \
+ $$PWD/bindings/scripts/preprocessor.pm
}
addExtraCompiler(idl)
@@ -655,6 +657,7 @@
$$PWD/bindings/scripts/IDLParser.pm \
$$PWD/bindings/scripts/IDLStructure.pm \
$$PWD/bindings/scripts/InFilesParser.pm \
+ $$PWD/bindings/scripts/preprocessor.pm \
$$PWD/inspector/Inspector.json \
$$PWD/inspector/generate-inspector-idl
inspectorIDL.wkExtraSources = $$inspectorIDL.output
Modified: trunk/Source/WebCore/DerivedSources.make (86935 => 86936)
--- trunk/Source/WebCore/DerivedSources.make 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/DerivedSources.make 2011-05-20 10:47:56 UTC (rev 86936)
@@ -748,8 +748,8 @@
USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/fullscreen.css $(WebCore)/css/fullscreenQuickTime.css
endif
-UserAgentStyleSheets.h : css/make-css-file-arrays.pl $(USER_AGENT_STYLE_SHEETS)
- perl $< $@ UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)
+UserAgentStyleSheets.h : css/make-css-file-arrays.pl bindings/scripts/preprocessor.pm $(USER_AGENT_STYLE_SHEETS)
+ perl -I$(WebCore)/bindings/scripts $< --defines "$(FEATURE_DEFINES)" $@ UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)
# --------
@@ -860,7 +860,8 @@
bindings/scripts/CodeGenerator.pm \
bindings/scripts/IDLParser.pm \
bindings/scripts/IDLStructure.pm \
- bindings/scripts/generate-bindings.pl
+ bindings/scripts/generate-bindings.pl \
+ bindings/scripts/preprocessor.pm
generator_script = perl $(addprefix -I $(WebCore)/, $(sort $(dir $(1)))) $(WebCore)/bindings/scripts/generate-bindings.pl
Modified: trunk/Source/WebCore/GNUmakefile.am (86935 => 86936)
--- trunk/Source/WebCore/GNUmakefile.am 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/GNUmakefile.am 2011-05-20 10:47:56 UTC (rev 86936)
@@ -627,11 +627,12 @@
$(WebCore)/bindings/scripts/IDLParser.pm \
$(WebCore)/bindings/scripts/IDLStructure.pm \
$(WebCore)/bindings/scripts/InFilesParser.pm \
- $(WebCore)/bindings/scripts/generate-bindings.pl
+ $(WebCore)/bindings/scripts/generate-bindings.pl \
+ $(WebCore)/bindings/scripts/preprocessor.pm
DerivedSources/WebCore/UserAgentStyleSheetsData.cpp: DerivedSources/WebCore/UserAgentStyleSheets.h
-DerivedSources/WebCore/UserAgentStyleSheets.h: $(WebCore)/css/make-css-file-arrays.pl $(USER_AGENT_STYLE_SHEETS)
- $(AM_V_GEN)$(PERL) $< $@ DerivedSources/WebCore/UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)
+DerivedSources/WebCore/UserAgentStyleSheets.h: $(WebCore)/css/make-css-file-arrays.pl $(WebCore)/bindings/scripts/preprocessor.pm $(USER_AGENT_STYLE_SHEETS)
+ $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --defines "$(FEATURE_DEFINES)" $@ DerivedSources/WebCore/UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)
# HTML tag and attribute names
DerivedSources/WebCore/JSHTMLElementWrapperFactory.cpp: DerivedSources/WebCore/HTMLElementFactory.cpp
Modified: trunk/Source/WebCore/WebCore.gyp/WebCore.gyp (86935 => 86936)
--- trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2011-05-20 10:47:56 UTC (rev 86936)
@@ -637,22 +637,31 @@
},
{
'action_name': 'UserAgentStyleSheets',
- # The .css files are in the same order as ../DerivedSources.make.
+ 'variables': {
+ 'scripts': [
+ '../css/make-css-file-arrays.pl',
+ '../bindings/scripts/preprocessor.pm',
+ ],
+ # The .css files are in the same order as ../DerivedSources.make.
+ 'stylesheets': [
+ '../css/html.css',
+ '../css/quirks.css',
+ '../css/view-source.css',
+ '../css/themeChromiumLinux.css', # Chromium only.
+ '../css/themeChromiumSkia.css', # Chromium only.
+ '../css/themeWin.css',
+ '../css/themeWinQuirks.css',
+ '../css/svg.css',
+ '../css/mathml.css',
+ '../css/mediaControls.css',
+ '../css/mediaControlsChromium.css',
+ '../css/fullscreen.css',
+ # Skip fullscreenQuickTime.
+ ],
+ },
'inputs': [
- '../css/make-css-file-arrays.pl',
- '../css/html.css',
- '../css/quirks.css',
- '../css/view-source.css',
- '../css/themeChromiumLinux.css', # Chromium only.
- '../css/themeChromiumSkia.css', # Chromium only.
- '../css/themeWin.css',
- '../css/themeWinQuirks.css',
- '../css/svg.css',
- '../css/mathml.css',
- '../css/mediaControls.css',
- '../css/mediaControlsChromium.css',
- '../css/fullscreen.css',
- # Skip fullscreenQuickTime.
+ '<@(scripts)',
+ '<@(stylesheets)'
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit/UserAgentStyleSheets.h',
@@ -662,8 +671,11 @@
'python',
'scripts/action_useragentstylesheets.py',
'<@(_outputs)',
+ '<@(stylesheets)',
'--',
- '<@(_inputs)'
+ '<@(scripts)',
+ '--',
+ '--defines', '<(feature_defines)',
],
},
{
@@ -813,6 +825,7 @@
'../bindings/scripts/CodeGeneratorV8.pm',
'../bindings/scripts/IDLParser.pm',
'../bindings/scripts/IDLStructure.pm',
+ '../bindings/scripts/preprocessor.pm',
],
'outputs': [
# FIXME: The .cpp file should be in webkit/bindings once
Modified: trunk/Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py (86935 => 86936)
--- trunk/Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py 2011-05-20 10:47:56 UTC (rev 86936)
@@ -32,20 +32,21 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# usage: action_useragentstylesheets.py OUTPUTS -- INPUTS
+# usage:
+# action_useragentstylesheets.py OUTPUTS INPUTS -- MAINSCRIPT MODULES -- OPTIONS
#
-# Multiple OUTPUTS and INPUTS may be listed. The sections are separated by
-# -- arguments.
-#
# OUTPUTS must contain two items, in order: a path to UserAgentStyleSheets.h
# and a path to UserAgentStyleSheetsData.cpp.
+# INPUTS contains one or more CSS files.
#
-# INPUTS must contain at least two items. The first item must be the path to
-# make-css-file-arrays.pl. The remaining items are paths to style sheets to
-# be fed to that script.
+# MAINSCRIPT is the path to make-css-file-arrays.pl. MODULES may contain
+# multiple paths to additional perl modules.
+#
+# OPTIONS are passed as-is to MAINSCRIPT as additional arguments.
import os
+import shlex
import subprocess
import sys
@@ -76,18 +77,39 @@
def main(args):
sections = SplitArgsIntoSections(args[1:])
- assert len(sections) == 2
- (outputs, inputs) = sections
+ assert len(sections) == 3
+ (outputsInputs, scripts, options) = sections
- assert len(outputs) == 2
- outputH = outputs[0]
- outputCpp = outputs[1]
+ assert len(outputsInputs) >= 3
+ outputH = outputsInputs[0]
+ outputCpp = outputsInputs[1]
+ styleSheets = outputsInputs[2:]
- makeCssFileArrays = inputs[0]
- styleSheets = inputs[1:]
+ assert len(scripts) >= 1
+ makeCssFileArrays = scripts[0]
+ perlModules = scripts[1:]
+ includeDirs = []
+ for perlModule in perlModules:
+ includeDir = os.path.dirname(perlModule)
+ if not includeDir in includeDirs:
+ includeDirs.append(includeDir)
+
+ # The defines come in as one flat string. Split it up into distinct arguments.
+ if '--defines' in options:
+ definesIndex = options.index('--defines')
+ if definesIndex + 1 < len(options):
+ splitOptions = shlex.split(options[definesIndex + 1])
+ if splitOptions:
+ options[definesIndex + 1] = ' '.join(splitOptions)
+
# Build up the command.
- command = ['perl', makeCssFileArrays, outputH, outputCpp]
+ command = ['perl']
+ for includeDir in includeDirs:
+ command.extend(['-I', includeDir])
+ command.append(makeCssFileArrays)
+ command.extend(options)
+ command.extend([outputH, outputCpp])
command.extend(styleSheets)
# Do it. check_call is new in 2.5, so simulate its behavior with call and
Modified: trunk/Source/WebCore/WebCore.vcproj/MigrateScripts (86935 => 86936)
--- trunk/Source/WebCore/WebCore.vcproj/MigrateScripts 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/WebCore.vcproj/MigrateScripts 2011-05-20 10:47:56 UTC (rev 86936)
@@ -30,6 +30,7 @@
$(WEBKIT_OUTPUT)/IDLParser.pm \
$(WEBKIT_OUTPUT)/IDLStructure.pm \
$(WEBKIT_OUTPUT)/generate-bindings.pl \
+ $(WEBKIT_OUTPUT)/preprocessor.pm \
#
MIGRATE_CMD = cp $< $@
Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (86935 => 86936)
--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm 2011-05-20 10:47:56 UTC (rev 86936)
@@ -25,6 +25,7 @@
use IPC::Open2;
use IDLStructure;
+use preprocessor;
use constant MODE_UNDEF => 0; # Default mode.
@@ -65,31 +66,8 @@
my $preprocessor = shift;
$parentsOnly = shift;
- if (!$preprocessor) {
- require Config;
- my $gccLocation = "";
- if ($ENV{CC}) {
- $gccLocation = $ENV{CC};
- } elsif (($Config::Config{'osname'}) =~ /solaris/i) {
- $gccLocation = "/usr/sfw/bin/gcc";
- } else {
- $gccLocation = "/usr/bin/gcc";
- }
- $preprocessor = $gccLocation . " -E -P -x c++";
- }
+ my @documentContent = applyPreprocessor($fileName, $defines, $preprocessor, $beQuiet);
- if (!$defines) {
- $defines = "";
- }
-
- print " | *** Starting to parse $fileName...\n |\n" unless $beQuiet;
-
- my $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName);
- close PP_IN;
- my @documentContent = <PP_OUT>;
- close PP_OUT;
- waitpid($pid, 0);
-
my $dataAvailable = 0;
# Simple IDL Parser (tm)
Added: trunk/Source/WebCore/bindings/scripts/preprocessor.pm (0 => 86936)
--- trunk/Source/WebCore/bindings/scripts/preprocessor.pm (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/preprocessor.pm 2011-05-20 10:47:56 UTC (rev 86936)
@@ -0,0 +1,71 @@
+#
+# Copyright (C) 2005 Nikolas Zimmermann <wild...@kde.org>
+# Copyright (C) 2011 Google Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+
+use strict;
+use warnings;
+
+use IPC::Open2;
+
+BEGIN {
+ use Exporter ();
+ our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+ $VERSION = 1.00;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(&applyPreprocessor);
+ %EXPORT_TAGS = ( );
+ @EXPORT_OK = ();
+}
+
+# Returns an array of lines.
+sub applyPreprocessor
+{
+ my $fileName = shift;
+ my $defines = shift;
+ my $preprocessor = shift;
+ my $beQuiet = shift;
+
+ if (!$preprocessor) {
+ require Config;
+ my $gccLocation = "";
+ if ($ENV{CC}) {
+ $gccLocation = $ENV{CC};
+ } elsif (($Config::Config{'osname'}) =~ /solaris/i) {
+ $gccLocation = "/usr/sfw/bin/gcc";
+ } else {
+ $gccLocation = "/usr/bin/gcc";
+ }
+ $preprocessor = $gccLocation . " -E -P -x c++";
+ }
+
+ if (!$defines) {
+ $defines = "";
+ }
+
+ print " | *** Starting to parse $fileName...\n |\n" unless $beQuiet;
+
+ my $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName);
+ close PP_IN;
+ my @documentContent = <PP_OUT>;
+ close PP_OUT;
+ waitpid($pid, 0);
+ return @documentContent;
+}
+
+1;
Modified: trunk/Source/WebCore/css/html.css (86935 => 86936)
--- trunk/Source/WebCore/css/html.css 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/css/html.css 2011-05-20 10:47:56 UTC (rev 86936)
@@ -438,10 +438,12 @@
display: inline-block;
}
+#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
input::-webkit-input-list-button {
-webkit-appearance: list-button;
display: inline-block;
}
+#endif
input::-webkit-inner-spin-button {
-webkit-appearance: inner-spin-button;
@@ -460,10 +462,12 @@
-webkit-user-select: none;
}
+#if defined(ENABLE_INPUT_SPEECH) && ENABLE_INPUT_SPEECH
input::-webkit-input-speech-button {
-webkit-appearance: -webkit-input-speech-button;
display: inline-block;
}
+#endif
keygen, select {
-webkit-border-radius: 5px;
@@ -674,6 +678,7 @@
height: 16px;
}
+#if defined(ENABLE_METER_TAG) && ENABLE_METER_TAG
/* meter */
meter {
@@ -709,7 +714,9 @@
height: 100%;
-webkit-box-sizing: border-box;
}
+#endif
+#if defined(ENABLE_PROGRESS_TAG) && ENABLE_PROGRESS_TAG
/* progress */
progress {
@@ -734,6 +741,7 @@
width: 50%; /* should be removed later */
-webkit-box-sizing: border-box;
}
+#endif
/* inline elements */
Modified: trunk/Source/WebCore/css/make-css-file-arrays.pl (86935 => 86936)
--- trunk/Source/WebCore/css/make-css-file-arrays.pl 2011-05-20 10:16:44 UTC (rev 86935)
+++ trunk/Source/WebCore/css/make-css-file-arrays.pl 2011-05-20 10:47:56 UTC (rev 86936)
@@ -23,6 +23,11 @@
use strict;
use Getopt::Long;
+my $defines;
+my $preprocessor;
+GetOptions('defines=s' => \$defines,
+ 'preprocessor=s' => \$preprocessor);
+
my $header = $ARGV[0];
shift;
@@ -40,9 +45,19 @@
my $name = $1;
# Slurp in the CSS file.
- open IN, "<", $in or die;
- my $text; { local $/; $text = <IN>; }
- close IN;
+ my $text;
+ # We should not set --defines option and run "moc" preprocessor on Qt.
+ # See http://webkit.org/b/37296.
+ if (!$defines) {
+ open IN, "<", $in or die;
+ { local $/; $text = <IN>; }
+ close IN;
+ # Remove preprocessor directives.
+ $text =~ s|^#.*?$||mg;
+ } else {
+ require preprocessor;
+ $text = join('', applyPreprocessor($in, $defines, $preprocessor, 1));
+ }
# Remove comments in a simple-minded way that will work fine for our files.
# Could do this a fancier way if we were worried about arbitrary CSS source.