Title: [249707] branches/safari-608-branch

Diff

Modified: branches/safari-608-branch/LayoutTests/ChangeLog (249706 => 249707)


--- branches/safari-608-branch/LayoutTests/ChangeLog	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/LayoutTests/ChangeLog	2019-09-10 05:30:56 UTC (rev 249707)
@@ -1,3 +1,15 @@
+2019-09-09  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION (iOS 13): Bulleted list copied from Notes to Mail results in Times New Roman
+        https://bugs.webkit.org/show_bug.cgi?id=201490
+
+        Reviewed by Daniel Bates.
+
+        Added a test to make sure -webkit-standard font family name isn't stripped away when sanitization is not in effect.
+
+        * editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family-expected.txt: Added.
+        * editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html: Added.
+
 2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r249605. rdar://problem/55182896

Added: branches/safari-608-branch/LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family-expected.txt (0 => 249707)


--- branches/safari-608-branch/LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family-expected.txt	2019-09-10 05:30:56 UTC (rev 249707)
@@ -0,0 +1,12 @@
+This tests pasting a markup with -webkit-standard font family name. WebKit should not strip it away upon paste.
+To manually test, click on "start" first then trigger paste from menu or callout bar or press cmd+v
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.clipboardData.getData('text/html') is markup
+PASS editor.innerHTML.includes('-webkit-standard') is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/safari-608-branch/LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html (0 => 249707)


--- branches/safari-608-branch/LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html	2019-09-10 05:30:56 UTC (rev 249707)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<body>
+<button id="start">Start</button>
+<div id="editor" style="font-family: Arial" contenteditable>hello</div>
+<script src=""
+<script>
+
+jsTestIsAsync = true;
+
+description(`This tests pasting a markup with -webkit-standard font family name. WebKit should not strip it away upon paste.<br>
+To manually test, click on "start" first then trigger paste from menu or callout bar or press cmd+v`);
+
+const markup = `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<meta name="Generator" content="Cocoa HTML Writer">
+</head>
+<body>
+<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 17.0px '-webkit-standard'; color: #454545">Hello</p>
+</body>
+</html>`;
+
+editor.focus();
+start.addEventListener('click', () => {
+    editor.focus();
+    document.execCommand('selectAll');
+    document.execCommand('copy');
+    if (window.testRunner)
+        document.execCommand('paste');
+});
+editor.addEventListener('copy', (event) => {
+    event.clipboardData.setData('text/html', markup);
+    event.preventDefault();
+});
+editor.addEventListener('paste', (event) => {
+    shouldBe(`event.clipboardData.getData('text/html')`, `markup`);
+    document.execCommand('insertHTML', false, event.clipboardData.getData('text/html'));
+    shouldBeTrue(`editor.innerHTML.includes('-webkit-standard')`);
+    editor.innerHTML = '';
+    event.preventDefault();
+    start.style.display = 'none';
+    finishJSTest();
+});
+
+if (window.testRunner)
+    start.click();
+
+</script>
+</body>
+</html>

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (249706 => 249707)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-09-10 05:30:56 UTC (rev 249707)
@@ -1,3 +1,49 @@
+2019-09-09  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION (iOS 13): Bulleted list copied from Notes to Mail results in Times New Roman
+        https://bugs.webkit.org/show_bug.cgi?id=201490
+
+        Reviewed by Daniel Bates.
+
+        The bug was caused by an element in the pasted content not having any explicit font name resolving
+        to use the font-family value of `-webkit-standard`. When such an inline style is inserted into
+        Mail's WKWebView which sets a different font family, ReplaceSelectionCommand would fail to strip away,
+        making the pasted content using the default font family of Times New Roman.
+
+        Fixed the bug by stripping away font-family set to -webkit-standard in the sanitization document
+        since that's indicative of the pasted content not having any font family being specified.
+
+        In the future, we should consider making regular copy (as opposed to the copy for sanitization)
+        resolve generic font family names to concrete font names since different WKWebView might be using
+        different concrete font names. Unfortuantely, such a change is quite involved and risky since various
+        paste side code in EditingStyle that removes redundant inline styles (i.e. redundant `font-family`)
+        need to be aware of this special font family resolution.
+
+        Tests: editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html
+               PasteHTML.DoesNotAddStandardFontFamily
+
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
+        (WebCore::EditingStyle::wrappingStyleForSerialization):
+        (WebCore::familyNameFromCSSPrimitiveValue): Added.
+        (WebCore::loneFontFamilyName): Extracted from usesForbiddenSystemFontAsOnlyFontFamilyName. Fixed
+        a bug that it was not handling the case when `font-family` property's value is a CSSPrimitiveValue
+        instead of a CSSValueList.
+        (WebCore::usesForbiddenSystemFontAsOnlyFontFamilyName): Deleted.
+        (WebCore::EditingStyle::mergeStyleFromRulesForSerialization): Remove `font-family` property when
+        StandardFontFamilySerializationMode::Strip is specified and its value is `-webkit-standard`.
+        * editing/EditingStyle.h:
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator): Added
+        StandardFontFamilySerializationMode as an argument.
+        (WebCore::StyledMarkupAccumulator::appendStartTag):
+        (WebCore::StyledMarkupAccumulator::serializeNodes):
+        (WebCore::serializePreservingVisualAppearanceInternal): Ditto.
+        (WebCore::serializePreservingVisualAppearance): Use StandardFontFamilySerializationMode::Keep
+        to preserve the pre-existing behavior.
+        (WebCore::sanitizedMarkupForFragmentInDocument): Use StandardFontFamilySerializationMode::Strip
+        as this is the code used by sanitization code.
+
 2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r249605. rdar://problem/55182896

