| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "sky/engine/config.h" | 32 #include "sky/engine/config.h" |
| 33 #include "sky/engine/web/ChromeClientImpl.h" | 33 #include "sky/engine/web/ChromeClientImpl.h" |
| 34 | 34 |
| 35 #include "gen/sky/platform/RuntimeEnabledFeatures.h" | 35 #include "gen/sky/platform/RuntimeEnabledFeatures.h" |
| 36 #include "sky/engine/bindings/core/v8/ScriptController.h" | 36 #include "sky/engine/bindings/core/v8/ScriptController.h" |
| 37 #include "sky/engine/core/dom/Document.h" | 37 #include "sky/engine/core/dom/Document.h" |
| 38 #include "sky/engine/core/dom/Node.h" | 38 #include "sky/engine/core/dom/Node.h" |
| 39 #include "sky/engine/core/events/KeyboardEvent.h" | 39 #include "sky/engine/core/events/KeyboardEvent.h" |
| 40 #include "sky/engine/core/events/MouseEvent.h" | |
| 41 #include "sky/engine/core/events/WheelEvent.h" | |
| 42 #include "sky/engine/core/frame/Console.h" | 40 #include "sky/engine/core/frame/Console.h" |
| 43 #include "sky/engine/core/frame/FrameView.h" | 41 #include "sky/engine/core/frame/FrameView.h" |
| 44 #include "sky/engine/core/frame/Settings.h" | 42 #include "sky/engine/core/frame/Settings.h" |
| 45 #include "sky/engine/core/page/Page.h" | 43 #include "sky/engine/core/page/Page.h" |
| 46 #include "sky/engine/core/rendering/HitTestResult.h" | 44 #include "sky/engine/core/rendering/HitTestResult.h" |
| 47 #include "sky/engine/platform/Cursor.h" | 45 #include "sky/engine/platform/Cursor.h" |
| 48 #include "sky/engine/platform/NotImplemented.h" | 46 #include "sky/engine/platform/NotImplemented.h" |
| 49 #include "sky/engine/platform/PlatformScreen.h" | 47 #include "sky/engine/platform/PlatformScreen.h" |
| 50 #include "sky/engine/platform/exported/WrappedResourceRequest.h" | 48 #include "sky/engine/platform/exported/WrappedResourceRequest.h" |
| 51 #include "sky/engine/platform/geometry/FloatRect.h" | 49 #include "sky/engine/platform/geometry/FloatRect.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 m_webView->client()->setKeyboardFocusURL(focusURL); | 153 m_webView->client()->setKeyboardFocusURL(focusURL); |
| 156 } | 154 } |
| 157 | 155 |
| 158 void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame) | 156 void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame) |
| 159 { | 157 { |
| 160 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 158 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 161 if (webframe && webframe->client()) | 159 if (webframe && webframe->client()) |
| 162 webframe->client()->frameFocused(); | 160 webframe->client()->frameFocused(); |
| 163 } | 161 } |
| 164 | 162 |
| 165 static inline void updatePolicyForEvent(const WebInputEvent* inputEvent, Navigat
ionPolicy* policy) | |
| 166 { | |
| 167 if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp) | |
| 168 return; | |
| 169 | |
| 170 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEve
nt); | |
| 171 | |
| 172 unsigned short buttonNumber; | |
| 173 switch (mouseEvent->button) { | |
| 174 case WebMouseEvent::ButtonLeft: | |
| 175 buttonNumber = 0; | |
| 176 break; | |
| 177 case WebMouseEvent::ButtonMiddle: | |
| 178 buttonNumber = 1; | |
| 179 break; | |
| 180 case WebMouseEvent::ButtonRight: | |
| 181 buttonNumber = 2; | |
| 182 break; | |
| 183 default: | |
| 184 return; | |
| 185 } | |
| 186 bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey; | |
| 187 bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey; | |
| 188 bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey; | |
| 189 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; | |
| 190 | |
| 191 NavigationPolicy userPolicy = *policy; | |
| 192 navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPo
licy); | |
| 193 // User and app agree that we want a new window; let the app override the de
corations. | |
| 194 if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNe
wPopup) | |
| 195 return; | |
| 196 *policy = userPolicy; | |
| 197 } | |
| 198 | |
| 199 WebNavigationPolicy ChromeClientImpl::getNavigationPolicy() | 163 WebNavigationPolicy ChromeClientImpl::getNavigationPolicy() |
| 200 { | 164 { |
| 201 NavigationPolicy policy = NavigationPolicyNewForegroundTab; | 165 return WebNavigationPolicyCurrentTab; |
| 202 updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy); | |
| 203 | |
| 204 return static_cast<WebNavigationPolicy>(policy); | |
| 205 } | 166 } |
| 206 | 167 |
| 207 void ChromeClientImpl::show(NavigationPolicy navigationPolicy) | 168 void ChromeClientImpl::show(NavigationPolicy navigationPolicy) |
| 208 { | 169 { |
| 209 if (!m_webView->client()) | 170 if (!m_webView->client()) |
| 210 return; | 171 return; |
| 211 | 172 |
| 212 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli
cy); | 173 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli
cy); |
| 213 if (policy == WebNavigationPolicyIgnore) | 174 if (policy == WebNavigationPolicyIgnore) |
| 214 policy = getNavigationPolicy(); | 175 policy = getNavigationPolicy(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 Frame* frame, Event* event) | 308 Frame* frame, Event* event) |
| 348 { | 309 { |
| 349 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(fram
e)); | 310 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(fram
e)); |
| 350 | 311 |
| 351 // This is only called when we have out-of-process iframes, which | 312 // This is only called when we have out-of-process iframes, which |
| 352 // need to forward input events across processes. | 313 // need to forward input events across processes. |
| 353 // FIXME: Add a check for out-of-process iframes enabled. | 314 // FIXME: Add a check for out-of-process iframes enabled. |
| 354 if (event->isKeyboardEvent()) { | 315 if (event->isKeyboardEvent()) { |
| 355 WebKeyboardEventBuilder webEvent(*static_cast<KeyboardEvent*>(event)); | 316 WebKeyboardEventBuilder webEvent(*static_cast<KeyboardEvent*>(event)); |
| 356 webFrame->client()->forwardInputEvent(&webEvent); | 317 webFrame->client()->forwardInputEvent(&webEvent); |
| 357 } else if (event->isMouseEvent()) { | |
| 358 WebMouseEventBuilder webEvent(webFrame->frameView(), 0, *static_cast<Mou
seEvent*>(event)); | |
| 359 // Internal Blink events should not be forwarded. | |
| 360 if (webEvent.type == WebInputEvent::Undefined) | |
| 361 return; | |
| 362 | |
| 363 webFrame->client()->forwardInputEvent(&webEvent); | |
| 364 } else if (event->isWheelEvent()) { | |
| 365 WebMouseWheelEventBuilder webEvent(webFrame->frameView(), 0, *static_cas
t<WheelEvent*>(event)); | |
| 366 if (webEvent.type == WebInputEvent::Undefined) | |
| 367 return; | |
| 368 webFrame->client()->forwardInputEvent(&webEvent); | |
| 369 } | 318 } |
| 370 } | 319 } |
| 371 | 320 |
| 372 } // namespace blink | 321 } // namespace blink |
| OLD | NEW |