[webkit-changes] cvs commit: WebCore/manual-tests select-element-type-select.html

Darin darin at opensource.apple.com
Sat Oct 8 19:36:15 PDT 2005


darin       05/10/08 19:36:15

  Modified:    .        ChangeLog
               kwq      KWQListBox.mm
  Added:       manual-tests select-element-type-select.html
  Log:
          Reviewed by Darin.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3852
            typeahead doesn't work in multiple row select boxes.
  
          * kwq/KWQListBox.mm:
          (KWQTableViewTypeSelectCallback): Added.
          (-[KWQTableView finalize]): Deallocate the UCTypeSelect object.
          (-[KWQTableView dealloc]): Ditto.
          (-[KWQTableView keyUp:]): If character typed is a graphic character, pass it along to
          the UCTypeSelect object and use it to type select, otherwise flush the object.
  
          * manual-tests/select-element-type-select.html: Added.
  
  Revision  Changes    Path
  1.223     +16 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.222
  retrieving revision 1.223
  diff -u -r1.222 -r1.223
  --- ChangeLog	9 Oct 2005 02:14:01 -0000	1.222
  +++ ChangeLog	9 Oct 2005 02:36:11 -0000	1.223
  @@ -1,3 +1,19 @@
  +2005-10-08  Rosyna  <rosyna at unsanity.com>
  +
  +        Reviewed by Darin.
  +
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3852
  +          typeahead doesn't work in multiple row select boxes.
  +
  +        * kwq/KWQListBox.mm:
  +        (KWQTableViewTypeSelectCallback): Added.
  +        (-[KWQTableView finalize]): Deallocate the UCTypeSelect object.
  +        (-[KWQTableView dealloc]): Ditto.
  +        (-[KWQTableView keyUp:]): If character typed is a graphic character, pass it along to
  +        the UCTypeSelect object and use it to type select, otherwise flush the object.
  +
  +        * manual-tests/select-element-type-select.html: Added.
  +
   2005-10-08  Mitz Pettel  <opendarwin.org at mitzpettel.com>
   
           Reviewed by Darin.
  
  
  
  1.61      +86 -9     WebCore/kwq/KWQListBox.mm
  
  Index: KWQListBox.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQListBox.mm,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- KWQListBox.mm	6 Oct 2005 15:45:55 -0000	1.60
  +++ KWQListBox.mm	9 Oct 2005 02:36:14 -0000	1.61
  @@ -60,6 +60,7 @@
       BOOL inNextValidKeyView;
       NSWritingDirection _direction;
       BOOL isSystemFont;
  +    UCTypeSelectRef typeSelectSelector;
   }
   - (id)initWithListBox:(QListBox *)b;
   - (void)detach;
  @@ -416,6 +417,26 @@
   
   @end
   
  +static Boolean KWQTableViewTypeSelectCallback(UInt32 index, void *listDataPtr, void *refcon, CFStringRef *outString, UCTypeSelectOptions *tsOptions)
  +{
  +    KWQTableView *self = static_cast<KWQTableView *>(refcon);   
  +    QListBox *box = static_cast<QListBox *>([self widget]);
  +    
  +    if (!box)
  +        return false;
  +    
  +    if (index > box->count())
  +        return false;
  +    
  +    if (outString)
  +        *outString = box->itemAtIndex(index).string.getCFString();
  +    
  +    if (tsOptions)
  +        *tsOptions = kUCTSOptionsNoneMask;
  +    
  +    return true;
  +}
  +
   @implementation KWQTableView
   
   - (id)initWithListBox:(QListBox *)b
  @@ -442,6 +463,22 @@
       return self;
   }
   
  +- (void)finalize
  +{
  +    if (typeSelectSelector)
  +        UCTypeSelectReleaseSelector(&typeSelectSelector);
  +    
  +    [super finalize];
  +}
  +
  +- (void)dealloc
  +{
  +    if (typeSelectSelector)
  +        UCTypeSelectReleaseSelector(&typeSelectSelector);
  +    
  +    [super dealloc];
  +}
  +
   - (void)detach
   {
       _box = 0;
  @@ -465,9 +502,9 @@
       processingMouseEvent = NO;
   
       if (clickedDuringMouseEvent) {
  -	clickedDuringMouseEvent = false;
  +    clickedDuringMouseEvent = false;
       } else if (_box) {
  -	_box->sendConsumedMouseUp();
  +    _box->sendConsumedMouseUp();
       }
   }
   
  @@ -478,7 +515,7 @@
       }
       WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(_box);
       if (![bridge interceptKeyEvent:event toView:self]) {
  -	[super keyDown:event];
  +    [super keyDown:event];
       }
   }
   
  @@ -487,9 +524,49 @@
       if (!_box)  {
           return;
       }
  +    
       WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(_box);
       if (![bridge interceptKeyEvent:event toView:self]) {
  -	[super keyUp:event];
  +        [super keyUp:event];
  +        NSString *string = [event characters];
  +       
  +        if ([string length] == 0)
  +           return;
  +       
  +        // type select should work with any graphic character as defined in D13a of the unicode standard.
  +        const uint32_t graphicCharacterMask = U_GC_L_MASK | U_GC_M_MASK | U_GC_N_MASK | U_GC_P_MASK | U_GC_S_MASK | U_GC_ZS_MASK;
  +        unichar pressedCharacter = [string characterAtIndex:0];
  +        
  +        if (!(U_GET_GC_MASK(pressedCharacter) & graphicCharacterMask)) {
  +            if (typeSelectSelector)
  +                UCTypeSelectFlushSelectorData(typeSelectSelector);
  +            return;            
  +        }
  +        
  +        OSStatus err = noErr;
  +        if (!typeSelectSelector)
  +            err = UCTypeSelectCreateSelector(0, 0, kUCCollateStandardOptions, &typeSelectSelector);
  +        
  +        if (err || !typeSelectSelector)
  +            return;
  +        
  +        Boolean updateSelector = false;
  +        // the timestamp and what the AddKey function want for time are the same thing.
  +        err = UCTypeSelectAddKeyToSelector(typeSelectSelector, (CFStringRef)string, [event timestamp], &updateSelector);
  +        
  +        if (err || !updateSelector)
  +            return;
  +  
  +        UInt32 closestItem = 0;
  +        
  +        err = UCTypeSelectFindItem(typeSelectSelector, [self numberOfRowsInTableView:self], 0, self, KWQTableViewTypeSelectCallback, &closestItem); 
  +
  +        if (err)
  +            return;
  +        
  +        [self selectRowIndexes:[NSIndexSet indexSetWithIndex:closestItem] byExtendingSelection:NO];
  +        [self scrollRowToVisible:closestItem];
  +        
       }
   }
   
  @@ -505,7 +582,7 @@
           if (_box && !KWQKHTMLPart::currentEventIsMouseDownInWidget(_box)) {
               [self _KWQ_scrollFrameToVisible];
           }        
  -	[self _KWQ_setKeyboardFocusRingNeedsDisplay];
  +    [self _KWQ_setKeyboardFocusRingNeedsDisplay];
   
           if (_box) {
               QFocusEvent event(QEvent::FocusIn);
  @@ -583,10 +660,10 @@
           _box->selectionChanged();
       }
       if (_box && !_box->changingSelection()) {
  -	if (processingMouseEvent) {
  -	    clickedDuringMouseEvent = true;
  -	    _box->sendConsumedMouseUp();
  -	}
  +    if (processingMouseEvent) {
  +        clickedDuringMouseEvent = true;
  +        _box->sendConsumedMouseUp();
  +    }
           if (_box) {
               _box->clicked();
           }
  
  
  
  1.1                  WebCore/manual-tests/select-element-type-select.html
  
  Index: select-element-type-select.html
  ===================================================================
  <html>
  <head>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
  
  	<title>select test</title>
  </head>
  
  <body>
  Typing c should select c for you here:<br/>
  <select>
  <option value="1">aaaaa</option>
  <option value="2">bbbbb</option>
  <option value="3">ccccc</option>
  <option value="4">ddddd</option>
  <option value="5">eeeee</option>
  <option value="6">fffff</option>
  <option value="7">ggggg</option>
  </select>
  <br/><br/>
  And should here too:<br/>
  <select multiple size="3">
  <option value="1">aaaaa</option>
  <option value="2">bbbbb</option>
  <option value="3">cccc</option>
  <option value="4">ddddd</option>
  <option value="5">ßcccc</option>
  <option value="6">eeeee</option>
  <option value="7">fffff</option>
  <option value="8">zgggg</option>
  </select>
  </body>
  
  </html>
  
  
  



More information about the webkit-changes mailing list