| 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 26 matching lines...) Expand all Loading... |
| 37 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 37 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 38 #include "sky/engine/core/editing/Editor.h" | 38 #include "sky/engine/core/editing/Editor.h" |
| 39 #include "sky/engine/core/editing/FrameSelection.h" | 39 #include "sky/engine/core/editing/FrameSelection.h" |
| 40 #include "sky/engine/core/editing/htmlediting.h" | 40 #include "sky/engine/core/editing/htmlediting.h" |
| 41 #include "sky/engine/core/events/Event.h" | 41 #include "sky/engine/core/events/Event.h" |
| 42 #include "sky/engine/core/frame/FrameView.h" | 42 #include "sky/engine/core/frame/FrameView.h" |
| 43 #include "sky/engine/core/frame/LocalDOMWindow.h" | 43 #include "sky/engine/core/frame/LocalDOMWindow.h" |
| 44 #include "sky/engine/core/frame/LocalFrame.h" | 44 #include "sky/engine/core/frame/LocalFrame.h" |
| 45 #include "sky/engine/core/frame/Settings.h" | 45 #include "sky/engine/core/frame/Settings.h" |
| 46 #include "sky/engine/core/html/HTMLImageElement.h" | 46 #include "sky/engine/core/html/HTMLImageElement.h" |
| 47 #include "sky/engine/core/page/Chrome.h" | |
| 48 #include "sky/engine/core/page/ChromeClient.h" | 47 #include "sky/engine/core/page/ChromeClient.h" |
| 49 #include "sky/engine/core/page/EventHandler.h" | 48 #include "sky/engine/core/page/EventHandler.h" |
| 50 #include "sky/engine/core/page/Page.h" | 49 #include "sky/engine/core/page/Page.h" |
| 51 #include "sky/engine/core/rendering/HitTestResult.h" | 50 #include "sky/engine/core/rendering/HitTestResult.h" |
| 52 #include "sky/engine/core/rendering/RenderLayer.h" | 51 #include "sky/engine/core/rendering/RenderLayer.h" |
| 53 | 52 |
| 54 namespace blink { | 53 namespace blink { |
| 55 | 54 |
| 56 // FIXME: Some of Node* return values and Node* arguments should be Element*. | 55 // FIXME: Some of Node* return values and Node* arguments should be Element*. |
| 57 | 56 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 oldFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::blur)
); | 208 oldFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::blur)
); |
| 210 } | 209 } |
| 211 | 210 |
| 212 if (newFrame && newFrame->view() && isFocused()) { | 211 if (newFrame && newFrame->view() && isFocused()) { |
| 213 newFrame->selection().setFocused(true); | 212 newFrame->selection().setFocused(true); |
| 214 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus
)); | 213 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus
)); |
| 215 } | 214 } |
| 216 | 215 |
| 217 m_isChangingFocusedFrame = false; | 216 m_isChangingFocusedFrame = false; |
| 218 | 217 |
| 219 m_page->chrome().client().focusedFrameChanged(newFrame.get()); | 218 m_page->focusedFrameChanged(newFrame.get()); |
| 220 } | 219 } |
| 221 | 220 |
| 222 void FocusController::focusDocumentView(PassRefPtr<LocalFrame> frame) | 221 void FocusController::focusDocumentView(PassRefPtr<LocalFrame> frame) |
| 223 { | 222 { |
| 224 ASSERT(!frame || frame->page() == m_page); | 223 ASSERT(!frame || frame->page() == m_page); |
| 225 if (m_focusedFrame == frame) | 224 if (m_focusedFrame == frame) |
| 226 return; | 225 return; |
| 227 | 226 |
| 228 RefPtr<LocalFrame> focusedFrame = m_focusedFrame.get(); | 227 RefPtr<LocalFrame> focusedFrame = m_focusedFrame.get(); |
| 229 if (focusedFrame && focusedFrame->view()) { | 228 if (focusedFrame && focusedFrame->view()) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 Document* document = frame->document(); | 318 Document* document = frame->document(); |
| 320 | 319 |
| 321 Node* currentNode = document->focusedElement(); | 320 Node* currentNode = document->focusedElement(); |
| 322 | 321 |
| 323 document->updateLayout(); | 322 document->updateLayout(); |
| 324 | 323 |
| 325 RefPtr<Node> node = findFocusableNodeAcrossFocusScope(type, FocusNavigationS
cope::focusNavigationScopeOf(currentNode ? currentNode : document), currentNode)
; | 324 RefPtr<Node> node = findFocusableNodeAcrossFocusScope(type, FocusNavigationS
cope::focusNavigationScopeOf(currentNode ? currentNode : document), currentNode)
; |
| 326 | 325 |
| 327 if (!node) { | 326 if (!node) { |
| 328 // We didn't find a node to focus, so we should try to pass focus to Chr
ome. | 327 // We didn't find a node to focus, so we should try to pass focus to Chr
ome. |
| 329 if (!initialFocus && m_page->chrome().canTakeFocus(type)) { | 328 if (!initialFocus && m_page->canTakeFocus(type)) { |
| 330 document->setFocusedElement(nullptr); | 329 document->setFocusedElement(nullptr); |
| 331 setFocusedFrame(nullptr); | 330 setFocusedFrame(nullptr); |
| 332 m_page->chrome().takeFocus(type); | 331 m_page->takeFocus(type); |
| 333 return true; | 332 return true; |
| 334 } | 333 } |
| 335 | 334 |
| 336 // Chrome doesn't want focus, so we should wrap focus. | 335 // Chrome doesn't want focus, so we should wrap focus. |
| 337 node = findFocusableNodeRecursively(type, FocusNavigationScope::focusNav
igationScopeOf(m_page->mainFrame()->document()), 0); | 336 node = findFocusableNodeRecursively(type, FocusNavigationScope::focusNav
igationScopeOf(m_page->mainFrame()->document()), 0); |
| 338 node = findFocusableNodeDecendingDownIntoFrameDocument(type, node.get())
; | 337 node = findFocusableNodeDecendingDownIntoFrameDocument(type, node.get())
; |
| 339 | 338 |
| 340 if (!node) | 339 if (!node) |
| 341 return false; | 340 return false; |
| 342 } | 341 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: 0; | 546 RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: 0; |
| 548 | 547 |
| 549 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0
; | 548 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0
; |
| 550 if (element && oldFocusedElement == element) | 549 if (element && oldFocusedElement == element) |
| 551 return true; | 550 return true; |
| 552 | 551 |
| 553 // FIXME: Might want to disable this check for caretBrowsing | 552 // FIXME: Might want to disable this check for caretBrowsing |
| 554 if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !reli
nquishesEditingFocus(oldFocusedElement)) | 553 if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !reli
nquishesEditingFocus(oldFocusedElement)) |
| 555 return false; | 554 return false; |
| 556 | 555 |
| 557 m_page->chrome().client().willSetInputMethodState(); | |
| 558 | |
| 559 RefPtr<Document> newDocument = nullptr; | 556 RefPtr<Document> newDocument = nullptr; |
| 560 if (element) | 557 if (element) |
| 561 newDocument = &element->document(); | 558 newDocument = &element->document(); |
| 562 else if (newFocusedFrame) | 559 else if (newFocusedFrame) |
| 563 newDocument = newFocusedFrame->document(); | 560 newDocument = newFocusedFrame->document(); |
| 564 | 561 |
| 565 if (newDocument && oldDocument == newDocument && newDocument->focusedElement
() == element) | 562 if (newDocument && oldDocument == newDocument && newDocument->focusedElement
() == element) |
| 566 return true; | 563 return true; |
| 567 | 564 |
| 568 if (oldDocument && oldDocument != newDocument) | 565 if (oldDocument && oldDocument != newDocument) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 589 { | 586 { |
| 590 if (m_isActive == active) | 587 if (m_isActive == active) |
| 591 return; | 588 return; |
| 592 | 589 |
| 593 m_isActive = active; | 590 m_isActive = active; |
| 594 | 591 |
| 595 focusedOrMainFrame()->selection().pageActivationChanged(); | 592 focusedOrMainFrame()->selection().pageActivationChanged(); |
| 596 } | 593 } |
| 597 | 594 |
| 598 } // namespace blink | 595 } // namespace blink |
| OLD | NEW |