https://bugs.webkit.org/show_bug.cgi?id=128688
Reviewed by Ryosuke Niwa.
Source/WebCore:
Adds a field, m_needsPositionStyleConversion, to StyledMarkupAccumulator.
Also, renames the ConvertPositionStyleOnCopy setting to ShouldConvertPositionStyleOnCopy
Test: editing/pasteboard/copy-paste-doesnt-convert-sticky-and-fixed-during-partial-copy.html
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
(WebCore::StyledMarkupAccumulator::appendElement):
(WebCore::createMarkupInternal):
* page/Settings.in:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setShouldConvertPositionStyleOnCopy):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:
Source/WebKit/mac:
Renames the ConvertPositionStyleOnCopy setting to ShouldConvertPositionStyleOnCopy
* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(-[WebPreferences shouldConvertPositionStyleOnCopy]):
(-[WebPreferences setShouldConvertPositionStyleOnCopy:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):
Source/WebKit2:
Renames the ConvertPositionStyleOnCopy setting to ShouldConvertPositionStyleOnCopy
* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetShouldConvertPositionStyleOnCopy):
(WKPreferencesGetShouldConvertPositionStyleOnCopy):
* UIProcess/API/C/WKPreferencesPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
LayoutTests:
Performs a copy of the contents of a particular div, rather than the entire body. Makes sure that
no position:fixed -> position:absolute conversion occurs.
* editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt:
* editing/pasteboard/copy-paste-converts-sticky-and-fixed.html:
* editing/pasteboard/copy-paste-doesnt-convert-sticky-and-fixed-during-partial-copy-expected.txt: Added.
* editing/pasteboard/copy-paste-doesnt-convert-sticky-and-fixed-during-partial-copy.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164053
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-02-13 Myles C. Maxfield <mmaxfield@apple.com>
+
+ During a copy, position:fixed gets converted to position:absolute even if only part of the document is selected
+ https://bugs.webkit.org/show_bug.cgi?id=128688
+
+ Reviewed by Ryosuke Niwa.
+
+ Performs a copy of the contents of a particular div, rather than the entire body. Makes sure that
+ no position:fixed -> position:absolute conversion occurs.
+
+ * editing/pasteboard/copy-paste-converts-sticky-and-fixed-expected.txt:
+ * editing/pasteboard/copy-paste-converts-sticky-and-fixed.html:
+ * editing/pasteboard/copy-paste-doesnt-convert-sticky-and-fixed-during-partial-copy-expected.txt: Added.
+ * editing/pasteboard/copy-paste-doesnt-convert-sticky-and-fixed-during-partial-copy.html: Added.
+
2014-02-13 Chang Shu <cshu@webkit.org>
Copying (createMarkup) wrapping text results in space between wrapped lines stripped.
document.designMode = 'on';
if (window.internals)
- window.internals.settings.setConvertPositionStyleOnCopy(true);
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
var s = window.getSelection();
document.designMode = 'on';
if (window.internals)
- window.internals.settings.setConvertPositionStyleOnCopy(true);
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
var s = window.getSelection();
document.designMode = 'on';
if (window.internals)
- window.internals.settings.setConvertPositionStyleOnCopy(true);
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
var s = window.getSelection();
--- /dev/null
+This tests to see if position:sticky and position:fixed don't get converted to position:static and position:absolute upon copy/paste when there is only a partial selection (not the entire body is selected)
+
+Before:
+| "
+abc"
+| <div>
+| style="position: fixed; left: 0px; top: 0px;"
+| "def"
+| "ghi
+"
+
+After:
+| "abc"
+| <div>
+| style="position: fixed; left: 0px; top: 0px;"
+| "def"
+| "ghi<#selection-caret>"
--- /dev/null
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<script type="text/javascript" src="../../resources/dump-as-markup.js"></script>
+</head>
+<body>
+<div contenteditable="true" id="test">
+abc<div style="position: fixed; left: 0px; top: 0px;">def</div>ghi
+</div>
+
+<script>
+
+Markup.description('This tests to see if position:sticky and position:fixed don\'t get converted to position:static and position:absolute upon copy/paste when there is only a partial selection (not the entire body is selected)');
+
+if (window.internals)
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
+
+var e = document.getElementById("test");
+var s = window.getSelection();
+
+Markup.dump('test', 'Before');
+s.setPosition(e, 0);
+document.execCommand("SelectAll");
+document.execCommand("Cut");
+document.execCommand("Paste");
+Markup.dump('test', 'After');
+
+</script>
+</body>
+</html>
+2014-02-13 Myles C. Maxfield <mmaxfield@apple.com>
+
+ During a copy, position:fixed gets converted to position:absolute even if only part of the document is selected
+ https://bugs.webkit.org/show_bug.cgi?id=128688
+
+ Reviewed by Ryosuke Niwa.
+
+ Adds a field, m_needsPositionStyleConversion, to StyledMarkupAccumulator.
+
+ Also, renames the ConvertPositionStyleOnCopy setting to ShouldConvertPositionStyleOnCopy
+
+ Test: editing/pasteboard/copy-paste-doesnt-convert-sticky-and-fixed-during-partial-copy.html
+
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
+ (WebCore::StyledMarkupAccumulator::appendElement):
+ (WebCore::createMarkupInternal):
+ * page/Settings.in:
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::Backup::Backup):
+ (WebCore::InternalSettings::Backup::restoreTo):
+ (WebCore::InternalSettings::setShouldConvertPositionStyleOnCopy):
+ * testing/InternalSettings.h:
+ * testing/InternalSettings.idl:
+
2014-02-12 Timothy Hatcher <timothy@apple.com>
Enable inspection of recently used IndexedDB databases.
public:
enum RangeFullySelectsNode { DoesFullySelectNode, DoesNotFullySelectNode };
- StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs, EAnnotateForInterchange, const Range*, Node* highestNodeToBeSerialized = 0);
+ StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs, EAnnotateForInterchange, const Range*, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized = 0);
Node* serializeNodes(Node* startNode, Node* pastEnd);
void wrapWithNode(Node&, bool convertBlocksToInlines = false, RangeFullySelectsNode = DoesFullySelectNode);
void wrapWithStyleNode(StyleProperties*, Document&, bool isBlock = false);
String takeResults();
- bool needRelativeStyleWrapper() const
- {
- return m_needRelativeStyleWrapper;
- }
+ bool needRelativeStyleWrapper() const { return m_needRelativeStyleWrapper; }
using MarkupAccumulator::appendString;
Node* m_highestNodeToBeSerialized;
RefPtr<EditingStyle> m_wrappingStyle;
bool m_needRelativeStyleWrapper;
+ bool m_needsPositionStyleConversion;
};
-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, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
: MarkupAccumulator(nodes, shouldResolveURLs, range)
, m_shouldAnnotate(shouldAnnotate)
, m_highestNodeToBeSerialized(highestNodeToBeSerialized)
, m_needRelativeStyleWrapper(false)
+ , m_needsPositionStyleConversion(needsPositionStyleConversion)
{
}
if (addDisplayInline)
newInlineStyle->forceInline();
- if (element.document().settings() && element.document().settings()->convertPositionStyleOnCopy())
+ if (m_needsPositionStyleConversion)
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
fullySelectedRoot = body;
Node* specialCommonAncestor = highestAncestorToWrapMarkup(&updatedRange, shouldAnnotate);
- StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, shouldAnnotate, &updatedRange, specialCommonAncestor);
+ bool needsPositionStyleConversion = body && fullySelectedRoot == body
+ && document.settings() && document.settings()->shouldConvertPositionStyleOnCopy();
+ StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, shouldAnnotate, &updatedRange, needsPositionStyleConversion, specialCommonAncestor);
Node* pastEnd = updatedRange.pastLastNode();
Node* startNode = updatedRange.firstNode();
}
}
- if (accumulator.needRelativeStyleWrapper() && body && fullySelectedRoot == body) {
+ if (accumulator.needRelativeStyleWrapper() && needsPositionStyleConversion) {
RefPtr<EditingStyle> positionRelativeStyle = styleFromMatchedRulesAndInlineDecl(body);
positionRelativeStyle->style()->setProperty(CSSPropertyPosition, CSSValueRelative);
accumulator.wrapWithStyleNode(positionRelativeStyle->style(), document, true);
mediaPlaybackAllowsAirPlay initial=true, conditional=IOS_AIRPLAY
-convertPositionStyleOnCopy initial=false
+shouldConvertPositionStyleOnCopy initial=false
, m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
, m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
, m_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
- , m_convertPositionStyleOnCopy(settings.convertPositionStyleOnCopy())
+ , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
{
}
settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
- settings.setConvertPositionStyleOnCopy(m_convertPositionStyleOnCopy);
+ settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
}
settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
}
-void InternalSettings::setConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
+void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
{
InternalSettingsGuardForSettings();
- settings()->setConvertPositionStyleOnCopy(convert);
+ settings()->setShouldConvertPositionStyleOnCopy(convert);
}
}
bool m_useLegacyBackgroundSizeShorthandBehavior;
bool m_autoscrollForDragAndDropEnabled;
bool m_pluginReplacementEnabled;
- bool m_convertPositionStyleOnCopy;
+ bool m_shouldConvertPositionStyleOnCopy;
};
static PassRefPtr<InternalSettings> create(Page* page)
void setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode&);
void setPluginReplacementEnabled(bool);
void setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode&);
- void setConvertPositionStyleOnCopy(bool convert, ExceptionCode&);
+ void setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode&);
private:
[RaisesException] void setFontFallbackPrefersPictographs(boolean preferPictographs);
void setPluginReplacementEnabled(boolean enabled);
[RaisesException] void setBackgroundShouldExtendBeyondPage(boolean hasExtendedBackground);
- [RaisesException] void setConvertPositionStyleOnCopy(boolean convert);
+ [RaisesException] void setShouldConvertPositionStyleOnCopy(boolean convert);
};
+2014-02-13 Myles C. Maxfield <mmaxfield@apple.com>
+
+ During a copy, position:fixed gets converted to position:absolute even if only part of the document is selected
+ https://bugs.webkit.org/show_bug.cgi?id=128688
+
+ Reviewed by Ryosuke Niwa.
+
+ Renames the ConvertPositionStyleOnCopy setting to ShouldConvertPositionStyleOnCopy
+
+ * WebView/WebPreferenceKeysPrivate.h:
+ * WebView/WebPreferences.mm:
+ (-[WebPreferences shouldConvertPositionStyleOnCopy]):
+ (-[WebPreferences setShouldConvertPositionStyleOnCopy:]):
+ * WebView/WebPreferencesPrivate.h:
+ * WebView/WebView.mm:
+ (-[WebView _preferencesChanged:]):
+
2014-02-13 Alexey Proskuryakov <ap@apple.com>
[Mac] Add a WebKit1 SPI to get WebCrypto master key from a client
#define WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey @"WebKitLowPowerVideoAudioBufferSizeEnabled"
#define WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey @"WebKitUseLegacyTextAlignPositionedElementBehavior"
#define WebKitMediaSourceEnabledPreferenceKey @"WebKitMediaSourceEnabled"
-#define WebKitConvertPositionStyleOnCopyPreferenceKey @"WebKitConvertPositionStyleOnCopy"
+#define WebKitShouldConvertPositionStyleOnCopyPreferenceKey @"WebKitShouldConvertPositionStyleOnCopy"
#if !TARGET_OS_IPHONE
// These are private both because callers should be using the cover methods and because the
[self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
}
-- (BOOL)convertPositionStyleOnCopy
+- (BOOL)shouldConvertPositionStyleOnCopy
{
- return [self _boolValueForKey:WebKitConvertPositionStyleOnCopyPreferenceKey];
+ return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
}
-- (void)setConvertPositionStyleOnCopy:(BOOL)enabled
+- (void)setShouldConvertPositionStyleOnCopy:(BOOL)enabled
{
- [self _setBoolValue:enabled forKey:WebKitConvertPositionStyleOnCopyPreferenceKey];
+ [self _setBoolValue:enabled forKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
}
@end
- (void)setMediaSourceEnabled:(BOOL)flag;
- (BOOL)mediaSourceEnabled;
-- (void)setConvertPositionStyleOnCopy:(BOOL)flag;
-- (BOOL)convertPositionStyleOnCopy;
+- (void)setShouldConvertPositionStyleOnCopy:(BOOL)flag;
+- (BOOL)shouldConvertPositionStyleOnCopy;
@end
settings.setMediaSourceEnabled([preferences mediaSourceEnabled]);
#endif
- settings.setConvertPositionStyleOnCopy([preferences convertPositionStyleOnCopy]);
+ settings.setShouldConvertPositionStyleOnCopy([preferences shouldConvertPositionStyleOnCopy]);
switch ([preferences storageBlockingPolicy]) {
case WebAllowAllStorage:
+2014-02-13 Myles C. Maxfield <mmaxfield@apple.com>
+
+ During a copy, position:fixed gets converted to position:absolute even if only part of the document is selected
+ https://bugs.webkit.org/show_bug.cgi?id=128688
+
+ Reviewed by Ryosuke Niwa.
+
+ Renames the ConvertPositionStyleOnCopy setting to ShouldConvertPositionStyleOnCopy
+
+ * Shared/WebPreferencesStore.h:
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesSetShouldConvertPositionStyleOnCopy):
+ (WKPreferencesGetShouldConvertPositionStyleOnCopy):
+ * UIProcess/API/C/WKPreferencesPrivate.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+
2014-02-12 Timothy Hatcher <timothy@apple.com>
Enable inspection of recently used IndexedDB databases.
macro(SpatialNavigationEnabled, spatialNavigationEnabled, Bool, bool, false) \
macro(MediaSourceEnabled, mediaSourceEnabled, Bool, bool, false) \
macro(ViewGestureDebuggingEnabled, viewGestureDebuggingEnabled, Bool, bool, false) \
- macro(ConvertPositionStyleOnCopy, convertPositionStyleOnCopy, Bool, bool, false) \
+ macro(ShouldConvertPositionStyleOnCopy, shouldConvertPositionStyleOnCopy, Bool, bool, false) \
\
#define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
return toImpl(preferencesRef)->viewGestureDebuggingEnabled();
}
-void WKPreferencesSetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef, bool convert)
+void WKPreferencesSetShouldConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef, bool convert)
{
- toImpl(preferencesRef)->setConvertPositionStyleOnCopy(convert);
+ toImpl(preferencesRef)->setShouldConvertPositionStyleOnCopy(convert);
}
-bool WKPreferencesGetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef)
+bool WKPreferencesGetShouldConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef)
{
- return toImpl(preferencesRef)->convertPositionStyleOnCopy();
+ return toImpl(preferencesRef)->shouldConvertPositionStyleOnCopy();
}
WK_EXPORT bool WKPreferencesGetViewGestureDebuggingEnabled(WKPreferencesRef preferencesRef);
// Default to false.
-WK_EXPORT void WKPreferencesSetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef, bool convert);
-WK_EXPORT bool WKPreferencesGetConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef);
+WK_EXPORT void WKPreferencesSetShouldConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef, bool convert);
+WK_EXPORT bool WKPreferencesGetShouldConvertPositionStyleOnCopy(WKPreferencesRef preferencesRef);
#ifdef __cplusplus
}
settings.setMediaSourceEnabled(store.getBoolValueForKey(WebPreferencesKey::mediaSourceEnabledKey()));
#endif
- settings.setConvertPositionStyleOnCopy(store.getBoolValueForKey(WebPreferencesKey::convertPositionStyleOnCopyKey()));
+ settings.setShouldConvertPositionStyleOnCopy(store.getBoolValueForKey(WebPreferencesKey::shouldConvertPositionStyleOnCopyKey()));
if (store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey())) {
if (m_processSuppressionDisabledByWebPreference.isActive())