CSS Aspect Ratio Property Parsing Stage
authorfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Nov 2011 23:07:20 +0000 (23:07 +0000)
committerfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Nov 2011 23:07:20 +0000 (23:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70707

Reviewed by Ojan Vafai.

Source/WebCore:

Added parsing support for -webkit-aspect-ratio CSS property.
The spec can be found here: http://www.xanthir.com/blog/b4810

Test: fast/css/aspect-ratio-parsing-tests.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSAspectRatioValue.cpp: Added.
(WebCore::CSSAspectRatioValue::~CSSAspectRatioValue):
(WebCore::CSSAspectRatioValue::cssText):
* css/CSSAspectRatioValue.h: Added.
(WebCore::CSSAspectRatioValue::create):
(WebCore::CSSAspectRatioValue::numeratorValue):
(WebCore::CSSAspectRatioValue::denominatorValue):
(WebCore::CSSAspectRatioValue::CSSAspectRatioValue):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSMutableStyleDeclaration.cpp:
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseAspectRatio):
* css/CSSParser.h:
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):

LayoutTests:

* fast/css/aspect-ratio-parsing-tests-expected.txt: Added.
* fast/css/aspect-ratio-parsing-tests.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/aspect-ratio-parsing-tests-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/aspect-ratio-parsing-tests.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSAspectRatioValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSAspectRatioValue.h [new file with mode: 0644]
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSMutableStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp

index 33846495029f507d267c11812b8e96ed07926847..5ddfb8635459982d777ec4b21e1c81c3673a16c4 100644 (file)
@@ -1,3 +1,13 @@
+2011-11-04  Fady Samuel  <fsamuel@chromium.org>
+
+        CSS Aspect Ratio Property Parsing Stage
+        https://bugs.webkit.org/show_bug.cgi?id=70707
+
+        Reviewed by Ojan Vafai.
+
+        * fast/css/aspect-ratio-parsing-tests-expected.txt: Added.
+        * fast/css/aspect-ratio-parsing-tests.html: Added.
+
 2011-11-04  Adam Barth  <abarth@webkit.org>
 
         Delete FrameLoader::isSandboxed
diff --git a/LayoutTests/fast/css/aspect-ratio-parsing-tests-expected.txt b/LayoutTests/fast/css/aspect-ratio-parsing-tests-expected.txt
new file mode 100644 (file)
index 0000000..d14eb4b
--- /dev/null
@@ -0,0 +1,27 @@
+CSS Aspect Ratio Parsing Test
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testParsing("aspectRatioTest", "2/1", "-webkit-aspect-ratio") is "2/1"
+PASS testParsing("aspectRatioTest", "1/1", "-webkit-aspect-ratio") is "1/1"
+PASS testParsing("aspectRatioTest", "1/4", "-webkit-aspect-ratio") is "1/4"
+PASS testParsing("aspectRatioTest", "1 / 2", "-webkit-aspect-ratio") is "1/2"
+PASS testParsing("aspectRatioTest", "1.2 / 2", "-webkit-aspect-ratio") is "1.2/2"
+PASS testParsing("aspectRatioTest", "2 / 0.5", "-webkit-aspect-ratio") is "2/0.5"
+PASS testParsing("aspectRatioTest", "none", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "1 2", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "a/1", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "1/a", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "abc123", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "1", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "1 / 0", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "0 / 1", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "0 / 0", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "-1 / 8", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "1 / -9", "-webkit-aspect-ratio") is "none"
+PASS testParsing("aspectRatioTest", "-1 / -4", "-webkit-aspect-ratio") is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/aspect-ratio-parsing-tests.html b/LayoutTests/fast/css/aspect-ratio-parsing-tests.html
new file mode 100644 (file)
index 0000000..94ecd84
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+  <head>
+    <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+    <script src="../../fast/js/resources/js-test-pre.js"></script>
+  </head>
+  <body>
+    <p id="description"></p>
+    <div id="console"></div>
+    <div id="aspectRatioTest"></div>
+    <script>
+      description('CSS Aspect Ratio Parsing Test');
+      function testParsing(elementId, value, styleAttribute)
+      {
+          var div = document.getElementById(elementId);
+          div.style[styleAttribute] = value;
+          return div.style[styleAttribute];
+      }
+
+      shouldBeEqualToString('testParsing("aspectRatioTest", "2/1", "-webkit-aspect-ratio")', '2/1');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1/1", "-webkit-aspect-ratio")', '1/1');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1/4", "-webkit-aspect-ratio")', '1/4');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1 / 2", "-webkit-aspect-ratio")', '1/2');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1.2 / 2", "-webkit-aspect-ratio")', '1.2/2');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "2 / 0.5", "-webkit-aspect-ratio")', '2/0.5');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "none", "-webkit-aspect-ratio")', 'none');
+
+      // The following are invalid and should get ignored.
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1 2", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "a/1", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1/a", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "abc123", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1 / 0", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "0 / 1", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "0 / 0", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "-1 / 8", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "1 / -9", "-webkit-aspect-ratio")', 'none');
+      shouldBeEqualToString('testParsing("aspectRatioTest", "-1 / -4", "-webkit-aspect-ratio")', 'none');
+    </script>
+    <script src="../../fast/js/resources/js-test-post.js"></script>
+  </body>
+</html>
index 21ea38c62532dced3eeea25ebf6b5ee0bf180a98..1e4bea929ced2fc4e7e745b6bfe245ccf9ca2670 100644 (file)
@@ -416,6 +416,7 @@ SET(WebCore_SOURCES
     bindings/generic/ActiveDOMCallback.cpp
     bindings/generic/RuntimeEnabledFeatures.cpp
 
+    css/CSSAspectRatioValue.cpp
     css/CSSBorderImageValue.cpp
     css/CSSBorderImageSliceValue.cpp
     css/CSSCanvasValue.cpp
index 59b7bc52a4d661fd59f95299cba1704c22338fc1..9bdafd272a5d929fbaaa8b9908121033f84c5db0 100644 (file)
@@ -1,3 +1,42 @@
+2011-11-04  Fady Samuel  <fsamuel@chromium.org>
+
+        CSS Aspect Ratio Property Parsing Stage
+        https://bugs.webkit.org/show_bug.cgi?id=70707
+
+        Reviewed by Ojan Vafai.
+
+        Added parsing support for -webkit-aspect-ratio CSS property.
+        The spec can be found here: http://www.xanthir.com/blog/b4810
+
+        Test: fast/css/aspect-ratio-parsing-tests.html
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSAspectRatioValue.cpp: Added.
+        (WebCore::CSSAspectRatioValue::~CSSAspectRatioValue):
+        (WebCore::CSSAspectRatioValue::cssText):
+        * css/CSSAspectRatioValue.h: Added.
+        (WebCore::CSSAspectRatioValue::create):
+        (WebCore::CSSAspectRatioValue::numeratorValue):
+        (WebCore::CSSAspectRatioValue::denominatorValue):
+        (WebCore::CSSAspectRatioValue::CSSAspectRatioValue):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSMutableStyleDeclaration.cpp:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseAspectRatio):
+        * css/CSSParser.h:
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+
 2011-11-04  Adam Barth  <abarth@webkit.org>
 
         Delete FrameLoader::isSandboxed
index 7281af574dfbd604402860d1ced4b9dfc0a0dfc6..ed34e20cfd902b214088fccb3e3a0473bf63382c 100644 (file)
@@ -962,6 +962,8 @@ webcore_sources += \
        Source/WebCore/bridge/runtime_root.h \
        Source/WebCore/config.h \
        Source/WebCore/css/Counter.h \
+       Source/WebCore/css/CSSAspectRatioValue.cpp \
+       Source/WebCore/css/CSSAspectRatioValue.h \
        Source/WebCore/css/CSSBorderImageSliceValue.cpp \
        Source/WebCore/css/CSSBorderImageSliceValue.h \
        Source/WebCore/css/CSSBorderImageValue.cpp \
index 452e85cdd51dae1c937f9d7f85e98be652c14e22..0040003fb7457648ff8db55621ee63026b8ac015 100644 (file)
@@ -397,6 +397,7 @@ v8 {
 }
 
 SOURCES += \
+    css/CSSAspectRatioValue.cpp \
     css/CSSBorderImageSliceValue.cpp \
     css/CSSBorderImageValue.cpp \
     css/CSSCanvasValue.cpp \
@@ -1487,6 +1488,7 @@ v8 {
 }
 
 HEADERS += \
+    css/CSSAspectRatioValue.h \
     css/CSSBorderImageSliceValue.h \
     css/CSSBorderImageValue.h \
     css/CSSCanvasValue.h \
index 05afa897c81f3b908c041d17a67807e7683e3b3f..95c1916d36cd7306e74d297c4fa7d012759f1193 100644 (file)
             'bridge/testbindings.mm',
             'bridge/testqtbindings.cpp',
             'config.h',
+            'css/CSSAspectRatioValue.cpp',
+            'css/CSSAspectRatioValue.h',
             'css/CSSBorderImageValue.cpp',
             'css/CSSBorderImageValue.h',
             'css/CSSBorderImageSliceValue.cpp',
index fd69611fd8c4dbecc11e4ee5b260b2acb6904bea..dedb0e33aafa18cc942ba9a44069c2d38d079116 100755 (executable)
                                RelativePath="..\css\Counter.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\css\CSSAspectRatioValue.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\css\CSSAspectRatioValue.h"
+                               >
+                       </File>
                        <File
                                RelativePath="..\css\CSSBorderImageSliceValue.cpp"
                                >
index 01bcd5e17bf0fb39a63c19b507ccee97ba369d95..16c8ed3aa44df21bf0ac0af93c4afe5474910ad6 100644 (file)
                C6F41047130C6E8900393DE4 /* EntryBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F41046130C6E8900393DE4 /* EntryBase.cpp */; };
                CA3BF67C10D99BAE00E6CE53 /* ScrollAnimator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */; };
                CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */; };
