[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:23:58 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit db9104f88795a3d759a592afe26c88408e6de918
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 7 00:28:15 2003 +0000

            Reviewed by Ken.
    
            - fixed 3166693 -- REGRESSION: infinite recursion in makeFirstResponder while tabbing as page loaded
    
            Because we now deliver blur events, we are triggering a handler on this page that changes focus.
            It triggered an infinite loop because setFocus kept setting the focus back to a text field, which
            then changed the focus to its editor. The fix was to make QWidget::setFocus smarter about editors.
    
            * kwq/KWQTextField.mm: (-[KWQTextField becomeFirstResponder]): Don't do any changes in responder until
            after calling KWQKHTMLPart::setDocumentFocus, since that can change focus away. If it does, return NO.
    
            * kwq/KWQWidget.h: Add hasFocus, remove virtual from setFocus and clearFocus.
            * kwq/KWQWidget.mm:
            (QWidget::hasFocus): Added. Moved code to check if a particular view is first responder here.
            Here's the bug fix too, check if the first responder is this widget's view's editor, and if so return true.
            (QWidget::setFocus): Do nothing if this widget already has focus.
            (QWidget::clearFocus): Do nothing if this widget does not have focus.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3589 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 7f574b2..eedb5a1 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,25 @@
 2003-02-06  Darin Adler  <darin at apple.com>
 
+        Reviewed by Ken.
+
+        - fixed 3166693 -- REGRESSION: infinite recursion in makeFirstResponder while tabbing as page loaded
+
+        Because we now deliver blur events, we are triggering a handler on this page that changes focus.
+        It triggered an infinite loop because setFocus kept setting the focus back to a text field, which
+        then changed the focus to its editor. The fix was to make QWidget::setFocus smarter about editors.
+
+        * kwq/KWQTextField.mm: (-[KWQTextField becomeFirstResponder]): Don't do any changes in responder until
+        after calling KWQKHTMLPart::setDocumentFocus, since that can change focus away. If it does, return NO.
+
+        * kwq/KWQWidget.h: Add hasFocus, remove virtual from setFocus and clearFocus.
+        * kwq/KWQWidget.mm:
+        (QWidget::hasFocus): Added. Moved code to check if a particular view is first responder here.
+        Here's the bug fix too, check if the first responder is this widget's view's editor, and if so return true.
+        (QWidget::setFocus): Do nothing if this widget already has focus.
+        (QWidget::clearFocus): Do nothing if this widget does not have focus.
+
+2003-02-06  Darin Adler  <darin at apple.com>
+
         Reviewed by Dave.
 
         - fixed 3161953 -- crash in KWQListImpl, DOM::CSSStyleSheetImpl::isLoading on XML page
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 7f574b2..eedb5a1 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,25 @@
 2003-02-06  Darin Adler  <darin at apple.com>
 
+        Reviewed by Ken.
+
+        - fixed 3166693 -- REGRESSION: infinite recursion in makeFirstResponder while tabbing as page loaded
+
+        Because we now deliver blur events, we are triggering a handler on this page that changes focus.
+        It triggered an infinite loop because setFocus kept setting the focus back to a text field, which
+        then changed the focus to its editor. The fix was to make QWidget::setFocus smarter about editors.
+
+        * kwq/KWQTextField.mm: (-[KWQTextField becomeFirstResponder]): Don't do any changes in responder until
+        after calling KWQKHTMLPart::setDocumentFocus, since that can change focus away. If it does, return NO.
+
+        * kwq/KWQWidget.h: Add hasFocus, remove virtual from setFocus and clearFocus.
+        * kwq/KWQWidget.mm:
+        (QWidget::hasFocus): Added. Moved code to check if a particular view is first responder here.
+        Here's the bug fix too, check if the first responder is this widget's view's editor, and if so return true.
+        (QWidget::setFocus): Do nothing if this widget already has focus.
+        (QWidget::clearFocus): Do nothing if this widget does not have focus.
+
+2003-02-06  Darin Adler  <darin at apple.com>
+
         Reviewed by Dave.
 
         - fixed 3161953 -- crash in KWQListImpl, DOM::CSSStyleSheetImpl::isLoading on XML page
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
index bdd1696..4b99d46 100644
--- a/WebCore/kwq/KWQTextField.mm
+++ b/WebCore/kwq/KWQTextField.mm
@@ -295,14 +295,12 @@
 
 - (BOOL)becomeFirstResponder
 {
-    BOOL become = [super becomeFirstResponder];
-
-    if (become) {
-	KWQKHTMLPart::setDocumentFocus(widget);
-	[self _KWQ_scrollFrameToVisible];
+    KWQKHTMLPart::setDocumentFocus(widget);
+    if (!widget->hasFocus()) {
+        return NO;
     }
-       
-    return become;
+    [self _KWQ_scrollFrameToVisible];
+    return [super becomeFirstResponder];
 }
 
 - (void)fieldEditorWillBecomeFirstResponder
diff --git a/WebCore/kwq/KWQWidget.h b/WebCore/kwq/KWQWidget.h
index 19bd5ae..d82e22c 100644
--- a/WebCore/kwq/KWQWidget.h
+++ b/WebCore/kwq/KWQWidget.h
@@ -99,8 +99,9 @@ public:
     virtual QPoint mapToGlobal(const QPoint &) const;
     virtual QPoint mapFromGlobal(const QPoint &) const;
 
-    virtual void setFocus();
-    virtual void clearFocus();
+    bool hasFocus() const;
+    void setFocus();
+    void clearFocus();
     
     virtual FocusPolicy focusPolicy() const;
     virtual void setFocusPolicy(FocusPolicy);
diff --git a/WebCore/kwq/KWQWidget.mm b/WebCore/kwq/KWQWidget.mm
index e903d35..894bcc7 100644
--- a/WebCore/kwq/KWQWidget.mm
+++ b/WebCore/kwq/KWQWidget.mm
@@ -186,8 +186,32 @@ QPoint QWidget::mapToGlobal(const QPoint &p) const
     }
 }
 
+bool QWidget::hasFocus() const
+{
+    NSView *view = getView();
+    NSWindow *window = [view window];
+    NSView *firstResponder = [window firstResponder];
+    if (!firstResponder) {
+        return false;
+    }
+    if (firstResponder == view) {
+        return true;
+    }
+    if ([view isKindOfClass:[NSControl class]]) {
+        NSControl *control = view;
+        if (firstResponder == [control currentEditor]) {
+            return true;
+        }
+    }
+    return false;
+}
+
 void QWidget::setFocus()
 {
+    if (hasFocus()) {
+        return;
+    }
+    
     // KHTML will call setFocus on us without first putting us in our
     // superview and positioning us. This works around that issue.
     RenderWidget *renderWidget = dynamic_cast<RenderWidget *>(const_cast<QObject *>(eventFilterObject()));
@@ -197,14 +221,17 @@ void QWidget::setFocus()
     }
     
     NSView *view = getView();
-    NSWindow *window = [view window];
-    if ([window firstResponder] != view && [view acceptsFirstResponder]) {
-        [window makeFirstResponder:view];
+    if ([view acceptsFirstResponder]) {
+        [[view window] makeFirstResponder:view];
     }
 }
 
 void QWidget::clearFocus()
 {
+    if (!hasFocus()) {
+        return;
+    }
+    
     KWQKHTMLPart::clearDocumentFocus(this);
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list