Modified: branches/safari-608-branch/Source/WebCore/editing/EditingStyle.cpp (249706 => 249707)


--- branches/safari-608-branch/Source/WebCore/editing/EditingStyle.cpp	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Source/WebCore/editing/EditingStyle.cpp	2019-09-10 05:30:56 UTC (rev 249707)
@@ -1157,10 +1157,10 @@
     return copyEditingProperties(style, AllEditingProperties);
 }
 
-void EditingStyle::mergeInlineAndImplicitStyleOfElement(StyledElement& element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
+void EditingStyle::mergeInlineAndImplicitStyleOfElement(StyledElement& element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude, StandardFontFamilySerializationMode standardFontFamilySerializationMode)
 {
     auto styleFromRules = EditingStyle::create();
-    styleFromRules->mergeStyleFromRulesForSerialization(element);
+    styleFromRules->mergeStyleFromRulesForSerialization(element, standardFontFamilySerializationMode);
 
     if (element.inlineStyle())
         styleFromRules->m_mutableStyle->mergeAndOverrideOnConflict(*element.inlineStyle());
@@ -1181,7 +1181,7 @@
     }
 }
 
-Ref<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node& context, bool shouldAnnotate)
+Ref<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node& context, bool shouldAnnotate, StandardFontFamilySerializationMode standardFontFamilySerializationMode)
 {
     if (shouldAnnotate) {
         auto wrappingStyle = EditingStyle::create(&context, EditingStyle::EditingPropertiesInEffect);
@@ -1202,7 +1202,7 @@
     // When not annotating for interchange, we only preserve inline style declarations.
     for (Node* node = &context; node && !node->isDocumentNode(); node = node->parentNode()) {
         if (is<StyledElement>(*node) && !isMailBlockquote(node))
-            wrappingStyle->mergeInlineAndImplicitStyleOfElement(downcast<StyledElement>(*node), EditingStyle::DoNotOverrideValues, EditingStyle::EditingPropertiesInEffect);
+            wrappingStyle->mergeInlineAndImplicitStyleOfElement(downcast<StyledElement>(*node), DoNotOverrideValues, EditingPropertiesInEffect, standardFontFamilySerializationMode);
     }
 
     return wrappingStyle;
@@ -1282,22 +1282,29 @@
     m_mutableStyle = styleFromMatchedRules;
 }
 
-static bool usesForbiddenSystemFontAsOnlyFontFamilyName(CSSValue& value)
+static String familyNameFromCSSPrimitiveValue(const CSSPrimitiveValue& primitiveValue)
 {
+    if (!primitiveValue.isFontFamily())
+        return { };
+    return primitiveValue.fontFamily().familyName;
+}
+
+static String loneFontFamilyName(const CSSValue& value)
+{
+    if (is<CSSPrimitiveValue>(value))
+        return familyNameFromCSSPrimitiveValue(downcast<CSSPrimitiveValue>(value));
+
     if (!is<CSSValueList>(value) || downcast<CSSValueList>(value).length() != 1)
-        return false;
+        return { };
 
     auto& item = *downcast<CSSValueList>(value).item(0);
     if (!is<CSSPrimitiveValue>(item))
-        return false;
+        return { };
 
-    auto& primitiveValue = downcast<CSSPrimitiveValue>(item);
-    if (!primitiveValue.isFontFamily())
-        return false;
-    return FontCache::isSystemFontForbiddenForEditing(primitiveValue.fontFamily().familyName);
+    return familyNameFromCSSPrimitiveValue(downcast<CSSPrimitiveValue>(item));
 }
 
-void EditingStyle::mergeStyleFromRulesForSerialization(StyledElement& element)
+void EditingStyle::mergeStyleFromRulesForSerialization(StyledElement& element, StandardFontFamilySerializationMode standardFontFamilySerializationMode)
 {
     mergeStyleFromRules(element);
 
@@ -1313,8 +1320,11 @@
         for (unsigned i = 0; i < propertyCount; ++i) {
             StyleProperties::PropertyReference property = m_mutableStyle->propertyAt(i);
             CSSValue& value = *property.value();
-            if (property.id() == CSSPropertyFontFamily && usesForbiddenSystemFontAsOnlyFontFamilyName(value)) {
-                shouldRemoveFontFamily = true;
+            if (property.id() == CSSPropertyFontFamily) {
+                auto familyName = loneFontFamilyName(value);
+                if (FontCache::isSystemFontForbiddenForEditing(familyName)
+                    || (standardFontFamilySerializationMode == StandardFontFamilySerializationMode::Strip && familyName == standardFamily))
+                    shouldRemoveFontFamily = true;
                 continue;
             }
             if (!is<CSSPrimitiveValue>(value))

Modified: branches/safari-608-branch/Source/WebCore/editing/EditingStyle.h (249706 => 249707)


--- branches/safari-608-branch/Source/WebCore/editing/EditingStyle.h	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Source/WebCore/editing/EditingStyle.h	2019-09-10 05:30:56 UTC (rev 249707)
@@ -60,6 +60,9 @@
 
 enum class TextDecorationChange { None, Add, Remove };
 
+// FIXME: "Keep" should be "Resolve" instead and resolve all generic font family names.
+enum class StandardFontFamilySerializationMode : uint8_t { Keep, Strip };
+
 class EditingStyle : public RefCounted<EditingStyle> {
 public:
 
@@ -141,9 +144,9 @@
     void mergeTypingStyle(Document&);
     enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues };
     void mergeInlineStyleOfElement(StyledElement&, CSSPropertyOverrideMode, PropertiesToInclude = AllProperties);
-    static Ref<EditingStyle> wrappingStyleForSerialization(Node& context, bool shouldAnnotate);
+    static Ref<EditingStyle> wrappingStyleForSerialization(Node& context, bool shouldAnnotate, StandardFontFamilySerializationMode);
     void mergeStyleFromRules(StyledElement&);
-    void mergeStyleFromRulesForSerialization(StyledElement&);
+    void mergeStyleFromRulesForSerialization(StyledElement&, StandardFontFamilySerializationMode);
     void removeStyleFromRulesAndContext(StyledElement&, Node* context);
     void removePropertiesInElementDefaultStyle(Element&);
     void forceInline();
@@ -181,7 +184,7 @@
     void extractFontSizeDelta();
     template<typename T> TriState triStateOfStyle(T& styleToCompare, ShouldIgnoreTextOnlyProperties) const;
     bool conflictsWithInlineStyleOfElement(StyledElement&, RefPtr<MutableStyleProperties>* newInlineStyle, EditingStyle* extractedStyle) const;
-    void mergeInlineAndImplicitStyleOfElement(StyledElement&, CSSPropertyOverrideMode, PropertiesToInclude);
+    void mergeInlineAndImplicitStyleOfElement(StyledElement&, CSSPropertyOverrideMode, PropertiesToInclude, StandardFontFamilySerializationMode);
     void mergeStyle(const StyleProperties*, CSSPropertyOverrideMode);
 
     RefPtr<MutableStyleProperties> m_mutableStyle;

Modified: branches/safari-608-branch/Source/WebCore/editing/markup.cpp (249706 => 249707)


--- branches/safari-608-branch/Source/WebCore/editing/markup.cpp	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Source/WebCore/editing/markup.cpp	2019-09-10 05:30:56 UTC (rev 249707)
@@ -222,7 +222,7 @@
     enum RangeFullySelectsNode { DoesFullySelectNode, DoesNotFullySelectNode };
 
     StyledMarkupAccumulator(const Position& start, const Position& end, Vector<Node*>* nodes, ResolveURLs, SerializeComposedTree,
-        AnnotateForInterchange, MSOListMode, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized = nullptr);
+        AnnotateForInterchange, StandardFontFamilySerializationMode, MSOListMode, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized = nullptr);
 
     Node* serializeNodes(const Position& start, const Position& end);
     void wrapWithNode(Node&, bool convertBlocksToInlines = false, RangeFullySelectsNode = DoesFullySelectNode);
@@ -318,14 +318,15 @@
     RefPtr<EditingStyle> m_wrappingStyle;
     bool m_useComposedTree;
     bool m_needsPositionStyleConversion;
+    StandardFontFamilySerializationMode m_standardFontFamilySerializationMode;
+    bool m_shouldPreserveMSOList;
     bool m_needRelativeStyleWrapper { false };
     bool m_needClearingDiv { false };
-    bool m_shouldPreserveMSOList;
     bool m_inMSOList { false };
 };
 
 inline StyledMarkupAccumulator::StyledMarkupAccumulator(const Position& start, const Position& end, Vector<Node*>* nodes, ResolveURLs urlsToResolve, SerializeComposedTree serializeComposedTree,
-    AnnotateForInterchange annotate, MSOListMode msoListMode, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
+    AnnotateForInterchange annotate, StandardFontFamilySerializationMode standardFontFamilySerializationMode, MSOListMode msoListMode, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
     : MarkupAccumulator(nodes, urlsToResolve)
     , m_start(start)
     , m_end(end)
@@ -333,6 +334,7 @@
     , m_highestNodeToBeSerialized(highestNodeToBeSerialized)
     , m_useComposedTree(serializeComposedTree == SerializeComposedTree::Yes)
     , m_needsPositionStyleConversion(needsPositionStyleConversion)
+    , m_standardFontFamilySerializationMode(standardFontFamilySerializationMode)
     , m_shouldPreserveMSOList(msoListMode == MSOListMode::Preserve)
 {
 }
@@ -531,7 +533,7 @@
 
         if (shouldAnnotateOrForceInline) {
             if (shouldAnnotate())
-                newInlineStyle->mergeStyleFromRulesForSerialization(downcast<HTMLElement>(*const_cast<Element*>(&element)));
+                newInlineStyle->mergeStyleFromRulesForSerialization(downcast<HTMLElement>(*const_cast<Element*>(&element)), m_standardFontFamilySerializationMode);
 
             if (addDisplayInline)
                 newInlineStyle->forceInline();
@@ -579,7 +581,7 @@
     }
 
     if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode())
-        m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(*m_highestNodeToBeSerialized->parentNode(), shouldAnnotate());
+        m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(*m_highestNodeToBeSerialized->parentNode(), shouldAnnotate(), m_standardFontFamilySerializationMode);
 
     return traverseNodesForSerialization(startNode.get(), pastEnd, NodeTraversalMode::EmitString);
 }
@@ -822,7 +824,7 @@
 }
 
 static String serializePreservingVisualAppearanceInternal(const Position& start, const Position& end, Vector<Node*>* nodes, ResolveURLs urlsToResolve, SerializeComposedTree serializeComposedTree,
-    AnnotateForInterchange annotate, ConvertBlocksToInlines convertBlocksToInlines, MSOListMode msoListMode)
+    AnnotateForInterchange annotate, ConvertBlocksToInlines convertBlocksToInlines, StandardFontFamilySerializationMode standardFontFamilySerializationMode, MSOListMode msoListMode)
 {
     static NeverDestroyed<const String> interchangeNewlineString(MAKE_STATIC_STRING_IMPL("<br class=\"" AppleInterchangeNewline "\">"));
 
@@ -848,7 +850,7 @@
 
     Node* specialCommonAncestor = highestAncestorToWrapMarkup(start, end, *commonAncestor, annotate);
 
-    StyledMarkupAccumulator accumulator(start, end, nodes, urlsToResolve, serializeComposedTree, annotate, msoListMode, needsPositionStyleConversion, specialCommonAncestor);
+    StyledMarkupAccumulator accumulator(start, end, nodes, urlsToResolve, serializeComposedTree, annotate, standardFontFamilySerializationMode, msoListMode, needsPositionStyleConversion, specialCommonAncestor);
 
     Position startAdjustedForInterchangeNewline = start;
     if (annotate == AnnotateForInterchange::Yes && needInterchangeNewlineAfter(visibleStart)) {
@@ -917,13 +919,13 @@
 String serializePreservingVisualAppearance(const Range& range, Vector<Node*>* nodes, AnnotateForInterchange annotate, ConvertBlocksToInlines convertBlocksToInlines, ResolveURLs urlsToReslve)
 {
     return serializePreservingVisualAppearanceInternal(range.startPosition(), range.endPosition(), nodes, urlsToReslve, SerializeComposedTree::No,
-        annotate, convertBlocksToInlines, MSOListMode::DoNotPreserve);
+        annotate, convertBlocksToInlines, StandardFontFamilySerializationMode::Keep, MSOListMode::DoNotPreserve);
 }
 
 String serializePreservingVisualAppearance(const VisibleSelection& selection, ResolveURLs resolveURLs, SerializeComposedTree serializeComposedTree, Vector<Node*>* nodes)
 {
     return serializePreservingVisualAppearanceInternal(selection.start(), selection.end(), nodes, resolveURLs, serializeComposedTree,
-        AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, MSOListMode::DoNotPreserve);
+        AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, StandardFontFamilySerializationMode::Keep, MSOListMode::DoNotPreserve);
 }
 
 