+               CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; };
                CD0DBF011422768500280263 /* IRC_Composite_C_R0195_T000_P000.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD0DBD201422759500280263 /* IRC_Composite_C_R0195_T000_P000.wav */; };
                CD0DBF021422768500280263 /* IRC_Composite_C_R0195_T000_P015.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD0DBD211422759500280263 /* IRC_Composite_C_R0195_T000_P015.wav */; };
                CD0DBF031422768500280263 /* IRC_Composite_C_R0195_T000_P030.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD0DBD221422759500280263 /* IRC_Composite_C_R0195_T000_P030.wav */; };
                C6F41046130C6E8900393DE4 /* EntryBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EntryBase.cpp; path = fileapi/EntryBase.cpp; sourceTree = "<group>"; };
                CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollAnimator.cpp; sourceTree = "<group>"; };
                CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimator.h; sourceTree = "<group>"; };
+               CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = "<group>"; };
+               CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; };
                CD0DBD201422759500280263 /* IRC_Composite_C_R0195_T000_P000.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = IRC_Composite_C_R0195_T000_P000.wav; path = platform/audio/resources/IRC_Composite_C_R0195_T000_P000.wav; sourceTree = SOURCE_ROOT; };
                CD0DBD211422759500280263 /* IRC_Composite_C_R0195_T000_P015.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = IRC_Composite_C_R0195_T000_P015.wav; path = platform/audio/resources/IRC_Composite_C_R0195_T000_P015.wav; sourceTree = SOURCE_ROOT; };
                CD0DBD221422759500280263 /* IRC_Composite_C_R0195_T000_P030.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = IRC_Composite_C_R0195_T000_P030.wav; path = platform/audio/resources/IRC_Composite_C_R0195_T000_P030.wav; sourceTree = SOURCE_ROOT; };
                F523D18402DE42E8018635CA /* css */ = {
                        isa = PBXGroup;
                        children = (
+                               CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */,
+                               CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */,
                                93CA4C9C09DF93FA00DF8677 /* maketokenizer */,
                                A80E6CDA0A1989CA007FB8C5 /* Counter.h */,
                                930705C709E0C95F00B17FE4 /* Counter.idl */,
                                07846385145B1B8E00A58DF1 /* JSTrackCustom.h in Headers */,
                                2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
                                3169379C14609C6C00C01362 /* DragSession.h in Headers */,
+                               CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                07846342145B151A00A58DF1 /* JSTrackEvent.cpp in Sources */,
                                07689D6E145B52CC001CD132 /* JSTrackEventCustom.cpp in Sources */,
                                2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */,
+                               CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
                                CDEA763014608A53008B31F1 /* PlatformClockCA.cpp in Sources */,
                                CDEA76341460B56F008B31F1 /* PlatformClockPOSIX.cpp in Sources */,
                                CDEA76351460B71A008B31F1 /* Clock.cpp in Sources */,
diff --git a/Source/WebCore/css/CSSAspectRatioValue.cpp b/Source/WebCore/css/CSSAspectRatioValue.cpp
new file mode 100644 (file)
index 0000000..6d8f9b1
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSAspectRatioValue.h"
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+CSSAspectRatioValue::~CSSAspectRatioValue()
+{
+}
+
+String CSSAspectRatioValue::cssText() const
+{
+    StringBuilder result;
+    result.append(String::number(m_numeratorValue));
+    result.append("/");
+    result.append(String::number(m_denominatorValue));
+    return result.toString();
+}
+
+}
diff --git a/Source/WebCore/css/CSSAspectRatioValue.h b/Source/WebCore/css/CSSAspectRatioValue.h
new file mode 100644 (file)
index 0000000..fe0945e
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSAspectRatioValue_h
+#define CSSAspectRatioValue_h
+
+#include "CSSPrimitiveValue.h"
+#include "CSSValue.h"
+
+namespace WebCore {
+
+class CSSAspectRatioValue : public CSSValue {
+public:
+    static PassRefPtr<CSSAspectRatioValue> create(float numeratorValue, float denominatorValue)
+    {
+        return adoptRef(new CSSAspectRatioValue(numeratorValue, denominatorValue));
+    }
+
+    virtual ~CSSAspectRatioValue();
+
+    virtual String cssText() const;
+
+    float numeratorValue() const { return m_numeratorValue; }
+    float denominatorValue() const { return m_denominatorValue; }
+
+private:
+    CSSAspectRatioValue(float numeratorValue, float denominatorValue)
+        : m_numeratorValue(numeratorValue)
+        , m_denominatorValue(denominatorValue)
+    {
+    }
+
+    float m_numeratorValue;
+    float m_denominatorValue;
+};
+
+}
+
+#endif
index d2a50dfcc67fde64ed437786b42b1d33cb0d2dea..956fb2a5b71a5f975e4d00b0563ee7204c7fefbd 100644 (file)
@@ -2033,6 +2033,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             break;
 
         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
+        case CSSPropertyWebkitAspectRatio:
         case CSSPropertyWebkitTextEmphasis:
         case CSSPropertyTextLineThrough:
         case CSSPropertyTextLineThroughColor:
index 44cf807c6c613ac1bf9b08e562dcab14e45891a2..c4ebb8b06c12b62ee7737e2018f30d3505c1d9a1 100644 (file)
@@ -787,6 +787,7 @@ void CSSMutableStyleDeclaration::addSubresourceStyleURLs(ListHashSet<KURL>& urls
 static const int blockProperties[] = {
     CSSPropertyOrphans,
     CSSPropertyOverflow, // This can be also be applied to replaced elements
+    CSSPropertyWebkitAspectRatio,
     CSSPropertyWebkitColumnCount,
     CSSPropertyWebkitColumnGap,
     CSSPropertyWebkitColumnRuleColor,
index d4fea74a3ebe2cd8bce93a68f8555924524e5954..a4e2e3115b2778e7efdd39e484381c4b33d6038b 100644 (file)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "CSSParser.h"
 
+#include "CSSAspectRatioValue.h"
 #include "CSSBorderImageValue.h"
 #include "CSSCanvasValue.h"
 #include "CSSCharsetRule.h"
@@ -1509,6 +1510,8 @@ bool CSSParser::parseValue(int propId, bool important)
         addProperty(propId, val.release(), important);
         return true;
     }
+    case CSSPropertyWebkitAspectRatio:
+        return parseAspectRatio(important);
     case CSSPropertyBorderRadius:
     case CSSPropertyWebkitBorderRadius:
         return parseBorderRadius(propId, important);
@@ -5648,6 +5651,35 @@ bool CSSParser::parseBorderRadius(int propId, bool important)
     return true;
 }
 
+bool CSSParser::parseAspectRatio(bool important)
+{
+    unsigned num = m_valueList->size();
+    if (num == 1 && m_valueList->valueAt(0)->id == CSSValueNone) {
+        addProperty(CSSPropertyWebkitAspectRatio, primitiveValueCache()->createIdentifierValue(CSSValueNone), important);
+        return true;
+    }
+
+    if (num != 3)
+        return false;
+
+    CSSParserValue* lvalue = m_valueList->valueAt(0);
+    CSSParserValue* op = m_valueList->valueAt(1);
+    CSSParserValue* rvalue = m_valueList->valueAt(2);
+
+    if (op->unit != CSSParserValue::Operator || op->iValue != '/')
+        return false;
+
+    if (!validUnit(lvalue, FNumber | FNonNeg, m_strict) || !validUnit(rvalue, FNumber | FNonNeg, m_strict))
+        return false;
+
+    if (!lvalue->fValue || !rvalue->fValue)
+        return false;
+
+    addProperty(CSSPropertyWebkitAspectRatio, CSSAspectRatioValue::create(lvalue->fValue, rvalue->fValue), important);
+
+    return true;
+}
+
 bool CSSParser::parseCounter(int propId, int defaultValue, bool important)
 {
     enum { ID, VAL } state = ID;
index 744d3c75c95e0ca194ca2e58078b9d2eaf5720a2..b12e8c92187f5a01542aab9b072dd0a88e74d1d3 100644 (file)
@@ -171,6 +171,8 @@ public:
     bool parseBorderImageOutset(RefPtr<CSSPrimitiveValue>&);
     bool parseBorderRadius(int propId, bool important);
 
+    bool parseAspectRatio(bool important);
+
     bool parseReflect(int propId, bool important);
 
     bool parseFlex(int propId, bool important);
index 3e7df5115b9bea270b27cee8cc98031894880ae3..de7c9273b79d678dfd03648d736db77ac5ac8992 100644 (file)
@@ -317,6 +317,7 @@ bool CSSProperty::isInheritedProperty(unsigned propertyID)
     case CSSPropertyTextShadow:
     case CSSPropertyTextTransform:
     case CSSPropertyVisibility:
+    case CSSPropertyWebkitAspectRatio:
     case CSSPropertyWebkitBorderHorizontalSpacing:
     case CSSPropertyWebkitBorderVerticalSpacing:
     case CSSPropertyWebkitBoxDirection:
index d1ef2aed25d4410ca6328a04cf7b6ae25dab734f..52944d82e9cda7bb57ddca66eeec9e9c6999bde1 100644 (file)
@@ -193,6 +193,7 @@ z-index
 -webkit-animation-play-state
 -webkit-animation-timing-function
 -webkit-appearance
+-webkit-aspect-ratio
 -webkit-backface-visibility
 -webkit-background-clip
 -webkit-background-composite
index bae736f799ad60abe97c616a7c9761672a7c4aa8..34f063b87198105c6d9c827d76bc36a714daf4b4 100644 (file)
@@ -3772,6 +3772,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSSPropertyTextUnderlineMode:
     case CSSPropertyTextUnderlineStyle:
     case CSSPropertyTextUnderlineWidth:
+    case CSSPropertyWebkitAspectRatio:
     case CSSPropertyWebkitFontSizeDelta:
     case CSSPropertyWebkitTextDecorationsInEffect:
     case CSSPropertyWebkitTextStroke: