Commit 82c11d19 authored by adele's avatar adele
Browse files

LayoutTests:

        Reviewed by Darin.

        Test for http://bugs.webkit.org/show_bug.cgi?id=13796
        Crash in [NSInputContext currentInputContext] when you click on this map

        * fast/frames/frame-display-none-focus-expected.txt: Added.
        * fast/frames/frame-display-none-focus.html: Added.
        * fast/frames/resources/iframe-focus.html: Added.

WebCore:

        Reviewed by Darin.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=13796
        Crash in [NSInputContext currentInputContext] when you click on this map

        This is another case of <rdar://problem/5171145> Safari crashed closing tab in NSInputContext updateInputContexts

        Test: fast/frames/frame-display-none-focus.html

        * WebCore.xcodeproj/project.pbxproj: Added ChromeMac.mm
        * page/Chrome.h:
        * page/mac/ChromeMac.mm: Added.
        (WebCore::Chrome::focusNSView): Moved code from Widget::setFocus so it can be used whenever we need to make a view the first responder.
        * page/mac/EventHandlerMac.mm: (WebCore::EventHandler::focusDocumentView): Calls focusNSView.
        * platform/mac/WidgetMac.mm: (WebCore::Widget::setFocus): Calls focusNSView.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 384cf314
2007-05-22 Adele Peterson <adele@apple.com>
Reviewed by Darin.
Test for http://bugs.webkit.org/show_bug.cgi?id=13796
Crash in [NSInputContext currentInputContext] when you click on this map
* fast/frames/frame-display-none-focus-expected.txt: Added.
* fast/frames/frame-display-none-focus.html: Added.
* fast/frames/resources/iframe-focus.html: Added.
2007-05-22 Justin Garcia <justin.garcia@apple.com>
 
Reviewed by darin
This tests that trying to focus a frame that is display:none will not crash.
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
</script>
This tests that trying to focus a frame that is display:none will not crash.<br>
<iframe src="resources/iframe-focus.html" style="display: none"></iframe>
<html>
<head>
<script>
function test()
{
window.focus();
if (parent.location.href.indexOf('?') == -1) {
parent.location.href= parent.location.href + "?";
}
}
</script>
</head>
<body onload="test()">
Test
</body>
</html>
2007-05-22 Adele Peterson <adele@apple.com>
Reviewed by Darin.
Fix for http://bugs.webkit.org/show_bug.cgi?id=13796
Crash in [NSInputContext currentInputContext] when you click on this map
This is another case of <rdar://problem/5171145> Safari crashed closing tab in NSInputContext updateInputContexts
Test: fast/frames/frame-display-none-focus.html
* WebCore.xcodeproj/project.pbxproj: Added ChromeMac.mm
* page/Chrome.h:
* page/mac/ChromeMac.mm: Added.
(WebCore::Chrome::focusNSView): Moved code from Widget::setFocus so it can be used whenever we need to make a view the first responder.
* page/mac/EventHandlerMac.mm: (WebCore::EventHandler::focusDocumentView): Calls focusNSView.
* platform/mac/WidgetMac.mm: (WebCore::Widget::setFocus): Calls focusNSView.
2007-05-22 Justin Garcia <justin.garcia@apple.com>
 
Reviewed by darin
......@@ -2281,6 +2281,7 @@
AB67D1A9097F3AE300F9392E /* RenderTextControl.h in Headers */ = {isa = PBXBuildFile; fileRef = AB67D1A7097F3AE300F9392E /* RenderTextControl.h */; };
AB7170890B3118080017123E /* SearchPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = AB7170880B3118080017123E /* SearchPopupMenu.h */; };
AB7170A00B31193B0017123E /* SearchPopupMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB71709F0B31193B0017123E /* SearchPopupMenuMac.mm */; };
ABAF22080C03B1C700B0BCF0 /* ChromeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABAF22070C03B1C700B0BCF0 /* ChromeMac.mm */; };
ABB5419E0ACDDFE4002820EB /* RenderListBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB5419C0ACDDFE4002820EB /* RenderListBox.cpp */; };
ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */ = {isa = PBXBuildFile; fileRef = ABB5419D0ACDDFE4002820EB /* RenderListBox.h */; };
ABC128770B33AA6D00C693D5 /* PopupMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = ABC128760B33AA6D00C693D5 /* PopupMenuClient.h */; };
......@@ -5389,6 +5390,7 @@
AB67D1A7097F3AE300F9392E /* RenderTextControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTextControl.h; sourceTree = "<group>"; };
AB7170880B3118080017123E /* SearchPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SearchPopupMenu.h; sourceTree = "<group>"; };
AB71709F0B31193B0017123E /* SearchPopupMenuMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchPopupMenuMac.mm; sourceTree = "<group>"; };
ABAF22070C03B1C700B0BCF0 /* ChromeMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ChromeMac.mm; sourceTree = "<group>"; };
ABB5419C0ACDDFE4002820EB /* RenderListBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderListBox.cpp; sourceTree = "<group>"; };
ABB5419D0ACDDFE4002820EB /* RenderListBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderListBox.h; sourceTree = "<group>"; };
ABC128760B33AA6D00C693D5 /* PopupMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PopupMenuClient.h; sourceTree = "<group>"; };
......@@ -8088,6 +8090,7 @@
93C09A820B064F05005ABD4D /* mac */ = {
isa = PBXGroup;
children = (
ABAF22070C03B1C700B0BCF0 /* ChromeMac.mm */,
93C09A7E0B064EEF005ABD4D /* EventHandlerMac.mm */,
A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */,
65BF023C0974819000C43196 /* FrameMac.mm */,
......@@ -12733,6 +12736,7 @@
BC4918C60BFEA050009D6316 /* JSHTMLFrameElement.cpp in Sources */,
BC4918C80BFEA050009D6316 /* JSHTMLIFrameElement.cpp in Sources */,
BC491B780C023EFD009D6316 /* JSHTMLMarqueeElement.cpp in Sources */,
ABAF22080C03B1C700B0BCF0 /* ChromeMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -25,6 +25,12 @@
#include <wtf/Forward.h>
#include <wtf/RefPtr.h>
#if PLATFORM(MAC)
#ifndef __OBJC__
class NSView;
#endif
#endif
namespace WebCore {
class ChromeClient;
......@@ -97,6 +103,9 @@ namespace WebCore {
void scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect);
void updateBackingStore();
#if PLATFORM(MAC)
void focusNSView(NSView*);
#endif
private:
Page* m_page;
ChromeClient* m_client;
......
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2007 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import "config.h"
#import "Chrome.h"
#import "BlockExceptions.h"
#import "Frame.h"
#import "Page.h"
namespace WebCore {
void Chrome::focusNSView(NSView* view)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
WebCoreFrameBridge *bridge = m_page->mainFrame()->bridge();
NSResponder *firstResponder = [bridge firstResponder];
if (firstResponder == view)
return;
if (![view window] || ![view superview] || ![view acceptsFirstResponder])
return;
[bridge makeFirstResponder:view];
// Setting focus can actually cause a style change which might
// remove the view from its superview while it's being made
// first responder. This confuses AppKit so we must restore
// the old first responder.
if (![view superview])
[bridge makeFirstResponder:firstResponder];
END_BLOCK_OBJC_EXCEPTIONS;
}
} // namespace WebCore
......@@ -150,16 +150,15 @@ bool EventHandler::keyEvent(NSEvent *event)
void EventHandler::focusDocumentView()
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
if (FrameView* frameView = m_frame->view()) {
if (NSView *documentView = frameView->getDocumentView()) {
if ([m_frame->bridge() firstResponder] != documentView)
[m_frame->bridge() makeFirstResponder:documentView];
}
}
END_BLOCK_OBJC_EXCEPTIONS;
if (Page* page = m_frame->page())
page->focusController()->setFocusedFrame(m_frame);
Page* page = m_frame->page();
if (!page)
return;
if (FrameView* frameView = m_frame->view())
if (NSView *documentView = frameView->getDocumentView())
page->chrome()->focusNSView(documentView);
page->focusController()->setFocusedFrame(m_frame);
}
bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
......
......@@ -32,6 +32,7 @@
#import "Font.h"
#import "Frame.h"
#import "GraphicsContext.h"
#import "Page.h"
#import "PlatformMouseEvent.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreFrameView.h"
......@@ -127,25 +128,9 @@ void Widget::setFocus()
BEGIN_BLOCK_OBJC_EXCEPTIONS;
NSView *view = [getView() _webcore_effectiveFirstResponder];
WebCoreFrameBridge *bridge = frame->bridge();
id firstResponder = [bridge firstResponder];
if (firstResponder && firstResponder == view)
return;
if (![view window] || ![view superview] || ![view acceptsFirstResponder])
return;
NSResponder *oldFirstResponder = [bridge firstResponder];
[bridge makeFirstResponder:view];
// Setting focus can actually cause a style change which might
// remove the view from its superview while it's being made
// first responder. This confuses AppKit so we must restore
// the old first responder.
if (![view superview])
[bridge makeFirstResponder:oldFirstResponder];
if (Page* page = frame->page())
page->chrome()->focusNSView(view);
END_BLOCK_OBJC_EXCEPTIONS;
}
......
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