Reviewed by John.
- fixed <rdar://problem/
4025088> window onblur and onfocus don't fire when text field has focus
* kwq/KWQKHTMLPart.h: Added setWindowHasFocus function and m_windowHasFocus data member.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::setDisplaysWithFocusAttributes): Took out the code that sends the focus and blur events.
(KWQKHTMLPart::setWindowHasFocus): Put that code here instead.
* kwq/WebCoreBridge.h: Added setWindowHasFocus: method to the bridge.
* kwq/WebCoreBridge.mm: (-[WebCoreBridge setWindowHasFocus:]): Added. Calls method on the part.
WebKit:
Reviewed by John.
- fixed <rdar://problem/
4025088> window onblur and onfocus don't fire when text field has focus
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView updateFocusState]): Renamed from updateFocusDisplay. Added call to setWindowHasFocus: method.
(-[WebHTMLView viewDidMoveToWindow]): Call method by new name.
(-[WebHTMLView windowDidBecomeKey:]): Ditto.
(-[WebHTMLView windowDidResignKey:]): Ditto.
(-[WebHTMLView becomeFirstResponder]): Ditto.
(-[WebHTMLView resignFirstResponder]): Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8712
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-02-25 Darin Adler <darin@apple.com>
+
+ Reviewed by John.
+
+ - fixed <rdar://problem/4025088> window onblur and onfocus don't fire when text field has focus
+
+ * kwq/KWQKHTMLPart.h: Added setWindowHasFocus function and m_windowHasFocus data member.
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::setDisplaysWithFocusAttributes): Took out the code that sends the focus and blur events.
+ (KWQKHTMLPart::setWindowHasFocus): Put that code here instead.
+
+ * kwq/WebCoreBridge.h: Added setWindowHasFocus: method to the bridge.
+ * kwq/WebCoreBridge.mm: (-[WebCoreBridge setWindowHasFocus:]): Added. Calls method on the part.
+
2005-02-25 Darin Adler <darin@apple.com>
Reviewed by John.
void setSelectionFromNone();
void setDisplaysWithFocusAttributes(bool flag);
bool displaysWithFocusAttributes() const;
+
+ void setWindowHasFocus(bool flag);
// Convenience, to avoid repeating the code to dig down to get this.
QChar backslashAsCurrencySymbol() const;
DOM::Range m_markedTextRange;
bool m_markedTextUsesUnderlines;
QValueList<MarkedTextUnderline> m_markedTextUnderlines;
+
+ bool m_windowHasFocus;
};
inline KWQKHTMLPart *KWQ(KHTMLPart *part) { return static_cast<KWQKHTMLPart *>(part); }
, _dragSrc(0)
, _dragClipboard(0)
, _elementToDraw(0)
+ , m_markedTextUsesUnderlines(false)
+ , m_windowHasFocus(false)
{
// Must init the cache before connecting to any signals
Cache::init();
if (d->m_isFocused == flag)
return;
d->m_isFocused = flag;
-
+
// This method does the job of updating the view based on whether the view is "active".
// This involves three kinds of drawing updates:
// 2. Caret blinking (blinks | does not blink)
if (flag)
setSelectionFromNone();
- setCaretVisible(d->m_isFocused);
+ setCaretVisible(flag);
// 3. The drawing of a focus ring around links in web pages.
DocumentImpl *doc = xmlDocImpl();
if (node && node->renderer())
node->renderer()->repaint();
}
-
- if (doc && doc->body()) {
- if (flag) {
- // Send onfocus event.
- doc->body()->dispatchWindowEvent(EventImpl::FOCUS_EVENT, false, false);
- }
- else {
- // Send onblur event.
- doc->body()->dispatchWindowEvent(EventImpl::BLUR_EVENT, false, false);
- }
- }
}
bool KWQKHTMLPart::displaysWithFocusAttributes() const
return d->m_isFocused;
}
+void KWQKHTMLPart::setWindowHasFocus(bool flag)
+{
+ if (m_windowHasFocus == flag)
+ return;
+ m_windowHasFocus = flag;
+
+ DocumentImpl *doc = xmlDocImpl();
+ if (doc) {
+ NodeImpl *body = doc->body();
+ if (body) {
+ int eventID = flag ? EventImpl::FOCUS_EVENT : EventImpl::BLUR_EVENT;
+ body->dispatchWindowEvent(eventID, false, false);
+ }
+ }
+}
+
QChar KWQKHTMLPart::backslashAsCurrencySymbol() const
{
DocumentImpl *doc = xmlDocImpl();
- (void)setSelectionFromNone;
- (void)setDisplaysWithFocusAttributes:(BOOL)flag;
+- (void)setWindowHasFocus:(BOOL)flag;
+
- (NSString *)stringForRange:(DOMRange *)range;
- (NSString *)markupStringFromNode:(DOMNode *)node nodes:(NSArray **)nodes;
_part->setDisplaysWithFocusAttributes(flag);
}
+- (void)setWindowHasFocus:(BOOL)flag
+{
+ _part->setWindowHasFocus(flag);
+}
+
- (void)setShouldCreateRenderers:(BOOL)f
{
_shouldCreateRenderers = f;
+2005-02-25 Darin Adler <darin@apple.com>
+
+ Reviewed by John.
+
+ - fixed <rdar://problem/4025088> window onblur and onfocus don't fire when text field has focus
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView updateFocusState]): Renamed from updateFocusDisplay. Added call to setWindowHasFocus: method.
+ (-[WebHTMLView viewDidMoveToWindow]): Call method by new name.
+ (-[WebHTMLView windowDidBecomeKey:]): Ditto.
+ (-[WebHTMLView windowDidResignKey:]): Ditto.
+ (-[WebHTMLView becomeFirstResponder]): Ditto.
+ (-[WebHTMLView resignFirstResponder]): Ditto.
+
=== Safari-400 ===
2005-02-25 Richard Williamson <rjw@apple.com>
name:NSMouseMovedNotification object:nil];
}
-- (void)updateFocusDisplay
+- (void)updateFocusState
{
// This method does the job of updating the view based on the view's firstResponder-ness and
// the window key-ness of the window containing this view. This involves three kinds of
// 1. The background color used to draw behind selected content (active | inactive color)
// 2. Caret blinking (blinks | does not blink)
// 3. The drawing of a focus ring around links in web pages.
+ //
+ // Also, this is responsible for letting the bridge know if the window has gained or lost focus
+ // so we can send focus and blur events.
- BOOL flag = !_private->resigningFirstResponder && [[self window] isKeyWindow] && [self _web_firstResponderCausesFocusDisplay];
- [[self _bridge] setDisplaysWithFocusAttributes:flag];
+ WebBridge *bridge = [self _bridge];
+ BOOL windowIsKey = [[self window] isKeyWindow];
+
+ BOOL flag = !_private->resigningFirstResponder && windowIsKey && [self _web_firstResponderCausesFocusDisplay];
+ [bridge setDisplaysWithFocusAttributes:flag];
+
+ [bridge setWindowHasFocus:windowIsKey];
}
- (void)addSuperviewObservers
[self addWindowObservers];
[self addSuperviewObservers];
[self addMouseMovedObserver];
+
// Schedule this update, rather than making the call right now.
// The reason is that placing the caret in the just-installed view requires
// the HTML/XML document to be available on the WebCore side, but it is not
// at the time this code is running. However, it will be there on the next
// crank of the run loop. Doing this helps to make a blinking caret appear
// in a new, empty window "automatic".
- [self performSelector:@selector(updateFocusDisplay) withObject:nil afterDelay:0];
-
+ [self performSelector:@selector(updateFocusState) withObject:nil afterDelay:0];
+
[[self _pluginController] startAllPlugins];
_private->lastScrollPosition = NSZeroPoint;
{
ASSERT([notification object] == [self window]);
[self addMouseMovedObserver];
- [self updateFocusDisplay];
+ [self updateFocusState];
}
- (void)windowDidResignKey: (NSNotification *)notification
ASSERT([notification object] == [self window]);
[_private->compController endRevertingChange:NO moveLeft:NO];
[self removeMouseMovedObserver];
- [self updateFocusDisplay];
+ [self updateFocusState];
}
- (void)windowWillClose:(NSNotification *)notification
if (view) {
[[self window] makeFirstResponder:view];
}
- [self updateFocusDisplay];
+ [self updateFocusState];
_private->startNewKillRingSequence = YES;
return YES;
}
[self deselectAll];
}
}
- [self updateFocusDisplay];
+ [self updateFocusState];
_private->resigningFirstResponder = NO;
}
return resign;