diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index cd30a69c018d46ef5af0e688638a3e03f2a16dc6..fac13ca26564bd44251283935b77fc0b5c5059e4 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,14 @@ +2008-06-14 Darin Adler + + Reviewed by Maciej. + + - test for https://bugs.webkit.org/show_bug.cgi?id=19538 + Reading transition property from the style JS gives the wrong value + + * fast/dom/CSSStyleDeclaration/resources/transition-property-names.js: Added. + * fast/dom/CSSStyleDeclaration/transition-property-names-expected.txt: Added. + * fast/dom/CSSStyleDeclaration/transition-property-names.html: Added. + 2008-06-14 Cameron Zwarich Reviewed by Oliver. diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/resources/transition-property-names.js b/LayoutTests/fast/dom/CSSStyleDeclaration/resources/transition-property-names.js new file mode 100644 index 0000000000000000000000000000000000000000..4fbfc4328a6c719c39814024c6dd3481ae37e1ca --- /dev/null +++ b/LayoutTests/fast/dom/CSSStyleDeclaration/resources/transition-property-names.js @@ -0,0 +1,13 @@ +description( +'This test checks that CSS property names work round trip in the transition property.' +); + +var element = document.createElement('a'); + +element.style.webkitTransitionProperty = "height"; +shouldBe("element.style.webkitTransitionProperty", "'height'"); + +element.style.webkitTransitionProperty = "opacity"; +shouldBe("element.style.webkitTransitionProperty", "'opacity'"); + +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/transition-property-names-expected.txt b/LayoutTests/fast/dom/CSSStyleDeclaration/transition-property-names-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe7940f05b18182e3166345b384a6a18f59db4d1 --- /dev/null +++ b/LayoutTests/fast/dom/CSSStyleDeclaration/transition-property-names-expected.txt @@ -0,0 +1,11 @@ +This test checks that CSS property names work round trip in the transition property. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS element.style.webkitTransitionProperty is 'height' +PASS element.style.webkitTransitionProperty is 'opacity' +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/transition-property-names.html b/LayoutTests/fast/dom/CSSStyleDeclaration/transition-property-names.html new file mode 100644 index 0000000000000000000000000000000000000000..35990bc2d90451c65e5d224b08483ecaebdfc96c --- /dev/null +++ b/LayoutTests/fast/dom/CSSStyleDeclaration/transition-property-names.html @@ -0,0 +1,13 @@ + + + + + + + +

