Title: [163916] trunk
Revision
163916
Author
mmaxfi...@apple.com
Date
2014-02-11 16:06:01 -0800 (Tue, 11 Feb 2014)

Log Message

Source/WebCore: Convert position:fixed property to position:absolute upon copy
https://bugs.webkit.org/show_bug.cgi?id=128194

Reviewed by Simon Fraser.

This adds a Setting and Preference that allows clients to opt-in to this behavior.

This new behavior is only activated if the entire body is copied. If there is a position:fixed
element in the copied selection, it is replaced with position:absolute, and a containing
block (position:relative) is wrapped around the copied text.

This patch originally converted position:-webkit-sticky to position:relative. However, we
currently don't support copying and pasting of position:-webkit-sticky content (See below).
Therefore, this patch only deals with position:fixed.

Right now we don't copy position:-webkit-sticky. This is because:
1. When copying styled elements, we parse the style properties again
2. CSSParserContext has a flag which can disable parsing -webkit-sticky
3. There are two constructors to CSSParserContext: one that takes a document and sets up the
aforementioned flag, and a simple one that doesn't take a document and sets all the enableFoo
flags to false
4. At the relevant place within copy code, we are far removed from the Document object, so we
instead call the second constructor, thereby disabling parsing of -webkit-sticky

Test: editing/pasteboard/copy-paste-converts-sticky-and-fixed.html

* WebCore.exp.in: Export the Setting setter
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::convertFixedAndStickyPosition): Converts a single style
* editing/EditingStyle.h:
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator): Remember if we found
an element which needs the position:relative containing block
(WebCore::StyledMarkupAccumulator::appendElement): Surround with the position:relative
containing block if necessary
(WebCore::createMarkupInternal):
* page/Settings.cpp:
(WebCore::Settings::Settings): New setting to opt-in to this new behavior
(WebCore::Settings::setConvertPositionStyleOnCopy):
* page/Settings.h:
(WebCore::Settings::convertPositionStyleOnCopy):
* testing/InternalSettings.cpp: Allow setting the setting from a Layout Test
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setConvertPositionStyleOnCopy):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:

Source/WebKit/mac: Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
https://bugs.webkit.org/show_bug.cgi?id=128194

Reviewed by Simon Fraser.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(-[WebPreferences convertPositionStyleOnCopy]):
(-[WebPreferences setConvertPositionStyleOnCopy:]):
* WebView/WebPreferencesPrivate.h: Opt-in to new behavior
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit2: Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
https://bugs.webkit.org/show_bug.cgi?id=128194

Reviewed by Simon Fraser.

* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetConvertPositionStyleOnCopy):
(WKPreferencesGetConvertPositionStyleOnCopy):
* UIProcess/API/C/WKPreferencesPrivate.h: Opt-in to new behavior
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

LayoutTests: Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
https://bugs.webkit.org/show_bug.cgi?id=128194

Reviewed by Simon Fraser.

Checks that the style properties get converted.

* editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt: Added.
* editing/pasteboard/copy-paste-converts-sticky-and-fixed.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (163915 => 163916)


--- trunk/LayoutTests/ChangeLog	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/LayoutTests/ChangeLog	2014-02-12 00:06:01 UTC (rev 163916)
@@ -1,3 +1,15 @@
+2014-02-10  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
+        https://bugs.webkit.org/show_bug.cgi?id=128194
+
+        Reviewed by Simon Fraser.
+
+        Checks that the style properties get converted.
+
+        * editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt: Added.
+        * editing/pasteboard/copy-paste-converts-sticky-and-fixed.html: Added.
+
 2014-02-11  Youenn Fablet  <youe...@gmail.com>
 
         XMLHttpRequest should not send DNT header

Added: trunk/LayoutTests/editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt (0 => 163916)


