Mac:
- Don't show the "drop" icon outside of valid drop regions. - Fix a crash if the WebViewHost is destroyed before the BrowserWebView. - Remove unused/unnecessary code. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@276 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
f25b353b1f
commit
6880d990a8
|
@ -38,7 +38,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc {
|
- (void) dealloc {
|
||||||
browser_->UIT_DestroyBrowser();
|
if (browser)
|
||||||
|
browser_->UIT_DestroyBrowser();
|
||||||
|
|
||||||
[self removeTrackingArea:trackingArea_];
|
[self removeTrackingArea:trackingArea_];
|
||||||
[trackingArea_ release];
|
[trackingArea_ release];
|
||||||
|
@ -156,7 +157,7 @@
|
||||||
- (BOOL)becomeFirstResponder {
|
- (BOOL)becomeFirstResponder {
|
||||||
if (browser_ && browser_->UIT_GetWebView()) {
|
if (browser_ && browser_->UIT_GetWebView()) {
|
||||||
browser_->UIT_GetWebViewHost()->SetFocus(YES);
|
browser_->UIT_GetWebViewHost()->SetFocus(YES);
|
||||||
return YES;
|
return [super becomeFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -165,7 +166,7 @@
|
||||||
- (BOOL)resignFirstResponder {
|
- (BOOL)resignFirstResponder {
|
||||||
if (browser_ && browser_->UIT_GetWebView()) {
|
if (browser_ && browser_->UIT_GetWebView()) {
|
||||||
browser_->UIT_GetWebViewHost()->SetFocus(NO);
|
browser_->UIT_GetWebViewHost()->SetFocus(NO);
|
||||||
return YES;
|
return [super resignFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
|
|
|
@ -288,10 +288,6 @@ void PromiseWriterTask::Run() {
|
||||||
if (operation == (NSDragOperationMove | NSDragOperationCopy))
|
if (operation == (NSDragOperationMove | NSDragOperationCopy))
|
||||||
operation &= ~NSDragOperationMove;
|
operation &= ~NSDragOperationMove;
|
||||||
|
|
||||||
// TODO: Figure out why |operation| is always NSDragOperationNone.
|
|
||||||
if (operation == NSDragOperationNone)
|
|
||||||
operation = NSDragOperationCopy;
|
|
||||||
|
|
||||||
WebView* webview = view_.browser->UIT_GetWebView();
|
WebView* webview = view_.browser->UIT_GetWebView();
|
||||||
|
|
||||||
gfx::Point client(localPoint.x, localPoint.y);
|
gfx::Point client(localPoint.x, localPoint.y);
|
||||||
|
|
|
@ -21,10 +21,6 @@ class WebViewHost;
|
||||||
// Our associated WebView. Weak reference.
|
// Our associated WebView. Weak reference.
|
||||||
BrowserWebView* view_;
|
BrowserWebView* view_;
|
||||||
|
|
||||||
// Updated asynchronously during a drag to tell us whether or not we should
|
|
||||||
// allow the drop.
|
|
||||||
NSDragOperation current_operation_;
|
|
||||||
|
|
||||||
// Keep track of the WebViewHost we're dragging over. If it changes during a
|
// Keep track of the WebViewHost we're dragging over. If it changes during a
|
||||||
// drag, we need to re-send the DragEnter message.
|
// drag, we need to re-send the DragEnter message.
|
||||||
WebViewHost* current_wvh_;
|
WebViewHost* current_wvh_;
|
||||||
|
@ -35,11 +31,6 @@ class WebViewHost;
|
||||||
// (if necessary).
|
// (if necessary).
|
||||||
- (id)initWithWebView:(BrowserWebView*)view;
|
- (id)initWithWebView:(BrowserWebView*)view;
|
||||||
|
|
||||||
// Sets the current operation negotiated by the source and destination,
|
|
||||||
// which determines whether or not we should allow the drop. Takes effect the
|
|
||||||
// next time |-draggingUpdated:| is called.
|
|
||||||
- (void)setCurrentOperation: (NSDragOperation)operation;
|
|
||||||
|
|
||||||
// Messages to send during the tracking of a drag, ususally upon receiving
|
// Messages to send during the tracking of a drag, ususally upon receiving
|
||||||
// calls from the view system. Communicates the drag messages to WebCore.
|
// calls from the view system. Communicates the drag messages to WebCore.
|
||||||
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info
|
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)info
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "webkit/glue/webdropdata.h"
|
#include "webkit/glue/webdropdata.h"
|
||||||
#include "webkit/glue/window_open_disposition.h"
|
#include "webkit/glue/window_open_disposition.h"
|
||||||
|
|
||||||
|
using WebKit::WebDragOperation;
|
||||||
using WebKit::WebDragOperationsMask;
|
using WebKit::WebDragOperationsMask;
|
||||||
using WebKit::WebPoint;
|
using WebKit::WebPoint;
|
||||||
using WebKit::WebView;
|
using WebKit::WebView;
|
||||||
|
@ -34,12 +35,6 @@ using WebKit::WebView;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call to set whether or not we should allow the drop. Takes effect the
|
|
||||||
// next time |-draggingUpdated:| is called.
|
|
||||||
- (void)setCurrentOperation: (NSDragOperation)operation {
|
|
||||||
current_operation_ = operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Given a point in window coordinates and a view in that window, return a
|
// Given a point in window coordinates and a view in that window, return a
|
||||||
// flipped point in the coordinate system of |view|.
|
// flipped point in the coordinate system of |view|.
|
||||||
- (NSPoint)flipWindowPointToView:(const NSPoint&)windowPoint
|
- (NSPoint)flipWindowPointToView:(const NSPoint&)windowPoint
|
||||||
|
@ -100,15 +95,12 @@ using WebKit::WebView;
|
||||||
NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
|
NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
|
||||||
NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
|
NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
|
||||||
NSDragOperation mask = [info draggingSourceOperationMask];
|
NSDragOperation mask = [info draggingSourceOperationMask];
|
||||||
webview->dragTargetDragEnter(data.ToDragData(),
|
WebDragOperation op =
|
||||||
WebPoint(viewPoint.x, viewPoint.y),
|
webview->dragTargetDragEnter(data.ToDragData(),
|
||||||
WebPoint(screenPoint.x, screenPoint.y),
|
WebPoint(viewPoint.x, viewPoint.y),
|
||||||
static_cast<WebDragOperationsMask>(mask));
|
WebPoint(screenPoint.x, screenPoint.y),
|
||||||
|
static_cast<WebDragOperationsMask>(mask));
|
||||||
// We won't know the true operation (whether the drag is allowed) until we
|
return static_cast<NSDragOperation>(op);
|
||||||
// hear back from the renderer. For now, be optimistic:
|
|
||||||
current_operation_ = NSDragOperationCopy;
|
|
||||||
return current_operation_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)draggingExited:(id<NSDraggingInfo>)info {
|
- (void)draggingExited:(id<NSDraggingInfo>)info {
|
||||||
|
@ -143,11 +135,11 @@ using WebKit::WebView;
|
||||||
NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
|
NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
|
||||||
NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
|
NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
|
||||||
NSDragOperation mask = [info draggingSourceOperationMask];
|
NSDragOperation mask = [info draggingSourceOperationMask];
|
||||||
webview->dragTargetDragOver(WebPoint(viewPoint.x, viewPoint.y),
|
WebDragOperation op =
|
||||||
WebPoint(screenPoint.x, screenPoint.y),
|
webview->dragTargetDragOver(WebPoint(viewPoint.x, viewPoint.y),
|
||||||
static_cast<WebDragOperationsMask>(mask));
|
WebPoint(screenPoint.x, screenPoint.y),
|
||||||
|
static_cast<WebDragOperationsMask>(mask));
|
||||||
return current_operation_;
|
return static_cast<NSDragOperation>(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)info
|
- (BOOL)performDragOperation:(id<NSDraggingInfo>)info
|
||||||
|
|
|
@ -8,6 +8,8 @@ WebViewHost::WebViewHost()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(OS_MACOSX)
|
||||||
WebViewHost::~WebViewHost()
|
WebViewHost::~WebViewHost()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -50,6 +50,11 @@ WebViewHost* WebViewHost::Create(NSView* parent_view,
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebViewHost::~WebViewHost() {
|
||||||
|
BrowserWebView* webView = static_cast<BrowserWebView*>(view_);
|
||||||
|
webView.browser = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
WebView* WebViewHost::webview() const {
|
WebView* WebViewHost::webview() const {
|
||||||
return static_cast<WebView*>(webwidget_);
|
return static_cast<WebView*>(webwidget_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,6 @@ class WebWidgetHost {
|
||||||
|
|
||||||
virtual ~WebWidgetHost();
|
virtual ~WebWidgetHost();
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
|
||||||
static void HandleEvent(gfx::NativeView view, NSEvent* event);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gfx::NativeView view_handle() const { return view_; }
|
gfx::NativeView view_handle() const { return view_; }
|
||||||
WebKit::WebWidget* webwidget() const { return webwidget_; }
|
WebKit::WebWidget* webwidget() const { return webwidget_; }
|
||||||
|
|
||||||
|
|
|
@ -45,46 +45,6 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view,
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/
|
|
||||||
void WebWidgetHost::HandleEvent(NSView* view, NSEvent* event) {
|
|
||||||
/* TODO(port): rig up a way to get to the host */
|
|
||||||
WebWidgetHost* host = NULL;
|
|
||||||
if (host) {
|
|
||||||
switch ([event type]) {
|
|
||||||
case NSLeftMouseDown:
|
|
||||||
case NSLeftMouseUp:
|
|
||||||
case NSRightMouseDown:
|
|
||||||
case NSRightMouseUp:
|
|
||||||
case NSOtherMouseDown:
|
|
||||||
case NSOtherMouseUp:
|
|
||||||
case NSMouseEntered:
|
|
||||||
case NSMouseExited:
|
|
||||||
host->MouseEvent(event);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSScrollWheel:
|
|
||||||
host->WheelEvent(event);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyDown:
|
|
||||||
case NSKeyUp:
|
|
||||||
host->KeyEvent(event);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSAppKitDefined:
|
|
||||||
switch ([event subtype]) {
|
|
||||||
case NSApplicationActivatedEventType:
|
|
||||||
host->SetFocus(true);
|
|
||||||
break;
|
|
||||||
case NSApplicationDeactivatedEventType:
|
|
||||||
host->SetFocus(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
|
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
|
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
|
||||||
|
|
Loading…
Reference in New Issue