Fixed: <rdar://problem/3802781> rtf->html pasteboard conversion using xhtml
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2005 22:41:01 +0000 (22:41 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2005 22:41:01 +0000 (22:41 +0000)
        Reviewed by kocienda.

        * WebView.subproj/WebHTMLView.m:
        (+[WebHTMLView _excludedElementsForAttributedStringConversion]): new
        (-[WebHTMLView _documentFragmentFromPasteboard:allowPlainText:]): call _excludedElementsForAttributedStringConversion

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8525 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebView.subproj/WebHTMLView.m

index 450837decf66b8a7989d81f9e7b62d859020f1da..37e2af8a4f639bfb378997d29fdd89a0ec30b41c 100644 (file)
@@ -1,3 +1,13 @@
+2005-02-04  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed: <rdar://problem/3802781> rtf->html pasteboard conversion using xhtml
+
+        Reviewed by kocienda.
+
+        * WebView.subproj/WebHTMLView.m:
+        (+[WebHTMLView _excludedElementsForAttributedStringConversion]): new
+        (-[WebHTMLView _documentFragmentFromPasteboard:allowPlainText:]): call _excludedElementsForAttributedStringConversion
+
 2005-02-04  Chris Blumenberg  <cblu@apple.com>
 
        Fixed: <rdar://problem/3832973> copy text from PowerPoint, paste into Blot (or presumably Mail) and get a single missing image icon
index 98b98a6354edda805b4e85c59ad25c907ae11edc..586699013fcd8bbe33864c353ef148939c6b2ba1 100644 (file)
@@ -278,6 +278,25 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
     return [fragment firstChild] != nil ? fragment : nil;
 }
 
++ (NSArray *)_excludedElementsForAttributedStringConversion
+{
+    static NSArray *elements = nil;
+    if (elements == nil) {
+        elements = [[NSArray alloc] initWithObjects:
+            // Omit style since we want style to be inline so the fragment can be easily inserted.
+            @"style",
+            // Omit xml so the result is not XHTML.
+            @"xml", 
+            // Omit tags that will get stripped when converted to a fragment anyway.
+            @"doctype", @"html", @"head", @"body",
+            // Omit deprecated tags.
+            @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
+            // Omit object so no file attachments are part of the fragment.
+            @"object", nil];
+    }
+    return elements;
+}
+
 - (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText
 {
     NSArray *types = [pasteboard types];
@@ -325,13 +344,9 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
         string = [[NSAttributedString alloc] initWithRTF:[pasteboard dataForType:NSRTFPboardType] documentAttributes:NULL];
     }
     if (string != nil) {
-        NSArray *elements = [[NSArray alloc] initWithObjects:
-            // Omit style since we want style to be inline so the fragment can be easily inserted.
-            @"style", nil];
         NSDictionary *documentAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
-            elements, NSExcludedElementsDocumentAttribute,
+            [[self class] _excludedElementsForAttributedStringConversion], NSExcludedElementsDocumentAttribute,
             self, @"WebResourceHandler", nil];
-        [elements release];
         NSArray *subresources;
         DOMDocumentFragment *fragment = [string _documentFromRange:NSMakeRange(0, [string length]) 
                                                           document:[[self _bridge] DOMDocument]