[iOS] Upstream WebKit support for various features
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jan 2014 00:42:20 +0000 (00:42 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jan 2014 00:42:20 +0000 (00:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126413

Reviewed by Sam Weinig.

Upstream iOS WebKit changes needed for these features:

- ENABLE(DELETION_UI)
- ENABLE(TOUCH_EVENTS)
- USE(QUICK_LOOK)
- USE(UIKIT_EDITING)
- ENABLE(DISK_IMAGE_CACHE)
- ENABLE(IOS_TEXT_AUTOSIZING)
- ENABLE(ICONDATABASE)
- ENABLE(DASHBOARD_SUPPORT)

* DefaultDelegates/WebDefaultEditingDelegate.m:
* Misc/WebCache.mm:
* WebCoreSupport/WebChromeClient.h:
* WebView/WebDataSource.mm:
(-[WebDataSource dealloc]):
* WebView/WebEditingDelegatePrivate.h:
* WebView/WebFrame.mm:
(-[WebFrame _loadData:MIMEType:textEncodingName:baseURL:unreachableURL:]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView maintainsInactiveSelection]):
(-[WebHTMLView touch:]):
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):
(-[WebView _cacheFrameLoadDelegateImplementations]):
(-[WebView quickLookContentForURL:]):
(-[WebView _touchEventRegions]):
* WebView/WebViewPrivate.h:

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

12 files changed:
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DefaultDelegates/WebDefaultEditingDelegate.m
Source/WebKit/mac/Misc/WebCache.mm
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebView/WebDataSource.mm
Source/WebKit/mac/WebView/WebEditingDelegatePrivate.h
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewPrivate.h

index e52b754..7a67aa1 100644 (file)
@@ -1,5 +1,44 @@
 2014-01-02  Andy Estes  <aestes@apple.com>
 
+        [iOS] Upstream WebKit support for various features
+        https://bugs.webkit.org/show_bug.cgi?id=126413
+
+        Reviewed by Sam Weinig.
+
+        Upstream iOS WebKit changes needed for these features:
+
+        - ENABLE(DELETION_UI)
+        - ENABLE(TOUCH_EVENTS)
+        - USE(QUICK_LOOK)
+        - USE(UIKIT_EDITING)
+        - ENABLE(DISK_IMAGE_CACHE)
+        - ENABLE(IOS_TEXT_AUTOSIZING)
+        - ENABLE(ICONDATABASE)
+        - ENABLE(DASHBOARD_SUPPORT)
+
+        * DefaultDelegates/WebDefaultEditingDelegate.m:
+        * Misc/WebCache.mm:
+        * WebCoreSupport/WebChromeClient.h:
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource dealloc]):
+        * WebView/WebEditingDelegatePrivate.h:
+        * WebView/WebFrame.mm:
+        (-[WebFrame _loadData:MIMEType:textEncodingName:baseURL:unreachableURL:]):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView maintainsInactiveSelection]):
+        (-[WebHTMLView touch:]):
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+        (-[WebView _cacheFrameLoadDelegateImplementations]):
+        (-[WebView quickLookContentForURL:]):
+        (-[WebView _touchEventRegions]):
+        * WebView/WebViewPrivate.h:
+
+2014-01-02  Andy Estes  <aestes@apple.com>
+
         [iOS] Upstream a bug fix for plugin-backed media elements
         https://bugs.webkit.org/show_bug.cgi?id=126412
 
index 01f9043..6cd5f39 100644 (file)
@@ -45,10 +45,12 @@ static WebDefaultEditingDelegate *sharedDelegate = nil;
     return sharedDelegate;
 }
 
+#if ENABLE(DELETION_UI)
 - (BOOL)webView:(WebView *)webView shouldShowDeleteInterfaceForElement:(DOMHTMLElement *)element
 {
     return NO;
 }
+#endif
 
 - (BOOL)webView:(WebView *)webView shouldBeginEditingInDOMRange:(DOMRange *)range
 {
index d0b254a..18e6c23 100644 (file)
 #import <WebCore/WebCoreThreadRun.h>
 #endif
 
+#if ENABLE(CACHE_PARTITIONING)
+#import <WebCore/Document.h>
+#endif
+
 @implementation WebCache
 
 + (void)initialize
index de778d4..b839286 100644 (file)
@@ -152,6 +152,10 @@ public:
     virtual void enableSuddenTermination() OVERRIDE;
     virtual void disableSuddenTermination() OVERRIDE;
     
+#if ENABLE(TOUCH_EVENTS)
+    virtual void needTouchEvents(bool) OVERRIDE { }
+#endif
+
     virtual bool shouldReplaceWithGeneratedFileForUpload(const WTF::String& path, WTF::String &generatedFilename) OVERRIDE;
     virtual WTF::String generateReplacementFile(const WTF::String& path) OVERRIDE;
 
index 9267e6b..d194033 100644 (file)
@@ -488,6 +488,12 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
         }
     }
 #endif