+
+ + + + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 339e6552dc9ad08c555121ac86e1240e253218e5..d44c438ab6814edea4b803f75015cda132a9a47e 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2008-06-14 Darin Adler + + Reviewed by Maciej. + + - fix https://bugs.webkit.org/show_bug.cgi?id=19538 + Reading transition property from the style JS gives the wrong value + + Test: fast/dom/CSSStyleDeclaration/transition-property-names.html + + * css/CSSPrimitiveValue.cpp: + (WebCore::valueOrPropertyName): Added. + (WebCore::CSSPrimitiveValue::getStringValue): Use valueOrPropertyName since the ident can either + be a value or property ID. + (WebCore::CSSPrimitiveValue::cssText): Ditto. + + * css/makeprop.pl: Assign property IDs starting at 1001 instead of 1 so they can be stored along + with value IDs with no ambiguity. + 2008-06-14 Adam Barth Reviewed by David Kilzer. diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp index 06a76c3ad7762e9c63ee012f9cdb44885414bb53..557ae7eef78bc78b8ed210ce022e70b8b0e0774c 100644 --- a/WebCore/css/CSSPrimitiveValue.cpp +++ b/WebCore/css/CSSPrimitiveValue.cpp @@ -22,6 +22,7 @@ #include "CSSPrimitiveValue.h" #include "CSSHelper.h" +#include "CSSPropertyNames.h" #include "CSSValueKeywords.h" #include "Color.h" #include "Counter.h" @@ -39,6 +40,13 @@ using namespace WTF; namespace WebCore { +static const char* valueOrPropertyName(int valueOrPropertyID) +{ + if (const char* valueName = getValueName(valueOrPropertyID)) + return valueName; + return getPropertyName(static_cast(valueOrPropertyID)); +} + // "ident" from the CSS tokenizer, minus backslash-escape sequences static bool isCSSTokenizerIdentifier(const String& string) { @@ -504,7 +512,7 @@ String CSSPrimitiveValue::getStringValue(ExceptionCode& ec) const case CSS_URI: return m_value.string; case CSS_IDENT: - return getValueName(m_value.ident); + return valueOrPropertyName(m_value.ident); default: ec = INVALID_ACCESS_ERR; break; @@ -521,7 +529,7 @@ String CSSPrimitiveValue::getStringValue() const case CSS_URI: return m_value.string; case CSS_IDENT: - return getValueName(m_value.ident); + return valueOrPropertyName(m_value.ident); default: break; } @@ -661,7 +669,7 @@ String CSSPrimitiveValue::cssText() const text = "url(" + quoteURLIfNeeded(m_value.string) + ")"; break; case CSS_IDENT: - text = getValueName(m_value.ident); + text = valueOrPropertyName(m_value.ident); break; case CSS_ATTR: // FIXME diff --git a/WebCore/css/makeprop.pl b/WebCore/css/makeprop.pl index 8076db553d17eb3921d02e29cbd117eeda8271d3..314a9f4de47a29d51ea897590e55e56dc6e9babd 100644 --- a/WebCore/css/makeprop.pl +++ b/WebCore/css/makeprop.pl @@ -3,7 +3,7 @@ # This file is part of the WebKit project # # Copyright (C) 1999 Waldo Bastian (bastian@kde.org) -# Copyright (C) 2007 Apple Inc. All rights reserved. +# Copyright (C) 2007, 2008 Apple Inc. All rights reserved. # Copyright (C) 2007 Trolltech ASA # # This library is free software; you can redistribute it and/or @@ -65,7 +65,8 @@ enum CSSPropertyID { CSSPropertyInvalid = 0, EOF -my $i = 1; +my $first = 1001; +my $i = 1001; my $maxLen = 0; foreach my $name (@names) { my $id = $name; @@ -76,9 +77,12 @@ foreach my $name (@names) { $maxLen = length($name); } } +my $num = $i - $first; + print HEADER "};\n\n"; -print HEADER "const int numCSSProperties = " . $i . ";\n"; -print HEADER "const size_t maxCSSPropertyNameLength = " . $maxLen . ";\n"; +print HEADER "const int firstCSSProperty = $first;\n"; +print HEADER "const int numCSSProperties = $num;\n"; +print HEADER "const size_t maxCSSPropertyNameLength = $maxLen;\n"; print HEADER << "EOF"; @@ -92,21 +96,22 @@ close HEADER; system("gperf -a -L ANSI-C -E -C -c -o -t --key-positions=\"*\" -NfindProp -Hhash_prop -Wwordlist_prop -D -s 2 CSSPropertyNames.gperf > CSSPropertyNames.cpp"); open C, ">>CSSPropertyNames.cpp" || die "Could not open CSSPropertyNames.cpp for writing"; -print C "static const char * const propertyList[] = {\n"; -print C "\"\",\n"; +print C "static const char * const propertyNameStrings[$num] = {\n"; foreach my $name (@names) { - print C "\"" . $name . "\", \n"; + print C "\"$name\",\n"; } print C << "EOF"; - 0 }; const char* getPropertyName(CSSPropertyID id) { - if (id >= numCSSProperties || id <= 0) + if (id < firstCSSProperty) + return 0; + int index = id - firstCSSProperty; + if (index >= numCSSProperties) return 0; - return propertyList[id]; + return propertyNameStrings[index]; } EOF