--- trunk/LayoutTests/editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt	2014-02-12 00:06:01 UTC (rev 163916)
@@ -0,0 +1,98 @@
+These tests to see if position:sticky and position:fixed get converted to position:static and position:absolute upon copy/paste
+
+first test - before:
+| <html>
+|   <head>
+|     "
+"
+|     <meta>
+|       content="text/html; charset=utf-8"
+|       http-equiv="Content-type"
+|     "
+"
+|     <script>
+|       src=""
+|       type="text/_javascript_"
+|     "
+"
+|   "
+"
+|   <body>
+|     "
+abc"
+|     <div>
+|       style="position: fixed; left: 0px; top: 0px;"
+|       "def"
+|     "ghi
+"
+|     <br>
+|     "
+
+"
+|     <script>
+|       "
+
+Markup.description('These tests to see if position:sticky and position:fixed get converted to position:static and position:absolute upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+    window.internals.settings.setConvertPositionStyleOnCopy(true);
+
+var s = window.getSelection();
+
+Markup.dump('test1', 'first test - before');
+document.execCommand("SelectAll");
+document.execCommand("Cut");
+document.execCommand("Paste");
+Markup.dump('test1', 'first test - after');
+
+"
+
+first test - after:
+| <html>
+|   <head>
+|     "
+"
+|     <meta>
+|       content="text/html; charset=utf-8"
+|       http-equiv="Content-type"
+|     "
+"
+|     <script>
+|       src=""
+|       type="text/_javascript_"
+|     "
+"
+|   "
+"
+|   <body>
+|     <div>
+|       style="position: relative;"
+|       "abc"
+|       <div>
+|         style="position: absolute; left: 0px; top: 0px;"
+|         "def"
+|       "ghi <#selection-caret>"
+|     "
+
+"
+|     <script>
+|       "
+
+Markup.description('These tests to see if position:sticky and position:fixed get converted to position:static and position:absolute upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+    window.internals.settings.setConvertPositionStyleOnCopy(true);
+
+var s = window.getSelection();
+
+Markup.dump('test1', 'first test - before');
+document.execCommand("SelectAll");
+document.execCommand("Cut");
+document.execCommand("Paste");
+Markup.dump('test1', 'first test - after');
+
+"

Added: trunk/LayoutTests/editing/pasteboard/copy-paste-converts-sticky-and-fixed.html (0 => 163916)


--- trunk/LayoutTests/editing/pasteboard/copy-paste-converts-sticky-and-fixed.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-paste-converts-sticky-and-fixed.html	2014-02-12 00:06:01 UTC (rev 163916)
@@ -0,0 +1,29 @@
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<script type="text/_javascript_" src=""
+</head>
+<body>
+abc<div style="position: fixed; left: 0px; top: 0px;">def</div>ghi
+<br/>
+
+<script>
+
+Markup.description('These tests to see if position:sticky and position:fixed get converted to position:static and position:absolute upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+    window.internals.settings.setConvertPositionStyleOnCopy(true);
+
+var s = window.getSelection();
+
+Markup.dump('test1', 'first test - before');
+document.execCommand("SelectAll");
+document.execCommand("Cut");
+document.execCommand("Paste");
+Markup.dump('test1', 'first test - after');
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (163915 => 163916)


--- trunk/Source/WebCore/ChangeLog	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/ChangeLog	2014-02-12 00:06:01 UTC (rev 163916)
@@ -1,3 +1,53 @@
+2014-02-10  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Convert position:fixed property to position:absolute upon copy
+        https://bugs.webkit.org/show_bug.cgi?id=128194
+
+        Reviewed by Simon Fraser.
+
+        This adds a Setting and Preference that allows clients to opt-in to this behavior.
+
+        This new behavior is only activated if the entire body is copied. If there is a position:fixed
+        element in the copied selection, it is replaced with position:absolute, and a containing
+        block (position:relative) is wrapped around the copied text.
+
+        This patch originally converted position:-webkit-sticky to position:relative. However, we
+        currently don't support copying and pasting of position:-webkit-sticky content (See below).
+        Therefore, this patch only deals with position:fixed.
+
+        Right now we don't copy position:-webkit-sticky. This is because:
+        1. When copying styled elements, we parse the style properties again
+        2. CSSParserContext has a flag which can disable parsing -webkit-sticky
+        3. There are two constructors to CSSParserContext: one that takes a document and sets up the
+        aforementioned flag, and a simple one that doesn't take a document and sets all the enableFoo
+        flags to false
+        4. At the relevant place within copy code, we are far removed from the Document object, so we
+        instead call the second constructor, thereby disabling parsing of -webkit-sticky
+
+        Test: editing/pasteboard/copy-paste-converts-sticky-and-fixed.html
+
+        * WebCore.exp.in: Export the Setting setter
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::convertFixedAndStickyPosition): Converts a single style
+        * editing/EditingStyle.h:
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator): Remember if we found
+        an element which needs the position:relative containing block
+        (WebCore::StyledMarkupAccumulator::appendElement): Surround with the position:relative
+        containing block if necessary
+        (WebCore::createMarkupInternal):
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings): New setting to opt-in to this new behavior
+        (WebCore::Settings::setConvertPositionStyleOnCopy):
+        * page/Settings.h:
+        (WebCore::Settings::convertPositionStyleOnCopy):
+        * testing/InternalSettings.cpp: Allow setting the setting from a Layout Test
+        (WebCore::InternalSettings::Backup::Backup):
+        (WebCore::InternalSettings::Backup::restoreTo):
+        (WebCore::InternalSettings::setConvertPositionStyleOnCopy):
+        * testing/InternalSettings.h:
+        * testing/InternalSettings.idl:
+
 2014-02-11  Youenn Fablet  <youe...@gmail.com>
 
         XMLHttpRequest should not send DNT header

Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (163915 => 163916)


