Changeset 456 for trunk


Ignore:
Timestamp:
03/27/08 22:13:15 (17 years ago)
Author:
Nicholas Riley
Message:

Support WebKit past r31014; patch PDFView in some places (not WebKit yet).

Location:
trunk/ICeCoffEE/ICeCoffEE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/APEMain.m

    r443 r456  
    156156        } else if (ICCF_CFBundleIDMatches(bundleID, CFSTR("org.mozilla.camino"))) {
    157157            ICCF_PatchMethod("ChildView", "ICeCoffEEMenuOnly", "ICeCoffEEMenuSuper", "menuForEvent:");
    158             ICapeprintf("ICeCoffEE APE: loaded in ChildView for Camino\n");
     158            ICapeprintf("ICeCoffEE APE: loaded in ChildView for Camino\n");
    159159        }
    160160    }
    161161
    162     objc_getClass("WebCoreFrameBridge") != NULL /* require Safari 3 */ &&
    163         ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseUp:") &&
    164         ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseDown:") &&
    165         ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "menuForEvent:");
    166         ICapeprintf("ICeCoffEE APE: loaded in WebHTMLView for WebKit/Safari 3\n");
     162    ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseUp:") &&
     163        ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseDown:") &&
     164        ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "menuForEvent:");
     165    ICapeprintf("ICeCoffEE APE: loaded in WebHTMLView for WebKit/Safari 3\n");
    167166   
    168167    if (shouldLoadInNSTextView) {
     
    172171        ICapeprintf("ICeCoffEE APE: loaded generic NSTextView support\n");
    173172    }
     173   
     174    ICCF_PatchMethod("PDFView", "ICeCoffEEMenuOnly", "ICeCoffEEMenuSuper", "menuForEvent:");
     175    ICapeprintf("ICeCoffEE APE: loaded in PDFView for PDFKit\n");
    174176
    175177    ICCF_ReloadPrefs();
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEWebKit.m

    r455 r456  
    2121@end
    2222
     23// r31014 and later; likely to move again
     24@interface WebFrame (WebFrameInternal)
     25- (DOMRange *)_convertNSRangeToDOMRange:(NSRange)range;
     26- (NSString *)_stringForRange:(DOMRange *)range;
     27@end
     28
    2329// XXX WebHTMLView is going away
    2430@interface WebHTMLView : NSObject
     
    2834
    2935- (WebView *)_webView;
    30 - (WebCoreFrameBridge *)_bridge;
     36- (WebCoreFrameBridge *)_bridge; // moved from WebNSViewExtras in r14032; removed in r31014
     37- (WebFrame *)_frame; // moved from WebNSViewExtras in r14032
    3138
    3239@end
     
    142149            ICLog(@"got a link");
    143150            if (!elementIsEditable) {
    144                 ICCF_StopIC();
    145151                return;
    146152            }
     
    156162            NSAssert(range.location != NSNotFound, ICCF_LocalizedString(@"Sorry, ICeCoffEE was unable to find anything to select"));
    157163
    158             WebCoreFrameBridge *bridge = [(WebHTMLView *)self _bridge];
     164            WebFrame *frame = [(WebHTMLView *)self _frame];
     165            WebCoreFrameBridge *bridge = nil;
     166            if ([self respondsToSelector: @selector(_bridge)])
     167                bridge = [(WebHTMLView *)self _bridge];
    159168
    160169            // XXX limit to a reasonable size
     
    162171            if (elementIsEditable) // for form fields, range will be field-relative rather than document-relative
    163172                s = [[(NSView<NSTextInput> *)self attributedSubstringFromRange: NSMakeRange(0, UINT_MAX)] string];
    164             else // sometimes attributedSubstringFromRange: returns nil
    165                 s = [bridge stringForRange: [(WebHTMLView *)self _documentRange]];
    166            
     173            else { // sometimes attributedSubstringFromRange: returns nil
     174                domRange = [(WebHTMLView *)self _documentRange];
     175                if (bridge != nil)
     176                    s = [bridge stringForRange: domRange];
     177                else if (![frame respondsToSelector: @selector(_stringForRange:)])
     178                    return; // WebKit too new?
     179                else
     180                    s = [frame _stringForRange: domRange];
     181            }
     182           
     183            if (bridge == nil && ![frame respondsToSelector: @selector(_convertNSRangeToDOMRange:)]) {
     184                return; // WebKit too new?
     185            }
     186               
    167187            if (range.length == 0) {
    168188                range.length = 1;
    169189                range = ICCF_URLEnclosingRange(s, range);
    170                 domRange = [bridge convertNSRangeToDOMRange: range];
     190                domRange = bridge ? [bridge convertNSRangeToDOMRange: range] :
     191                                    [frame _convertNSRangeToDOMRange: range];
    171192                [webView setSelectedDOMRange: domRange affinity: NSSelectionAffinityDownstream];
    172193            } else {
    173                 domRange = [bridge convertNSRangeToDOMRange: range];
     194                domRange = bridge ? [bridge convertNSRangeToDOMRange: range] :
     195                                    [frame _convertNSRangeToDOMRange: range];
    174196            }
    175197           
     
    202224                [webView setGrammarCheckingEnabled: YES];
    203225        }
     226        ICCF_StopIC();
    204227    }
    205 
    206     ICCF_StopIC();
    207228}
    208229
Note: See TracChangeset for help on using the changeset viewer.