Commit aa81b2bb authored by mjs's avatar mjs

WebCore:

        Reviewed by Trey.

	- fixed 3132120 - onchange handler not firing on mac.com webmail

        * khtml/rendering/render_form.h:
        * khtml/rendering/render_replaced.cpp:
        (RenderWidget::handleFocusOut): Moved empty virtual method here from render_form.
        (RenderWidget::eventFilter): Uncomment call to handleFocusOut - we
	need it to send onChange properly.
	* khtml/rendering/render_replaced.h:
        * kwq/KWQObject.h: Add empty eventFilter virtual method.
        * kwq/KWQComboBox.h: Remove no longer needed empty eventFilter.
        * kwq/KWQEvent.h: Implement a bit more of QFocusEvent.
        * kwq/KWQTextArea.mm:
        (-[KWQTextArea _createTextView]): Tell the text view its widget.
        (-[KWQTextAreaTextView setWidget:]): New method to set widget.
        (-[KWQTextAreaTextView becomeFirstResponder]): In addition to the usual stuff,
	call the widget's event filter with a focus in event.
        (-[KWQTextAreaTextView resignFirstResponder]): In addition to the usual stuff,
	call the widget's event filter with a focus out event.
        * kwq/KWQTextField.mm:
        (-[KWQTextField becomeFirstResponder]): Cleaned up a bit.
        (-[KWQTextField fieldWillBecomeFirstResponder]): Call the widget's event filter with a focus in event.
        (-[KWQTextField fieldWillResignFirstResponder]): Call the widget's event filter with a focus out event.
        * kwq/KWQView.mm:

WebKit:

        Reviewed by Trey.

	- fixed 3132120 - onchange handler not firing on mac.com webmail

        * WebView.subproj/WebHTMLViewPrivate.m:
        (-[WebNSTextView resignFirstResponder]): If we really resign first responder, and
	our delegate responds to filedWillBecomeFirstResponder, then call that method.
        (-[WebNSTextView becomeFirstResponder]): If we really become first responder, and
	our delegate responds to filedWillBecomeFirstResponder, then call that method.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3862c857
