| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 // Only change the focus when clicking scrollbars if it can transfered to a | 2064 // Only change the focus when clicking scrollbars if it can transfered to a |
| 2065 // mouse focusable node. | 2065 // mouse focusable node. |
| 2066 if (!element && targetedEvent.hitTestResult().scrollbar()) | 2066 if (!element && targetedEvent.hitTestResult().scrollbar()) |
| 2067 return true; | 2067 return true; |
| 2068 | 2068 |
| 2069 if (Page* page = m_frame->page()) { | 2069 if (Page* page = m_frame->page()) { |
| 2070 // If focus shift is blocked, we eat the event. Note we should never | 2070 // If focus shift is blocked, we eat the event. Note we should never |
| 2071 // clear swallowEvent if the page already set it (e.g., by canceling | 2071 // clear swallowEvent if the page already set it (e.g., by canceling |
| 2072 // default behavior). | 2072 // default behavior). |
| 2073 if (element) { | 2073 if (element) { |
| 2074 if (slideFocusOnShadowHostIfNecessary(*element)) |
| 2075 return true; |
| 2074 if (!page->focusController().setFocusedElement(element, m_frame, Web
FocusTypeMouse)) | 2076 if (!page->focusController().setFocusedElement(element, m_frame, Web
FocusTypeMouse)) |
| 2075 return true; | 2077 return true; |
| 2076 } else { | 2078 } else { |
| 2077 // We call setFocusedElement even with !element in order to blur | 2079 // We call setFocusedElement even with !element in order to blur |
| 2078 // current focus element when a link is clicked; this is expected by | 2080 // current focus element when a link is clicked; this is expected by |
| 2079 // some sites that rely on onChange handlers running from form | 2081 // some sites that rely on onChange handlers running from form |
| 2080 // fields before the button click is processed. | 2082 // fields before the button click is processed. |
| 2081 if (!page->focusController().setFocusedElement(0, m_frame)) | 2083 if (!page->focusController().setFocusedElement(0, m_frame)) |
| 2082 return true; | 2084 return true; |
| 2083 } | 2085 } |
| 2084 } | 2086 } |
| 2085 | 2087 |
| 2086 return false; | 2088 return false; |
| 2087 } | 2089 } |
| 2088 | 2090 |
| 2091 bool EventHandler::slideFocusOnShadowHostIfNecessary(const Element& element) |
| 2092 { |
| 2093 if (element.shadowRoot() && element.shadowRoot()->delegatesFocus()) { |
| 2094 Document* doc = m_frame->document(); |
| 2095 if (element.containsIncludingShadowDOM(doc->focusedElement())) { |
| 2096 // If the inner element is already focused, do nothing. |
| 2097 return true; |
| 2098 } |
| 2099 |
| 2100 // If the host has a focusable inner element, focus it. Otherwise, the h
ost takes focus. |
| 2101 Page* page = m_frame->page(); |
| 2102 ASSERT(page); |
| 2103 Node* next = page->focusController().findFocusableNode(WebFocusTypeForwa
rd, *element.shadowRoot()); |
| 2104 if (next && next->isElementNode() && element.containsIncludingShadowDOM(
next)) { |
| 2105 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean
the focus has slided. |
| 2106 toElement(next)->focus(false, WebFocusTypeForward); |
| 2107 return true; |
| 2108 } |
| 2109 } |
| 2110 return false; |
| 2111 } |
| 2112 |
| 2089 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event) | 2113 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event) |
| 2090 { | 2114 { |
| 2091 #define RETURN_WHEEL_EVENT_HANDLED() \ | 2115 #define RETURN_WHEEL_EVENT_HANDLED() \ |
| 2092 { \ | 2116 { \ |
| 2093 setFrameWasScrolledByUser(); \ | 2117 setFrameWasScrolledByUser(); \ |
| 2094 return true; \ | 2118 return true; \ |
| 2095 } | 2119 } |
| 2096 | 2120 |
| 2097 Document* doc = m_frame->document(); | 2121 Document* doc = m_frame->document(); |
| 2098 | 2122 |
| (...skipping 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4179 unsigned EventHandler::accessKeyModifiers() | 4203 unsigned EventHandler::accessKeyModifiers() |
| 4180 { | 4204 { |
| 4181 #if OS(MACOSX) | 4205 #if OS(MACOSX) |
| 4182 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4206 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4183 #else | 4207 #else |
| 4184 return PlatformEvent::AltKey; | 4208 return PlatformEvent::AltKey; |
| 4185 #endif | 4209 #endif |
| 4186 } | 4210 } |
| 4187 | 4211 |
| 4188 } // namespace blink | 4212 } // namespace blink |
| OLD | NEW |