Skip to content

Commit f110110

Browse files
Fix the build on other platforms after r220865
https://bugs.webkit.org/show_bug.cgi?id=175683 Reviewed by Tim Horton. Source/WebCore: Instead of special casing iOS 10 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED < 110000, revert to special casing iOS 11 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000. This is because other targets that are neither iOS 10 nor 11 will fail the "before iOS 11" compile-time check, and subsequently assume that item providers exist. To fix this, flip the compiler-time checks and the order of codeblocks in the PlatformPasteboard::write methods. There is no change in behavior. * platform/ios/PlatformPasteboardIOS.mm: (WebCore::registerItemToPasteboard): (WebCore::PlatformPasteboard::write): Tools: Check __IPHONE_OS_VERSION_MAX_ALLOWED instead of __IPHONE_OS_VERSION_MIN_REQUIRED in an SPI header. SPI availability is determined by SDK version rather than deployment version. * TestWebKitAPI/ios/UIKitSPI.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@220883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 66ec88f commit f110110

File tree

4 files changed

+92
-61
lines changed

4 files changed

+92
-61
lines changed

Source/WebCore/ChangeLog

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2017-08-17 Wenson Hsieh <[email protected]>
2+
3+
Fix the build on other platforms after r220865
4+
https://bugs.webkit.org/show_bug.cgi?id=175683
5+
6+
Reviewed by Tim Horton.
7+
8+
Instead of special casing iOS 10 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED < 110000, revert to special
9+
casing iOS 11 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000. This is because other targets that are
10+
neither iOS 10 nor 11 will fail the "before iOS 11" compile-time check, and subsequently assume that item
11+
providers exist. To fix this, flip the compiler-time checks and the order of codeblocks in the
12+
PlatformPasteboard::write methods.
13+
14+
There is no change in behavior.
15+
16+
* platform/ios/PlatformPasteboardIOS.mm:
17+
(WebCore::registerItemToPasteboard):
18+
(WebCore::PlatformPasteboard::write):
19+
120
2017-08-17 Michael Catanzaro <[email protected]>
221

322
-Wreturn-type warnings in CryptoKey.cpp and SubtleCrypto.cpp

Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

+60-60
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,22 @@
175175

176176
static NSString *webIOSPastePboardType = @"iOS rich content paste pasteboard type";
177177

178-
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
178+
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
179+
180+
static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard)
181+
{
182+
UIItemProvider *itemProvider = [representationsToRegister itemProvider];
183+
if (!itemProvider) {
184+
[pasteboard setItemProviders:@[ ]];
185+
return;
186+
}
187+
188+
[pasteboard setItemProviders:@[ itemProvider ]];
189+
if ([pasteboard respondsToSelector:@selector(setRegistrationInfoLists:)])
190+
[pasteboard setRegistrationInfoLists:@[ representationsToRegister ]];
191+
}
192+
193+
#else
179194

180195
static RetainPtr<NSDictionary> richTextRepresentationsForPasteboardWebContent(const PasteboardWebContent& content)
181196
{
@@ -199,21 +214,6 @@
199214
return representations;
200215
}
201216

202-
#else
203-
204-
static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard)
205-
{
206-
UIItemProvider *itemProvider = [representationsToRegister itemProvider];
207-
if (!itemProvider) {
208-
[pasteboard setItemProviders:@[ ]];
209-
return;
210-
}
211-
212-
[pasteboard setItemProviders:@[ itemProvider ]];
213-
if ([pasteboard respondsToSelector:@selector(setRegistrationInfoLists:)])
214-
[pasteboard setRegistrationInfoLists:@[ representationsToRegister ]];
215-
}
216-
217217
#endif
218218

219219
#if ENABLE(DATA_INTERACTION)
@@ -252,21 +252,7 @@ static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *
252252

