Ignore:
Timestamp:
04/18/05 05:30:49 (19 years ago)
Author:
Nicholas Riley
Message:

ICeCoffEE 1.4 and preliminary 1.4.1 changes. Sorry, I forgot to
commit version 1.4 when it was released, so the precise source for
that release has been lost.

See the release notes for details of what changed in these versions.
1.4 was a significant feature release; 1.4.1 is a bug fix for 10.3.9,
incorporating up-to-date Unsanity Installer and APE.

package-ICeCoffEE.sh: use xcodebuild instead of pbxbuild.

File:
1 edited

Legend:

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

    r106 r167  
    1111
    1212// from WebCoreBridge.h
    13 @interface WebCoreBridge
     13@interface WebCoreBridge : NSObject
    1414
    1515- (NSDictionary *)elementAtPoint:(NSPoint)point;
    16 
    17 - (void)setSelectionFrom:(id /* WebDOMNode */)start startOffset:(int)startOffset to:(id /* WebDOMNode */)end endOffset:(int) endOffset;
     16- (NSString *)selectedString;
    1817- (void)deselectAll;
    1918
    20 - (void)forceLayout;
    21 
    22 - (NSString *)selectedString;
     19// only in Safari 1.0-1.2
     20- (void)setSelectionFrom:(id /* WebDOMNode */)start startOffset:(int)startOffset to:(id /* WebDOMNode */)end endOffset:(int) endOffset;
    2321
    2422- (id /* WebDOMNode */)selectionStart;
     
    2725- (int)selectionEndOffset;
    2826
     27// only in Safari 1.1-1.2
     28- (NSRect)selectionRect;
     29
     30// only in Safari 1.3
     31- (void)selectNSRange:(NSRange)range;
     32
    2933@end
    3034
    31 // from WebKit, not yet public
    32 @interface WebHTMLView
     35// from WebKit, private
     36@interface WebHTMLView : NSObject
    3337
    3438- (WebCoreBridge *)_bridge;
    35 - (NSDictionary *)_elementAtPoint:(NSPoint)point;
     39
     40// only in Safari 1.3
     41- (NSRange)selectedRange;
    3642
    3743@end
     
    4652
    4753static NSEvent *downEvent = nil;
     54
     55// used in Safari < 1.3 because there's no sane way to set the selection
    4856typedef struct {
    4957    int startOffset;
     
    5260    id toNode;
    5361} ICCF_WebCoreSelection;
    54 static NSString *selectedString = nil; // XXX remove when we can do this properly
    5562
    5663static ICCF_WebCoreSelection selection = {nil, nil, 0, 0};
     
    6168    ioSel->startOffset = [bridge selectionStartOffset];
    6269    ioSel->endOffset = [bridge selectionEndOffset];
    63     if (ioSel->startOffset != 0 && ioSel->endOffset != 0) {
    64         ioSel->fromNode = [[bridge selectionStart] retain];
    65         ioSel->toNode = [[bridge selectionEnd] retain];
    66     }
     70    ioSel->fromNode = [[bridge selectionStart] retain];
     71    ioSel->toNode = [[bridge selectionEnd] retain];
    6772}
    6873
     
    7580                   endOffset: inSel->endOffset];
    7681}
     82// end Safari < 1.3 section
     83
     84static NSString *selectedString = nil;
     85static NSRange selectedRange;
    7786
    7887- (void)mouseDown:(NSEvent *)e;
    7988{
     89        [downEvent release]; downEvent = nil;
    8090    // don't want command-option-click, command-shift-click, etc. to trigger
    8191    if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) {
    82         // save selection: it will be deselected on super mouseDown
    8392        WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
    84         ICCF_GetWebCoreBridgeSelection(bridge, &selection);
    85         ICLog(@"selection start %d@%@ end %d@%@ string %@", [bridge selectionStartOffset], [bridge selectionStart], [bridge selectionEndOffset], [bridge selectionEnd], [bridge selectedString]);
    86         // XXX hack until we have something better
    87         [selectedString release]; selectedString = nil;
    88         selectedString = [[bridge selectedString] retain];
    89         downEvent = e;
    90     } else {
    91         downEvent = nil;
     93                if ([self respondsToSelector: @selector(selectedRange)]) {
     94                        // Safari 1.3 save selection: it may be deselected on super mouseDown
     95                        selectedRange = [(WebHTMLView *)self selectedRange];
     96                } else if ([bridge respondsToSelector: @selector(selectionStartOffset)]) {
     97                        // Safari < 1.3 save selection: it will be deselected on super mouseDown
     98                        ICCF_GetWebCoreBridgeSelection(bridge, &selection);
     99                        ICLog(@"selection start %d@%@ end %d@%@ string %@", [bridge selectionStartOffset], [bridge selectionStart], [bridge selectionEndOffset], [bridge selectionEnd], [bridge selectedString]);
     100                }
     101                [selectedString release]; selectedString = nil;
     102                selectedString = [[bridge selectedString] retain];
     103        downEvent = [e retain];
    92104    }
    93105    [super mouseDown: e];
     
    100112        NSPoint downPt = [downEvent locationInWindow];
    101113        NSPoint upPt = [e locationInWindow];
    102         downEvent = nil;
     114                [downEvent release]; downEvent = nil;
    103115        if (abs(downPt.x - upPt.x) > kICHysteresisPixels && abs(downPt.y - upPt.y) > kICHysteresisPixels)
    104116            return;
     
    107119            WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
    108120            NSPoint viewClickPt = [self convertPoint: downPt fromView: nil];
    109             NSDictionary *elementDict = [(WebHTMLView *)self _elementAtPoint: viewClickPt];
     121            NSDictionary *elementDict = [bridge elementAtPoint: viewClickPt];
    110122            ICLog(@"elementDict: %@", elementDict);
    111             NSAssert([elementDict count] != 0, @"ShouldnÕt get empty element dictionary"); // XXX clarify
     123            NSAssert([elementDict count] != 0, @"Internal error: Got empty element dictionary from WebHTMLView");
    112124            if ([elementDict objectForKey: @"WebElementLinkURL"] != nil) {
    113125                ICLog(@"got a link");
    114126                NS_VOIDRETURN; // donÕt activate on links
    115127            }
    116             if (selectedString == nil || [selectedString length] == 0)
    117                 NS_VOIDRETURN;
    118             // XXX works, but doesn't update
    119             ICCF_StartIC();
    120             ICCF_LaunchURL(selectedString, ICCF_KeyboardAction());
    121             // breaks in Safari v62 and before
    122             ICCF_SetWebCoreBridgeSelection(bridge, &selection);
    123             if (ICCF_prefs.textBlinkEnabled) {
    124                 int i;
    125                 for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
    126                     [bridge deselectAll];
    127                     usleep(kICBlinkDelayUsecs);
    128                     ICCF_SetWebCoreBridgeSelection(bridge, &selection);
    129                     usleep(kICBlinkDelayUsecs);
    130                 }
    131             }
     128                        if (selectedString == nil || [selectedString length] == 0) {
     129                                ICLog(@"no selected string");
     130                                NS_VOIDRETURN;
     131                        }
     132                        ICCF_StartIC();
     133                        // ICCF_LaunchURL(selectedString, ICCF_KeyboardAction());
     134                        if (ICCF_prefs.textBlinkEnabled &&
     135                                [bridge respondsToSelector: @selector(selectNSRange:)]) {
     136                                // blink text in Safari 1.3
     137                                [bridge selectNSRange: selectedRange];
     138                                int i;
     139                                NSRect selectionRect = [bridge selectionRect];
     140                                ICLog(@"selectedRange %@ selectionRect %@ textBlinkCount %d", NSStringFromRange(selectedRange), NSStringFromRect(selectionRect), ICCF_prefs.textBlinkCount);
     141                                for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
     142                                        [bridge deselectAll];
     143                                        [self setNeedsDisplayInRect: selectionRect];
     144                                        [self display];
     145                                        usleep(kICBlinkDelayUsecs);
     146                                        [bridge selectNSRange: selectedRange];
     147                                        [self setNeedsDisplayInRect: selectionRect];
     148                                        [self display];
     149                                        usleep(kICBlinkDelayUsecs);
     150                                }
     151                        } else {
     152                                // select text in Safari 1.0-1.2
     153                                ICCF_SetWebCoreBridgeSelection(bridge, &selection);
     154                                if (ICCF_prefs.textBlinkEnabled &&
     155                                        [bridge respondsToSelector: @selector(selectionRect)]) {
     156                                        // blink text in Safari 1.1/1.2
     157                                        int i;
     158                                        NSRect selectionRect = [bridge selectionRect];
     159                                        for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
     160                                                [bridge deselectAll];
     161                                                [self setNeedsDisplayInRect: selectionRect];
     162                                                [self display];
     163                                                usleep(kICBlinkDelayUsecs);
     164                                                ICCF_SetWebCoreBridgeSelection(bridge, &selection);
     165                                                [self setNeedsDisplayInRect: selectionRect];
     166                                                [self display];
     167                                                usleep(kICBlinkDelayUsecs);
     168                                        }
     169                                }
     170                        }
    132171        NS_HANDLER
    133172            ICCF_HandleException(localException);
     
    135174
    136175        ICCF_StopIC();
    137         // XXX need to release fromNode, toNode
    138 
    139         // [bridge forceLayout];
    140         // ICLog(@"force start %d end %d string %@", [bridge selectionStartOffset], [bridge selectionEndOffset], [bridge selectedString]);
    141 
    142         // check selected string, first
    143         // fabricate triple-click, examine selected string
    144 
    145         // setSelectionFrom:startOffset:to:endOffset:
    146 
    147         // ICCF_LaunchURLFromTextView(self);
    148176    }       
    149177}
    150178
    151 
    152 
    153179@end
Note: See TracChangeset for help on using the changeset viewer.