Title: [230120] trunk
- Revision
- 230120
- Author
- rn...@webkit.org
- Date
- 2018-03-30 16:57:50 -0700 (Fri, 30 Mar 2018)
Log Message
Copying a list from Microsoft Word to TinyMCE fails when mso-list is the first property
https://bugs.webkit.org/show_bug.cgi?id=182938
<rdar://problem/37683007>
Reviewed by Wenson Hsieh.
Source/WebCore:
Made the logic to detect Microsoft Word's mso-list CSS property more generic by detecting
inline styles which start with "mso-list:" and one which line-break right before it: "\nmso-list:"
Tests: PasteHTML.PreservesMSOList
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::shouldPreserveMSOListStyleForElement):
Tools:
Added more assertions to PasteHTML.PreservesMSOList for preserving an inline style which starts with mso-list
or the one which line-breaks right before it.
* TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
* TestWebKitAPI/Tests/WebKitCocoa/mso-list.html:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (230119 => 230120)
--- trunk/Source/WebCore/ChangeLog 2018-03-30 23:12:44 UTC (rev 230119)
+++ trunk/Source/WebCore/ChangeLog 2018-03-30 23:57:50 UTC (rev 230120)
@@ -1,3 +1,19 @@
+2018-03-30 Ryosuke Niwa <rn...@webkit.org>
+
+ Copying a list from Microsoft Word to TinyMCE fails when mso-list is the first property
+ https://bugs.webkit.org/show_bug.cgi?id=182938
+ <rdar://problem/37683007>
+
+ Reviewed by Wenson Hsieh.
+
+ Made the logic to detect Microsoft Word's mso-list CSS property more generic by detecting
+ inline styles which start with "mso-list:" and one which line-break right before it: "\nmso-list:"
+
+ Tests: PasteHTML.PreservesMSOList
+
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::shouldPreserveMSOListStyleForElement):
+
2018-03-30 Youenn Fablet <you...@apple.com>
NetworkLoadChecker should upgrade redirects if needed
Modified: trunk/Source/WebCore/editing/markup.cpp (230119 => 230120)
--- trunk/Source/WebCore/editing/markup.cpp 2018-03-30 23:12:44 UTC (rev 230119)
+++ trunk/Source/WebCore/editing/markup.cpp 2018-03-30 23:57:50 UTC (rev 230120)
@@ -425,7 +425,13 @@
bool StyledMarkupAccumulator::shouldPreserveMSOListStyleForElement(const Element& element)
{
- return m_inMSOList || (m_shouldPreserveMSOList && element.getAttribute(styleAttr).contains(";mso-list:"));
+ if (m_inMSOList)
+ return true;
+ if (m_shouldPreserveMSOList) {
+ auto style = element.getAttribute(styleAttr);
+ return style.startsWith("mso-list:") || style.contains(";mso-list:") || style.contains("\nmso-list:");
+ }
+ return false;
}
void StyledMarkupAccumulator::appendElement(StringBuilder& out, const Element& element, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode)
Modified: trunk/Tools/ChangeLog (230119 => 230120)
--- trunk/Tools/ChangeLog 2018-03-30 23:12:44 UTC (rev 230119)
+++ trunk/Tools/ChangeLog 2018-03-30 23:57:50 UTC (rev 230120)
@@ -1,3 +1,17 @@
+2018-03-30 Ryosuke Niwa <rn...@webkit.org>
+
+ Copying a list from Microsoft Word to TinyMCE fails when mso-list is the first property
+ https://bugs.webkit.org/show_bug.cgi?id=182938
+ <rdar://problem/37683007>
+
+ Reviewed by Wenson Hsieh.
+
+ Added more assertions to PasteHTML.PreservesMSOList for preserving an inline style which starts with mso-list
+ or the one which line-breaks right before it.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
+ * TestWebKitAPI/Tests/WebKitCocoa/mso-list.html:
+
2018-03-29 Ryosuke Niwa <rn...@webkit.org>
Copying a list from Microsoft Word to TinyMCE fails when mso-list is on tags other than P
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm (230119 => 230120)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm 2018-03-30 23:12:44 UTC (rev 230119)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm 2018-03-30 23:57:50 UTC (rev 230120)
@@ -178,6 +178,9 @@
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('[if !supportLists]')"].boolValue);
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('[endif]')"].boolValue);
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes(' style=\"text-indent:-.25in;mso-list:l0 level1 lfo1\">')"].boolValue);
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('<p class=\"MsoNormal\" style=\"margin-left:0cm;text-indent:0cm;mso-pagination:none;\\n"
+ "mso-list:l1 level1 lfo1;mso-layout-grid-align:none;text-autospace:none\">')"].boolValue);
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('<p class=\"MsoNormal\" style=\"mso-list:l1 level1 lfo1;margin-left:0cm\">')"].boolValue);
EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('/Users/webkitten/Library/')"].boolValue);
[webView stringByEvaluatingJavaScript:@"getSelection().setPosition(document.querySelector('.MsoListParagraphCxSpLast'));"];
@@ -193,6 +196,9 @@
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('[if !supportLists]')"].boolValue);
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('[endif]')"].boolValue);
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes(' style=\"text-indent:-.25in;mso-list:l0 level1 lfo1\">')"].boolValue);
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('<p class=\"MsoNormal\" style=\"margin-left:0cm;text-indent:0cm;mso-pagination:none;\\n"
+ "mso-list:l1 level1 lfo1;mso-layout-grid-align:none;text-autospace:none\">')"].boolValue);
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('<p class=\"MsoNormal\" style=\"mso-list:l1 level1 lfo1;margin-left:0cm\">')"].boolValue);
EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('/Users/webkitten/Library/')"].boolValue);
[webView stringByEvaluatingJavaScript:@"editor.innerHTML = ''; editor.focus();"];
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/mso-list.html (230119 => 230120)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/mso-list.html 2018-03-30 23:12:44 UTC (rev 230119)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/mso-list.html 2018-03-30 23:57:50 UTC (rev 230120)
@@ -932,6 +932,17 @@
style='mso-list:Ignore'>}<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span style='color:red'>WebKit</span><o:p></o:p></span></span></p>
+<p class=MsoNormal style='margin-left:0cm;text-indent:0cm;mso-pagination:none;
+mso-list:l1 level1 lfo1;mso-layout-grid-align:none;text-autospace:none'><![if !supportLists]><span style='font-family:
+"Courier New",serif;mso-fareast-font-family:"Courier New"'><span
+style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
+</span></span></span><![endif]><span style='color:red'>rocks</span><o:p></o:p></span></span></p>
+
+<p class=MsoNormal style='mso-list:l1 level1 lfo1;margin-left:0cm'><![if !supportLists]><span style='font-family:
+"Courier New",serif;mso-fareast-font-family:"Courier New"'><span
+style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
+</span></span></span><![endif]><span style='color:red'>foo</span><o:p></o:p></span></span></p>
+
<p class=MsoNormal><span style='mso-bookmark:OLE_LINK1'><span style='mso-bookmark:
OLE_LINK2'><o:p> </o:p></span></span></p>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes