| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 bool FocusController::advanceFocusInDocumentOrder(FocusType type, bool initialFo
cus) | 330 bool FocusController::advanceFocusInDocumentOrder(FocusType type, bool initialFo
cus) |
| 331 { | 331 { |
| 332 LocalFrame* frame = focusedOrMainFrame(); | 332 LocalFrame* frame = focusedOrMainFrame(); |
| 333 ASSERT(frame); | 333 ASSERT(frame); |
| 334 Document* document = frame->document(); | 334 Document* document = frame->document(); |
| 335 | 335 |
| 336 Node* currentNode = document->focusedElement(); | 336 Node* currentNode = document->focusedElement(); |
| 337 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself | |
| 338 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); | |
| 339 | |
| 340 if (caretBrowsing && !currentNode) | |
| 341 currentNode = frame->selection().start().deprecatedNode(); | |
| 342 | 337 |
| 343 document->updateLayoutIgnorePendingStylesheets(); | 338 document->updateLayoutIgnorePendingStylesheets(); |
| 344 | 339 |
| 345 RefPtrWillBeRawPtr<Node> node = findFocusableNodeAcrossFocusScope(type, Focu
sNavigationScope::focusNavigationScopeOf(currentNode ? currentNode : document),
currentNode); | 340 RefPtrWillBeRawPtr<Node> node = findFocusableNodeAcrossFocusScope(type, Focu
sNavigationScope::focusNavigationScopeOf(currentNode ? currentNode : document),
currentNode); |
| 346 | 341 |
| 347 if (!node) { | 342 if (!node) { |
| 348 // We didn't find a node to focus, so we should try to pass focus to Chr
ome. | 343 // We didn't find a node to focus, so we should try to pass focus to Chr
ome. |
| 349 if (!initialFocus && m_page->chrome().canTakeFocus(type)) { | 344 if (!initialFocus && m_page->chrome().canTakeFocus(type)) { |
| 350 document->setFocusedElement(nullptr); | 345 document->setFocusedElement(nullptr); |
| 351 setFocusedFrame(nullptr); | 346 setFocusedFrame(nullptr); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 378 // and HTMLTextAreaElement) do extra work in their focus() methods. | 373 // and HTMLTextAreaElement) do extra work in their focus() methods. |
| 379 Document& newDocument = element->document(); | 374 Document& newDocument = element->document(); |
| 380 | 375 |
| 381 if (&newDocument != document) { | 376 if (&newDocument != document) { |
| 382 // Focus is going away from this document, so clear the focused node. | 377 // Focus is going away from this document, so clear the focused node. |
| 383 document->setFocusedElement(nullptr); | 378 document->setFocusedElement(nullptr); |
| 384 } | 379 } |
| 385 | 380 |
| 386 setFocusedFrame(newDocument.frame()); | 381 setFocusedFrame(newDocument.frame()); |
| 387 | 382 |
| 388 if (caretBrowsing) { | |
| 389 Position position = firstPositionInOrBeforeNode(element); | |
| 390 VisibleSelection newSelection(position, position, DOWNSTREAM); | |
| 391 frame->selection().setSelection(newSelection); | |
| 392 } | |
| 393 | |
| 394 element->focus(false, type); | 383 element->focus(false, type); |
| 395 return true; | 384 return true; |
| 396 } | 385 } |
| 397 | 386 |
| 398 Node* FocusController::findFocusableNodeAcrossFocusScope(FocusType type, FocusNa
vigationScope scope, Node* currentNode) | 387 Node* FocusController::findFocusableNodeAcrossFocusScope(FocusType type, FocusNa
vigationScope scope, Node* currentNode) |
| 399 { | 388 { |
| 400 ASSERT(!currentNode || !isNonFocusableShadowHost(currentNode)); | 389 ASSERT(!currentNode || !isNonFocusableShadowHost(currentNode)); |
| 401 Node* found; | 390 Node* found; |
| 402 if (currentNode && type == FocusTypeForward && isKeyboardFocusableShadowHost
(currentNode)) { | 391 if (currentNode && type == FocusTypeForward && isKeyboardFocusableShadowHost
(currentNode)) { |
| 403 Node* foundInInnerFocusScope = findFocusableNodeRecursively(type, FocusN
avigationScope::ownedByShadowHost(currentNode), 0); | 392 Node* foundInInnerFocusScope = findFocusableNodeRecursively(type, FocusN
avigationScope::ownedByShadowHost(currentNode), 0); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 { | 604 { |
| 616 if (m_isActive == active) | 605 if (m_isActive == active) |
| 617 return; | 606 return; |
| 618 | 607 |
| 619 m_isActive = active; | 608 m_isActive = active; |
| 620 | 609 |
| 621 focusedOrMainFrame()->selection().pageActivationChanged(); | 610 focusedOrMainFrame()->selection().pageActivationChanged(); |
| 622 } | 611 } |
| 623 | 612 |
| 624 } // namespace blink | 613 } // namespace blink |
| OLD | NEW |