[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:41:07 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 3c46af15c5724c48e0cc784bd06b77fecd4e582b
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu May 8 22:23:38 2003 +0000

            Reviewed by Maciej.
    
    	- fixed 3251985 -- REGRESSION: tabbing doesn't scroll text fields into view any more
    
            * kwq/KWQTextField.h: Add a _hasFocus field, which prevents us from focusing
            multiple times.
            * kwq/KWQTextField.mm:
            (+[KWQTextField initialize]): Set KWQTextFieldCell as the cell class. We need a cell
            subclass to detect when editing begins.
            (-[KWQTextField setPasswordMode:]): Don't pass a QLineEdit to the secure text field
            when creating it. It's no longer needed.
            (-[KWQTextField controlTextDidEndEditing:]): Call setHasFocus:NO, and do the actual
            work in there.
            (-[KWQTextField control:textShouldBeginEditing:]): Remove the work that was done in
            here. This is only called when you actually start typing, so it's too late.
            (-[KWQTextField becomeFirstResponder]): Keep the code to forward first responder to
            the password field, but get rid of the rest, because this code path does not cover
            all the ways to start editing.
            (-[KWQTextField currentEditorForEitherField]): Moved this method inside the
            KWQInternal category.
            (-[KWQTextField selectedRange]): Ditto.
            (-[KWQTextField setSelectedRange:]): Ditto.
            (-[KWQTextField setHasFocus:]): Added. This method does all the work we want to do
            when we get focus and when we relinquish focus, including scrolling to make the field
            visible.
            (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]):
            Call setHasFocus:YES on the KWQTextField.
            (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Ditto.
            (+[KWQSecureTextField cellClass]): Use KWQSecureTextFieldCell as the cell class.
            We need a cell subclass to detect when editing begins and we can't use the normal
            technique because NSSecureTextField will raise an exception.
            (-[KWQSecureTextField nextKeyView]): Simplified to just call through to KWQTextField.
            (-[KWQSecureTextField previousKeyView]): Ditto.
            (-[KWQSecureTextField nextValidKeyView]): Ditto.
            (-[KWQSecureTextField previousValidKeyView]): Ditto.
            (-[KWQSecureTextField widget]): Ditto.
            (-[KWQSecureTextField fieldEditorDidMouseDown:]): Ditto.
            (-[KWQSecureTextFieldCell editWithFrame:inView:editor:delegate:event:]):
            Call setHasFocus:YES on the KWQTextField.
            (-[KWQSecureTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Ditto.
    
            * kwq/KWQWidget.mm: (QWidget::setFocus): Do a layout before positioning the widget.
            The code dealt with calls after a layout and before a draw, before, but not calls
            before a layout.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 5543dc1..54e7714 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,50 @@
+2003-05-08  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+	- fixed 3251985 -- REGRESSION: tabbing doesn't scroll text fields into view any more
+
+        * kwq/KWQTextField.h: Add a _hasFocus field, which prevents us from focusing
+        multiple times.
+        * kwq/KWQTextField.mm:
+        (+[KWQTextField initialize]): Set KWQTextFieldCell as the cell class. We need a cell
+        subclass to detect when editing begins.
+        (-[KWQTextField setPasswordMode:]): Don't pass a QLineEdit to the secure text field
+        when creating it. It's no longer needed.
+        (-[KWQTextField controlTextDidEndEditing:]): Call setHasFocus:NO, and do the actual
+        work in there.
+        (-[KWQTextField control:textShouldBeginEditing:]): Remove the work that was done in
+        here. This is only called when you actually start typing, so it's too late.
+        (-[KWQTextField becomeFirstResponder]): Keep the code to forward first responder to
+        the password field, but get rid of the rest, because this code path does not cover
+        all the ways to start editing.
+        (-[KWQTextField currentEditorForEitherField]): Moved this method inside the
+        KWQInternal category.
+        (-[KWQTextField selectedRange]): Ditto.
+        (-[KWQTextField setSelectedRange:]): Ditto.
+        (-[KWQTextField setHasFocus:]): Added. This method does all the work we want to do
+        when we get focus and when we relinquish focus, including scrolling to make the field
+        visible.
+        (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]):
+        Call setHasFocus:YES on the KWQTextField.
+        (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Ditto.
+        (+[KWQSecureTextField cellClass]): Use KWQSecureTextFieldCell as the cell class.
+        We need a cell subclass to detect when editing begins and we can't use the normal
+        technique because NSSecureTextField will raise an exception.
+        (-[KWQSecureTextField nextKeyView]): Simplified to just call through to KWQTextField.
+        (-[KWQSecureTextField previousKeyView]): Ditto.
+        (-[KWQSecureTextField nextValidKeyView]): Ditto.
+        (-[KWQSecureTextField previousValidKeyView]): Ditto.
+        (-[KWQSecureTextField widget]): Ditto.
+        (-[KWQSecureTextField fieldEditorDidMouseDown:]): Ditto.
+        (-[KWQSecureTextFieldCell editWithFrame:inView:editor:delegate:event:]):
+        Call setHasFocus:YES on the KWQTextField.
+        (-[KWQSecureTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Ditto.
+        
+        * kwq/KWQWidget.mm: (QWidget::setFocus): Do a layout before positioning the widget.
+        The code dealt with calls after a layout and before a draw, before, but not calls
+        before a layout.
+
 2003-05-08  David Hyatt  <hyatt at apple.com>
 
 	Fix for a problem where positioned/floating children with
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5543dc1..54e7714 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,50 @@
+2003-05-08  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+	- fixed 3251985 -- REGRESSION: tabbing doesn't scroll text fields into view any more
+
+        * kwq/KWQTextField.h: Add a _hasFocus field, which prevents us from focusing
+        multiple times.
+        * kwq/KWQTextField.mm:
+        (+[KWQTextField initialize]): Set KWQTextFieldCell as the cell class. We need a cell
+        subclass to detect when editing begins.
+        (-[KWQTextField setPasswordMode:]): Don't pass a QLineEdit to the secure text field
+        when creating it. It's no longer needed.
+        (-[KWQTextField controlTextDidEndEditing:]): Call setHasFocus:NO, and do the actual
+        work in there.
+        (-[KWQTextField control:textShouldBeginEditing:]): Remove the work that was done in
+        here. This is only called when you actually start typing, so it's too late.
+        (-[KWQTextField becomeFirstResponder]): Keep the code to forward first responder to
+        the password field, but get rid of the rest, because this code path does not cover
+        all the ways to start editing.
+        (-[KWQTextField currentEditorForEitherField]): Moved this method inside the
+        KWQInternal category.
+        (-[KWQTextField selectedRange]): Ditto.
+        (-[KWQTextField setSelectedRange:]): Ditto.
+        (-[KWQTextField setHasFocus:]): Added. This method does all the work we want to do
+        when we get focus and when we relinquish focus, including scrolling to make the field
+        visible.
+        (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]):
+        Call setHasFocus:YES on the KWQTextField.
+        (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Ditto.
+        (+[KWQSecureTextField cellClass]): Use KWQSecureTextFieldCell as the cell class.
+        We need a cell subclass to detect when editing begins and we can't use the normal
+        technique because NSSecureTextField will raise an exception.
+        (-[KWQSecureTextField nextKeyView]): Simplified to just call through to KWQTextField.
+        (-[KWQSecureTextField previousKeyView]): Ditto.
+        (-[KWQSecureTextField nextValidKeyView]): Ditto.
+        (-[KWQSecureTextField previousValidKeyView]): Ditto.
+        (-[KWQSecureTextField widget]): Ditto.
+        (-[KWQSecureTextField fieldEditorDidMouseDown:]): Ditto.
+        (-[KWQSecureTextFieldCell editWithFrame:inView:editor:delegate:event:]):
+        Call setHasFocus:YES on the KWQTextField.
+        (-[KWQSecureTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Ditto.
+        
+        * kwq/KWQWidget.mm: (QWidget::setFocus): Do a layout before positioning the widget.
+        The code dealt with calls after a layout and before a draw, before, but not calls
+        before a layout.
+
 2003-05-08  David Hyatt  <hyatt at apple.com>
 
 	Fix for a problem where positioned/floating children with
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index 5d61cad..0047cf5 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -8085,7 +8085,7 @@
 			buildSettings = {
 				COPY_PHASE_STRIP = NO;
 				DEBUG_CFLAGS = "";
-				EXPORTED_SYMBOLS_FILE = "WebCore.exp";
+				EXPORTED_SYMBOLS_FILE = WebCore.exp;
 				OTHER_LDFLAGS = "\U0001-seg1addr $(LOCAL_SEG1_ADDR)";
 			};
 			isa = PBXBuildStyle;
diff --git a/WebCore/kwq/KWQTextField.h b/WebCore/kwq/KWQTextField.h
index ac3329e..529bcda 100644
--- a/WebCore/kwq/KWQTextField.h
+++ b/WebCore/kwq/KWQTextField.h
@@ -35,6 +35,7 @@ class QLineEdit;
     QLineEdit *widget;
     NSTextField *secureField;
     KWQTextFieldFormatter *formatter;
+    BOOL _hasFocus;
     BOOL edited;
     BOOL inNextValidKeyView;
     NSRange lastSelectedRange;
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
index 1dd6211..8a10aa0 100644
--- a/WebCore/kwq/KWQTextField.mm
+++ b/WebCore/kwq/KWQTextField.mm
@@ -25,46 +25,53 @@
 
 #import "KWQTextField.h"
 
-#import "KWQView.h"
-#import "KWQLineEdit.h"
+#import "KWQAssertions.h"
 #import "KWQKHTMLPart.h"
+#import "KWQLineEdit.h"
 #import "KWQNSViewExtras.h"
-#import "WebCoreFirstResponderChanges.h"
+#import "KWQView.h"
 #import "WebCoreBridge.h"
+#import "WebCoreFirstResponderChanges.h"
 
 @interface KWQTextField (KWQInternal)
-- (void)didBecomeFirstResponder;
+- (void)setHasFocus:(BOOL)hasFocus;
 @end
 
-// KWQTextFieldFormatter enforces a maximum length.
+// KWQTextFieldCell allows us to tell when we get focus without an editor subclass.
+ at interface KWQTextFieldCell : NSTextFieldCell
+ at end
 
+// KWQTextFieldFormatter enforces a maximum length.
 @interface KWQTextFieldFormatter : NSFormatter
 {
     int maxLength;
 }
-
 - (void)setMaximumLength:(int)len;
 - (int)maximumLength;
-
 @end
 
-// KWQSecureTextField has two purposes.
+// KWQSecureTextField has a few purposes.
 // One is a workaround for bug 3024443.
-// The other is hook up next and previous key views to KHTML.
-
+// Another is hook up next and previous key views to KHTML.
 @interface KWQSecureTextField : NSSecureTextField <KWQWidgetHolder>
 {
-    QLineEdit *widget;
     BOOL inSetFrameSize;
-    BOOL inNextValidKeyView;
 }
+ at end
 
-- initWithQLineEdit:(QLineEdit *)widget;
-
+// KWQSecureTextFieldCell allows us to tell when we get focus without an editor subclass.
+ at interface KWQSecureTextFieldCell : NSSecureTextFieldCell
 @end
 
 @implementation KWQTextField
 
++ (void)initialize
+{
+    if (self == [KWQTextField class]) {
+        [self setCellClass:[KWQTextFieldCell class]];
+    }
+}
+
 - (void)setUpTextField:(NSTextField *)field
 {
     // This is initialization that's shared by both self and the secure text field.
@@ -135,7 +142,7 @@
         [secureField removeFromSuperview];
     } else {
         if (secureField == nil) {
-            secureField = [[KWQSecureTextField alloc] initWithQLineEdit:widget];
+            secureField = [[KWQSecureTextField alloc] init];
             [secureField setFormatter:formatter];
             [secureField setFont:[self font]];
             [secureField setEditable:[self isEditable]];
@@ -206,36 +213,6 @@
     edited = ed;
 }
 
-- (NSText *)currentEditorForEitherField
-{
-    NSResponder *firstResponder = [[self window] firstResponder];
-    if ([firstResponder isKindOfClass:[NSText class]]) {
-        NSText *editor = (NSText *)firstResponder;
-        id delegate = [editor delegate];
-        if (delegate == self || delegate == secureField) {
-            return editor;
-        }
-    }
-    return nil;
-}
-
-- (NSRange)selectedRange
-{
-    NSText *editor = [self currentEditorForEitherField];
-    return editor ? [editor selectedRange] : NSMakeRange(NSNotFound, 0);
-}
-
-- (void)setSelectedRange:(NSRange)range
-{
-    // Range check just in case the saved range has gotten out of sync.
-    // Even though we don't see this in testing, we really don't want
-    // an exception in this case, so we protect ourselves.
-    NSText *editor = [self currentEditorForEitherField];    
-    if (NSMaxRange(range) <= [[editor string] length]) {
-        [editor setSelectedRange:range];
-    }
-}
-
 - (void)controlTextDidBeginEditing:(NSNotification *)notification
 {
     WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(widget);
@@ -244,10 +221,7 @@
 
 - (void)controlTextDidEndEditing:(NSNotification *)notification
 {
-    lastSelectedRange = [self selectedRange];
-
-    QFocusEvent event(QEvent::FocusOut);
-    const_cast<QObject *>(widget->eventFilterObject())->eventFilter(widget, &event);
+    [self setHasFocus:NO];
 
     WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(widget);
     [bridge controlTextDidEndEditing:notification];
@@ -257,6 +231,7 @@
 {
     WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(widget);
     [bridge controlTextDidChange:notification];
+
     edited = YES;
     widget->textChanged();
 }
@@ -264,16 +239,7 @@
 - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
 {
     WebCoreBridge *bridge = KWQKHTMLPart::bridgeForWidget(widget);
-    if (![bridge control:control textShouldBeginEditing:fieldEditor]) {
-        return NO;
-    }
-    
-    [self _KWQ_scrollFrameToVisible];
-
-    QFocusEvent event(QEvent::FocusIn);
-    const_cast<QObject *>(widget->eventFilterObject())->eventFilter(widget, &event);
-
-    return YES;
+    return [bridge control:control textShouldBeginEditing:fieldEditor];
 }
 
 - (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
@@ -361,31 +327,12 @@
     return view;
 }
 
-- (void)didBecomeFirstResponder
-{
-    // Select all the text if we are tabbing in, but otherwise preserve/remember
-    // the selection from last time we had focus (to match WinIE).
-    // This has to be done after [super becomeFirstResponder] is done, which is why
-    // we can't just do this in textShouldBeginEditing.
-    if ([[self window] keyViewSelectionDirection] != NSDirectSelection) {
-        lastSelectedRange.location = NSNotFound;
-    }
-    if (lastSelectedRange.location != NSNotFound) {
-        [self setSelectedRange:lastSelectedRange];
-    }
-}
-
 - (BOOL)becomeFirstResponder
 {
     if ([self passwordMode]) {
         return [[self window] makeFirstResponder:secureField];
     }
-    KWQKHTMLPart::setDocumentFocus(widget);
-    if (![super becomeFirstResponder]) {
-        return NO;
-    }
-    [self didBecomeFirstResponder];
-    return YES;
+    return [super becomeFirstResponder];
 }
 
 - (void)display
@@ -414,6 +361,90 @@
 
 @end
 
+ at implementation KWQTextField (KWQInternal)
+
+- (NSText *)currentEditorForEitherField
+{
+    NSResponder *firstResponder = [[self window] firstResponder];
+    if ([firstResponder isKindOfClass:[NSText class]]) {
+        NSText *editor = (NSText *)firstResponder;
+        id delegate = [editor delegate];
+        if (delegate == self || delegate == secureField) {
+            return editor;
+        }
+    }
+    return nil;
+}
+
+- (NSRange)selectedRange
+{
+    NSText *editor = [self currentEditorForEitherField];
+    return editor ? [editor selectedRange] : NSMakeRange(NSNotFound, 0);
+}
+
+- (void)setSelectedRange:(NSRange)range
+{
+    // Range check just in case the saved range has gotten out of sync.
+    // Even though we don't see this in testing, we really don't want
+    // an exception in this case, so we protect ourselves.
+    NSText *editor = [self currentEditorForEitherField];    
+    if (NSMaxRange(range) <= [[editor string] length]) {
+        [editor setSelectedRange:range];
+    }
+}
+
+- (void)setHasFocus:(BOOL)hasFocus
+{
+    if (hasFocus == _hasFocus) {
+        return;
+    }
+
+    _hasFocus = hasFocus;
+
+    if (hasFocus) {
+        KWQKHTMLPart::setDocumentFocus(widget);
+
+        // Select all the text if we are tabbing in, but otherwise preserve/remember
+        // the selection from last time we had focus (to match WinIE).
+        if ([[self window] keyViewSelectionDirection] != NSDirectSelection) {
+            lastSelectedRange.location = NSNotFound;
+        }
+        if (lastSelectedRange.location != NSNotFound) {
+            [self setSelectedRange:lastSelectedRange];
+        }
+
+        [self _KWQ_scrollFrameToVisible];
+
+        QFocusEvent event(QEvent::FocusIn);
+        const_cast<QObject *>(widget->eventFilterObject())->eventFilter(widget, &event);
+    } else {
+        lastSelectedRange = [self selectedRange];
+
+        QFocusEvent event(QEvent::FocusOut);
+        const_cast<QObject *>(widget->eventFilterObject())->eventFilter(widget, &event);
+    }
+}
+
+ at end
+
+ at implementation KWQTextFieldCell
+
+- (void)editWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event
+{
+    [super editWithFrame:frame inView:view editor:editor delegate:delegate event:event];
+    ASSERT([delegate isKindOfClass:[KWQTextField class]]);
+    [(KWQTextField *)delegate setHasFocus:YES];
+}
+
+- (void)selectWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate start:(int)start length:(int)length
+{
+    [super selectWithFrame:frame inView:view editor:editor delegate:delegate start:start length:length];
+    ASSERT([delegate isKindOfClass:[KWQTextField class]]);
+    [(KWQTextField *)delegate setHasFocus:YES];
+}
+
+ at end
+
 @implementation KWQTextFieldFormatter
 
 - init
@@ -463,40 +494,34 @@
 
 @implementation KWQSecureTextField
 
-- initWithQLineEdit:(QLineEdit *)w
+// Can't use setCellClass: because NSSecureTextField won't let us (for no good reason).
++ (Class)cellClass
 {
-    widget = w;
-    return [super init];
+    return [KWQSecureTextFieldCell class];
 }
 
 - (NSView *)nextKeyView
 {
-    return inNextValidKeyView
-        ? KWQKHTMLPart::nextKeyViewForWidget(widget, KWQSelectingNext)
-        : [super nextKeyView];
+    ASSERT([self delegate] == nil || [[self delegate] isKindOfClass:[KWQTextField class]]);
+    return [(KWQTextField *)[self delegate] nextKeyView];
 }
 
 - (NSView *)previousKeyView
 {
-   return inNextValidKeyView
-        ? KWQKHTMLPart::nextKeyViewForWidget(widget, KWQSelectingPrevious)
-        : [super previousKeyView];
+    ASSERT([self delegate] == nil || [[self delegate] isKindOfClass:[KWQTextField class]]);
+    return [(KWQTextField *)[self delegate] previousKeyView];
 }
 
 - (NSView *)nextValidKeyView
 {
-    inNextValidKeyView = YES;
-    NSView *view = [super nextValidKeyView];
-    inNextValidKeyView = NO;
-    return view;
+    ASSERT([self delegate] == nil || [[self delegate] isKindOfClass:[KWQTextField class]]);
+    return [(KWQTextField *)[self delegate] nextValidKeyView];
 }
 
 - (NSView *)previousValidKeyView
 {
-    inNextValidKeyView = YES;
-    NSView *view = [super previousValidKeyView];
-    inNextValidKeyView = NO;
-    return view;
+    ASSERT([self delegate] == nil || [[self delegate] isKindOfClass:[KWQTextField class]]);
+    return [(KWQTextField *)[self delegate] previousValidKeyView];
 }
 
 // The currentEditor method does not work for secure text fields.
@@ -522,7 +547,7 @@
     if (sender == self && inSetFrameSize) {
         return;
     }
-    
+
     // Don't call the NSSecureTextField's selectText if the field is already first responder.
     // If we do, we'll end up deactivating and then reactivating, which will send
     // unwanted onBlur events and wreak havoc in other ways as well by setting the focus
@@ -543,16 +568,6 @@
     inSetFrameSize = NO;
 }
 
-- (BOOL)becomeFirstResponder
-{
-    KWQKHTMLPart::setDocumentFocus(widget);
-    if (![super becomeFirstResponder]) {
-        return NO;
-    }
-    [(KWQTextField *)[self delegate] didBecomeFirstResponder];
-    return YES;
-}
-
 - (void)display
 {
     // This is a workaround for Radar 2753974.
@@ -562,13 +577,32 @@
 
 - (QWidget *)widget
 {
-    return widget;
+    ASSERT([[self delegate] isKindOfClass:[KWQTextField class]]);
+    return [(KWQTextField *)[self delegate] widget];
 }
 
 - (void)fieldEditorDidMouseDown:(NSEvent *)event
 {
-    widget->sendConsumedMouseUp();
-    widget->clicked();
+    ASSERT([[self delegate] isKindOfClass:[KWQTextField class]]);
+    [[self delegate] fieldEditorDidMouseDown:event];
+}
+
+ at end
+
+ at implementation KWQSecureTextFieldCell
+
+- (void)editWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event
+{
+    [super editWithFrame:frame inView:view editor:editor delegate:delegate event:event];
+    ASSERT([[delegate delegate] isKindOfClass:[KWQTextField class]]);
+    [(KWQTextField *)[delegate delegate] setHasFocus:YES];
+}
+
+- (void)selectWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate start:(int)start length:(int)length
+{
+    [super selectWithFrame:frame inView:view editor:editor delegate:delegate start:start length:length];
+    ASSERT([[delegate delegate] isKindOfClass:[KWQTextField class]]);
+    [(KWQTextField *)[delegate delegate] setHasFocus:YES];
 }
 
 @end
diff --git a/WebCore/kwq/KWQWidget.mm b/WebCore/kwq/KWQWidget.mm
index b54ee1d..8f5a5f0 100644
--- a/WebCore/kwq/KWQWidget.mm
+++ b/WebCore/kwq/KWQWidget.mm
@@ -31,6 +31,7 @@
 #import "KWQWindowWidget.h"
 
 #import "khtmlview.h"
+#import "render_canvas.h"
 #import "render_replaced.h"
 #import "KWQKHTMLPart.h"
 #import "WebCoreBridge.h"
@@ -189,11 +190,15 @@ void QWidget::setFocus()
     }
     
     // KHTML will call setFocus on us without first putting us in our
-    // superview and positioning us. This works around that issue.
+    // superview and positioning us. Normally layout computes the position
+    // and the drawing process positions the widget. Do both things explicitly.
     RenderWidget *renderWidget = dynamic_cast<RenderWidget *>(const_cast<QObject *>(eventFilterObject()));
     int x, y;
-    if (renderWidget && renderWidget->absolutePosition(x, y)) {
-        renderWidget->view()->addChild(this, x, y);
+    if (renderWidget) {
+        renderWidget->canvas()->layoutIfNeeded();
+        if (renderWidget->absolutePosition(x, y)) {
+            renderWidget->view()->addChild(this, x, y);
+        }
     }
     
     NSView *view = getView();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list