+    
+#if USE(QUICK_LOOK)
+    // Added in -[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:].
+    if (NSURL *url = [[self response] URL])
+        removeQLPreviewConverterForURL(url);
+#endif
 
     delete toPrivate(_private);
 
index a694c2e..835a020 100644 (file)
@@ -31,8 +31,8 @@
 @class DOMHTMLElement;
 
 @interface NSObject (WebViewEditingDelegatePrivate)
-- (BOOL)webView:(WebView *)webView shouldShowDeleteInterfaceForElement:(DOMHTMLElement *)element;
 #if !TARGET_OS_IPHONE
+- (BOOL)webView:(WebView *)webView shouldShowDeleteInterfaceForElement:(DOMHTMLElement *)element;
 - (void)webView:(WebView *)webView didWriteSelectionToPasteboard:(NSPasteboard *)pasteboard;
 #else
 - (NSArray *)supportedPasteboardTypesForCurrentSelection;
index f7a9e7b..382e5c4 100644 (file)
 #import <WebCore/WebCoreThreadRun.h>
 #endif
 
+#if USE(QUICK_LOOK)
+#import <WebCore/QuickLook.h>
+#import <WebCore/WebCoreURLResponseIOS.h>
+#endif
+
 using namespace WebCore;
 using namespace HTMLNames;
 
@@ -2431,6 +2436,19 @@ static NSURL *createUniqueWebDataURL()
         responseURL = createUniqueWebDataURL();
     }
     
+#if USE(QUICK_LOOK)
+    if (shouldUseQuickLookForMIMEType(MIMEType)) {
+        URL qlURL = responseURL;
+        if (qlURL.isEmpty())
+            qlURL = [baseURL absoluteURL];
+        OwnPtr<ResourceRequest> qlRequest(registerQLPreviewConverterIfNeeded((NSURL *)qlURL, MIMEType, data));
+        if (qlRequest) {
+            _private->coreFrame->loader().load(FrameLoadRequest(_private->coreFrame, *qlRequest));
+            return;
+        }
+    }
+#endif // USE(QUICK_LOOK)
+
     ResourceRequest request([baseURL absoluteURL]);
 
 #if !PLATFORM(IOS)
index fd24944..ce47343 100644 (file)
@@ -3052,6 +3052,17 @@ WEBCORE_COMMAND(toggleUnderline)
 
 - (BOOL)maintainsInactiveSelection
 {
+#if USE(UIKIT_EDITING)
+    // We want to maintain an inactive selection, when in editable content.
+    if ([[self _webView] maintainsInactiveSelection])
+        return YES;
+
+    if ([[self window] _newFirstResponderAfterResigning] == self)
+        return YES;
+    
+    Frame* coreFrame = core([self _frame]);
+    return coreFrame && coreFrame->selection().isContentEditable();
+#else
     // This method helps to determine whether the WebHTMLView should maintain
     // an inactive selection when it's not first responder.
     // Traditionally, these views have not maintained such selections,
@@ -3086,6 +3097,7 @@ WEBCORE_COMMAND(toggleUnderline)
         && [nextResponder isDescendantOf:[[[self _webView] mainFrame] frameView]];
 
     return selectionIsEditable && nextResponderIsInWebView;
+#endif
 }
 
 #if !PLATFORM(IOS)
@@ -3953,6 +3965,18 @@ static void setMenuTargets(NSMenu* menu)
     _private->handlingMouseDownEvent = NO;
 }
 
+#if ENABLE(TOUCH_EVENTS)
+- (void)touch:(WebEvent *)event
+{
+    RetainPtr<WebHTMLView> protector = self;
+
+    // Let WebCore get a chance to deal with the event. This will call back to us
+    // to start the autoscroll timer if appropriate.
+    if (Frame* coreframe = core([self _frame]))
+        coreframe->eventHandler().touchEvent(event);
+}
+#endif
+
 #if ENABLE(DRAG_SUPPORT)
 - (void)dragImage:(NSImage *)dragImage
                at:(NSPoint)at
index 7bdb12c..35480ca 100644 (file)
@@ -557,6 +557,11 @@ public:
         [NSNumber numberWithBool:NO],     WebKitNetworkDataUsageTrackingEnabledPreferenceKey,
         @"",                              WebKitNetworkInterfaceNamePreferenceKey,
 #endif
+#if ENABLE(DISK_IMAGE_CACHE)
+        [NSNumber numberWithBool:YES], WebKitDiskImageCacheEnabledPreferenceKey,
+        [NSNumber numberWithUnsignedInt:(100 * 1024)], WebKitDiskImageCacheMinimumImageSizePreferenceKey,
+        [NSNumber numberWithUnsignedInt:(100 * 1024 * 1024)], WebKitDiskImageCacheMaximumCacheSizePreferenceKey,
+#endif
 #if ENABLE(IOS_TEXT_AUTOSIZING)
         [NSNumber numberWithFloat:WKGetMinimumZoomFontSize()], WebKitMinimumZoomFontSizePreferenceKey,
 #endif
index 132226a..58f32f7 100644 (file)
@@ -268,6 +268,21 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (void)setNetworkInterfaceName:(NSString *)name;
 - (NSString *)networkInterfaceName;
 
+- (void)_setMinimumZoomFontSize:(float)size;
+- (float)_minimumZoomFontSize;
+
+- (BOOL)diskImageCacheEnabled;
+- (void)setDiskImageCacheEnabled:(BOOL)enabled;
+
+- (unsigned)diskImageCacheMinimumImageSize;
+- (void)setDiskImageCacheMinimumImageSize:(unsigned)minimumSize;
+
+- (unsigned)diskImageCacheMaximumCacheSize;
+- (void)setDiskImageCacheMaximumCacheSize:(unsigned)maximumSize;
+
+- (NSString *)_diskImageCacheSavedCacheDirectory;
+- (void)_setDiskImageCacheSavedCacheDirectory:(NSString *)path;
+
 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)flag;
 - (BOOL)mediaPlaybackAllowsAirPlay;
 #endif
index c4a4842..b31c139 100644 (file)
 #import <glib.h>
 #endif
 
+#if USE(QUICK_LOOK)
+#include <WebCore/QuickLook.h>
+#endif
+
+#if ENABLE(TOUCH_EVENTS)
+#import <WebCore/WebEventRegion.h>
+#endif
+
+#if ENABLE(DISK_IMAGE_CACHE)
+#import "WebDiskImageCacheClientIOS.h"
+#import <WebCore/DiskImageCacheIOS.h>
+#endif
+
 #if !PLATFORM(IOS)
 @interface NSSpellChecker (WebNSSpellCheckerDetails)
 - (void)_preflightChosenSpellServer;
@@ -587,6 +600,11 @@ NSString *_WebMainFrameURLKey =         @"mainFrameURL";
 NSString *_WebMainFrameDocumentKey =    @"mainFrameDocument";
 #endif
 
+#if USE(QUICK_LOOK)
+NSString *WebQuickLookFileNameKey = @"WebQuickLookFileNameKey";
+NSString *WebQuickLookUTIKey      = @"WebQuickLookUTIKey";
+#endif
+
 NSString *_WebViewDidStartAcceleratedCompositingNotification = @"_WebViewDidStartAcceleratedCompositing";
 NSString * const WebViewWillCloseNotification = @"WebViewWillCloseNotification";
 
@@ -2476,6 +2494,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     if (_private->zoomsTextOnly != zoomsTextOnly)
         [self _setZoomMultiplier:_private->zoomMultiplier isTextOnly:zoomsTextOnly];
 
+#if ENABLE(IOS_TEXT_AUTOSIZING)
+    settings.setMinimumZoomFontSize([preferences _minimumZoomFontSize]);
+#endif
+
 #if ENABLE(DISK_IMAGE_CACHE) && PLATFORM(IOS)
     DiskImageCache& diskImageCache = WebCore::diskImageCache();
     diskImageCache.setEnabled([preferences diskImageCacheEnabled]);
@@ -2588,7 +2610,9 @@ static inline IMP getMethod(id o, SEL s)
     cache->didFirstVisuallyNonEmptyLayoutInFrameFunc = getMethod(delegate, @selector(webView:didFirstVisuallyNonEmptyLayoutInFrame:));
     cache->didLayoutFunc = getMethod(delegate, @selector(webView:didLayout:));
     cache->didHandleOnloadEventsForFrameFunc = getMethod(delegate, @selector(webView:didHandleOnloadEventsForFrame:));
+#if ENABLE(ICONDATABASE)
     cache->didReceiveIconForFrameFunc = getMethod(delegate, @selector(webView:didReceiveIcon:forFrame:));
