| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 inline void dispatchEventsOnWindowAndFocusedElement(Document* document, bool foc
used) | 169 inline void dispatchEventsOnWindowAndFocusedElement(Document* document, bool foc
used) |
| 170 { | 170 { |
| 171 ASSERT(document); | 171 ASSERT(document); |
| 172 // If we have a focused element we should dispatch blur on it before we blur
the window. | 172 // If we have a focused element we should dispatch blur on it before we blur
the window. |
| 173 // If we have a focused element we should dispatch focus on it after we focu
s the window. | 173 // If we have a focused element we should dispatch focus on it after we focu
s the window. |
| 174 // https://bugs.webkit.org/show_bug.cgi?id=27105 | 174 // https://bugs.webkit.org/show_bug.cgi?id=27105 |
| 175 | 175 |
| 176 if (document->focusedElement() && isHTMLPlugInElement(document->focusedEleme
nt())) | 176 if (document->focusedElement() && isHTMLPlugInElement(document->focusedEleme
nt())) |
| 177 toHTMLPlugInElement(document->focusedElement())->setPluginFocus(focused)
; | 177 toHTMLPlugInElement(document->focusedElement())->setPluginFocus(focused)
; |
| 178 | 178 |
| 179 if (document->focusedElement() && document->focusedElement()->isFrameletElem
ent()) |
| 180 toHTMLFrameOwnerElement(document->focusedElement())->ownedWidget()->setF
ocus(focused, WebFocusTypeNone); |
| 181 |
| 179 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o
rg/show_bug.cgi?id=33962 | 182 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o
rg/show_bug.cgi?id=33962 |
| 180 if (Page* page = document->page()) { | 183 if (Page* page = document->page()) { |
| 181 if (page->defersLoading()) | 184 if (page->defersLoading()) |
| 182 return; | 185 return; |
| 183 } | 186 } |
| 184 | 187 |
| 185 if (!focused && document->focusedElement()) { | 188 if (!focused && document->focusedElement()) { |
| 186 RefPtrWillBeRawPtr<Element> focusedElement(document->focusedElement()); | 189 RefPtrWillBeRawPtr<Element> focusedElement(document->focusedElement()); |
| 187 focusedElement->setFocus(false); | 190 focusedElement->setFocus(false); |
| 188 dispatchBlurEvent(*document, *focusedElement); | 191 dispatchBlurEvent(*document, *focusedElement); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 return false; | 775 return false; |
| 773 } | 776 } |
| 774 | 777 |
| 775 ASSERT(element); | 778 ASSERT(element); |
| 776 | 779 |
| 777 if (element == document->focusedElement()) { | 780 if (element == document->focusedElement()) { |
| 778 // Focus wrapped around to the same node. | 781 // Focus wrapped around to the same node. |
| 779 return true; | 782 return true; |
| 780 } | 783 } |
| 781 | 784 |
| 782 if (element->isFrameOwnerElement() && (!isHTMLPlugInElement(*element) || !el
ement->isKeyboardFocusable())) { | 785 if (element->isFrameOwnerElement() && ((!element->isFrameletElement() && !is
HTMLPlugInElement(*element)) || !element->isKeyboardFocusable())) { |
| 783 // We focus frames rather than frame owners. | 786 // We focus frames rather than frame owners. |
| 784 // FIXME: We should not focus frames that have no scrollbars, as focusin
g them isn't useful to the user. | 787 // FIXME: We should not focus frames that have no scrollbars, as focusin
g them isn't useful to the user. |
| 785 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(element); | 788 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(element); |
| 786 if (!owner->contentFrame()) | 789 if (!owner->contentFrame()) |
| 787 return false; | 790 return false; |
| 788 | 791 |
| 789 document->clearFocusedElement(); | 792 document->clearFocusedElement(); |
| 790 setFocusedFrame(owner->contentFrame()); | 793 setFocusedFrame(owner->contentFrame()); |
| 791 | 794 |
| 792 // If contentFrame is remote, continue the search for focusable | 795 // If contentFrame is remote, continue the search for focusable |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 return consumed; | 1125 return consumed; |
| 1123 } | 1126 } |
| 1124 | 1127 |
| 1125 DEFINE_TRACE(FocusController) | 1128 DEFINE_TRACE(FocusController) |
| 1126 { | 1129 { |
| 1127 visitor->trace(m_page); | 1130 visitor->trace(m_page); |
| 1128 visitor->trace(m_focusedFrame); | 1131 visitor->trace(m_focusedFrame); |
| 1129 } | 1132 } |
| 1130 | 1133 |
| 1131 } // namespace blink | 1134 } // namespace blink |
| OLD | NEW |