Title: [262323] trunk/Source/WebCore
- Revision
- 262323
- Author
- [email protected]
- Date
- 2020-05-29 16:09:46 -0700 (Fri, 29 May 2020)
Log Message
[iOS] Unable to paste images when composing mail at yahoo.com
https://bugs.webkit.org/show_bug.cgi?id=212544
<rdar://problem/63511613>
Reviewed by Megan Gardner and Andy Estes.
When pasting images in the mobile version of the mail compose editor on mail.yahoo.com, mail.yahoo.com's script
handles the paste by allowing images to be inserted into the DOM (i.e. by not preventing the "paste" event), and
then stripping away the `src` attribute of the pasted image afterwards. This leaves behind a blank space in the
email.
Work around this by avoiding images when converting the contents of the pasteboard into web content on iOS.
Instead, we fall back to inserting (sanitized) text, or nothing at all if there is no other representation
suitable for converting into web content.
Unfortunately, the mobile version of the website is loaded on iPad as well, even when the desktop website has
been requested (through sending the macOS user agent and "MacIntel" navigator platform).
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::WebContentReader::readImage):
* page/Quirks.cpp:
(WebCore::Quirks::shouldAvoidPastingImagesAsWebContent const):
* page/Quirks.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (262322 => 262323)
--- trunk/Source/WebCore/ChangeLog 2020-05-29 23:03:46 UTC (rev 262322)
+++ trunk/Source/WebCore/ChangeLog 2020-05-29 23:09:46 UTC (rev 262323)
@@ -1,3 +1,29 @@
+2020-05-29 Wenson Hsieh <[email protected]>
+
+ [iOS] Unable to paste images when composing mail at yahoo.com
+ https://bugs.webkit.org/show_bug.cgi?id=212544
+ <rdar://problem/63511613>
+
+ Reviewed by Megan Gardner and Andy Estes.
+
+ When pasting images in the mobile version of the mail compose editor on mail.yahoo.com, mail.yahoo.com's script
+ handles the paste by allowing images to be inserted into the DOM (i.e. by not preventing the "paste" event), and
+ then stripping away the `src` attribute of the pasted image afterwards. This leaves behind a blank space in the
+ email.
+
+ Work around this by avoiding images when converting the contents of the pasteboard into web content on iOS.
+ Instead, we fall back to inserting (sanitized) text, or nothing at all if there is no other representation
+ suitable for converting into web content.
+
+ Unfortunately, the mobile version of the website is loaded on iPad as well, even when the desktop website has
+ been requested (through sending the macOS user agent and "MacIntel" navigator platform).
+
+ * editing/cocoa/WebContentReaderCocoa.mm:
+ (WebCore::WebContentReader::readImage):
+ * page/Quirks.cpp:
+ (WebCore::Quirks::shouldAvoidPastingImagesAsWebContent const):
+ * page/Quirks.h:
+
2020-05-29 Darin Adler <[email protected]>
Remove things from FeatureDefines.xcconfig that are covered by PlatformEnableCocoa.h
Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (262322 => 262323)
--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2020-05-29 23:03:46 UTC (rev 262322)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2020-05-29 23:09:46 UTC (rev 262323)
@@ -53,6 +53,7 @@
#import "MIMETypeRegistry.h"
#import "Page.h"
#import "PublicURLManager.h"
+#import "Quirks.h"
#import "RenderView.h"
#import "RuntimeEnabledFeatures.h"
#import "SerializedAttachmentData.h"
@@ -678,6 +679,9 @@
{
ASSERT(frame.document());
auto& document = *frame.document();
+ if (document.quirks().shouldAvoidPastingImagesAsWebContent())
+ return false;
+
if (shouldReplaceRichContentWithAttachments())
addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize));
else
Modified: trunk/Source/WebCore/page/Quirks.cpp (262322 => 262323)
--- trunk/Source/WebCore/page/Quirks.cpp 2020-05-29 23:03:46 UTC (rev 262322)
+++ trunk/Source/WebCore/page/Quirks.cpp 2020-05-29 23:09:46 UTC (rev 262323)
@@ -815,4 +815,20 @@
return isFirstSyntheticClickOnPage && (equalLettersIgnoringASCIICase(host, "shutterstock.com") || host.endsWithIgnoringASCIICase(".shutterstock.com"));
}
+bool Quirks::shouldAvoidPastingImagesAsWebContent() const
+{
+ if (!needsQuirks())
+ return false;
+
+#if PLATFORM(IOS_FAMILY)
+ if (!m_shouldAvoidPastingImagesAsWebContent) {
+ auto host = m_document->topDocument().url().host().toString();
+ m_shouldAvoidPastingImagesAsWebContent = host.startsWithIgnoringASCIICase("mail.") && topPrivatelyControlledDomain(host).startsWith("yahoo.");
+ }
+ return *m_shouldAvoidPastingImagesAsWebContent;
+#else
+ return false;
+#endif
}
+
+}
Modified: trunk/Source/WebCore/page/Quirks.h (262322 => 262323)
--- trunk/Source/WebCore/page/Quirks.h 2020-05-29 23:03:46 UTC (rev 262322)
+++ trunk/Source/WebCore/page/Quirks.h 2020-05-29 23:09:46 UTC (rev 262323)
@@ -102,6 +102,8 @@
bool needsCanPlayAfterSeekedQuirk() const;
+ bool shouldAvoidPastingImagesAsWebContent() const;
+
private:
bool needsQuirks() const;
@@ -119,6 +121,7 @@
mutable Optional<bool> m_needsYouTubeOverflowScrollQuirk;
mutable Optional<bool> m_needsPreloadAutoQuirk;
mutable Optional<bool> m_needsFullscreenDisplayNoneQuirk;
+ mutable Optional<bool> m_shouldAvoidPastingImagesAsWebContent;
#endif
mutable Optional<bool> m_shouldDisableElementFullscreenQuirk;
#if ENABLE(TOUCH_EVENTS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes