Changeset 457


Ignore:
Timestamp:
03/28/08 21:52:35 (17 years ago)
Author:
Nicholas Riley
Message:

Better workarounds for WebKit range bugs.

File:
1 edited

Legend:

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

    r456 r457  
    7979}
    8080
     81
     82static BOOL ICCF_DOMParentOfClass(DOMNode *node, Class cls) {
     83    do {
     84        if ([node isKindOfClass: cls])
     85            return YES;
     86    } while ( (node = [node parentNode]) != nil);
     87   
     88    return NO;
     89}
     90#define ICCF_NodeIs(elt) [clickedNode isKindOfClass: NSClassFromString(@"DOMHTML"elt"Element")]
     91#define ICCF_DOMParentIs(elt) ICCF_DOMParentOfClass(clickedNode, NSClassFromString(@"DOMHTML"elt"Element"))
     92
    8193- (void)mouseUp:(NSEvent *)e;
    8294{
     
    132144
    133145        DOMNode *clickedNode = [elementDict objectForKey: @"WebElementDOMNode"];
    134        
    135         if (!elementIsEditable && ([clickedNode isKindOfClass: NSClassFromString(@"DOMHTMLInputElement")] ||
    136             [clickedNode isKindOfClass: NSClassFromString(@"DOMHTMLFieldSetElement")])) {
     146        BOOL elementIsHTMLInput = ICCF_NodeIs("Input");
     147       
     148        if (!elementIsEditable && (elementIsHTMLInput || ICCF_DOMParentIs("Button") || ICCF_NodeIs("FieldSet"))) {
    137149            ICLog(@"got an uneditable form field (e.g., button)");
    138150            return;
     
    169181            // XXX limit to a reasonable size
    170182            NSString *s;
    171             if (elementIsEditable) // for form fields, range will be field-relative rather than document-relative
     183            if (elementIsHTMLInput || ICCF_NodeIs("TextArea") || (elementIsEditable && !webViewIsEditable)) {
     184                // for form fields, range will be field-relative rather than document-relative
     185                ICLog(@"Using attributedSubstringFromRange:");
    172186                s = [[(NSView<NSTextInput> *)self attributedSubstringFromRange: NSMakeRange(0, UINT_MAX)] string];
    173             else { // sometimes attributedSubstringFromRange: returns nil
     187            } else { // sometimes attributedSubstringFromRange: returns nil
     188                ICLog(@"Using stringForRange:");
    174189                domRange = [(WebHTMLView *)self _documentRange];
    175190                if (bridge != nil)
Note: See TracChangeset for help on using the changeset viewer.