@@ -950,7 +952,7 @@
 
     // SerializeComposedTree::No because there can't be a shadow tree in the pasted fragment.
     auto result = serializePreservingVisualAppearanceInternal(firstPositionInNode(bodyElement.get()), lastPositionInNode(bodyElement.get()), nullptr,
-        ResolveURLs::YesExcludingLocalFileURLsForPrivacy, SerializeComposedTree::No, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No,  msoListMode);
+        ResolveURLs::YesExcludingLocalFileURLsForPrivacy, SerializeComposedTree::No, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No,  StandardFontFamilySerializationMode::Strip, msoListMode);
 
     if (msoListMode == MSOListMode::Preserve) {
         StringBuilder builder;

Modified: branches/safari-608-branch/Tools/ChangeLog (249706 => 249707)


--- branches/safari-608-branch/Tools/ChangeLog	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-09-10 05:30:56 UTC (rev 249707)
@@ -1,3 +1,16 @@
+2019-09-09  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION (iOS 13): Bulleted list copied from Notes to Mail results in Times New Roman
+        https://bugs.webkit.org/show_bug.cgi?id=201490
+
+        Reviewed by Daniel Bates.
+
+        Added a test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-lists.html: Added.
+
 2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r249605. rdar://problem/55182896

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (249706 => 249707)


--- branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-09-10 05:30:56 UTC (rev 249707)
@@ -714,6 +714,7 @@
 		9B62630C1F8C25C8007EE29B /* copy-url.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B62630B1F8C2510007EE29B /* copy-url.html */; };
 		9B7A37C41F8AEBA5004AA228 /* CopyURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B7A37C21F8AEBA5004AA228 /* CopyURL.mm */; };
 		9B7D740F1F8378770006C432 /* paste-rtfd.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B7D740E1F8377E60006C432 /* paste-rtfd.html */; };