253253
void PlatformPasteboard::write(const PasteboardWebContent& content)
254254
{
255-
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
256-
RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
257-
[representations addEntriesFromDictionary:richTextRepresentationsForPasteboardWebContent(content).autorelease()];
258-
259-
NSString *textAsString = content.dataInStringFormat;
260-
[representations setValue:[textAsString dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText];
261-
[representations setValue:[textAsString dataUsingEncoding:NSUTF16StringEncoding] forKey:(NSString *)kUTTypeUTF16PlainText];
262-
// FIXME: We vend "public.text" here for backwards compatibility with pre-iOS 11 apps. In the future, we should stop vending this UTI,
263-
// and instead set data for concrete plain text types. See <https://bugs.webkit.org/show_bug.cgi?id=173317>.
264-
[representations setValue:textAsString forKey:(NSString *)kUTTypeText];
265-
266-
// Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
267-
ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
268-
[(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
269-
#else
255+
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
270256
auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
271257

272258
[representationsToRegister addData:[webIOSPastePboardType dataUsingEncoding:NSUTF8StringEncoding] forType:webIOSPastePboardType];
@@ -294,23 +280,26 @@ static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *
294280
addRepresentationsForPlainText(representationsToRegister.get(), content.dataInStringFormat);
295281

296282
registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
297-
#endif
298-
}
299-
300-
void PlatformPasteboard::write(const PasteboardImage& pasteboardImage)
301-
{
302-
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
283+
#else
303284
RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
304-
if (!pasteboardImage.resourceMIMEType.isNull()) {
305-
[representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType];
306-
if (!pasteboardImage.url.url.isNull())
307-
[representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL];
308-
}
285+
[representations addEntriesFromDictionary:richTextRepresentationsForPasteboardWebContent(content).autorelease()];
286+
287+
NSString *textAsString = content.dataInStringFormat;
288+
[representations setValue:[textAsString dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText];
289+
[representations setValue:[textAsString dataUsingEncoding:NSUTF16StringEncoding] forKey:(NSString *)kUTTypeUTF16PlainText];
290+
// FIXME: We vend "public.text" here for backwards compatibility with pre-iOS 11 apps. In the future, we should stop vending this UTI,
291+
// and instead set data for concrete plain text types. See <https://bugs.webkit.org/show_bug.cgi?id=173317>.
292+
[representations setValue:textAsString forKey:(NSString *)kUTTypeText];
309293

310294
// Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
311295
ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
312296
[(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
313-
#else
297+
#endif
298+
}
299+
300+
void PlatformPasteboard::write(const PasteboardImage& pasteboardImage)
301+
{
302+
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
314303
auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
315304

316305
auto& types = pasteboardImage.clientTypes;
@@ -339,12 +328,36 @@ static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *
339328
}
340329

341330
registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
331+
#else
332+
RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
333+
if (!pasteboardImage.resourceMIMEType.isNull()) {
334+
[representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType];
335+
if (!pasteboardImage.url.url.isNull())
336+
[representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL];
337+
}
338+
339+
// Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
340+
ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
341+
[(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
342342
#endif
343343
}
344344

345345
void PlatformPasteboard::write(const String& pasteboardType, const String& text)
346346
{
347-
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
347+
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
348+
auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
349+
350+
NSString *pasteboardTypeAsNSString = pasteboardType;
351+
if (!text.isEmpty() && pasteboardTypeAsNSString.length) {
352+
auto pasteboardTypeAsCFString = (CFStringRef)pasteboardTypeAsNSString;
353+
if (UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeURL) || UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeText))
354+
addRepresentationsForPlainText(representationsToRegister.get(), text);
355+
else
356+
[representationsToRegister addData:[pasteboardTypeAsNSString dataUsingEncoding:NSUTF8StringEncoding] forType:pasteboardType];
357+
}
358+
359+
registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
360+
#else
348361
RetainPtr<NSDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
349362

350363
NSString *textAsString = text;
@@ -363,27 +376,12 @@ static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *
363376
// Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
364377
ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
365378
[(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
366-
#else
367-
auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
368-
369-
NSString *pasteboardTypeAsNSString = pasteboardType;
370-
if (!text.isEmpty() && pasteboardTypeAsNSString.length) {
371-
auto pasteboardTypeAsCFString = (CFStringRef)pasteboardTypeAsNSString;
372-
if (UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeURL) || UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeText))
373-
addRepresentationsForPlainText(representationsToRegister.get(), text);
374-
else
375-
[representationsToRegister addData:[pasteboardTypeAsNSString dataUsingEncoding:NSUTF8StringEncoding] forType:pasteboardType];
376-
}
377-
378-
registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
379379
#endif
380380
}
381381

382382
void PlatformPasteboard::write(const PasteboardURL& url)
383383
{
384-
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
385-
write(kUTTypeURL, url.url.string());
386-
#else
384+
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
387385
auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
388386

389387
if (NSURL *nsURL = url.url) {
@@ -393,6 +391,8 @@ static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *
393391
}
394392

395393
registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
394+
#else
395+
write(kUTTypeURL, url.url.string());
396396
#endif
397397
}
398398

Tools/ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2017-08-17 Wenson Hsieh <[email protected]>
2+
3+
Fix the build on other platforms after r220865
4+
https://bugs.webkit.org/show_bug.cgi?id=175683
5+
6+
Reviewed by Tim Horton.
7+
8+
Check __IPHONE_OS_VERSION_MAX_ALLOWED instead of __IPHONE_OS_VERSION_MIN_REQUIRED in an SPI header. SPI
9+
availability is determined by SDK version rather than deployment version.
10+
11+
* TestWebKitAPI/ios/UIKitSPI.h:
12+
113
2017-08-17 Andreas Kling <[email protected]>
214

315
Disable CSS regions at compile time

Tools/TestWebKitAPI/ios/UIKitSPI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#if PLATFORM(IOS)
2727

28-
#if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
28+
#if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
2929

3030
#import <UIKit/UIApplication_Private.h>
3131

0 commit comments

Comments
 (0)