Provide a runtime setting to disable position:sticky
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 22:49:38 +0000 (22:49 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 22:49:38 +0000 (22:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=96827

Reviewed by James Robinson.

Source/WebCore:

Have it be on by default so that only ports that both enable
the define and don't want it on by default need to do something special.

* css/CSSParser.cpp:
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::operator==):
(WebCore::isValidKeywordPropertyAndValue):
* css/CSSParserMode.h:
(CSSParserContext):
* dom/Document.cpp:
(WebCore::Document::cssStickyPositionEnabled):
(WebCore):
* dom/Document.h:
(Document):
* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(Settings):
(WebCore::Settings::setCSSStickyPositionEnabled):
(WebCore::Settings::cssStickyPositionEnabled):

Source/WebKit/chromium:

* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setCSSStickyPositionEnabled):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):

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

Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParserMode.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebSettings.h
Source/WebKit/chromium/src/WebSettingsImpl.cpp
Source/WebKit/chromium/src/WebSettingsImpl.h

index 2bb4734..3755b83 100644 (file)
@@ -1,3 +1,31 @@
+2012-09-14  Ojan Vafai  <ojan@chromium.org>
+
+        Provide a runtime setting to disable position:sticky
+        https://bugs.webkit.org/show_bug.cgi?id=96827
+
+        Reviewed by James Robinson.
+
+        Have it be on by default so that only ports that both enable
+        the define and don't want it on by default need to do something special.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParserContext::CSSParserContext):
+        (WebCore::operator==):
+        (WebCore::isValidKeywordPropertyAndValue):
+        * css/CSSParserMode.h:
+        (CSSParserContext):
+        * dom/Document.cpp:
+        (WebCore::Document::cssStickyPositionEnabled):
+        (WebCore):
+        * dom/Document.h:
+        (Document):
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        * page/Settings.h:
+        (Settings):
+        (WebCore::Settings::setCSSStickyPositionEnabled):
+        (WebCore::Settings::cssStickyPositionEnabled):
+
 2012-09-14  Simon Fraser  <simon.fraser@apple.com>
 
         Fix builds with CSS_IMAGE_RESOLUTION enabled after r128656.
index 7f8505c..d5e5b7d 100644 (file)
@@ -199,6 +199,7 @@ CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL)
     , mode(mode)
     , isHTMLDocument(false)
     , isCSSCustomFilterEnabled(false)
+    , isCSSStickyPositionEnabled(false)
     , isCSSRegionsEnabled(false)
     , isCSSGridLayoutEnabled(false)
 #if ENABLE(CSS_VARIABLES)
@@ -215,6 +216,7 @@ CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
     , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode)
     , isHTMLDocument(document->isHTMLDocument())
     , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCSSCustomFilterEnabled() : false)
+    , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled())
     , isCSSRegionsEnabled(document->cssRegionsEnabled())
     , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled())
 #if ENABLE(CSS_VARIABLES)
@@ -232,6 +234,7 @@ bool operator==(const CSSParserContext& a, const CSSParserContext& b)
         && a.mode == b.mode
         && a.isHTMLDocument == b.isHTMLDocument
         && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled
+        && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled
         && a.isCSSRegionsEnabled == b.isCSSRegionsEnabled
         && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled
 #if ENABLE(CSS_VARIABLES)
@@ -670,7 +673,7 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
     case CSSPropertyPosition: // static | relative | absolute | fixed | sticky | inherit
         if (valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed
 #if ENABLE(CSS_STICKY_POSITION)
-            || valueID == CSSValueWebkitSticky
+            || (parserContext.isCSSStickyPositionEnabled && valueID == CSSValueWebkitSticky)
 #endif
             )
             return true;
index 7248bb5..bf77c3c 100644 (file)
@@ -65,6 +65,7 @@ public:
     CSSParserMode mode;
     bool isHTMLDocument;
     bool isCSSCustomFilterEnabled;
+    bool isCSSStickyPositionEnabled;
     bool isCSSRegionsEnabled;
     bool isCSSGridLayoutEnabled;
 #if ENABLE(CSS_VARIABLES)
index 4546ff5..de0a5ce 100644 (file)
@@ -1139,6 +1139,11 @@ bool Document::regionBasedColumnsEnabled() const
     return settings() && settings()->regionBasedColumnsEnabled(); 
 }
 
+bool Document::cssStickyPositionEnabled() const
+{
+    return settings() && settings()->cssStickyPositionEnabled(); 
+}
+
 bool Document::cssRegionsEnabled() const
 {
     return settings() && settings()->cssRegionsEnabled(); 
index 50f7eb2..a8161d9 100644 (file)
@@ -355,6 +355,7 @@ public:
     virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
     PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser);
 