+		9B9332CE2320C745002D50E8 /* cocoa-writer-markup-with-lists.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B9332CD2320C73E002D50E8 /* cocoa-writer-markup-with-lists.html */; };
 		9BAD7F3E22690F2000F8DA66 /* DeallocWebViewInEventListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BAD7F3D22690F1400F8DA66 /* DeallocWebViewInEventListener.mm */; };
 		9BAE177B22E2BBFB00DF3098 /* cocoa-writer-markup-with-system-fonts.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9BAE177A22E2BB6B00DF3098 /* cocoa-writer-markup-with-system-fonts.html */; };
 		9BCB7C2820130600003E7C0C /* PasteHTML.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BCB7C2620130600003E7C0C /* PasteHTML.mm */; };
@@ -1141,6 +1142,7 @@
 				1A50AA201A2A51FC00F4C345 /* close-from-within-create-page.html in Copy Resources */,
 				9B270FEE1DDC2C0B002D53F3 /* closed-shadow-tree-test.html in Copy Resources */,
 				E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */,
+				9B9332CE2320C745002D50E8 /* cocoa-writer-markup-with-lists.html in Copy Resources */,
 				F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */,
 				5C9E56871DF914AE00C9EE33 /* contentBlockerCheck.html in Copy Resources */,
 				F469FB241F01804B00401539 /* contenteditable-and-target.html in Copy Resources */,
@@ -2060,6 +2062,7 @@
 		9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderScrollingPosition.mm; sourceTree = "<group>"; };
 		9B7A37C21F8AEBA5004AA228 /* CopyURL.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CopyURL.mm; sourceTree = "<group>"; };
 		9B7D740E1F8377E60006C432 /* paste-rtfd.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "paste-rtfd.html"; sourceTree = "<group>"; };
+		9B9332CD2320C73E002D50E8 /* cocoa-writer-markup-with-lists.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "cocoa-writer-markup-with-lists.html"; sourceTree = "<group>"; };
 		9BAD7F3D22690F1400F8DA66 /* DeallocWebViewInEventListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeallocWebViewInEventListener.mm; sourceTree = "<group>"; };
 		9BAE177A22E2BB6B00DF3098 /* cocoa-writer-markup-with-system-fonts.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "cocoa-writer-markup-with-system-fonts.html"; sourceTree = "<group>"; };
 		9BCB7C2620130600003E7C0C /* PasteHTML.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteHTML.mm; sourceTree = "<group>"; };
@@ -3136,6 +3139,7 @@
 				E5036F77211BC22800BFDBE2 /* color-drop.html */,
 				F4B825D61EF4DBD4006E417F /* compressed-files.zip */,
 				F469FB231F01803500401539 /* contenteditable-and-target.html */,
