Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 #include "core/loader/FrameLoader.h" | 138 #include "core/loader/FrameLoader.h" |
| 139 #include "core/loader/FrameLoaderClient.h" | 139 #include "core/loader/FrameLoaderClient.h" |
| 140 #include "core/loader/ImageLoader.h" | 140 #include "core/loader/ImageLoader.h" |
| 141 #include "core/loader/appcache/ApplicationCacheHost.h" | 141 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 142 #include "core/page/Chrome.h" | 142 #include "core/page/Chrome.h" |
| 143 #include "core/page/ChromeClient.h" | 143 #include "core/page/ChromeClient.h" |
| 144 #include "core/page/ContentSecurityPolicy.h" | 144 #include "core/page/ContentSecurityPolicy.h" |
| 145 #include "core/page/DOMSecurityPolicy.h" | 145 #include "core/page/DOMSecurityPolicy.h" |
| 146 #include "core/page/DOMWindow.h" | 146 #include "core/page/DOMWindow.h" |
| 147 #include "core/page/EventHandler.h" | 147 #include "core/page/EventHandler.h" |
| 148 #include "core/page/FocusController.h" | |
| 148 #include "core/page/Frame.h" | 149 #include "core/page/Frame.h" |
| 149 #include "core/page/FrameTree.h" | 150 #include "core/page/FrameTree.h" |
| 150 #include "core/page/FrameView.h" | 151 #include "core/page/FrameView.h" |
| 151 #include "core/page/History.h" | 152 #include "core/page/History.h" |
| 152 #include "core/page/MouseEventWithHitTestResults.h" | 153 #include "core/page/MouseEventWithHitTestResults.h" |
| 153 #include "core/page/Page.h" | 154 #include "core/page/Page.h" |
| 154 #include "core/page/PageConsole.h" | 155 #include "core/page/PageConsole.h" |
| 155 #include "core/page/PointerLockController.h" | 156 #include "core/page/PointerLockController.h" |
| 156 #include "core/page/Settings.h" | 157 #include "core/page/Settings.h" |
| 157 #include "core/page/animation/AnimationController.h" | 158 #include "core/page/animation/AnimationController.h" |
| (...skipping 3139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3297 if (oldFocusedElement->active()) | 3298 if (oldFocusedElement->active()) |
| 3298 oldFocusedElement->setActive(false); | 3299 oldFocusedElement->setActive(false); |
| 3299 | 3300 |
| 3300 oldFocusedElement->setFocus(false); | 3301 oldFocusedElement->setFocus(false); |
| 3301 | 3302 |
| 3302 // Dispatch a change event for text fields or textareas that have been e dited | 3303 // Dispatch a change event for text fields or textareas that have been e dited |
| 3303 if (oldFocusedElement->wasChangedSinceLastFormControlChangeEvent()) | 3304 if (oldFocusedElement->wasChangedSinceLastFormControlChangeEvent()) |
| 3304 oldFocusedElement->dispatchFormControlChangeEvent(); | 3305 oldFocusedElement->dispatchFormControlChangeEvent(); |
| 3305 | 3306 |
| 3306 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields) | 3307 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields) |
| 3307 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get()); | 3308 // If old element's page is unfocused, blur event will have already been dispatched |
| 3309 if (page() && page()->focusController().isFocused()) { | |
|
tkent
2013/10/08 22:47:20
I remembered no elements could be focusable if a d
| |
| 3310 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get()); | |
| 3308 | 3311 |
| 3309 if (m_focusedElement) { | 3312 if (m_focusedElement) { |
| 3310 // handler shifted focus | 3313 // handler shifted focus |
| 3311 focusChangeBlocked = true; | 3314 focusChangeBlocked = true; |
| 3312 newFocusedElement = 0; | 3315 newFocusedElement = 0; |
| 3313 } | 3316 } |
| 3314 | 3317 |
| 3315 oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, new FocusedElement.get()); // DOM level 3 name for the bubbling blur event. | 3318 oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement.get()); // DOM level 3 name for the bubbling blur event. |
| 3316 // FIXME: We should remove firing DOMFocusOutEvent event when we are sur e no content depends | 3319 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends |
| 3317 // on it, probably when <rdar://problem/8503958> is resolved. | 3320 // on it, probably when <rdar://problem/8503958> is resolved. |
| 3318 oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement.get()); // DOM level 2 name for compatibility. | 3321 oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEve nt, newFocusedElement.get()); // DOM level 2 name for compatibility. |
| 3319 | 3322 |
| 3320 if (m_focusedElement) { | 3323 if (m_focusedElement) { |
| 3321 // handler shifted focus | 3324 // handler shifted focus |
| 3322 focusChangeBlocked = true; | 3325 focusChangeBlocked = true; |
| 3323 newFocusedElement = 0; | 3326 newFocusedElement = 0; |
| 3327 } | |
| 3324 } | 3328 } |
| 3325 | 3329 |
| 3326 if (oldFocusedElement->isRootEditableElement()) | 3330 if (oldFocusedElement->isRootEditableElement()) |
| 3327 frame()->editor().didEndEditing(); | 3331 frame()->editor().didEndEditing(); |
| 3328 | 3332 |
| 3329 if (view()) { | 3333 if (view()) { |
| 3330 Widget* oldWidget = widgetForElement(oldFocusedElement.get()); | 3334 Widget* oldWidget = widgetForElement(oldFocusedElement.get()); |
| 3331 if (oldWidget) | 3335 if (oldWidget) |
| 3332 oldWidget->setFocus(false); | 3336 oldWidget->setFocus(false); |
| 3333 else | 3337 else |
| 3334 view()->setFocus(false); | 3338 view()->setFocus(false); |
| 3335 } | 3339 } |
| 3336 | 3340 |
| 3337 // Autofill client may have modified the value of newFocusedElement, thu s require | 3341 // Autofill client may have modified the value of newFocusedElement, thu s require |
| 3338 // a layout update here, otherwise it will assert at newFocusedElement-> isFocusable(). | 3342 // a layout update here, otherwise it will assert at newFocusedElement-> isFocusable(). |
| 3339 // See crbug.com/251163. | 3343 // See crbug.com/251163. |
| 3340 updateLayoutIgnorePendingStylesheets(); | 3344 updateLayoutIgnorePendingStylesheets(); |
| 3341 } | 3345 } |
| 3342 | 3346 |
| 3343 if (newFocusedElement && newFocusedElement->isFocusable()) { | 3347 if (newFocusedElement && newFocusedElement->isFocusable()) { |
| 3344 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(n ewFocusedElement.get())) { | 3348 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(n ewFocusedElement.get())) { |
| 3345 // delegate blocks focus change | 3349 // delegate blocks focus change |
| 3346 focusChangeBlocked = true; | 3350 focusChangeBlocked = true; |
| 3347 goto SetFocusedElementDone; | 3351 goto SetFocusedElementDone; |
| 3348 } | 3352 } |
| 3349 // Set focus on the new node | 3353 // Set focus on the new node |
| 3350 m_focusedElement = newFocusedElement; | 3354 m_focusedElement = newFocusedElement; |
| 3351 | 3355 |
| 3352 // Dispatch the focus event and let the node do any other focus related activities (important for text fields) | 3356 // Dispatch the focus event and let the node do any other focus related activities (important for text fields) |
| 3353 m_focusedElement->dispatchFocusEvent(oldFocusedElement.get(), direction) ; | 3357 // If page is unfocused, focus event will be dispatched on page focus, d on't duplicate |
| 3358 if (page() && page()->focusController().isFocused()) { | |
| 3359 m_focusedElement->dispatchFocusEvent(oldFocusedElement.get(), direct ion); | |
| 3354 | 3360 |
| 3355 if (m_focusedElement != newFocusedElement) { | 3361 if (m_focusedElement != newFocusedElement) { |
| 3356 // handler shifted focus | 3362 // handler shifted focus |
| 3357 focusChangeBlocked = true; | 3363 focusChangeBlocked = true; |
| 3358 goto SetFocusedElementDone; | 3364 goto SetFocusedElementDone; |
| 3365 } | |
| 3366 | |
| 3367 m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, ol dFocusedElement.get()); // DOM level 3 bubbling focus event. | |
| 3368 | |
| 3369 if (m_focusedElement != newFocusedElement) { | |
| 3370 // handler shifted focus | |
| 3371 focusChangeBlocked = true; | |
| 3372 goto SetFocusedElementDone; | |
| 3373 } | |
| 3374 | |
| 3375 // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends | |
| 3376 // on it, probably when <rdar://problem/8503958> is m. | |
| 3377 m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement.get()); // DOM level 2 for compatibility. | |
| 3378 | |
| 3379 if (m_focusedElement != newFocusedElement) { | |
| 3380 // handler shifted focus | |
| 3381 focusChangeBlocked = true; | |
| 3382 goto SetFocusedElementDone; | |
| 3383 } | |
| 3359 } | 3384 } |
| 3360 | 3385 |
| 3361 m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFoc usedElement.get()); // DOM level 3 bubbling focus event. | |
| 3362 | |
| 3363 if (m_focusedElement != newFocusedElement) { | |
| 3364 // handler shifted focus | |
| 3365 focusChangeBlocked = true; | |
| 3366 goto SetFocusedElementDone; | |
| 3367 } | |
| 3368 | |
| 3369 // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends | |
| 3370 // on it, probably when <rdar://problem/8503958> is m. | |
| 3371 m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, old FocusedElement.get()); // DOM level 2 for compatibility. | |
| 3372 | |
| 3373 if (m_focusedElement != newFocusedElement) { | |
| 3374 // handler shifted focus | |
| 3375 focusChangeBlocked = true; | |
| 3376 goto SetFocusedElementDone; | |
| 3377 } | |
| 3378 m_focusedElement->setFocus(true); | 3386 m_focusedElement->setFocus(true); |
| 3379 | 3387 |
| 3380 if (m_focusedElement->isRootEditableElement()) | 3388 if (m_focusedElement->isRootEditableElement()) |
| 3381 frame()->editor().didBeginEditing(m_focusedElement.get()); | 3389 frame()->editor().didBeginEditing(m_focusedElement.get()); |
| 3382 | 3390 |
| 3383 // eww, I suck. set the qt focus correctly | 3391 // eww, I suck. set the qt focus correctly |
| 3384 // ### find a better place in the code for this | 3392 // ### find a better place in the code for this |
| 3385 if (view()) { | 3393 if (view()) { |
| 3386 Widget* focusWidget = widgetForElement(m_focusedElement.get()); | 3394 Widget* focusWidget = widgetForElement(m_focusedElement.get()); |
| 3387 if (focusWidget) { | 3395 if (focusWidget) { |
| (...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5312 { | 5320 { |
| 5313 return DocumentLifecycleNotifier::create(this); | 5321 return DocumentLifecycleNotifier::create(this); |
| 5314 } | 5322 } |
| 5315 | 5323 |
| 5316 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5324 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
| 5317 { | 5325 { |
| 5318 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); | 5326 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); |
| 5319 } | 5327 } |
| 5320 | 5328 |
| 5321 } // namespace WebCore | 5329 } // namespace WebCore |
| OLD | NEW |