+    bool cssStickyPositionEnabled() const;
     bool cssRegionsEnabled() const;
 #if ENABLE(CSS_REGIONS)
     PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&);
index 2332185..2a4c7b4 100644 (file)
@@ -202,6 +202,9 @@ Settings::Settings(Page* page)
     , m_acceleratedDrawingEnabled(false)
     , m_acceleratedFiltersEnabled(false)
     , m_isCSSCustomFilterEnabled(false)
+#if ENABLE(CSS_STICKY_POSITION)
+    , m_cssStickyPositionEnabled(true)
+#endif
 #if ENABLE(CSS_REGIONS)
     , m_cssRegionsEnabled(false)
 #endif
index 3c18483..6247f85 100644 (file)
@@ -337,6 +337,14 @@ namespace WebCore {
         void setCSSCustomFilterEnabled(bool enabled) { m_isCSSCustomFilterEnabled = enabled; }
         bool isCSSCustomFilterEnabled() const { return m_isCSSCustomFilterEnabled; }
 
+#if ENABLE(CSS_STICKY_POSITION)
+        void setCSSStickyPositionEnabled(bool enabled) { m_cssStickyPositionEnabled = enabled; }
+        bool cssStickyPositionEnabled() const { return m_cssStickyPositionEnabled; }
+#else
+        void setCSSStickyPositionEnabled(bool) { }
+        bool cssStickyPositionEnabled() const { return false; }
+#endif
+
 #if ENABLE(CSS_REGIONS)
         void setCSSRegionsEnabled(bool enabled) { m_cssRegionsEnabled = enabled; }
         bool cssRegionsEnabled() const { return m_cssRegionsEnabled; }
@@ -711,6 +719,9 @@ namespace WebCore {
         bool m_acceleratedDrawingEnabled : 1;
         bool m_acceleratedFiltersEnabled : 1;
         bool m_isCSSCustomFilterEnabled : 1;
+#if ENABLE(CSS_STICKY_POSITION)
+        bool m_cssStickyPositionEnabled : 1;
+#endif        
 #if ENABLE(CSS_REGIONS)
         bool m_cssRegionsEnabled : 1;
 #endif
index fe44e09..4c30b7a 100644 (file)
@@ -1,3 +1,17 @@
+2012-09-14  Ojan Vafai  <ojan@chromium.org>
+
+        Provide a runtime setting to disable position:sticky
+        https://bugs.webkit.org/show_bug.cgi?id=96827
+
+        Reviewed by James Robinson.
+
+        * public/WebSettings.h:
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setCSSStickyPositionEnabled):
+        (WebKit):
+        * src/WebSettingsImpl.h:
+        (WebSettingsImpl):
+
 2012-09-14  Adam Barth  <abarth@webkit.org>
 
         Remove webkitPostMessage
index fd0dcb6..5ff206b 100644 (file)
@@ -93,6 +93,7 @@ public:
     virtual void setEnableScrollAnimator(bool) = 0;
     virtual void setExperimentalCSSCustomFilterEnabled(bool) = 0;
     virtual void setExperimentalCSSGridLayoutEnabled(bool) = 0;
+    virtual void setCSSStickyPositionEnabled(bool) = 0;
     virtual void setExperimentalCSSRegionsEnabled(bool) = 0;
     virtual void setExperimentalCSSVariablesEnabled(bool) = 0;
     virtual void setExperimentalWebGLEnabled(bool) = 0;
index 51731fd..4cc3ef7 100644 (file)
@@ -337,6 +337,11 @@ void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled)
     m_settings->setWebGLEnabled(enabled);
 }
 
+void WebSettingsImpl::setCSSStickyPositionEnabled(bool enabled)
+{
+    m_settings->setCSSStickyPositionEnabled(enabled);
+}
+
 void WebSettingsImpl::setExperimentalCSSRegionsEnabled(bool enabled)
 {
     m_settings->setCSSRegionsEnabled(enabled);
index a5f7c02..e9e01bf 100644 (file)
@@ -85,6 +85,7 @@ public:
     virtual void setEnableScrollAnimator(bool);
     virtual void setExperimentalCSSCustomFilterEnabled(bool);
     virtual void setExperimentalCSSGridLayoutEnabled(bool);
+    virtual void setCSSStickyPositionEnabled(bool);
     virtual void setExperimentalCSSRegionsEnabled(bool);
     virtual void setExperimentalCSSVariablesEnabled(bool);
     virtual void setExperimentalWebGLEnabled(bool);