2003-01-20 Maciej Stachowiak <mjs@apple.com>
Reviewed by Trey.
- fixed 3132120 - onchange handler not firing on mac.com webmail
* khtml/rendering/render_form.h:
* khtml/rendering/render_replaced.cpp:
(RenderWidget::handleFocusOut): Moved empty virtual method here from render_form.
(RenderWidget::eventFilter): Uncomment call to handleFocusOut - we
need it to send onChange properly.
* khtml/rendering/render_replaced.h:
* kwq/KWQObject.h: Add empty eventFilter virtual method.
* kwq/KWQComboBox.h: Remove no longer needed empty eventFilter.
* kwq/KWQEvent.h: Implement a bit more of QFocusEvent.
* kwq/KWQTextArea.mm:
(-[KWQTextArea _createTextView]): Tell the text view its widget.
(-[KWQTextAreaTextView setWidget:]): New method to set widget.
(-[KWQTextAreaTextView becomeFirstResponder]): In addition to the usual stuff,
call the widget's event filter with a focus in event.
(-[KWQTextAreaTextView resignFirstResponder]): In addition to the usual stuff,
call the widget's event filter with a focus out event.
* kwq/KWQTextField.mm:
(-[KWQTextField becomeFirstResponder]): Cleaned up a bit.
(-[KWQTextField fieldWillBecomeFirstResponder]): Call the widget's event filter with a focus in event.
(-[KWQTextField fieldWillResignFirstResponder]): Call the widget's event filter with a focus out event.
* kwq/KWQView.mm:
2003-01-20 David Hyatt <hyatt@apple.com>
Fix for 3147213. <nobr> is treated like other inlines now,
......
2003-01-20 Maciej Stachowiak <mjs@apple.com>
Reviewed by Trey.
- fixed 3132120 - onchange handler not firing on mac.com webmail
* khtml/rendering/render_form.h:
* khtml/rendering/render_replaced.cpp:
(RenderWidget::handleFocusOut): Moved empty virtual method here from render_form.
(RenderWidget::eventFilter): Uncomment call to handleFocusOut - we
need it to send onChange properly.
* khtml/rendering/render_replaced.h:
* kwq/KWQObject.h: Add empty eventFilter virtual method.
* kwq/KWQComboBox.h: Remove no longer needed empty eventFilter.
* kwq/KWQEvent.h: Implement a bit more of QFocusEvent.
* kwq/KWQTextArea.mm:
(-[KWQTextArea _createTextView]): Tell the text view its widget.
(-[KWQTextAreaTextView setWidget:]): New method to set widget.
(-[KWQTextAreaTextView becomeFirstResponder]): In addition to the usual stuff,
call the widget's event filter with a focus in event.
(-[KWQTextAreaTextView resignFirstResponder]): In addition to the usual stuff,
call the widget's event filter with a focus out event.
* kwq/KWQTextField.mm:
(-[KWQTextField becomeFirstResponder]): Cleaned up a bit.
(-[KWQTextField fieldWillBecomeFirstResponder]): Call the widget's event filter with a focus in event.
(-[KWQTextField fieldWillResignFirstResponder]): Call the widget's event filter with a focus out event.
* kwq/KWQView.mm:
2003-01-20 David Hyatt <hyatt@apple.com>
Fix for 3147213. <nobr> is treated like other inlines now,
......
......@@ -175,7 +175,6 @@
</dict>
</plist>
";
shouldUseHeadermap = 0;
};
0867D69DFE84028FC02AAC07 = {
buildActionMask = 2147483647;
......@@ -484,6 +483,7 @@
931BFCD403D4AEE5008635CE,
931BFCD803D4AEFD008635CE,
93955A4303D72932008635CE,
6504A7BF03DCE19800000124,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -876,6 +876,21 @@
//652
//653
//654
6504A7BE03DCE19800000124 = {
fileEncoding = 30;
isa = PBXFileReference;
path = WebCoreFirstResponderChanges.h;
refType = 4;
};
6504A7BF03DCE19800000124 = {
fileRef = 6504A7BE03DCE19800000124;
isa = PBXBuildFile;
settings = {
ATTRIBUTES = (
Private,
);
};
};
6573C63B03A0BE5700FCA39F = {
buildActionMask = 8;
files = (
......@@ -6283,6 +6298,7 @@
F58785E902DE378A01EA4122 = {
children = (
F587854702DE375901EA4122,
6504A7BE03DCE19800000124,
F587854802DE375901EA4122,
F5B2A4FC02E2220F018635CB,
F5B2A4FD02E2220F018635CB,
......
......@@ -100,8 +100,6 @@ protected:
virtual bool isRenderButton() const { return false; }
virtual bool isEditable() const { return false; }
virtual void handleFocusOut() {};
QPoint m_mousePos;
int m_state;
int m_button;
......
......@@ -291,6 +291,10 @@ void RenderWidget::paintObject(QPainter* /*p*/, int, int, int, int, int _tx, int
#endif
}
void RenderWidget::handleFocusOut()
{
}
bool RenderWidget::eventFilter(QObject* /*o*/, QEvent* e)
{
if ( !element() ) return true;
......@@ -315,7 +319,7 @@ bool RenderWidget::eventFilter(QObject* /*o*/, QEvent* e)
// KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>( element()->view->part()->browserExtension() );
// if ( ext ) ext->editableWidgetBlurred( m_widget );
// }
// handleFocusOut();
handleFocusOut();
}
break;
case QEvent::FocusIn:
......
......@@ -92,6 +92,7 @@ protected:
bool eventFilter(QObject* /*o*/, QEvent* e);
void setQWidget(QWidget *widget);
void resizeWidget( QWidget *widget, int w, int h );
virtual void handleFocusOut();
QWidget *m_widget;
KHTMLView* m_view;
......
......@@ -54,8 +54,6 @@ public:
void setFrameGeometry(const QRect &);
int baselinePosition() const;
bool eventFilter(QObject *object, QEvent *event) { return false; }
void activated() { _activated.call(currentItem()); }
private:
......
......@@ -119,10 +119,11 @@ public:
bool _isAccepted;
};
class QFocusEvent {
class QFocusEvent : public QEvent {
public:
enum Reason { Popup, Other };
static Reason reason() { return Other; }
QFocusEvent (Type type) : QEvent (type) {}
};
class QHideEvent;
......
......@@ -88,6 +88,8 @@ public:
void removeEventFilter(const QObject *) { _eventFilterObject = 0; }
const QObject *eventFilterObject() const { return _eventFilterObject; }
virtual bool eventFilter(QObject *object, QEvent *event) { return false; }
void blockSignals(bool b) { _signalsBlocked = b; }
virtual bool event(QEvent *);
......
......@@ -55,7 +55,9 @@
@interface KWQTextAreaTextView : NSTextView
{
QTextEdit *widget;
}
- (void)setWidget:(QTextEdit *)widget;
@end
@implementation KWQTextArea
......@@ -81,7 +83,8 @@ const float LargeNumberForText = 1.0e7;
textView = [[KWQTextAreaTextView alloc] initWithFrame:textFrame];
[[textView textContainer] setWidthTracksTextView:YES];
[textView setRichText:NO];
[textView setWidget:widget];
// Setup attributes for default cases WRAP=SOFT|VIRTUAL and WRAP=HARD|PHYSICAL.
// If WRAP=OFF we reset many of these attributes.
[style setLineBreakMode:NSLineBreakByWordWrapping];
......@@ -473,6 +476,11 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
@implementation KWQTextAreaTextView
- (void)setWidget:(QTextEdit *)w
{
widget = w;
}
- (void)insertTab:(id)sender
{
NSView *view = [[self delegate] nextValidKeyView];
......@@ -489,19 +497,32 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
}
}
- (BOOL)becomeFirstResponder
{
[super becomeFirstResponder];
[self selectAll:nil];
[self _KWQ_setKeyboardFocusRingNeedsDisplay];
return YES;
BOOL become = [super becomeFirstResponder];
if (become) {
[self selectAll:nil];
[self _KWQ_setKeyboardFocusRingNeedsDisplay];
QFocusEvent event(QEvent::FocusIn);
(const_cast<QObject *>(widget->eventFilterObject()))->eventFilter(widget, &event);
}
return become;
}
- (BOOL)resignFirstResponder
{
[super resignFirstResponder];
[self _KWQ_setKeyboardFocusRingNeedsDisplay];
return YES;
BOOL resign = [super resignFirstResponder];
if (resign) {
[self _KWQ_setKeyboardFocusRingNeedsDisplay];
QFocusEvent event(QEvent::FocusOut);
(const_cast<QObject *>(widget->eventFilterObject()))->eventFilter(widget, &event);
}
return resign;
}
- (BOOL)shouldDrawInsertionPoint
......
......@@ -28,6 +28,7 @@
#import "KWQLineEdit.h"
#import "KWQKHTMLPart.h"
#import "KWQNSViewExtras.h"
#import "WebCoreFirstResponderChanges.h"
// KWQTextFieldFormatter enforces a maximum length.
......@@ -243,9 +244,26 @@
- (BOOL)becomeFirstResponder
{
KWQKHTMLPart::setDocumentFocus(widget);
[self _KWQ_scrollFrameToVisible];
return [super becomeFirstResponder];
BOOL become = [super becomeFirstResponder];
if (become) {
KWQKHTMLPart::setDocumentFocus(widget);
[self _KWQ_scrollFrameToVisible];
}
return become;
}
- (void)fieldWillBecomeFirstResponder
{
QFocusEvent event(QEvent::FocusIn);
(const_cast<QObject *>(widget->eventFilterObject()))->eventFilter(widget, &event);
}
- (void)fieldWillResignFirstResponder
{
QFocusEvent event(QEvent::FocusOut);
(const_cast<QObject *>(widget->eventFilterObject()))->eventFilter(widget, &event);
}
- (void)display
......
/*
* Copyright (C) 2002, 2003 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// The WebCore client must arrange to call these methods when a text
// field's field editor becomes or resigns first responder.
@interface NSObject (WebCoreFirstResponderChanges)
- (void)fieldEditorWillBecomeFirstResponder;
- (void)fieldEditorWillResignFirstResponder;
@end
2003-01-20 Maciej Stachowiak <mjs@apple.com>
Reviewed by Trey.
- fixed 3132120 - onchange handler not firing on mac.com webmail
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebNSTextView resignFirstResponder]): If we really resign first responder, and
our delegate responds to filedWillBecomeFirstResponder, then call that method.
(-[WebNSTextView becomeFirstResponder]): If we really become first responder, and
our delegate responds to filedWillBecomeFirstResponder, then call that method.
2003-01-20 Trey Matteson <trey@apple.com>
Nit fix to remove a dead "cursor" ivar found while grepping.
......
......@@ -11,6 +11,8 @@
#import <WebFoundation/WebAssertions.h>
#import <WebFoundation/WebNSURLExtras.h>
#import <WebCore/WebCoreFirstResponderChanges.h>
#import <WebKit/WebBridge.h>
#import <WebKit/WebContextMenuDelegate.h>
#import <WebKit/WebController.h>
......@@ -627,6 +629,40 @@ - (void)_drawRect:(NSRect)rect clip:(BOOL)clip
inNSTextViewDrawRect = NO;
}
- (BOOL)resignFirstResponder
{
bool resign = [super resignFirstResponder];
if (![self _web_inHTMLView]) {
return resign;
}
NSView *possibleContainingField = [self delegate];
if (resign && [possibleContainingField respondsToSelector:@selector(fieldEditorWillResignFirstResponder)]) {
[possibleContainingField fieldEditorWillResignFirstResponder];
}
return resign;
}
- (BOOL)becomeFirstResponder
{
bool become = [super becomeFirstResponder];
if (![self _web_inHTMLView]) {
return become;
}
NSView *possibleContainingField = [self delegate];
if (become && [possibleContainingField respondsToSelector:@selector(fieldEditorWillBecomeFirstResponder)]) {
[possibleContainingField fieldEditorWillBecomeFirstResponder];
}
return become;
}
@end
@implementation WebNSView
......
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