--- trunk/Source/WebCore/editing/EditingStyle.cpp	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp	2014-02-12 00:06:01 UTC (rev 163916)
@@ -1221,6 +1221,20 @@
     m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsImportant);
 }
 
+bool EditingStyle::convertFixedAndStickyPosition()
+{
+    if (!m_mutableStyle)
+        return false;
+
+    RefPtr<CSSPrimitiveValue> sticky = cssValuePool().createIdentifierValue(CSSValueWebkitSticky);
+    RefPtr<CSSPrimitiveValue> fixed = cssValuePool().createIdentifierValue(CSSValueFixed);
+    if (m_mutableStyle->propertyMatches(CSSPropertyPosition, fixed.get())) {
+        m_mutableStyle->setProperty(CSSPropertyPosition, cssValuePool().createIdentifierValue(CSSValueAbsolute), m_mutableStyle->propertyIsImportant(CSSPropertyPosition));
+        return true;
+    }
+    return false;
+}
+
 int EditingStyle::legacyFontSize(Document* document) const
 {
     RefPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);

Modified: trunk/Source/WebCore/editing/EditingStyle.h (163915 => 163916)


--- trunk/Source/WebCore/editing/EditingStyle.h	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/editing/EditingStyle.h	2014-02-12 00:06:01 UTC (rev 163916)
@@ -135,6 +135,7 @@
     void removeStyleFromRulesAndContext(StyledElement*, Node* context);
     void removePropertiesInElementDefaultStyle(Element*);
     void forceInline();
+    bool convertFixedAndStickyPosition();
     int legacyFontSize(Document*) const;
 
     float fontSizeDelta() const { return m_fontSizeDelta; }

Modified: trunk/Source/WebCore/editing/markup.cpp (163915 => 163916)


--- trunk/Source/WebCore/editing/markup.cpp	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/editing/markup.cpp	2014-02-12 00:06:01 UTC (rev 163916)
@@ -52,6 +52,7 @@
 #include "MarkupAccumulator.h"
 #include "Range.h"
 #include "RenderBlock.h"
+#include "Settings.h"
 #include "StyleProperties.h"
 #include "VisibleSelection.h"
 #include "VisibleUnits.h"
@@ -122,6 +123,11 @@
     void wrapWithNode(Node&, bool convertBlocksToInlines = false, RangeFullySelectsNode = DoesFullySelectNode);
     void wrapWithStyleNode(StyleProperties*, Document&, bool isBlock = false);
     String takeResults();
+    
+    bool needRelativeStyleWrapper() const
+    {
+        return m_needRelativeStyleWrapper;
+    }
 
     using MarkupAccumulator::appendString;
 
@@ -157,13 +163,14 @@
     const EAnnotateForInterchange m_shouldAnnotate;
     Node* m_highestNodeToBeSerialized;
     RefPtr<EditingStyle> m_wrappingStyle;
+    bool m_needRelativeStyleWrapper;
 };
 
-inline StyledMarkupAccumulator::StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, EAnnotateForInterchange shouldAnnotate,
-    const Range* range, Node* highestNodeToBeSerialized)
+inline StyledMarkupAccumulator::StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, EAnnotateForInterchange shouldAnnotate, const Range* range, Node* highestNodeToBeSerialized)
     : MarkupAccumulator(nodes, shouldResolveURLs, range)
     , m_shouldAnnotate(shouldAnnotate)
     , m_highestNodeToBeSerialized(highestNodeToBeSerialized)
+    , m_needRelativeStyleWrapper(false)
 {
 }
 
@@ -317,6 +324,9 @@
 
             if (addDisplayInline)
                 newInlineStyle->forceInline();
+            
+            if (element.document().settings() && element.document().settings()->convertPositionStyleOnCopy())
+                m_needRelativeStyleWrapper |= newInlineStyle->convertFixedAndStickyPosition();
 
             // If the node is not fully selected by the range, then we don't want to keep styles that affect its relationship to the nodes around it
             // only the ones that affect it and the nodes within it.
@@ -613,6 +623,12 @@
                 break;
         }
     }
+    
+    if (accumulator.needRelativeStyleWrapper() && body && fullySelectedRoot == body) {
+        RefPtr<EditingStyle> positionRelativeStyle = styleFromMatchedRulesAndInlineDecl(body);
+        positionRelativeStyle->style()->setProperty(CSSPropertyPosition, CSSValueRelative);
+        accumulator.wrapWithStyleNode(positionRelativeStyle->style(), document, true);
+    }
 
     // FIXME: The interchange newline should be placed in the block that it's in, not after all of the content, unconditionally.
     if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter(visibleEnd.previous()))

Modified: trunk/Source/WebCore/page/Settings.in (163915 => 163916)


--- trunk/Source/WebCore/page/Settings.in	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/page/Settings.in	2014-02-12 00:06:01 UTC (rev 163916)
@@ -204,3 +204,5 @@
 allowMultiElementImplicitSubmission initial=false
 
 mediaPlaybackAllowsAirPlay initial=true, conditional=IOS_AIRPLAY
+
+convertPositionStyleOnCopy initial=false

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (163915 => 163916)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2014-02-12 00:06:01 UTC (rev 163916)
@@ -94,6 +94,7 @@
     , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
     , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
     , m_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
+    , m_convertPositionStyleOnCopy(settings.convertPositionStyleOnCopy())
 {
 }
 
@@ -155,6 +156,7 @@
     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
+    settings.setConvertPositionStyleOnCopy(m_convertPositionStyleOnCopy);
     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
 }
 
@@ -527,4 +529,10 @@
     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
 }
 
+void InternalSettings::setConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
+{
+    InternalSettingsGuardForSettings();
+    settings()->setConvertPositionStyleOnCopy(convert);
 }
+
+}

Modified: trunk/Source/WebCore/testing/InternalSettings.h (163915 => 163916)


--- trunk/Source/WebCore/testing/InternalSettings.h	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/testing/InternalSettings.h	2014-02-12 00:06:01 UTC (rev 163916)
@@ -91,6 +91,7 @@
         bool m_useLegacyBackgroundSizeShorthandBehavior;
         bool m_autoscrollForDragAndDropEnabled;
         bool m_pluginReplacementEnabled;
+        bool m_convertPositionStyleOnCopy;
     };
 
     static PassRefPtr<InternalSettings> create(Page* page)
@@ -136,6 +137,7 @@
     void setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode&);
     void setPluginReplacementEnabled(bool);
     void setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode&);
+    void setConvertPositionStyleOnCopy(bool convert, ExceptionCode&);
 
 
 private:

Modified: trunk/Source/WebCore/testing/InternalSettings.idl (163915 => 163916)


--- trunk/Source/WebCore/testing/InternalSettings.idl	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebCore/testing/InternalSettings.idl	2014-02-12 00:06:01 UTC (rev 163916)
@@ -60,4 +60,5 @@
     [RaisesException] void setFontFallbackPrefersPictographs(boolean preferPictographs);
     void setPluginReplacementEnabled(boolean enabled);
     [RaisesException] void setBackgroundShouldExtendBeyondPage(boolean hasExtendedBackground);
+    [RaisesException] void setConvertPositionStyleOnCopy(boolean convert);
 };

Modified: trunk/Source/WebKit/mac/ChangeLog (163915 => 163916)


--- trunk/Source/WebKit/mac/ChangeLog	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-02-12 00:06:01 UTC (rev 163916)
@@ -1,3 +1,18 @@
+2014-02-10  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
+        https://bugs.webkit.org/show_bug.cgi?id=128194
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences convertPositionStyleOnCopy]):
+        (-[WebPreferences setConvertPositionStyleOnCopy:]):
+        * WebView/WebPreferencesPrivate.h: Opt-in to new behavior
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2014-02-11  Andy Estes  <aes...@apple.com>
 
         [Mac] connection:willStopBufferingData: no longer exists in NSURLConnectionDelegate

Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (163915 => 163916)


--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2014-02-12 00:06:01 UTC (rev 163916)
@@ -146,6 +146,7 @@
 #define WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey @"WebKitLowPowerVideoAudioBufferSizeEnabled"
 #define WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey @"WebKitUseLegacyTextAlignPositionedElementBehavior"
 #define WebKitMediaSourceEnabledPreferenceKey @"WebKitMediaSourceEnabled"
+#define WebKitConvertPositionStyleOnCopyPreferenceKey @"WebKitConvertPositionStyleOnCopy"
 
 #if !TARGET_OS_IPHONE
 // These are private both because callers should be using the cover methods and because the

Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (163915 => 163916)


--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2014-02-12 00:06:01 UTC (rev 163916)
@@ -2535,6 +2535,16 @@
     [self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
 }
 
+- (BOOL)convertPositionStyleOnCopy
+{
+    return [self _boolValueForKey:WebKitConvertPositionStyleOnCopyPreferenceKey];
+}
+
+- (void)setConvertPositionStyleOnCopy:(BOOL)enabled
+{
+    [self _setBoolValue:enabled forKey:WebKitConvertPositionStyleOnCopyPreferenceKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)

Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (163915 => 163916)


--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2014-02-12 00:06:01 UTC (rev 163916)
@@ -432,4 +432,7 @@
 - (void)setMediaSourceEnabled:(BOOL)flag;
 - (BOOL)mediaSourceEnabled;
 
+- (void)setConvertPositionStyleOnCopy:(BOOL)flag;
+- (BOOL)convertPositionStyleOnCopy;
+
 @end

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (163915 => 163916)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2014-02-12 00:06:01 UTC (rev 163916)
@@ -2378,6 +2378,8 @@
     settings.setMediaSourceEnabled([preferences mediaSourceEnabled]);
 #endif
 
+    settings.setConvertPositionStyleOnCopy([preferences convertPositionStyleOnCopy]);
+
     switch ([preferences storageBlockingPolicy]) {
     case WebAllowAllStorage:
         settings.setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);

Modified: trunk/Source/WebKit2/ChangeLog (163915 => 163916)


--- trunk/Source/WebKit2/ChangeLog	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-12 00:06:01 UTC (rev 163916)
@@ -1,3 +1,18 @@
+2014-02-10  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Convert position:sticky and position:fixed properties to position:static and position:absolute upon copy
+        https://bugs.webkit.org/show_bug.cgi?id=128194
+
+        Reviewed by Simon Fraser.
+
+        * Shared/WebPreferencesStore.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetConvertPositionStyleOnCopy):
+        (WKPreferencesGetConvertPositionStyleOnCopy):
+        * UIProcess/API/C/WKPreferencesPrivate.h: Opt-in to new behavior
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2014-02-11  Benjamin Poulain  <bpoul...@apple.com>
 
         [WK2] Rename screenToWindow to screenToRootView and windowToScreen to rootViewToScreen

Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.h (163915 => 163916)


--- trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2014-02-12 00:06:01 UTC (rev 163916)
@@ -190,6 +190,7 @@
     macro(SpatialNavigationEnabled, spatialNavigationEnabled, Bool, bool, false) \
     macro(MediaSourceEnabled, mediaSourceEnabled, Bool, bool, false) \
     macro(ViewGestureDebuggingEnabled, viewGestureDebuggingEnabled, Bool, bool, false) \
+    macro(ConvertPositionStyleOnCopy, convertPositionStyleOnCopy, Bool, bool, false) \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (163915 => 163916)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2014-02-12 00:06:01 UTC (rev 163916)
@@ -1235,3 +1235,13 @@
 {
     return toImpl(preferencesRef)->viewGestureDebuggingEnabled();
 }
+
+void WKPreferencesSetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef, bool convert)
+{
+    toImpl(preferencesRef)->setConvertPositionStyleOnCopy(convert);
+}
+
+bool WKPreferencesGetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->convertPositionStyleOnCopy();
+}

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h (163915 => 163916)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2014-02-12 00:06:01 UTC (rev 163916)
@@ -314,6 +314,10 @@
 WK_EXPORT void WKPreferencesSetViewGestureDebuggingEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetViewGestureDebuggingEnabled(WKPreferencesRef preferencesRef);
 
+// Default to false.
+WK_EXPORT void WKPreferencesSetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef, bool convert);
+WK_EXPORT bool WKPreferencesGetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (163915 => 163916)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-02-12 00:02:31 UTC (rev 163915)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-02-12 00:06:01 UTC (rev 163916)
@@ -2575,6 +2575,8 @@
     settings.setMediaSourceEnabled(store.getBoolValueForKey(WebPreferencesKey::mediaSourceEnabledKey()));
 #endif
 
+    settings.setConvertPositionStyleOnCopy(store.getBoolValueForKey(WebPreferencesKey::convertPositionStyleOnCopyKey()));
+
     if (store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey())) {
         if (m_processSuppressionDisabledByWebPreference.isActive())
             m_processSuppressionDisabledByWebPreference.endActivity();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to