+				9B9332CD2320C73E002D50E8 /* cocoa-writer-markup-with-lists.html */,
 				F41AB99C1EF4692C0083FA08 /* contenteditable-and-textarea.html */,
 				F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */,
 				A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */,

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm (249706 => 249707)


--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm	2019-09-10 05:03:13 UTC (rev 249706)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm	2019-09-10 05:30:56 UTC (rev 249707)
@@ -358,3 +358,30 @@
 }
 
 #endif // PLATFORM(COCOA)
+TEST(PasteHTML, DoesNotAddStandardFontFamily)
+{
+    writeHTMLToPasteboard([NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cocoa-writer-markup-with-lists" ofType:@"html" inDirectory:@"TestWebKitAPI.resources"] encoding:NSUTF8StringEncoding error:NULL]);
+
+    auto webView = createWebViewWithCustomPasteboardDataSetting(true);
+    [webView synchronouslyLoadTestPageNamed:@"paste-rtfd"];
+    [webView stringByEvaluatingJavaScript:@"document.body.style.fontFamily = 'Arial'"];
+    [webView paste:nil];
+
+    EXPECT_WK_STREQ("[\"text/html\"]", [webView stringByEvaluatingJavaScript:@"JSON.stringify(clipboardData.types)"]);
+    [webView stringByEvaluatingJavaScript:@"window.htmlInDataTransfer = clipboardData.values[0]"];
+    [webView stringByEvaluatingJavaScript:@"window.pastedHTML = editor.innerHTML"];
+
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('Hello')"].boolValue);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('font-weight: bold')"].boolValue);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!pastedHTML.includes('-webkit-standard')"].boolValue);
+
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('Hello')"].boolValue);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('font-weight: bold')"].boolValue);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!htmlInDataTransfer.includes('-webkit-standard')"].boolValue);
+
+    EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getComputedStyle(document.querySelector('.s2')).fontFamily"],
+        [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.body).fontFamily"]);
+    EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getComputedStyle(document.querySelector('.s4')).fontFamily"],
+        [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.body).fontFamily"]);
+}
+

Added: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-lists.html (0 => 249707)


--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-lists.html	                        (rev 0)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-lists.html	2019-09-10 05:30:56 UTC (rev 249707)
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<title></title>
+<meta name="Generator" content="Cocoa HTML Writer">
+<style type="text/css">
+p.p1 {margin: 0.0px 0.0px 3.0px 0.0px; font: 22.0px '.AppleSystemUIFont'; color: #454545; min-height: 26.3px}
+p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 17.0px '.SF UI Mono'; color: #454545}
+li.li2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 17.0px '.AppleSystemUIFont'; color: #454545}
+span.s1 {font-family: '.SFUI-Heavy'; font-weight: bold; font-style: normal; font-size: 22.00px}
+span.s2 {font-family: '.SFUI-Regular'; font-weight: normal; font-style: normal; font-size: 12.00px}
+span.s3 {font-family: '.SFUI-Regular'; font-weight: normal; font-style: normal; font-size: 17.00px}
+span.s4 {font-family: '.SFUI-Semibold'; font-weight: bold; font-style: normal; font-size: 17.00px}
+span.s5 {font-family: '.SFUIMono-Regular'; font-weight: normal; font-style: normal; font-size: 17.00px}
+ul.ul1 {list-style-type: hyphen}
+</style>
+</head>
+<body>
+<p class="p1"><span class="s1"></span><br></p>
+<ul class="ul1">
+<li class="li2"><span class="s2"></span><span class="s3">Hello</span></li>
+<li class="li2"><span class="s2"></span><span class="s4">World</span></li>
+</ul>
+<p class="p3"><span class="s5">World</span></p>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to