+#endif
     cache->didReceiveServerRedirectForProvisionalLoadForFrameFunc = getMethod(delegate, @selector(webView:didReceiveServerRedirectForProvisionalLoadForFrame:));
     cache->didReceiveTitleForFrameFunc = getMethod(delegate, @selector(webView:didReceiveTitle:forFrame:));
     cache->didStartProvisionalLoadForFrameFunc = getMethod(delegate, @selector(webView:didStartProvisionalLoadForFrame:));
@@ -3597,6 +3621,21 @@ static inline IMP getMethod(id o, SEL s)
     return _private->page->setDefersLoading(defer);
 }
 
+#if USE(QUICK_LOOK)
+- (NSDictionary *)quickLookContentForURL:(NSURL *)url
+{
+    NSString *uti = qlPreviewConverterUTIForURL(url);
+    if (!uti)
+        return nil;
+
+    NSString *fileName = qlPreviewConverterFileNameForURL(url);
+    if (!fileName)
+        return nil;
+
+    return [NSDictionary dictionaryWithObjectsAndKeys: fileName, WebQuickLookFileNameKey, uti, WebQuickLookUTIKey, nil];
+}
+#endif
+
 #if PLATFORM(IOS)
 - (BOOL)_isStopping
 {
@@ -3722,6 +3761,50 @@ static inline IMP getMethod(id o, SEL s)
 }
 #endif // PLATFORM(IOS)
 
+#if ENABLE(TOUCH_EVENTS)
+- (NSArray *)_touchEventRegions
+{
+    Frame* frame = [self _mainCoreFrame];
+    if (!frame)
+        return nil;
+    
+    Document* document = frame->document();
+    if (!document)
+        return nil;
+
+    Vector<IntRect> rects;
+    document->getTouchRects(rects);
+
+    if (rects.size() == 0)
+        return nil;
+
+    NSMutableArray *eventRegionArray = [[[NSMutableArray alloc] initWithCapacity:rects.size()] autorelease];
+
+    Vector<IntRect>::const_iterator end = rects.end();
+    for (Vector<IntRect>::const_iterator it = rects.begin(); it != end; ++it) {
+        const IntRect& rect = *it;
+        if (rect.isEmpty())
+            continue;
+
+        // The event region wants this points in this order:
+        //  p2------p3
+        //  |       |
+        //  p1------p4
+        //
+        WebEventRegion *eventRegion = [[WebEventRegion alloc] initWithPoints:FloatPoint(rect.x(), rect.maxY())
+                                                                            :FloatPoint(rect.x(), rect.y())
+                                                                            :FloatPoint(rect.maxX(), rect.y())
+                                                                            :FloatPoint(rect.maxX(), rect.maxY())];
+        if (eventRegion) {
+            [eventRegionArray addObject:eventRegion];
+            [eventRegion release];
+        }
+    }
+
+    return eventRegionArray;
+}
+#endif // ENABLE(TOUCH_EVENTS)
+
 // For backwards compatibility with the WebBackForwardList API, we honor both
 // a per-WebView and a per-preferences setting for whether to use the page cache.
 
@@ -3766,11 +3849,13 @@ static inline IMP getMethod(id o, SEL s)
     return [[[WebTextIterator alloc] initWithRange:kit(selectionInsideRect.toNormalizedRange().get())] autorelease];
 }
 
+#if ENABLE(DASHBOARD_SUPPORT)
 - (void)handleAuthenticationForResource:(id)identifier challenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource 
 {
     NSWindow *window = [self hostWindow] ? [self hostWindow] : [self window]; 
     [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window]; 
 } 
+#endif
 
 #if !PLATFORM(IOS)
 - (void)_clearUndoRedoOperations
index 8595c07..2a9f523 100644 (file)
@@ -101,6 +101,11 @@ extern NSString *_WebViewDidStartAcceleratedCompositingNotification;
 extern NSString *_WebViewRemoteInspectorHasSessionChangedNotification;
 #endif
 
+#if TARGET_OS_IPHONE
+extern NSString *WebQuickLookFileNameKey;
+extern NSString *WebQuickLookUTIKey;
+#endif
+
 extern NSString * const WebViewWillCloseNotification;
 
 #if ENABLE_DASHBOARD_SUPPORT
@@ -466,6 +471,10 @@ Could be worth adding to the API.
 + (void)_clearPrivateBrowsingSessionCookieStorage;
 
 - (void)_replaceCurrentHistoryItem:(WebHistoryItem *)item;
+#endif // PLATFORM(IOS)
+
+#if TARGET_OS_IPHONE
+- (NSDictionary *)quickLookContentForURL:(NSURL *)url;
 #endif
 
 // May well become public