- Revision
- 164521
- Author
- mmaxfi...@apple.com
- Date
- 2014-02-21 19:14:13 -0800 (Fri, 21 Feb 2014)
Log Message
After copy and paste, cursor may appear to be above the bottom of content
https://bugs.webkit.org/show_bug.cgi?id=129167
Reviewed by Ryosuke Niwa.
Source/WebCore:
Adding a clear:both to the end of content.
I can't handle the case of the cursor appearing above the bottom of
absolutely positioned divs (of the case of floats inside absolutely
positioned divs) because you can't know where the bottom of a div
will end up being rendered (it is affected by things like browser
window width and text size settings). Therefore, the only case I
can handle is the case where there is a floating div in the same
level as the document itself.
Test: editing/pasteboard/copy-paste-inserts-clearing-div.html
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::isFloating):
* editing/EditingStyle.h:
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
(WebCore::StyledMarkupAccumulator::appendElement):
(WebCore::createMarkupInternal):
LayoutTests:
Makes sure that the clearing div is inserted.
* editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt: Added.
* editing/pasteboard/copy-paste-inserts-clearing-div.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (164520 => 164521)
--- trunk/LayoutTests/ChangeLog 2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/LayoutTests/ChangeLog 2014-02-22 03:14:13 UTC (rev 164521)
@@ -1,3 +1,15 @@
+2014-02-21 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ After copy and paste, cursor may appear to be above the bottom of content
+ https://bugs.webkit.org/show_bug.cgi?id=129167
+
+ Reviewed by Ryosuke Niwa.
+
+ Makes sure that the clearing div is inserted.
+
+ * editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt: Added.
+ * editing/pasteboard/copy-paste-inserts-clearing-div.html: Added.
+
2014-02-21 Brian Burg <bb...@apple.com>
Move unported Web Inspector tests to LayoutTests/inspector-obsolete
Added: trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt (0 => 164521)
--- trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt 2014-02-22 03:14:13 UTC (rev 164521)
@@ -0,0 +1,100 @@
+This tests to see if floating elements cause a clearing element to be inserted 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>
+| "
+Before
+"
+| <div>
+| style="position: absolute; top: 0px; right: 0px; width: 100px; height: 100px; background: yellow;"
+| "
+"
+| <div>
+| style="float: right; width: 200px; height: 200px; background: blue;"
+| "
+After
+
+"
+| <script>
+| "
+
+Markup.description('This tests to see if floating elements cause a clearing element to be inserted upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(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;"
+| "BeforeĀ "
+| <div>
+| style="position: absolute; top: 0px; right: 0px; width: 100px; height: 100px; background-color: yellow;"
+| <div>
+| style="float: right; width: 200px; height: 200px; background-color: blue;"
+| "After<#selection-caret>"
+| <div>
+| style="clear: both;"
+| <script>
+| "
+
+Markup.description('This tests to see if floating elements cause a clearing element to be inserted upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(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-inserts-clearing-div.html (0 => 164521)
--- trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div.html 2014-02-22 03:14:13 UTC (rev 164521)
@@ -0,0 +1,31 @@
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<script type="text/_javascript_" src=""
+</head>
+<body>
+Before
+<div style="position: absolute; top: 0px; right: 0px; width: 100px; height: 100px; background: yellow;"></div>
+<div style="float: right; width: 200px; height: 200px; background: blue;"></div>
+After
+
+<script>
+
+Markup.description('This tests to see if floating elements cause a clearing element to be inserted upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+ window.internals.settings.setShouldConvertPositionStyleOnCopy(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 (164520 => 164521)
--- trunk/Source/WebCore/ChangeLog 2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/ChangeLog 2014-02-22 03:14:13 UTC (rev 164521)
@@ -1,3 +1,30 @@
+2014-02-21 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ After copy and paste, cursor may appear to be above the bottom of content
+ https://bugs.webkit.org/show_bug.cgi?id=129167
+
+ Reviewed by Ryosuke Niwa.
+
+ Adding a clear:both to the end of content.
+
+ I can't handle the case of the cursor appearing above the bottom of
+ absolutely positioned divs (of the case of floats inside absolutely
+ positioned divs) because you can't know where the bottom of a div
+ will end up being rendered (it is affected by things like browser
+ window width and text size settings). Therefore, the only case I
+ can handle is the case where there is a floating div in the same
+ level as the document itself.
+
+ Test: editing/pasteboard/copy-paste-inserts-clearing-div.html
+
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::isFloating):
+ * editing/EditingStyle.h:
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
+ (WebCore::StyledMarkupAccumulator::appendElement):
+ (WebCore::createMarkupInternal):
+
2014-02-21 Dean Jackson <d...@apple.com>
[iOS Media] Wireless target UI
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (164520 => 164521)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2014-02-22 03:14:13 UTC (rev 164521)
@@ -1242,6 +1242,13 @@
return false;
}
+bool EditingStyle::isFloating()
+{
+ RefPtr<CSSValue> v = m_mutableStyle->getPropertyCSSValue(CSSPropertyFloat);
+ RefPtr<CSSPrimitiveValue> noneValue = cssValuePool().createIdentifierValue(CSSValueNone);
+ return v && !v->equals(*noneValue);
+}
+
int EditingStyle::legacyFontSize(Document* document) const
{
RefPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
Modified: trunk/Source/WebCore/editing/EditingStyle.h (164520 => 164521)
--- trunk/Source/WebCore/editing/EditingStyle.h 2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/editing/EditingStyle.h 2014-02-22 03:14:13 UTC (rev 164521)
@@ -136,6 +136,7 @@
void removePropertiesInElementDefaultStyle(Element*);
void forceInline();
bool convertPositionStyle();
+ bool isFloating();
int legacyFontSize(Document*) const;
float fontSizeDelta() const { return m_fontSizeDelta; }
Modified: trunk/Source/WebCore/editing/markup.cpp (164520 => 164521)
--- trunk/Source/WebCore/editing/markup.cpp 2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/editing/markup.cpp 2014-02-22 03:14:13 UTC (rev 164521)
@@ -125,6 +125,7 @@
String takeResults();
bool needRelativeStyleWrapper() const { return m_needRelativeStyleWrapper; }
+ bool needClearingDiv() const { return m_needClearingDiv; }
using MarkupAccumulator::appendString;
@@ -162,6 +163,7 @@
RefPtr<EditingStyle> m_wrappingStyle;
bool m_needRelativeStyleWrapper;
bool m_needsPositionStyleConversion;
+ bool m_needClearingDiv;
};
inline StyledMarkupAccumulator::StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, EAnnotateForInterchange shouldAnnotate, const Range* range, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
@@ -170,6 +172,7 @@
, m_highestNodeToBeSerialized(highestNodeToBeSerialized)
, m_needRelativeStyleWrapper(false)
, m_needsPositionStyleConversion(needsPositionStyleConversion)
+ , m_needClearingDiv(false)
{
}
@@ -327,8 +330,10 @@
if (addDisplayInline)
newInlineStyle->forceInline();
- if (m_needsPositionStyleConversion)
+ if (m_needsPositionStyleConversion) {
m_needRelativeStyleWrapper |= newInlineStyle->convertPositionStyle();
+ m_needClearingDiv |= newInlineStyle->isFloating();
+ }
// 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.
@@ -629,6 +634,8 @@
}
if (accumulator.needRelativeStyleWrapper() && needsPositionStyleConversion) {
+ if (accumulator.needClearingDiv())
+ accumulator.appendString("<div style=\"clear: both;\"></div>");
RefPtr<EditingStyle> positionRelativeStyle = styleFromMatchedRulesAndInlineDecl(body);
positionRelativeStyle->style()->setProperty(CSSPropertyPosition, CSSValueRelative);
accumulator.wrapWithStyleNode(positionRelativeStyle->style(), document, true);