Expose document attributes and body background color through HTMLConverter.
[WebKit-https.git] / Source / WebCore / PAL / pal / spi / cocoa / NSAttributedStringSPI.h
1 /*
2  * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #pragma once
27
28 #import <wtf/SoftLinking.h>
29
30 #if PLATFORM(IOS_FAMILY)
31
32 #import <UIKit/NSAttributedString.h>
33
34 SOFT_LINK_PRIVATE_FRAMEWORK(UIFoundation)
35
36 SOFT_LINK_CONSTANT(UIFoundation, NSFontAttributeName, NSString *)
37 #define NSFontAttributeName getNSFontAttributeName()
38 SOFT_LINK_CONSTANT(UIFoundation, NSForegroundColorAttributeName, NSString *)
39 #define NSForegroundColorAttributeName getNSForegroundColorAttributeName()
40 SOFT_LINK_CONSTANT(UIFoundation, NSBackgroundColorAttributeName, NSString *)
41 #define NSBackgroundColorAttributeName getNSBackgroundColorAttributeName()
42 SOFT_LINK_CONSTANT(UIFoundation, NSStrokeColorAttributeName, NSString *)
43 #define NSStrokeColorAttributeName getNSStrokeColorAttributeName()
44 SOFT_LINK_CONSTANT(UIFoundation, NSStrokeWidthAttributeName, NSString *)
45 #define NSStrokeWidthAttributeName getNSStrokeWidthAttributeName()
46 SOFT_LINK_CONSTANT(UIFoundation, NSShadowAttributeName, NSString *)
47 #define NSShadowAttributeName getNSShadowAttributeName()
48 SOFT_LINK_CONSTANT(UIFoundation, NSKernAttributeName, NSString *)
49 #define NSKernAttributeName getNSKernAttributeName()
50 SOFT_LINK_CONSTANT(UIFoundation, NSLigatureAttributeName, NSString *)
51 #define NSLigatureAttributeName getNSLigatureAttributeName()
52 SOFT_LINK_CONSTANT(UIFoundation, NSUnderlineStyleAttributeName, NSString *)
53 #define NSUnderlineStyleAttributeName getNSUnderlineStyleAttributeName()
54 SOFT_LINK_CONSTANT(UIFoundation, NSStrikethroughStyleAttributeName, NSString *)
55 #define NSStrikethroughStyleAttributeName getNSStrikethroughStyleAttributeName()
56 SOFT_LINK_CONSTANT(UIFoundation, NSBaselineOffsetAttributeName, NSString *)
57 #define NSBaselineOffsetAttributeName getNSBaselineOffsetAttributeName()
58 SOFT_LINK_CONSTANT(UIFoundation, NSWritingDirectionAttributeName, NSString *)
59 #define NSWritingDirectionAttributeName getNSWritingDirectionAttributeName()
60 SOFT_LINK_CONSTANT(UIFoundation, NSParagraphStyleAttributeName, NSString *)
61 #define NSParagraphStyleAttributeName getNSParagraphStyleAttributeName()
62 SOFT_LINK_CONSTANT(UIFoundation, NSAttachmentAttributeName, NSString *)
63 #define NSAttachmentAttributeName getNSAttachmentAttributeName()
64 SOFT_LINK_CONSTANT(UIFoundation, NSLinkAttributeName, NSString *)
65 #define NSLinkAttributeName getNSLinkAttributeName()
66 SOFT_LINK_CONSTANT(UIFoundation, NSAuthorDocumentAttribute, NSString *)
67 #define NSAuthorDocumentAttribute getNSAuthorDocumentAttribute()
68 SOFT_LINK_CONSTANT(UIFoundation, NSEditorDocumentAttribute, NSString *)
69 #define NSEditorDocumentAttribute getNSEditorDocumentAttribute()
70 SOFT_LINK_CONSTANT(UIFoundation, NSGeneratorDocumentAttribute, NSString *)
71 #define NSGeneratorDocumentAttribute getNSGeneratorDocumentAttribute()
72 SOFT_LINK_CONSTANT(UIFoundation, NSCompanyDocumentAttribute, NSString *)
73 #define NSCompanyDocumentAttribute getNSCompanyDocumentAttribute()
74 SOFT_LINK_CONSTANT(UIFoundation, NSDisplayNameDocumentAttribute, NSString *)
75 #define NSDisplayNameDocumentAttribute getNSDisplayNameDocumentAttribute()
76 SOFT_LINK_CONSTANT(UIFoundation, NSCopyrightDocumentAttribute, NSString *)
77 #define NSCopyrightDocumentAttribute getNSCopyrightDocumentAttribute()
78 SOFT_LINK_CONSTANT(UIFoundation, NSSubjectDocumentAttribute, NSString *)
79 #define NSSubjectDocumentAttribute getNSSubjectDocumentAttribute()
80 SOFT_LINK_CONSTANT(UIFoundation, NSCommentDocumentAttribute, NSString *)
81 #define NSCommentDocumentAttribute getNSCommentDocumentAttribute()
82 SOFT_LINK_CONSTANT(UIFoundation, NSNoIndexDocumentAttribute, NSString *)
83 #define NSNoIndexDocumentAttribute getNSNoIndexDocumentAttribute()
84 SOFT_LINK_CONSTANT(UIFoundation, NSKeywordsDocumentAttribute, NSString *)
85 #define NSKeywordsDocumentAttribute getNSKeywordsDocumentAttribute()
86 SOFT_LINK_CONSTANT(UIFoundation, NSCreationTimeDocumentAttribute, NSString *)
87 #define NSCreationTimeDocumentAttribute getNSCreationTimeDocumentAttribute()
88 SOFT_LINK_CONSTANT(UIFoundation, NSModificationTimeDocumentAttribute, NSString *)
89 #define NSModificationTimeDocumentAttribute getNSModificationTimeDocumentAttribute()
90 SOFT_LINK_CONSTANT(UIFoundation, NSConvertedDocumentAttribute, NSString *)
91 #define NSConvertedDocumentAttribute getNSConvertedDocumentAttribute()
92 SOFT_LINK_CONSTANT(UIFoundation, NSCocoaVersionDocumentAttribute, NSString *)
93 #define NSCocoaVersionDocumentAttribute getNSCocoaVersionDocumentAttribute()
94 SOFT_LINK_CONSTANT(UIFoundation, NSBackgroundColorDocumentAttribute, NSString *)
95 #define NSBackgroundColorDocumentAttribute getNSBackgroundColorDocumentAttribute()
96
97 // We don't softlink NSSuperscriptAttributeName because UIFoundation stopped exporting it.
98 // This attribute is being deprecated at the API level, but internally UIFoundation
99 // will continue to support it.
100 static NSString *const NSSuperscriptAttributeName = @"NSSuperscript";
101
102 @interface NSAttributedString ()
103 - (id)initWithRTF:(NSData *)data documentAttributes:(NSDictionary **)dict;
104 - (id)initWithRTFD:(NSData *)data documentAttributes:(NSDictionary **)dict;
105 - (NSData *)RTFFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
106 - (NSData *)RTFDFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
107 - (BOOL)containsAttachments;
108 @end
109
110 #endif // PLATFORM(IOS_FAMILY)
111
112 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101300)
113 static NSString *const NSTextListMarkerCircle = @"{circle}";
114 static NSString *const NSTextListMarkerDisc = @"{disc}";
115 static NSString *const NSTextListMarkerSquare = @"{square}";
116 static NSString *const NSTextListMarkerLowercaseHexadecimal = @"{lower-hexadecimal}";
117 static NSString *const NSTextListMarkerUppercaseHexadecimal = @"{upper-hexadecimal}";
118 static NSString *const NSTextListMarkerOctal = @"{octal}";
119 static NSString *const NSTextListMarkerLowercaseAlpha = @"{lower-alpha}";
120 static NSString *const NSTextListMarkerUppercaseAlpha = @"{upper-alpha}";
121 static NSString *const NSTextListMarkerLowercaseLatin = @"{lower-latin}";
122 static NSString *const NSTextListMarkerUppercaseLatin = @"{upper-latin}";
123 static NSString *const NSTextListMarkerLowercaseRoman = @"{lower-roman}";
124 static NSString *const NSTextListMarkerUppercaseRoman = @"{upper-roman}";
125 static NSString *const NSTextListMarkerDecimal = @"{decimal}";
126 #endif // PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101300)