WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Refactoring
bug-176770-20170912020517.patch (text/plain), 65.63 KB, created by
Ryosuke Niwa
on 2017-09-12 02:05:17 PDT
(
hide
)
Description:
Refactoring
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2017-09-12 02:05:17 PDT
Size:
65.63 KB
patch
obsolete
>Subversion Revision: 221901 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 258863a25fb544ff7049b9129e59361f81143778..38439643ca4436b9105e595ccbaeebbdbe710f3c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,76 @@ >+2017-09-12 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Refactor WebContentReader out of EditorMac and EditorIOS >+ https://bugs.webkit.org/show_bug.cgi?id=176770 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Extracted WebContentReader.h, WebContentReaderMac.mm, and WebContentIOS.mm from Pasteboard.h, >+ EditorMac.mm, and EditorIOS.mm respectively. >+ >+ Also moved createFragmentForImageResourceAndAddResource and createFragmentAndAddResources >+ from EditorCocoa.mm to WebContentReader.mm, and createFragmentForImageAndURL to markup.cpp. >+ >+ * Configurations/WebCore.xcconfig: >+ * PlatformMac.cmake: >+ * WebCore.xcodeproj/project.pbxproj: >+ * editing/Editor.cpp: >+ (WebCore::Editor::createFragmentForImageAndURL): Deleted. >+ * editing/Editor.h: >+ * editing/WebContentReader.h: Added. >+ * editing/cocoa/EditorCocoa.mm: >+ (WebCore::Editor::replaceSelectionWithAttributedString): >+ (WebCore::Editor::createFragment): Deleted. >+ (WebCore::Editor::createFragmentForImageResourceAndAddResource): Deleted. >+ (WebCore::Editor::createFragmentAndAddResources): Deleted. >+ * editing/cocoa/WebContentReaderCocoa.mm: Added. >+ (WebCore::createFragmentForImageResourceAndAddResource): >+ (WebCore::createFragment): >+ (WebCore::createFragmentAndAddResources): >+ * editing/ios/EditorIOS.mm: >+ (): Deleted. >+ (WebCore::Editor::WebContentReader::addFragment): Deleted. >+ (WebCore::Editor::WebContentReader::readWebArchive): Deleted. >+ (WebCore::Editor::WebContentReader::readFilenames): Deleted. >+ (WebCore::Editor::WebContentReader::readHTML): Deleted. >+ (WebCore::Editor::WebContentReader::readRTFD): Deleted. >+ (WebCore::Editor::WebContentReader::readRTF): Deleted. >+ (WebCore::Editor::WebContentReader::readImage): Deleted. >+ (WebCore::Editor::WebContentReader::readURL): Deleted. >+ (WebCore::Editor::WebContentReader::readPlainText): Deleted. >+ * editing/ios/WebContentReaderIOS.mm: Added. >+ (WebCore::WebContentReader::addFragment): >+ (WebCore::WebContentReader::readWebArchive): >+ (WebCore::WebContentReader::readFilenames): >+ (WebCore::WebContentReader::readHTML): >+ (WebCore::WebContentReader::readRTFD): >+ (WebCore::WebContentReader::readRTF): >+ (WebCore::WebContentReader::readImage): >+ (WebCore::WebContentReader::readURL): >+ (WebCore::WebContentReader::readPlainText): >+ * editing/mac/EditorMac.mm: >+ (): Deleted. >+ (WebCore::Editor::WebContentReader::readWebArchive): Deleted. >+ (WebCore::Editor::WebContentReader::readFilenames): Deleted. >+ (WebCore::Editor::WebContentReader::readHTML): Deleted. >+ (WebCore::Editor::WebContentReader::readRTFD): Deleted. >+ (WebCore::Editor::WebContentReader::readRTF): Deleted. >+ (WebCore::Editor::WebContentReader::readImage): Deleted. >+ (WebCore::Editor::WebContentReader::readURL): Deleted. >+ (WebCore::Editor::WebContentReader::readPlainText): Deleted. >+ * editing/mac/WebContentReaderMac.mm: Added. >+ (WebCore::WebContentReader::readWebArchive): >+ (WebCore::WebContentReader::readFilenames): >+ (WebCore::WebContentReader::readHTML): >+ (WebCore::WebContentReader::readRTFD): >+ (WebCore::WebContentReader::readRTF): >+ (WebCore::WebContentReader::readImage): >+ (WebCore::WebContentReader::readURL): >+ (WebCore::WebContentReader::readPlainText): >+ * editing/markup.cpp: >+ (WebCore::createFragmentForImageAndURL): >+ * editing/markup.h: >+ > 2017-09-11 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS WK2] Support tapping to add items to the current drag session in web content >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 856a1aee981a9d6f0431d1f4c5af0ca9ad2a2c70..7112d30cc6f80e92a51d1abcad28186558da4383 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,12 @@ >+2017-09-12 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Refactor WebContentReader out of EditorMac and EditorIOS >+ https://bugs.webkit.org/show_bug.cgi?id=176770 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebEditorClient.mm: >+ > 2017-09-11 Andy Estes <aestes@apple.com> > > [Mac] Upstream QTKit-related WebKitSystemInterface functions >diff --git a/Source/WebCore/Configurations/WebCore.xcconfig b/Source/WebCore/Configurations/WebCore.xcconfig >index 35fc3e795ff8a29cb031c0593c26bebcddf3e447..76667bae740471d745a9512205eb1cf49d7a3235 100644 >--- a/Source/WebCore/Configurations/WebCore.xcconfig >+++ b/Source/WebCore/Configurations/WebCore.xcconfig >@@ -120,7 +120,7 @@ EXCLUDED_SOURCE_FILE_NAMES_FOR_TOUCH_EVENTS_IF_ENABLED_ = JSTouch*; > EXCLUDED_SOURCE_FILE_NAMES_FOR_GESTURE_EVENTS = $(EXCLUDED_SOURCE_FILE_NAMES_FOR_GESTURE_EVENTS_IF_ENABLED_$(ENABLE_IOS_GESTURE_EVENTS)$(ENABLE_MAC_GESTURE_EVENTS)); > EXCLUDED_SOURCE_FILE_NAMES_FOR_GESTURE_EVENTS_IF_ENABLED_ = JSGesture* DOMGesture*; > >-EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = *.tiff *Cursor.png AccessibilityObjectMac.mm AXObjectCacheMac.mm ColorMac.mm Cursor.cpp CursorMac.mm DataTransferMac.mm EditorMac.mm EventHandlerMac.mm EventLoopMac.mm GeolocationServiceMac.mm GraphicsContext3DOpenGLES.cpp IconDatabase.cpp IconMac.mm LocalCurrentGraphicsContext.mm MIMETypeRegistryMac.mm MediaPlayerPrivateQTKit.mm NSScrollerImpDetails.mm NetworkStateNotifierMac.cpp PasteboardMac.mm PlatformEventFactoryMac.mm PlatformMouseEventMac.mm PlatformPasteboardMac.mm PlatformScreenMac.mm PlatformSpeechSynthesizerMac.mm RunLoopMac.mm SSLKeyGeneratorMac.mm ScrollViewMac.mm ScrollbarThemeMac.mm SharedTimerMac.mm SystemTimeMac.cpp ThemeMac.mm ThreadCheck.mm UserAgentMac.mm WebAccessibilityObjectWrapperMac.mm WebCoreSystemInterface.mm WebCoreView.m WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm WidgetMac.mm DisplayRefreshMonitorMac.cpp npapi.h npfunctions.h npruntime.h npruntime_internal.h $(EXCLUDED_SOURCE_FILE_NAMES_FOR_TOUCH_EVENTS) $(EXCLUDED_SOURCE_FILE_NAMES_FOR_GESTURE_EVENTS); >+EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = *.tiff *Cursor.png AccessibilityObjectMac.mm AXObjectCacheMac.mm ColorMac.mm Cursor.cpp CursorMac.mm DataTransferMac.mm EditorMac.mm EventHandlerMac.mm EventLoopMac.mm GeolocationServiceMac.mm GraphicsContext3DOpenGLES.cpp IconDatabase.cpp IconMac.mm LocalCurrentGraphicsContext.mm MIMETypeRegistryMac.mm MediaPlayerPrivateQTKit.mm NSScrollerImpDetails.mm NetworkStateNotifierMac.cpp PasteboardMac.mm PlatformEventFactoryMac.mm PlatformMouseEventMac.mm PlatformPasteboardMac.mm PlatformScreenMac.mm PlatformSpeechSynthesizerMac.mm RunLoopMac.mm SSLKeyGeneratorMac.mm ScrollViewMac.mm ScrollbarThemeMac.mm SharedTimerMac.mm SystemTimeMac.cpp ThemeMac.mm ThreadCheck.mm UserAgentMac.mm WebAccessibilityObjectWrapperMac.mm WebContentReaderMac.mm WebCoreSystemInterface.mm WebCoreView.m WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm WidgetMac.mm DisplayRefreshMonitorMac.cpp npapi.h npfunctions.h npruntime.h npruntime_internal.h $(EXCLUDED_SOURCE_FILE_NAMES_FOR_TOUCH_EVENTS) $(EXCLUDED_SOURCE_FILE_NAMES_FOR_GESTURE_EVENTS); > EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] = *IOS.h *IOS.cpp *IOS.mm WAKAppKitStubs.h WAKClipView.h WAKResponder.h WAKScrollView.h WAKView.h WAKViewPrivate.h WAKWindow.h WKContentObservation.h WKGraphics.h WKTypes.h WKUtilities.h WKView.h WKViewPrivate.h WebCoreThread.h WebCoreThreadMessage.h WebCoreThreadRun.h WebCoreThreadSystemInterface.h $(EXCLUDED_SOURCE_FILE_NAMES_FOR_TOUCH_EVENTS) $(EXCLUDED_SOURCE_FILE_NAMES_FOR_GESTURE_EVENTS); > > WK_EMPTY_ = YES; >diff --git a/Source/WebCore/PlatformMac.cmake b/Source/WebCore/PlatformMac.cmake >index 55008e669d07dcff3050508f82568f714db360f6..072c6f5fdebb9a9c905b4224c517fbdd5b7c8025 100644 >--- a/Source/WebCore/PlatformMac.cmake >+++ b/Source/WebCore/PlatformMac.cmake >@@ -203,6 +203,7 @@ list(APPEND WebCore_SOURCES > editing/cocoa/DataDetection.mm > editing/cocoa/EditorCocoa.mm > editing/cocoa/HTMLConverter.mm >+ editing/cocoa/WebContentReaderCocoa.mm > > editing/mac/AlternativeTextUIController.mm > editing/mac/DictionaryLookup.mm >@@ -210,6 +211,7 @@ list(APPEND WebCore_SOURCES > editing/mac/FrameSelectionMac.mm > editing/mac/TextAlternativeWithRange.mm > editing/mac/TextUndoInsertionMarkupMac.mm >+ editing/mac/WebContentReaderMac.mm > > fileapi/FileCocoa.mm > >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 13794eeb1608222ff639dd74ccaa98a4ffbbb2a8..32ded2bdb4b7984155465af6b657f33dd9d7c867 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4278,6 +4278,7 @@ > 9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A528E8217D7F52F00AA9518 /* FloatingObjects.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */; }; > 9AB1F38118E2489A00534743 /* CSSToLengthConversionData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */; }; >+ 9B0811241F67CDC00074BDE2 /* WebContentReaderIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B0811231F67CDC00074BDE2 /* WebContentReaderIOS.mm */; }; > 9B098BD81F3D60DC002DD562 /* DataTransferItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B098BD51F3D6033002DD562 /* DataTransferItem.cpp */; }; > 9B098BE21F3D68AF002DD562 /* JSDataTransferItemList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B098BDF1F3D673D002DD562 /* JSDataTransferItemList.cpp */; }; > 9B098BE41F3D68B3002DD562 /* JSDataTransferItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B098BDD1F3D673D002DD562 /* JSDataTransferItem.cpp */; }; >@@ -4302,10 +4303,13 @@ > 9B6C41531344949000085B62 /* StringWithDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6C41521344949000085B62 /* StringWithDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9B714E201C91166900AC0E92 /* EventPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B714E1E1C91166900AC0E92 /* EventPath.cpp */; }; > 9B714E211C91166900AC0E92 /* EventPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B714E1F1C91166900AC0E92 /* EventPath.h */; }; >+ 9B9299AE1F67865B006723C2 /* WebContentReaderMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B9299AD1F67865B006723C2 /* WebContentReaderMac.mm */; }; >+ 9B9299B21F6796A4006723C2 /* WebContentReaderCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */; }; > 9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */; }; > 9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAB6C6A12550631001626D4 /* EditingStyle.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9BAB6C6D12550631001626D4 /* EditingStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BAB6C6B12550631001626D4 /* EditingStyle.cpp */; }; > 9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 9BBA2CAB1F679E0C00FD1C1E /* WebContentReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BF433761F67619B00E1FD71 /* WebContentReader.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9BC5F9E01D5AAF6B002B749D /* JSCustomElementRegistryCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */; }; > 9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */; }; >@@ -12662,6 +12666,7 @@ > 9B03D8061BB3110D00B764DA /* JSDOMBindingInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMBindingInternalsBuiltins.h; sourceTree = "<group>"; }; > 9B03D8061BB3110D00B764E8 /* WritableStreamBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableStreamBuiltins.h; sourceTree = "<group>"; }; > 9B03D8061BB3110D00B764E9 /* WritableStreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableStreamInternalsBuiltins.h; sourceTree = "<group>"; }; >+ 9B0811231F67CDC00074BDE2 /* WebContentReaderIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContentReaderIOS.mm; sourceTree = "<group>"; }; > 9B098BD51F3D6033002DD562 /* DataTransferItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataTransferItem.cpp; sourceTree = "<group>"; }; > 9B098BDD1F3D673D002DD562 /* JSDataTransferItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataTransferItem.cpp; sourceTree = "<group>"; }; > 9B098BDE1F3D673D002DD562 /* JSDataTransferItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDataTransferItem.h; sourceTree = "<group>"; }; >@@ -12696,6 +12701,8 @@ > 9B6C41521344949000085B62 /* StringWithDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringWithDirection.h; sourceTree = "<group>"; }; > 9B714E1E1C91166900AC0E92 /* EventPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventPath.cpp; sourceTree = "<group>"; }; > 9B714E1F1C91166900AC0E92 /* EventPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventPath.h; sourceTree = "<group>"; }; >+ 9B9299AD1F67865B006723C2 /* WebContentReaderMac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = WebContentReaderMac.mm; sourceTree = "<group>"; }; >+ 9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContentReaderCocoa.mm; sourceTree = "<group>"; }; > 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogicalSelectionOffsetCaches.h; sourceTree = "<group>"; }; > 9BA827781F06156500F71E75 /* NavigationDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationDisabler.h; sourceTree = "<group>"; }; > 9BAB6C6A12550631001626D4 /* EditingStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingStyle.h; sourceTree = "<group>"; }; >@@ -12716,6 +12723,7 @@ > 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectionIndexCache.cpp; sourceTree = "<group>"; }; > 9BE671091D5AEB0400345514 /* JSCustomElementRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementRegistry.cpp; sourceTree = "<group>"; }; > 9BE6710A1D5AEB0400345514 /* JSCustomElementRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementRegistry.h; sourceTree = "<group>"; }; >+ 9BF433761F67619B00E1FD71 /* WebContentReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContentReader.h; sourceTree = "<group>"; }; > 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollection.cpp; sourceTree = "<group>"; }; > 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLFormControlsCollection.h; sourceTree = "<group>"; }; > 9D63800F1AF16E160031A15C /* StyleSelfAlignmentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSelfAlignmentData.h; sourceTree = "<group>"; }; >@@ -18252,6 +18260,7 @@ > D0BD4F5A1408850F006839B6 /* DictationCommandIOS.cpp */, > D0BD4F5B1408850F006839B6 /* DictationCommandIOS.h */, > FED13D390CEA934600D89466 /* EditorIOS.mm */, >+ 9B0811231F67CDC00074BDE2 /* WebContentReaderIOS.mm */, > ); > path = ios; > sourceTree = "<group>"; >@@ -20088,6 +20097,7 @@ > 9B55EEE81B3E8898005342BC /* EditorCocoa.mm */, > 7C3E510818DF8F3500C112F7 /* HTMLConverter.h */, > 7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */, >+ 9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */, > ); > path = cocoa; > sourceTree = "<group>"; >@@ -20463,6 +20473,7 @@ > A883DF260F3D045D00F19BF6 /* VisibleSelection.h */, > 93309DCE099E64910056E581 /* VisibleUnits.cpp */, > 93309DCF099E64910056E581 /* VisibleUnits.h */, >+ 9BF433761F67619B00E1FD71 /* WebContentReader.h */, > 93309DD4099E64910056E581 /* WrapContentsInDummySpanCommand.cpp */, > 93309DD5099E64910056E581 /* WrapContentsInDummySpanCommand.h */, > 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */, >@@ -25351,6 +25362,7 @@ > CE7B2DB21586ABAD0098B3FA /* TextAlternativeWithRange.mm */, > 29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */, > 29498681195341940072D2BD /* TextUndoInsertionMarkupMac.mm */, >+ 9B9299AD1F67865B006723C2 /* WebContentReaderMac.mm */, > ); > path = mac; > sourceTree = "<group>"; >@@ -30512,6 +30524,7 @@ > 07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */, > 1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */, > A56C5B9B189F34570082D13C /* WebConsoleAgent.h in Headers */, >+ 9BBA2CAB1F679E0C00FD1C1E /* WebContentReader.h in Headers */, > 419BE7591BC7F42B00E1C85B /* WebCoreBuiltinNames.h in Headers */, > 2D3EF44A1917915C00034184 /* WebCoreCALayerExtras.h in Headers */, > 515F79541CFCA3D500CCED93 /* WebCoreCrossThreadCopier.h in Headers */, >@@ -34274,6 +34287,9 @@ > CDA29A311CBF74DA00901CCF /* WebAVPlayerController.mm in Sources */, > 1F36EA9D1E21BA1700621E25 /* WebBackgroundTaskController.mm in Sources */, > A56C5B9A189F34570082D13C /* WebConsoleAgent.cpp in Sources */, >+ 9B9299B21F6796A4006723C2 /* WebContentReaderCocoa.mm in Sources */, >+ 9B0811241F67CDC00074BDE2 /* WebContentReaderIOS.mm in Sources */, >+ 9B9299AE1F67865B006723C2 /* WebContentReaderMac.mm in Sources */, > CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */, > 2D3EF44B1917915C00034184 /* WebCoreCALayerExtras.mm in Sources */, > 515F79531CFCA3D000CCED93 /* WebCoreCrossThreadCopier.cpp in Sources */, >diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp >index 64251cf1dc7f69f5cabaca709dec5c7e876595e0..efcf7673312ec48fe8cd08993880201c4cbf2f22 100644 >--- a/Source/WebCore/editing/Editor.cpp >+++ b/Source/WebCore/editing/Editor.cpp >@@ -3818,15 +3818,4 @@ const Font* Editor::fontForSelection(bool& hasMultipleFonts) const > return font; > } > >-Ref<DocumentFragment> Editor::createFragmentForImageAndURL(const String& url) >-{ >- auto imageElement = HTMLImageElement::create(*m_frame.document()); >- imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, url); >- >- auto fragment = document().createDocumentFragment(); >- fragment->appendChild(imageElement); >- >- return fragment; >-} >- > } // namespace WebCore >diff --git a/Source/WebCore/editing/Editor.h b/Source/WebCore/editing/Editor.h >index 26c027deeee5bb7a7c05b5067653ded4950d9cde..464218291a9320536561915e6ce572c74268f78f 100644 >--- a/Source/WebCore/editing/Editor.h >+++ b/Source/WebCore/editing/Editor.h >@@ -92,15 +92,6 @@ enum class MailBlockquoteHandling { > IgnoreBlockquote, > }; > >-#if PLATFORM(COCOA) >- >-struct FragmentAndResources { >- RefPtr<DocumentFragment> fragment; >- Vector<Ref<ArchiveResource>> resources; >-}; >- >-#endif >- > enum TemporarySelectionOption : uint8_t { > // By default, no additional options are enabled. > TemporarySelectionOptionDefault = 0, >@@ -508,11 +499,7 @@ public: > void setIsGettingDictionaryPopupInfo(bool b) { m_isGettingDictionaryPopupInfo = b; } > bool isGettingDictionaryPopupInfo() const { return m_isGettingDictionaryPopupInfo; } > >- Ref<DocumentFragment> createFragmentForImageAndURL(const String&); >- > private: >- class WebContentReader; >- > Document& document() const; > > bool canDeleteRange(Range*) const; >@@ -548,9 +535,6 @@ private: > RefPtr<SharedBuffer> selectionInWebArchiveFormat(); > String selectionInHTMLFormat(); > RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&); >- RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&); >- RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *); >- FragmentAndResources createFragment(NSAttributedString *); > String userVisibleString(const URL&); > > static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *); >diff --git a/Source/WebCore/editing/WebContentReader.h b/Source/WebCore/editing/WebContentReader.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5509b4fca2daa137a05deb3f9678bfe7601b6a9f >--- /dev/null >+++ b/Source/WebCore/editing/WebContentReader.h >@@ -0,0 +1,80 @@ >+/* >+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "Frame.h" >+#include "Pasteboard.h" >+#include "Range.h" >+ >+namespace WebCore { >+ >+class ArchiveResource; >+ >+class WebContentReader final : public PasteboardWebContentReader { >+public: >+ Frame& frame; >+ Range& context; >+ const bool allowPlainText; >+ >+ RefPtr<DocumentFragment> fragment; >+ bool madeFragmentFromPlainText; >+ >+ WebContentReader(Frame& frame, Range& context, bool allowPlainText) >+ : frame(frame) >+ , context(context) >+ , allowPlainText(allowPlainText) >+ , madeFragmentFromPlainText(false) >+ { >+ } >+ >+#if PLATFORM(IOS) >+ void addFragment(RefPtr<DocumentFragment>&&); >+#endif >+ >+private: >+#if !(PLATFORM(GTK) || PLATFORM(WIN)) >+ bool readWebArchive(SharedBuffer*) override; >+ bool readFilenames(const Vector<String>&) override; >+ bool readHTML(const String&) override; >+ bool readRTFD(SharedBuffer&) override; >+ bool readRTF(SharedBuffer&) override; >+ bool readImage(Ref<SharedBuffer>&&, const String& type) override; >+ bool readURL(const URL&, const String& title) override; >+#endif >+ bool readPlainText(const String&) override; >+}; >+ >+#if PLATFORM(COCOA) >+struct FragmentAndResources { >+ RefPtr<DocumentFragment> fragment; >+ Vector<Ref<ArchiveResource>> resources; >+}; >+ >+RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(Frame&, RefPtr<ArchiveResource>&&); >+RefPtr<DocumentFragment> createFragmentAndAddResources(Frame&, NSAttributedString*); >+#endif >+ >+} >diff --git a/Source/WebCore/editing/cocoa/EditorCocoa.mm b/Source/WebCore/editing/cocoa/EditorCocoa.mm >index 7d1c2e97830c42c695e646f75daf0d6e335d5c07..e8a5734508c7e33efd52cea700a4cfc1cd160640 100644 >--- a/Source/WebCore/editing/cocoa/EditorCocoa.mm >+++ b/Source/WebCore/editing/cocoa/EditorCocoa.mm >@@ -48,20 +48,9 @@ > #import "RenderElement.h" > #import "RenderStyle.h" > #import "Text.h" >+#import "WebContentReader.h" > #import <pal/spi/cocoa/NSAttributedStringSPI.h> > #import <wtf/BlockObjCExceptions.h> >-#import <wtf/SoftLinking.h> >- >-#if PLATFORM(IOS) >-SOFT_LINK_PRIVATE_FRAMEWORK(WebKitLegacy) >-#endif >- >-#if PLATFORM(MAC) >-SOFT_LINK_FRAMEWORK_IN_UMBRELLA(WebKit, WebKitLegacy) >-#endif >- >-// FIXME: Get rid of this and change NSAttributedString conversion so it doesn't use WebKitLegacy (cf. rdar://problem/30597352). >-SOFT_LINK(WebKitLegacy, _WebCreateFragment, void, (WebCore::Document& document, NSAttributedString *string, WebCore::FragmentAndResources& result), (document, string, result)) > > namespace WebCore { > >@@ -145,15 +134,6 @@ RetainPtr<NSDictionary> Editor::fontAttributesForSelectionStart() const > return attributes; > } > >-FragmentAndResources Editor::createFragment(NSAttributedString *string) >-{ >- // FIXME: The algorithm to convert an attributed string into HTML should be implemented here in WebCore. >- // For now, though, we call into WebKitLegacy, which in turn calls into AppKit/TextKit. >- FragmentAndResources result; >- _WebCreateFragment(*m_frame.document(), string, result); >- return result; >-} >- > static RefPtr<SharedBuffer> archivedDataForAttributedString(NSAttributedString *attributedString) > { > if (!attributedString.length) >@@ -236,7 +216,7 @@ void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributed > return; > > if (m_frame.selection().selection().isContentRichlyEditable()) { >- RefPtr<DocumentFragment> fragment = createFragmentAndAddResources(attributedString); >+ RefPtr<DocumentFragment> fragment = createFragmentAndAddResources(m_frame, attributedString); > if (fragment && shouldInsertFragment(*fragment, selectedRange().get(), EditorInsertAction::Pasted)) > pasteAsFragment(fragment.releaseNonNull(), false, false, mailBlockquoteHandling); > } else { >@@ -246,31 +226,6 @@ void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributed > } > } > >-RefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&& resource) >-{ >- if (!resource) >- return nullptr; >- >- // FIXME: Why is this different? >-#if PLATFORM(MAC) >- String resourceURL = resource->url().string(); >-#else >- NSURL *URL = resource->url(); >- String resourceURL = URL.isFileURL ? URL.absoluteString : resource->url(); >-#endif >- >- if (DocumentLoader* loader = m_frame.loader().documentLoader()) >- loader->addArchiveResource(resource.releaseNonNull()); >- >- auto imageElement = HTMLImageElement::create(*m_frame.document()); >- imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, resourceURL); >- >- auto fragment = m_frame.document()->createDocumentFragment(); >- fragment->appendChild(imageElement); >- >- return WTFMove(fragment); >-} >- > RefPtr<SharedBuffer> Editor::dataInRTFDFormat(NSAttributedString *string) > { > NSUInteger length = string.length; >@@ -297,37 +252,4 @@ RefPtr<SharedBuffer> Editor::dataInRTFFormat(NSAttributedString *string) > return nullptr; > } > >-RefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string) >-{ >- if (!m_frame.page() || !m_frame.document()) >- return nullptr; >- >- auto& document = *m_frame.document(); >- if (!document.isHTMLDocument() || !string) >- return nullptr; >- >- bool wasDeferringCallbacks = m_frame.page()->defersLoading(); >- if (!wasDeferringCallbacks) >- m_frame.page()->setDefersLoading(true); >- >- auto& cachedResourceLoader = document.cachedResourceLoader(); >- bool wasImagesEnabled = cachedResourceLoader.imagesEnabled(); >- if (wasImagesEnabled) >- cachedResourceLoader.setImagesEnabled(false); >- >- auto fragmentAndResources = createFragment(string); >- >- if (auto* loader = m_frame.loader().documentLoader()) { >- for (auto& resource : fragmentAndResources.resources) >- loader->addArchiveResource(WTFMove(resource)); >- } >- >- if (wasImagesEnabled) >- cachedResourceLoader.setImagesEnabled(true); >- if (!wasDeferringCallbacks) >- m_frame.page()->setDefersLoading(false); >- >- return WTFMove(fragmentAndResources.fragment); >-} >- > } >diff --git a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..db6f4a3e8d93993be190b3b5ab5d70d9bdc6664e >--- /dev/null >+++ b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >@@ -0,0 +1,125 @@ >+/* >+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WebContentReader.h" >+ >+#include "ArchiveResource.h" >+#include "CachedResourceLoader.h" >+#include "Document.h" >+#include "DocumentFragment.h" >+#include "DocumentLoader.h" >+#include "Frame.h" >+#include "FrameLoader.h" >+#include "HTMLImageElement.h" >+#include "Page.h" >+#include <wtf/SoftLinking.h> >+ >+#if PLATFORM(IOS) >+SOFT_LINK_PRIVATE_FRAMEWORK(WebKitLegacy) >+#endif >+ >+#if PLATFORM(MAC) >+SOFT_LINK_FRAMEWORK_IN_UMBRELLA(WebKit, WebKitLegacy) >+#endif >+ >+// FIXME: Get rid of this and change NSAttributedString conversion so it doesn't use WebKitLegacy (cf. rdar://problem/30597352). >+SOFT_LINK(WebKitLegacy, _WebCreateFragment, void, (WebCore::Document& document, NSAttributedString *string, WebCore::FragmentAndResources& result), (document, string, result)) >+ >+#if PLATFORM(COCOA) >+ >+namespace WebCore { >+ >+RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(Frame& frame, RefPtr<ArchiveResource>&& resource) >+{ >+ if (!resource) >+ return nullptr; >+ >+ // FIXME: Why is this different? >+#if PLATFORM(MAC) >+ String resourceURL = resource->url().string(); >+#else >+ NSURL *URL = resource->url(); >+ String resourceURL = URL.isFileURL ? URL.absoluteString : resource->url(); >+#endif >+ >+ if (DocumentLoader* loader = frame.loader().documentLoader()) >+ loader->addArchiveResource(resource.releaseNonNull()); >+ >+ auto imageElement = HTMLImageElement::create(*frame.document()); >+ imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, resourceURL); >+ >+ auto fragment = frame.document()->createDocumentFragment(); >+ fragment->appendChild(imageElement); >+ >+ return WTFMove(fragment); >+} >+ >+static FragmentAndResources createFragment(Frame& frame, NSAttributedString *string) >+{ >+ // FIXME: The algorithm to convert an attributed string into HTML should be implemented here in WebCore. >+ // For now, though, we call into WebKitLegacy, which in turn calls into AppKit/TextKit. >+ FragmentAndResources result; >+ _WebCreateFragment(*frame.document(), string, result); >+ return result; >+} >+ >+RefPtr<DocumentFragment> createFragmentAndAddResources(Frame& frame, NSAttributedString *string) >+{ >+ if (!frame.page() || !frame.document()) >+ return nullptr; >+ >+ auto& document = *frame.document(); >+ if (!document.isHTMLDocument() || !string) >+ return nullptr; >+ >+ bool wasDeferringCallbacks = frame.page()->defersLoading(); >+ if (!wasDeferringCallbacks) >+ frame.page()->setDefersLoading(true); >+ >+ auto& cachedResourceLoader = document.cachedResourceLoader(); >+ bool wasImagesEnabled = cachedResourceLoader.imagesEnabled(); >+ if (wasImagesEnabled) >+ cachedResourceLoader.setImagesEnabled(false); >+ >+ auto fragmentAndResources = createFragment(frame, string); >+ >+ if (auto* loader = frame.loader().documentLoader()) { >+ for (auto& resource : fragmentAndResources.resources) >+ loader->addArchiveResource(WTFMove(resource)); >+ } >+ >+ if (wasImagesEnabled) >+ cachedResourceLoader.setImagesEnabled(true); >+ if (!wasDeferringCallbacks) >+ frame.page()->setDefersLoading(false); >+ >+ return WTFMove(fragmentAndResources.fragment); >+} >+ >+} >+ >+#endif >+ >diff --git a/Source/WebCore/editing/ios/EditorIOS.mm b/Source/WebCore/editing/ios/EditorIOS.mm >index dc6e7155900601fba96f49c1e00bdc04f8f0393a..3ddd3c368153519e9d928fed8223fb99c61477b6 100644 >--- a/Source/WebCore/editing/ios/EditorIOS.mm >+++ b/Source/WebCore/editing/ios/EditorIOS.mm >@@ -29,28 +29,18 @@ > #import "CSSComputedStyleDeclaration.h" > #import "CSSPrimitiveValueMappings.h" > #import "CachedImage.h" >-#import "CachedResourceLoader.h" > #import "DataTransfer.h" > #import "DictationCommandIOS.h" > #import "DocumentFragment.h" >-#import "DocumentLoader.h" > #import "DocumentMarkerController.h" > #import "Editing.h" > #import "EditorClient.h" >-#import "FontCascade.h" > #import "Frame.h" >-#import "FrameLoader.h" >-#import "FrameLoaderClient.h" >-#import "HTMLAnchorElement.h" > #import "HTMLConverter.h" >-#import "HTMLImageElement.h" > #import "HTMLInputElement.h" > #import "HTMLNames.h" > #import "HTMLParserIdioms.h" > #import "HTMLTextAreaElement.h" >-#import "LegacyWebArchive.h" >-#import "NodeTraversal.h" >-#import "Page.h" > #import "Pasteboard.h" > #import "RenderBlock.h" > #import "RenderImage.h" >@@ -58,12 +48,9 @@ > #import "StyleProperties.h" > #import "Text.h" > #import "TypingCommand.h" >-#import "UTIUtilities.h" > #import "WAKAppKitStubs.h" >+#import "WebContentReader.h" > #import "markup.h" >-#import <MobileCoreServices/MobileCoreServices.h> >-#import <pal/spi/cocoa/NSAttributedStringSPI.h> >-#import <wtf/SoftLinking.h> > #import <wtf/text/StringBuilder.h> > > namespace WebCore { >@@ -227,158 +214,6 @@ void Editor::writeImageToPasteboard(Pasteboard& pasteboard, Element& imageElemen > pasteboard.write(pasteboardImage); > } > >-class Editor::WebContentReader final : public PasteboardWebContentReader { >-public: >- WebContentReader(Frame& frame, Range& context, bool allowPlainText) >- : frame(frame) >- , context(context) >- , allowPlainText(allowPlainText) >- , madeFragmentFromPlainText(false) >- { >- } >- >- void addFragment(RefPtr<DocumentFragment>&&); >- >- Frame& frame; >- Range& context; >- const bool allowPlainText; >- >- RefPtr<DocumentFragment> fragment; >- bool madeFragmentFromPlainText; >- >-private: >- bool readWebArchive(SharedBuffer*) override; >- bool readFilenames(const Vector<String>&) override; >- bool readHTML(const String&) override; >- bool readRTFD(SharedBuffer&) override; >- bool readRTF(SharedBuffer&) override; >- bool readImage(Ref<SharedBuffer>&&, const String& type) override; >- bool readURL(const URL&, const String& title) override; >- bool readPlainText(const String&) override; >-}; >- >-void Editor::WebContentReader::addFragment(RefPtr<DocumentFragment>&& newFragment) >-{ >- if (!newFragment) >- return; >- >- if (!fragment) { >- fragment = WTFMove(newFragment); >- return; >- } >- >- while (auto* firstChild = newFragment->firstChild()) { >- if (fragment->appendChild(*firstChild).hasException()) >- break; >- } >-} >- >-bool Editor::WebContentReader::readWebArchive(SharedBuffer* buffer) >-{ >- if (!frame.document()) >- return false; >- >- if (!buffer) >- return false; >- >- auto archive = LegacyWebArchive::create(URL(), *buffer); >- if (!archive) >- return false; >- >- auto* mainResource = archive->mainResource(); >- if (!mainResource) >- return false; >- >- auto& type = mainResource->mimeType(); >- if (!frame.loader().client().canShowMIMETypeAsHTML(type)) >- return false; >- >- // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here? >- if (auto* loader = frame.loader().documentLoader()) >- loader->addAllArchiveResources(*archive); >- >- auto markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size()); >- addFragment(createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent)); >- return true; >-} >- >-bool Editor::WebContentReader::readFilenames(const Vector<String>&) >-{ >- return false; >-} >- >-bool Editor::WebContentReader::readHTML(const String& string) >-{ >- if (!frame.document()) >- return false; >- >- addFragment(createFragmentFromMarkup(*frame.document(), string, emptyString(), DisallowScriptingAndPluginContent)); >- return true; >-} >- >-bool Editor::WebContentReader::readRTFD(SharedBuffer& buffer) >-{ >- addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get())); >- return fragment; >-} >- >-bool Editor::WebContentReader::readRTF(SharedBuffer& buffer) >-{ >- addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get())); >- return fragment; >-} >- >-bool Editor::WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type) >-{ >- RetainPtr<CFStringRef> stringType = type.createCFString(); >- RetainPtr<NSString> filenameExtension = adoptNS((NSString *)UTTypeCopyPreferredTagWithClass(stringType.get(), kUTTagClassFilenameExtension)); >- NSString *relativeURLPart = [@"image" stringByAppendingString:filenameExtension.get()]; >- String mimeType = MIMETypeFromUTI(type); >- >- addFragment(frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(WTFMove(buffer), URL::fakeURLWithRelativePart(relativeURLPart), mimeType, emptyString(), emptyString()))); >- return fragment; >-} >- >-bool Editor::WebContentReader::readURL(const URL& url, const String& title) >-{ >- if (url.isEmpty()) >- return false; >- >- if (!frame.editor().client()->hasRichlyEditableSelection()) { >- if (readPlainText([(NSURL *)url absoluteString])) >- return true; >- } >- >- if ([(NSURL *)url isFileURL]) >- return false; >- >- auto anchor = HTMLAnchorElement::create(*frame.document()); >- anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string()); >- >- String linkText = title.length() ? title : String([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]); >- anchor->appendChild(frame.document()->createTextNode(linkText)); >- >- auto newFragment = frame.document()->createDocumentFragment(); >- if (fragment) >- newFragment->appendChild(Text::create(*frame.document(), { &space, 1 })); >- newFragment->appendChild(anchor); >- addFragment(WTFMove(newFragment)); >- return true; >-} >- >-bool Editor::WebContentReader::readPlainText(const String& text) >-{ >- if (!allowPlainText) >- return false; >- >- addFragment(createFragmentFromText(context, [text precomposedStringWithCanonicalMapping])); >- if (!fragment) >- return false; >- >- madeFragmentFromPlainText = true; >- return true; >-} >- > // FIXME: Should give this function a name that makes it clear it adds resources to the document loader as a side effect. > // Or refactor so it does not do that. > RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText) >diff --git a/Source/WebCore/editing/ios/WebContentReaderIOS.mm b/Source/WebCore/editing/ios/WebContentReaderIOS.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..218d0892b57515c8b04173dc94c8ed91b52c316d >--- /dev/null >+++ b/Source/WebCore/editing/ios/WebContentReaderIOS.mm >@@ -0,0 +1,177 @@ >+/* >+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "WebContentReader.h" >+ >+#import "ArchiveResource.h" >+#import "DOMURL.h" >+#import "Document.h" >+#import "DocumentFragment.h" >+#import "DocumentLoader.h" >+#import "Editor.h" >+#import "EditorClient.h" >+#import "FragmentScriptingPermission.h" >+#import "FrameLoader.h" >+#import "FrameLoaderClient.h" >+#import "HTMLAnchorElement.h" >+#import "HTMLNames.h" >+#import "LegacyWebArchive.h" >+#import "MIMETypeRegistry.h" >+#import "Text.h" >+#import "UTIUtilities.h" >+#import "WebNSAttributedStringExtras.h" >+#import "markup.h" >+#import <MobileCoreServices/MobileCoreServices.h> >+#import <pal/spi/cocoa/NSAttributedStringSPI.h> >+#import <wtf/unicode/CharacterNames.h> >+ >+namespace WebCore { >+ >+void WebContentReader::addFragment(RefPtr<DocumentFragment>&& newFragment) >+{ >+ if (!newFragment) >+ return; >+ >+ if (!fragment) { >+ fragment = WTFMove(newFragment); >+ return; >+ } >+ >+ while (auto* firstChild = newFragment->firstChild()) { >+ if (fragment->appendChild(*firstChild).hasException()) >+ break; >+ } >+} >+ >+bool WebContentReader::readWebArchive(SharedBuffer* buffer) >+{ >+ if (!frame.document()) >+ return false; >+ >+ if (!buffer) >+ return false; >+ >+ auto archive = LegacyWebArchive::create(URL(), *buffer); >+ if (!archive) >+ return false; >+ >+ auto* mainResource = archive->mainResource(); >+ if (!mainResource) >+ return false; >+ >+ auto& type = mainResource->mimeType(); >+ if (!frame.loader().client().canShowMIMETypeAsHTML(type)) >+ return false; >+ >+ // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here? >+ if (auto* loader = frame.loader().documentLoader()) >+ loader->addAllArchiveResources(*archive); >+ >+ auto markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size()); >+ addFragment(createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent)); >+ return true; >+} >+ >+bool WebContentReader::readFilenames(const Vector<String>&) >+{ >+ return false; >+} >+ >+bool WebContentReader::readHTML(const String& string) >+{ >+ if (!frame.document()) >+ return false; >+ >+ addFragment(createFragmentFromMarkup(*frame.document(), string, emptyString(), DisallowScriptingAndPluginContent)); >+ return true; >+} >+ >+bool WebContentReader::readRTFD(SharedBuffer& buffer) >+{ >+ addFragment(createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get())); >+ return fragment; >+} >+ >+bool WebContentReader::readRTF(SharedBuffer& buffer) >+{ >+ addFragment(createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get())); >+ return fragment; >+} >+ >+bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type) >+{ >+ RetainPtr<CFStringRef> stringType = type.createCFString(); >+ RetainPtr<NSString> filenameExtension = adoptNS((NSString *)UTTypeCopyPreferredTagWithClass(stringType.get(), kUTTagClassFilenameExtension)); >+ NSString *relativeURLPart = [@"image" stringByAppendingString:filenameExtension.get()]; >+ String mimeType = MIMETypeFromUTI(type); >+ >+ // FIXME: Use a blob URL instead. >+ addFragment(createFragmentForImageResourceAndAddResource(frame, ArchiveResource::create(WTFMove(buffer), URL::fakeURLWithRelativePart(relativeURLPart), mimeType, emptyString(), emptyString()))); >+ return fragment; >+} >+ >+bool WebContentReader::readURL(const URL& url, const String& title) >+{ >+ if (url.isEmpty()) >+ return false; >+ >+ // FIXME: This code shoudln't be accessing selection and changing the behavior. >+ if (!frame.editor().client()->hasRichlyEditableSelection()) { >+ if (readPlainText([(NSURL *)url absoluteString])) >+ return true; >+ } >+ >+ if ([(NSURL *)url isFileURL]) >+ return false; >+ >+ auto anchor = HTMLAnchorElement::create(*frame.document()); >+ anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string()); >+ >+ String linkText = title.length() ? title : String([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]); >+ anchor->appendChild(frame.document()->createTextNode(linkText)); >+ >+ auto newFragment = frame.document()->createDocumentFragment(); >+ if (fragment) >+ newFragment->appendChild(Text::create(*frame.document(), { &space, 1 })); >+ newFragment->appendChild(anchor); >+ addFragment(WTFMove(newFragment)); >+ return true; >+} >+ >+bool WebContentReader::readPlainText(const String& text) >+{ >+ if (!allowPlainText) >+ return false; >+ >+ addFragment(createFragmentFromText(context, [text precomposedStringWithCanonicalMapping])); >+ if (!fragment) >+ return false; >+ >+ madeFragmentFromPlainText = true; >+ return true; >+} >+ >+} >diff --git a/Source/WebCore/editing/mac/EditorMac.mm b/Source/WebCore/editing/mac/EditorMac.mm >index 4a26300f22be1663121e6e35cf37bb2346b6d1a7..216f140d73c6a6a817d055d6919fbc16bc1191df 100644 >--- a/Source/WebCore/editing/mac/EditorMac.mm >+++ b/Source/WebCore/editing/mac/EditorMac.mm >@@ -29,29 +29,17 @@ > #import "Blob.h" > #import "CSSPrimitiveValueMappings.h" > #import "CSSValuePool.h" >-#import "DOMURL.h" > #import "DataTransfer.h" > #import "DocumentFragment.h" >-#import "DocumentLoader.h" > #import "Editing.h" > #import "Editor.h" > #import "EditorClient.h" >-#import "File.h" >-#import "FontCascade.h" > #import "Frame.h" >-#import "FrameLoader.h" >-#import "FrameLoaderClient.h" > #import "FrameView.h" >-#import "HTMLAnchorElement.h" >-#import "HTMLAttachmentElement.h" > #import "HTMLConverter.h" > #import "HTMLElement.h" >-#import "HTMLImageElement.h" > #import "HTMLNames.h" > #import "LegacyWebArchive.h" >-#import "MIMETypeRegistry.h" >-#import "NodeTraversal.h" >-#import "Page.h" > #import "Pasteboard.h" > #import "PasteboardStrategy.h" > #import "PlatformStrategies.h" >@@ -59,12 +47,11 @@ > #import "RenderBlock.h" > #import "RenderImage.h" > #import "RuntimeApplicationChecks.h" >-#import "Settings.h" > #import "StyleProperties.h" >-#import "Text.h" >-#import "TypingCommand.h" >+#import "WebContentReader.h" > #import "WebNSAttributedStringExtras.h" > #import "markup.h" >+#import <AppKit/AppKit.h> > #import <pal/system/Sound.h> > > namespace WebCore { >@@ -298,184 +285,6 @@ void Editor::writeImageToPasteboard(Pasteboard& pasteboard, Element& imageElemen > pasteboard.write(pasteboardImage); > } > >-class Editor::WebContentReader final : public PasteboardWebContentReader { >-public: >- Frame& frame; >- Range& context; >- const bool allowPlainText; >- >- RefPtr<DocumentFragment> fragment; >- bool madeFragmentFromPlainText; >- >- WebContentReader(Frame& frame, Range& context, bool allowPlainText) >- : frame(frame) >- , context(context) >- , allowPlainText(allowPlainText) >- , madeFragmentFromPlainText(false) >- { >- } >- >-private: >- bool readWebArchive(SharedBuffer*) override; >- bool readFilenames(const Vector<String>&) override; >- bool readHTML(const String&) override; >- bool readRTFD(SharedBuffer&) override; >- bool readRTF(SharedBuffer&) override; >- bool readImage(Ref<SharedBuffer>&&, const String& type) override; >- bool readURL(const URL&, const String& title) override; >- bool readPlainText(const String&) override; >-}; >- >-bool Editor::WebContentReader::readWebArchive(SharedBuffer* buffer) >-{ >- if (frame.settings().preferMIMETypeForImages()) >- return false; >- >- if (!frame.document()) >- return false; >- >- if (!buffer) >- return false; >- >- auto archive = LegacyWebArchive::create(URL(), *buffer); >- if (!archive) >- return false; >- >- RefPtr<ArchiveResource> mainResource = archive->mainResource(); >- if (!mainResource) >- return false; >- >- const String& type = mainResource->mimeType(); >- >- if (frame.loader().client().canShowMIMETypeAsHTML(type)) { >- // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here? >- if (DocumentLoader* loader = frame.loader().documentLoader()) >- loader->addAllArchiveResources(*archive); >- >- String markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size()); >- fragment = createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent); >- return true; >- } >- >- if (MIMETypeRegistry::isSupportedImageMIMEType(type)) { >- fragment = frame.editor().createFragmentForImageResourceAndAddResource(WTFMove(mainResource)); >- return true; >- } >- >- return false; >-} >- >-bool Editor::WebContentReader::readFilenames(const Vector<String>& paths) >-{ >- if (paths.isEmpty()) >- return false; >- >- if (!frame.document()) >- return false; >- Document& document = *frame.document(); >- >- fragment = document.createDocumentFragment(); >- >- for (auto& text : paths) { >-#if ENABLE(ATTACHMENT_ELEMENT) >- auto attachment = HTMLAttachmentElement::create(attachmentTag, document); >- attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr()); >- fragment->appendChild(attachment); >-#else >- auto paragraph = createDefaultParagraphElement(document); >- paragraph->appendChild(document.createTextNode(frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text]))); >- fragment->appendChild(paragraph); >-#endif >- } >- >- return true; >-} >- >-bool Editor::WebContentReader::readHTML(const String& string) >-{ >- String stringOmittingMicrosoftPrefix = string; >- >- // This code was added to make HTML paste from Microsoft Word on Mac work, back in 2004. >- // It's a simple-minded way to ignore the CF_HTML clipboard format, just skipping over the >- // description part and parsing the entire context plus fragment. >- if (string.startsWith("Version:")) { >- size_t location = string.findIgnoringCase("<html"); >- if (location != notFound) >- stringOmittingMicrosoftPrefix = string.substring(location); >- } >- >- if (stringOmittingMicrosoftPrefix.isEmpty()) >- return false; >- >- if (!frame.document()) >- return false; >- Document& document = *frame.document(); >- >- fragment = createFragmentFromMarkup(document, stringOmittingMicrosoftPrefix, emptyString(), DisallowScriptingAndPluginContent); >- return fragment; >-} >- >-bool Editor::WebContentReader::readRTFD(SharedBuffer& buffer) >-{ >- if (frame.settings().preferMIMETypeForImages()) >- return false; >- >- fragment = frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get()); >- return fragment; >-} >- >-bool Editor::WebContentReader::readRTF(SharedBuffer& buffer) >-{ >- if (frame.settings().preferMIMETypeForImages()) >- return false; >- >- fragment = frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get()); >- return fragment; >-} >- >-bool Editor::WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type) >-{ >- ASSERT(type.contains('/')); >- String typeAsFilenameWithExtension = type; >- typeAsFilenameWithExtension.replace('/', '.'); >- >- Vector<uint8_t> data; >- data.append(buffer->data(), buffer->size()); >- auto blob = Blob::create(WTFMove(data), type); >- ASSERT(frame.document()); >- String blobURL = DOMURL::createObjectURL(*frame.document(), blob); >- >- fragment = frame.editor().createFragmentForImageAndURL(blobURL); >- return fragment; >-} >- >-bool Editor::WebContentReader::readURL(const URL& url, const String& title) >-{ >- if (url.string().isEmpty()) >- return false; >- >- auto anchor = HTMLAnchorElement::create(*frame.document()); >- anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string()); >- anchor->appendChild(frame.document()->createTextNode([title precomposedStringWithCanonicalMapping])); >- >- fragment = frame.document()->createDocumentFragment(); >- fragment->appendChild(anchor); >- return true; >-} >- >-bool Editor::WebContentReader::readPlainText(const String& text) >-{ >- if (!allowPlainText) >- return false; >- >- fragment = createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]); >- if (!fragment) >- return false; >- >- madeFragmentFromPlainText = true; >- return true; >-} >- > // FIXME: Should give this function a name that makes it clear it adds resources to the document loader as a side effect. > // Or refactor so it does not do that. > RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText) >diff --git a/Source/WebCore/editing/mac/WebContentReaderMac.mm b/Source/WebCore/editing/mac/WebContentReaderMac.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..30f832f8df889807f738d2ff586d49ec3233feac >--- /dev/null >+++ b/Source/WebCore/editing/mac/WebContentReaderMac.mm >@@ -0,0 +1,205 @@ >+/* >+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "WebContentReader.h" >+ >+#import "ArchiveResource.h" >+#import "DOMURL.h" >+#import "Document.h" >+#import "DocumentFragment.h" >+#import "DocumentLoader.h" >+#import "File.h" >+#import "FragmentScriptingPermission.h" >+#import "FrameLoader.h" >+#import "FrameLoaderClient.h" >+#import "HTMLAnchorElement.h" >+#import "HTMLAttachmentElement.h" >+#import "HTMLNames.h" >+#import "LegacyWebArchive.h" >+#import "MIMETypeRegistry.h" >+#import "Settings.h" >+#import "Text.h" >+#import "WebNSAttributedStringExtras.h" >+#import "markup.h" >+ >+namespace WebCore { >+ >+// Defined in EditorCocoa.mm >+RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(Frame&, RefPtr<ArchiveResource>&&); >+RefPtr<DocumentFragment> createFragmentAndAddResources(Frame&, NSAttributedString *); >+ >+bool WebContentReader::readWebArchive(SharedBuffer* buffer) >+{ >+ if (frame.settings().preferMIMETypeForImages()) >+ return false; >+ >+ if (!frame.document()) >+ return false; >+ >+ if (!buffer) >+ return false; >+ >+ auto archive = LegacyWebArchive::create(URL(), *buffer); >+ if (!archive) >+ return false; >+ >+ RefPtr<ArchiveResource> mainResource = archive->mainResource(); >+ if (!mainResource) >+ return false; >+ >+ const String& type = mainResource->mimeType(); >+ >+ if (frame.loader().client().canShowMIMETypeAsHTML(type)) { >+ // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here? >+ if (DocumentLoader* loader = frame.loader().documentLoader()) >+ loader->addAllArchiveResources(*archive); >+ >+ String markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size()); >+ fragment = createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent); >+ return true; >+ } >+ >+ if (MIMETypeRegistry::isSupportedImageMIMEType(type)) { >+ fragment = createFragmentForImageResourceAndAddResource(frame, WTFMove(mainResource)); >+ return true; >+ } >+ >+ return false; >+} >+ >+bool WebContentReader::readFilenames(const Vector<String>& paths) >+{ >+ if (paths.isEmpty()) >+ return false; >+ >+ if (!frame.document()) >+ return false; >+ Document& document = *frame.document(); >+ >+ fragment = document.createDocumentFragment(); >+ >+ for (auto& text : paths) { >+#if ENABLE(ATTACHMENT_ELEMENT) >+ auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); >+ attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr()); >+ fragment->appendChild(attachment); >+#else >+ auto paragraph = createDefaultParagraphElement(document); >+ paragraph->appendChild(document.createTextNode(frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text]))); >+ fragment->appendChild(paragraph); >+#endif >+ } >+ >+ return true; >+} >+ >+bool WebContentReader::readHTML(const String& string) >+{ >+ String stringOmittingMicrosoftPrefix = string; >+ >+ // This code was added to make HTML paste from Microsoft Word on Mac work, back in 2004. >+ // It's a simple-minded way to ignore the CF_HTML clipboard format, just skipping over the >+ // description part and parsing the entire context plus fragment. >+ if (string.startsWith("Version:")) { >+ size_t location = string.findIgnoringCase("<html"); >+ if (location != notFound) >+ stringOmittingMicrosoftPrefix = string.substring(location); >+ } >+ >+ if (stringOmittingMicrosoftPrefix.isEmpty()) >+ return false; >+ >+ if (!frame.document()) >+ return false; >+ Document& document = *frame.document(); >+ >+ fragment = createFragmentFromMarkup(document, stringOmittingMicrosoftPrefix, emptyString(), DisallowScriptingAndPluginContent); >+ return fragment; >+} >+ >+bool WebContentReader::readRTFD(SharedBuffer& buffer) >+{ >+ if (frame.settings().preferMIMETypeForImages()) >+ return false; >+ >+ fragment = createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get()); >+ return fragment; >+} >+ >+bool WebContentReader::readRTF(SharedBuffer& buffer) >+{ >+ if (frame.settings().preferMIMETypeForImages()) >+ return false; >+ >+ fragment = createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get()); >+ return fragment; >+} >+ >+bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type) >+{ >+ ASSERT(type.contains('/')); >+ String typeAsFilenameWithExtension = type; >+ typeAsFilenameWithExtension.replace('/', '.'); >+ >+ Vector<uint8_t> data; >+ data.append(buffer->data(), buffer->size()); >+ auto blob = Blob::create(WTFMove(data), type); >+ ASSERT(frame.document()); >+ Document& document = *frame.document(); >+ String blobURL = DOMURL::createObjectURL(document, blob); >+ >+ fragment = createFragmentForImageAndURL(document, blobURL); >+ return fragment; >+} >+ >+bool WebContentReader::readURL(const URL& url, const String& title) >+{ >+ if (url.string().isEmpty()) >+ return false; >+ >+ auto anchor = HTMLAnchorElement::create(*frame.document()); >+ anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string()); >+ anchor->appendChild(frame.document()->createTextNode([title precomposedStringWithCanonicalMapping])); >+ >+ fragment = frame.document()->createDocumentFragment(); >+ fragment->appendChild(anchor); >+ return true; >+} >+ >+bool WebContentReader::readPlainText(const String& text) >+{ >+ if (!allowPlainText) >+ return false; >+ >+ fragment = createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]); >+ if (!fragment) >+ return false; >+ >+ madeFragmentFromPlainText = true; >+ return true; >+} >+ >+} >diff --git a/Source/WebCore/editing/markup.cpp b/Source/WebCore/editing/markup.cpp >index 8a0b59a0bc38dd12e46e934f6243cc83cd4e917f..4eb7db509057bdf65ac58273f06ecb1456d69a84 100644 >--- a/Source/WebCore/editing/markup.cpp >+++ b/Source/WebCore/editing/markup.cpp >@@ -47,6 +47,7 @@ > #include "HTMLDivElement.h" > #include "HTMLHeadElement.h" > #include "HTMLHtmlElement.h" >+#include "HTMLImageElement.h" > #include "HTMLNames.h" > #include "HTMLTableElement.h" > #include "HTMLTextAreaElement.h" >@@ -918,6 +919,17 @@ RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document& outputDo > return fragment; > } > >+Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url) >+{ >+ auto imageElement = HTMLImageElement::create(document); >+ imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, url); >+ >+ auto fragment = document.createDocumentFragment(); >+ fragment->appendChild(imageElement); >+ >+ return fragment; >+} >+ > static Vector<Ref<HTMLElement>> collectElementsToRemoveFromFragment(ContainerNode& container) > { > Vector<Ref<HTMLElement>> toRemove; >diff --git a/Source/WebCore/editing/markup.h b/Source/WebCore/editing/markup.h >index 8d4fe389dd2e285c5ddf75b3105028066dfbe479..90928790caa69074344eb02c7fb473820e60ee8a 100644 >--- a/Source/WebCore/editing/markup.h >+++ b/Source/WebCore/editing/markup.h >@@ -51,6 +51,7 @@ WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromText(Range& context, cons > WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent); > ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy); > RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document&, const String& sourceString, const String& sourceMIMEType); >+Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String&); > ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element&, const String& markup, ParserContentPolicy); > > bool isPlainTextMarkup(Node*); >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >index 7fe459da177429ad947b12b770f94d368aa54332..7ad02e5ba4a6edf3e6cb2bf897e1bec84c5ce9ae 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >@@ -57,6 +57,7 @@ > #import <WebCore/Document.h> > #import <WebCore/DocumentFragment.h> > #import <WebCore/Editor.h> >+#import <WebCore/Event.h> > #import <WebCore/FloatQuad.h> > #import <WebCore/Frame.h> > #import <WebCore/FrameView.h> >@@ -74,6 +75,7 @@ > #import <WebCore/UndoStep.h> > #import <WebCore/UserTypingGestureIndicator.h> > #import <WebCore/VisibleUnits.h> >+#import <WebCore/WebContentReader.h> > #import <WebCore/WebCoreObjCExtras.h> > #import <pal/spi/mac/NSSpellCheckerSPI.h> > #import <runtime/InitializeThreading.h>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 176770
:
320530
|
320608
|
320616
|
320619
|
320621
|
320622