Part 2 of: Implement sticky positioning
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2012 21:03:45 +0000 (21:03 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2012 21:03:45 +0000 (21:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90046

Reviewed by Ojan Vafai.

Source/JavaScriptCore:

Turn on ENABLE_CSS_STICKY_POSITION.

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

Turn on ENABLE_CSS_STICKY_POSITION. Add support for parsing the new '-webkit-sticky'
value for position, returning it from getComputedStyle(), and storing it in RenderStyle.

Test: fast/css/sticky/parsing-position-sticky.html

* Configurations/FeatureDefines.xcconfig:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::getPositionOffsetValue):
* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EPosition):
* css/CSSValueKeywords.in:
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.h:

Source/WebKit/chromium:

Turn on ENABLE_CSS_STICKY_POSITION.

* features.gypi:

Source/WebKit/mac:

Turn on ENABLE_CSS_STICKY_POSITION.

* Configurations/FeatureDefines.xcconfig:

Source/WebKit2:

Turn on ENABLE_CSS_STICKY_POSITION.

* Configurations/FeatureDefines.xcconfig:

LayoutTests:

Test for parsing and returning fro getComputedStyle() the new
-webkit-sticky value for position.

* fast/css/sticky/parsing-position-sticky-expected.txt: Added.
* fast/css/sticky/parsing-position-sticky.html: Added.
* fast/css/sticky/resources/parsing-position-sticky.js: Added.
(test):

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/sticky/parsing-position-sticky-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/sticky/parsing-position-sticky.html [new file with mode: 0644]
LayoutTests/fast/css/sticky/resources/parsing-position-sticky.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/features.gypi
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/FeatureDefines.xcconfig
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/FeatureDefines.xcconfig

index cb74246..f14ad35 100644 (file)
@@ -1,3 +1,18 @@
+2012-07-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Part 2 of: Implement sticky positioning
+        https://bugs.webkit.org/show_bug.cgi?id=90046
+
+        Reviewed by Ojan Vafai.
+
+        Test for parsing and returning fro getComputedStyle() the new
+        -webkit-sticky value for position.
+
+        * fast/css/sticky/parsing-position-sticky-expected.txt: Added.
+        * fast/css/sticky/parsing-position-sticky.html: Added.
+        * fast/css/sticky/resources/parsing-position-sticky.js: Added.
+        (test):
+
 2012-07-23  Andrew Wilson  <atwilson@chromium.org>
 
         Unreviewed chromium expectations change to mark media/media-fragments/TC0010-TC0019.html as flaky/crashy.
diff --git a/LayoutTests/fast/css/sticky/parsing-position-sticky-expected.txt b/LayoutTests/fast/css/sticky/parsing-position-sticky-expected.txt
new file mode 100644 (file)
index 0000000..3fa4f04
--- /dev/null
@@ -0,0 +1,11 @@
+This tests checks that the -webkit-sticky value for position parses correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS test("position: -webkit-sticky;") is "-webkit-sticky"
+PASS test("position: sticky;") is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/sticky/parsing-position-sticky.html b/LayoutTests/fast/css/sticky/parsing-position-sticky.html
new file mode 100644 (file)
index 0000000..494ac70
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<style type="text/css"></style>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/parsing-position-sticky.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/sticky/resources/parsing-position-sticky.js b/LayoutTests/fast/css/sticky/resources/parsing-position-sticky.js
new file mode 100644 (file)
index 0000000..565d368
--- /dev/null
@@ -0,0 +1,15 @@
+description("This tests checks that the -webkit-sticky value for position parses correctly.");
+
+function test(value)
+{
+    var div = document.createElement("div");
+    div.setAttribute("style", value);
+    document.body.appendChild(div);
+    
+    var result = div.style.getPropertyValue("position");
+    document.body.removeChild(div);
+    return result;
+}
+
+shouldBe('test("position: -webkit-sticky;")', '"-webkit-sticky"');
+shouldBe('test("position: sticky;")', 'null');
index 2c7a2d0..75be30e 100644 (file)
@@ -1,3 +1,14 @@
+2012-07-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Part 2 of: Implement sticky positioning
+        https://bugs.webkit.org/show_bug.cgi?id=90046
+
+        Reviewed by Ojan Vafai.
+
+        Turn on ENABLE_CSS_STICKY_POSITION.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2012-07-23  Patrick Gansterer  <paroga@webkit.org>
 
         Move JSC::parseDate() from DateConversion to JSDateMath
index ab722dc..0a26e46 100644 (file)
@@ -43,7 +43,7 @@ ENABLE_CSS_IMAGE_ORIENTATION = ;
 ENABLE_CSS_IMAGE_RESOLUTION = ;
 ENABLE_CSS_REGIONS = ENABLE_CSS_REGIONS;
 ENABLE_CSS_SHADERS = ENABLE_CSS_SHADERS;
-ENABLE_CSS_STICKY_POSITION = ;
+ENABLE_CSS_STICKY_POSITION = ENABLE_CSS_STICKY_POSITION;
 ENABLE_CSS_VARIABLES = ;
 ENABLE_CSS3_FLEXBOX = ENABLE_CSS3_FLEXBOX;
 ENABLE_CUSTOM_SCHEME_HANDLER = ;
index 009ba0f..9632566 100644 (file)
@@ -1,3 +1,27 @@
+2012-07-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Part 2 of: Implement sticky positioning
+        https://bugs.webkit.org/show_bug.cgi?id=90046
+
+        Reviewed by Ojan Vafai.
+
+        Turn on ENABLE_CSS_STICKY_POSITION. Add support for parsing the new '-webkit-sticky'
+        value for position, returning it from getComputedStyle(), and storing it in RenderStyle.
+
+        Test: fast/css/sticky/parsing-position-sticky.html
+
+        * Configurations/FeatureDefines.xcconfig:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::getPositionOffsetValue):
+        * css/CSSParser.cpp:
+        (WebCore::isValidKeywordPropertyAndValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EPosition):
+        * css/CSSValueKeywords.in:
+        * rendering/style/RenderStyle.h:
+        * rendering/style/RenderStyleConstants.h:
+
 2012-07-23  Stephen Chenney  <schenney@chromium.org>
 
         Crash when setting empty class name on a new element
index 8a23d07..9183a57 100644 (file)
@@ -43,7 +43,7 @@ ENABLE_CSS_FILTERS = ENABLE_CSS_FILTERS;
 ENABLE_CSS_IMAGE_RESOLUTION = ;
 ENABLE_CSS_REGIONS = ENABLE_CSS_REGIONS;
 ENABLE_CSS_SHADERS = ENABLE_CSS_SHADERS;
-ENABLE_CSS_STICKY_POSITION = ;
+ENABLE_CSS_STICKY_POSITION = ENABLE_CSS_STICKY_POSITION;
 ENABLE_CSS_VARIABLES = ;
 ENABLE_CSS3_FLEXBOX = ENABLE_CSS3_FLEXBOX;
 ENABLE_CUSTOM_SCHEME_HANDLER = ;
index 26615c5..ae248ed 100644 (file)
@@ -608,7 +608,7 @@ static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSProper
         return cssValuePool().createValue(l);
     }
 
-    if (style->position() == RelativePosition) {
+    if (style->position() == RelativePosition || style->position() == StickyPosition) {
         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
         // In other words if left is auto and right is not auto, then left's computed value is negative right().
         // So we should get the opposite length unit and see if it is auto.
index 4bd9778..d64398a 100644 (file)
@@ -615,8 +615,12 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
         if (valueID == CSSValueVisible || valueID == CSSValueNone || valueID == CSSValueAll || valueID == CSSValueAuto || (valueID >= CSSValueVisiblepainted && valueID <= CSSValueStroke))
             return true;
         break;
-    case CSSPropertyPosition: // static | relative | absolute | fixed | inherit
-        if (valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed)
+    case CSSPropertyPosition: // static | relative | absolute | fixed | sticky | inherit
+        if (valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed
+#if ENABLE(CSS_STICKY_POSITION)
+            || valueID == CSSValueWebkitSticky
+#endif
+            )
             return true;
         break;
     case CSSPropertyResize: // none | both | horizontal | vertical | auto
index 97e0b63..a88f49c 100644 (file)
@@ -2032,6 +2032,11 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EPosition e)
         case FixedPosition:
             m_value.ident = CSSValueFixed;
             break;
+#if ENABLE(CSS_STICKY_POSITION)
+        case StickyPosition:
+            m_value.ident = CSSValueWebkitSticky;
+            break;
+#endif
     }
 }
 
@@ -2046,6 +2051,10 @@ template<> inline CSSPrimitiveValue::operator EPosition() const
             return AbsolutePosition;
         case CSSValueFixed:
             return FixedPosition;
+#if ENABLE(CSS_STICKY_POSITION)
+        case CSSValueWebkitSticky:
+            return StickyPosition;
+#endif
         default:
             ASSERT_NOT_REACHED();
             return StaticPosition;
index 8dc27c8..6e0db28 100644 (file)
@@ -915,6 +915,11 @@ wrap
 // -webkit-line-align
 edges
 
+// position
+#if defined(ENABLE_CSS_STICKY_POSITION) && ENABLE_CSS_STICKY_POSITION
+-webkit-sticky
+#endif // CSS_STICKY_POSITION
+
 // (pointer:) media feature
 // none
 coarse
index 5e8a12c..d56d2d3 100644 (file)
@@ -304,7 +304,7 @@ protected:
         unsigned _overflowY : 3; // EOverflow
         unsigned _vertical_align : 4; // EVerticalAlign
         unsigned _clear : 2; // EClear
-        unsigned _position : 2; // EPosition
+        unsigned _position : 3; // EPosition
         unsigned _floating : 2; // EFloat
         unsigned _table_layout : 1; // ETableLayout
 
@@ -331,7 +331,7 @@ protected:
         unsigned _affectedByDrag : 1;
         unsigned _isLink : 1;
         // If you add more style bits here, you will also need to update RenderStyle::copyNonInheritedFrom()
-        // 53 bits
+        // 54 bits
     } noninherited_flags;
 
 // !END SYNC!
index 9c03f39..149cd44 100644 (file)
@@ -94,7 +94,7 @@ enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL }
 enum OutlineIsAuto { AUTO_OFF = 0, AUTO_ON };
 
 enum EPosition {
-    StaticPosition, RelativePosition, AbsolutePosition, FixedPosition
+    StaticPosition, RelativePosition, AbsolutePosition, FixedPosition, StickyPosition
 };
 
 enum EFloat {
index 608d136..7885cd8 100644 (file)
@@ -1,3 +1,14 @@
+2012-07-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Part 2 of: Implement sticky positioning
+        https://bugs.webkit.org/show_bug.cgi?id=90046
+
+        Reviewed by Ojan Vafai.
+
+        Turn on ENABLE_CSS_STICKY_POSITION.
+
+        * features.gypi:
+
 2012-07-23  Shawn Singh  <shawnsingh@chromium.org>
 
         [chromium] Refactor CCLayerTreeHostCommon: clean up clipRect and drawableContentRect design
index 000e870..3432342 100644 (file)
@@ -47,7 +47,7 @@
       'ENABLE_CSS_REGIONS=1',
       'ENABLE_CSS_SHADERS=1',
       'ENABLE_CSS_VARIABLES=1',
-      'ENABLE_CSS_STICKY_POSITION=0',
+      'ENABLE_CSS_STICKY_POSITION=1',
       'ENABLE_CUSTOM_SCHEME_HANDLER=0',
       'ENABLE_DATALIST_ELEMENT=1',
       'ENABLE_DASHBOARD_SUPPORT=0',
index b8ee6b0..9df3450 100644 (file)
@@ -1,3 +1,14 @@
+2012-07-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Part 2 of: Implement sticky positioning
+        https://bugs.webkit.org/show_bug.cgi?id=90046
+
+        Reviewed by Ojan Vafai.
+
+        Turn on ENABLE_CSS_STICKY_POSITION.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2012-07-23  Pierre Rossi  <pierre.rossi@gmail.com>
 
         Unify numTouchEventHandlersChanged and needTouchEvents in the chrome client
index 64c384f..49182f3 100644 (file)
@@ -44,7 +44,7 @@ ENABLE_CSS_IMAGE_ORIENTATION = ;
 ENABLE_CSS_IMAGE_RESOLUTION = ;
 ENABLE_CSS_REGIONS = ENABLE_CSS_REGIONS;
 ENABLE_CSS_SHADERS = ENABLE_CSS_SHADERS;
-ENABLE_CSS_STICKY_POSITION = ;
+ENABLE_CSS_STICKY_POSITION = ENABLE_CSS_STICKY_POSITION;
 ENABLE_CSS_VARIABLES = ;
 ENABLE_CSS3_FLEXBOX = ENABLE_CSS3_FLEXBOX;
 ENABLE_CUSTOM_SCHEME_HANDLER = ;
index bc01e7d..56109ef 100644 (file)
@@ -1,3 +1,14 @@
+2012-07-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Part 2 of: Implement sticky positioning
+        https://bugs.webkit.org/show_bug.cgi?id=90046
+
+        Reviewed by Ojan Vafai.
+
+        Turn on ENABLE_CSS_STICKY_POSITION.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2012-07-23  Christophe Dumez  <christophe.dumez@intel.com>
 
         [WK2] WebKitTestRunner needs to print information about Web intents
index 64c384f..49182f3 100644 (file)
@@ -44,7 +44,7 @@ ENABLE_CSS_IMAGE_ORIENTATION = ;
 ENABLE_CSS_IMAGE_RESOLUTION = ;
 ENABLE_CSS_REGIONS = ENABLE_CSS_REGIONS;
 ENABLE_CSS_SHADERS = ENABLE_CSS_SHADERS;
-ENABLE_CSS_STICKY_POSITION = ;
+ENABLE_CSS_STICKY_POSITION = ENABLE_CSS_STICKY_POSITION;
 ENABLE_CSS_VARIABLES = ;
 ENABLE_CSS3_FLEXBOX = ENABLE_CSS3_FLEXBOX;
 ENABLE_CUSTOM_SCHEME_HANDLER = ;