Commit c64965d6 authored by darin's avatar darin

Reviewed by Adele.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7291
          REGRESSION: delete key does not work in isIndex fields

        * platform/mac/WebCoreTextField.mm:
        (inputElement): Added. Helper function to get the Objective-C wrapper for an
        input element associated with a QTextEdit. Returns nil if the element is not
        an input element. The bug was caused by passing a non-input element to the
        delegate methods.
        (-[KWQTextFieldController controlTextDidBeginEditing:]): Use inputElement
        and don't make the delegate call at all if there is none. This happens only
        with isindex elements; it's not important to have auto-fill work with those.
        (-[KWQTextFieldController controlTextDidEndEditing:]): Ditto.
        (-[KWQTextFieldController controlTextDidChange:]): Ditto.
        (-[KWQTextFieldController control:textShouldEndEditing:]): Ditto.
        (-[KWQTextFieldController control:textView:doCommandBySelector:]): Ditto.
        (-[KWQTextFieldController textView:shouldHandleEvent:]): Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a9406af1
2006-06-04 Darin Adler <darin@apple.com>
Reviewed by Adele.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7291
REGRESSION: delete key does not work in isIndex fields
* platform/mac/WebCoreTextField.mm:
(inputElement): Added. Helper function to get the Objective-C wrapper for an
input element associated with a QTextEdit. Returns nil if the element is not
an input element. The bug was caused by passing a non-input element to the
delegate methods.
(-[KWQTextFieldController controlTextDidBeginEditing:]): Use inputElement
and don't make the delegate call at all if there is none. This happens only
with isindex elements; it's not important to have auto-fill work with those.
(-[KWQTextFieldController controlTextDidEndEditing:]): Ditto.
(-[KWQTextFieldController controlTextDidChange:]): Ditto.
(-[KWQTextFieldController control:textShouldEndEditing:]): Ditto.
(-[KWQTextFieldController control:textView:doCommandBySelector:]): Ditto.
(-[KWQTextFieldController textView:shouldHandleEvent:]): Ditto.
2006-06-04 Darin Adler <darin@apple.com> 2006-06-04 Darin Adler <darin@apple.com>
Reviewed by Anders. Reviewed by Anders.
......
...@@ -26,15 +26,18 @@ ...@@ -26,15 +26,18 @@
#import "config.h" #import "config.h"
#import "WebCoreTextField.h" #import "WebCoreTextField.h"
#import "KWQLineEdit.h" #import "DOMInternal.h"
#import "Element.h"
#import "FrameMac.h" #import "FrameMac.h"
#import "HTMLNames.h"
#import "KWQKHTMLSettings.h" #import "KWQKHTMLSettings.h"
#import "KWQLineEdit.h"
#import "WebCoreFrameBridge.h" #import "WebCoreFrameBridge.h"
#import "WebCoreWidgetHolder.h"
#import "WidgetClient.h" #import "WidgetClient.h"
#import <wtf/Assertions.h> #import <wtf/Assertions.h>
using namespace WebCore; using namespace WebCore;
using namespace HTMLNames;
@interface NSString (WebCoreTextField) @interface NSString (WebCoreTextField)
- (int)_KWQ_numComposedCharacterSequences; - (int)_KWQ_numComposedCharacterSequences;
...@@ -163,6 +166,19 @@ using namespace WebCore; ...@@ -163,6 +166,19 @@ using namespace WebCore;
edited = ed; edited = ed;
} }
static DOMHTMLInputElement* inputElement(QLineEdit* widget)
{
if (!widget)
return nil;
WidgetClient* client = widget->client();
if (!client)
return nil;
Element* element = client->element(widget);
if (!element || !element->hasTagName(inputTag))
return nil;
return (DOMHTMLInputElement*)[DOMElement _elementWith:element];
}
- (void)controlTextDidBeginEditing:(NSNotification *)notification - (void)controlTextDidBeginEditing:(NSNotification *)notification
{ {
if (!widget) if (!widget)
...@@ -170,8 +186,8 @@ using namespace WebCore; ...@@ -170,8 +186,8 @@ using namespace WebCore;
[[field _KWQ_currentEditor] setWantsNotificationForMarkedText:YES]; [[field _KWQ_currentEditor] setWantsNotificationForMarkedText:YES];
WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(widget); if (DOMHTMLInputElement* input = inputElement(widget))
[bridge textFieldDidBeginEditing:(DOMHTMLInputElement *)[bridge elementForView:field]]; [FrameMac::bridgeForWidget(widget) textFieldDidBeginEditing:input];
} }
- (void)controlTextDidEndEditing:(NSNotification *)notification - (void)controlTextDidEndEditing:(NSNotification *)notification
...@@ -179,8 +195,8 @@ using namespace WebCore; ...@@ -179,8 +195,8 @@ using namespace WebCore;
if (!widget) if (!widget)
return; return;
WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(widget); if (DOMHTMLInputElement* input = inputElement(widget))
[bridge textFieldDidEndEditing:(DOMHTMLInputElement *)[bridge elementForView:field]]; [FrameMac::bridgeForWidget(widget) textFieldDidEndEditing:input];
if (widget && widget->client() && [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) if (widget && widget->client() && [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement)
widget->client()->returnPressed(widget); widget->client()->returnPressed(widget);
...@@ -194,10 +210,9 @@ using namespace WebCore; ...@@ -194,10 +210,9 @@ using namespace WebCore;
if (FrameMac::handleKeyboardOptionTabInView(field)) if (FrameMac::handleKeyboardOptionTabInView(field))
return; return;
if (![[field _KWQ_currentEditor] hasMarkedText]) { if (![[field _KWQ_currentEditor] hasMarkedText])
WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(widget); if (DOMHTMLInputElement* input = inputElement(widget))
[bridge textDidChangeInTextField:(DOMHTMLInputElement *)[bridge elementForView:field]]; [FrameMac::bridgeForWidget(widget) textDidChangeInTextField:input];
}
edited = YES; edited = YES;
[self textChanged]; [self textChanged];
...@@ -227,7 +242,7 @@ using namespace WebCore; ...@@ -227,7 +242,7 @@ using namespace WebCore;
{ {
if (!widget) if (!widget)
return NO; return NO;
return YES; return YES;
} }
...@@ -235,9 +250,11 @@ using namespace WebCore; ...@@ -235,9 +250,11 @@ using namespace WebCore;
{ {
if (!widget) if (!widget)
return NO; return NO;
WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(widget); if (DOMHTMLInputElement* input = inputElement(widget))
return [bridge textField:(DOMHTMLInputElement *)[bridge elementForView:field] doCommandBySelector:commandSelector]; return [FrameMac::bridgeForWidget(widget) textField:input doCommandBySelector:commandSelector];
return NO;
} }
- (void)textChanged - (void)textChanged
...@@ -287,7 +304,9 @@ using namespace WebCore; ...@@ -287,7 +304,9 @@ using namespace WebCore;
Widget::setDeferFirstResponderChanges(true); Widget::setDeferFirstResponderChanges(true);
BOOL intercepted = [bridge textField:(DOMHTMLInputElement *)[bridge elementForView:field] shouldHandleEvent:event]; BOOL intercepted = NO;
if (DOMHTMLInputElement* input = inputElement(widget))
intercepted = [bridge textField:input shouldHandleEvent:event];
if (!intercepted) if (!intercepted)
intercepted = [bridge interceptKeyEvent:event toView:view]; intercepted = [bridge interceptKeyEvent:event toView:view];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment