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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 if (!node) { | 404 if (!node) { |
405 // We didn't find a node to focus, so we should try to pass focus to Chr
ome. | 405 // We didn't find a node to focus, so we should try to pass focus to Chr
ome. |
406 if (!initialFocus && m_page->chrome().canTakeFocus(type)) { | 406 if (!initialFocus && m_page->chrome().canTakeFocus(type)) { |
407 document->setFocusedElement(nullptr); | 407 document->setFocusedElement(nullptr); |
408 setFocusedFrame(nullptr); | 408 setFocusedFrame(nullptr); |
409 m_page->chrome().takeFocus(type); | 409 m_page->chrome().takeFocus(type); |
410 return true; | 410 return true; |
411 } | 411 } |
412 | 412 |
413 // Chrome doesn't want focus, so we should wrap focus. | 413 // Chrome doesn't want focus, so we should wrap focus. |
414 node = findFocusableNodeRecursively(type, FocusNavigationScope::focusNav
igationScopeOf(m_page->mainFrame()->document()), 0); | 414 if (!m_page->mainFrame()->isLocalFrame()) |
| 415 return false; |
| 416 node = findFocusableNodeRecursively(type, FocusNavigationScope::focusNav
igationScopeOf(m_page->deprecatedLocalMainFrame()->document()), 0); |
415 node = findFocusableNodeDecendingDownIntoFrameDocument(type, node.get())
; | 417 node = findFocusableNodeDecendingDownIntoFrameDocument(type, node.get())
; |
416 | 418 |
417 if (!node) | 419 if (!node) |
418 return false; | 420 return false; |
419 } | 421 } |
420 | 422 |
421 ASSERT(node); | 423 ASSERT(node); |
422 | 424 |
423 if (node == document->focusedElement()) | 425 if (node == document->focusedElement()) |
424 // Focus wrapped around to the same node. | 426 // Focus wrapped around to the same node. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 return true; | 715 return true; |
714 } | 716 } |
715 | 717 |
716 void FocusController::setActive(bool active) | 718 void FocusController::setActive(bool active) |
717 { | 719 { |
718 if (m_isActive == active) | 720 if (m_isActive == active) |
719 return; | 721 return; |
720 | 722 |
721 m_isActive = active; | 723 m_isActive = active; |
722 | 724 |
723 if (FrameView* view = m_page->mainFrame()->view()) | 725 if (m_page->mainFrame()->isLocalFrame()) { |
724 view->updateControlTints(); | 726 if (FrameView* view = m_page->deprecatedLocalMainFrame()->view()) |
| 727 view->updateControlTints(); |
| 728 } |
725 | 729 |
726 toLocalFrame(focusedOrMainFrame())->selection().pageActivationChanged(); | 730 toLocalFrame(focusedOrMainFrame())->selection().pageActivationChanged(); |
727 } | 731 } |
728 | 732 |
729 static void updateFocusCandidateIfNeeded(FocusType type, const FocusCandidate& c
urrent, FocusCandidate& candidate, FocusCandidate& closest) | 733 static void updateFocusCandidateIfNeeded(FocusType type, const FocusCandidate& c
urrent, FocusCandidate& candidate, FocusCandidate& closest) |
730 { | 734 { |
731 ASSERT(candidate.visibleNode->isElementNode()); | 735 ASSERT(candidate.visibleNode->isElementNode()); |
732 ASSERT(candidate.visibleNode->renderer()); | 736 ASSERT(candidate.visibleNode->renderer()); |
733 | 737 |
734 // Ignore iframes that don't have a src attribute | 738 // Ignore iframes that don't have a src attribute |
(...skipping 15 matching lines...) Expand all Loading... |
750 closest = candidate; | 754 closest = candidate; |
751 return; | 755 return; |
752 } | 756 } |
753 | 757 |
754 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); | 758 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); |
755 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate
) | 759 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate
) |
756 && intersectionRect == candidate.rect) { | 760 && intersectionRect == candidate.rect) { |
757 // If 2 nodes are intersecting, do hit test to find which node in on top
. | 761 // If 2 nodes are intersecting, do hit test to find which node in on top
. |
758 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; | 762 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; |
759 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; | 763 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; |
760 HitTestResult result = candidate.visibleNode->document().page()->mainFra
me()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTestRequest::ReadOn
ly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::C
onfusingAndOftenMisusedDisallowShadowContent); | 764 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame
()) |
| 765 return; |
| 766 HitTestResult result = candidate.visibleNode->document().page()->depreca
tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest
Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | Hi
tTestRequest::ConfusingAndOftenMisusedDisallowShadowContent); |
761 if (candidate.visibleNode->contains(result.innerNode())) { | 767 if (candidate.visibleNode->contains(result.innerNode())) { |
762 closest = candidate; | 768 closest = candidate; |
763 return; | 769 return; |
764 } | 770 } |
765 if (closest.visibleNode->contains(result.innerNode())) | 771 if (closest.visibleNode->contains(result.innerNode())) |
766 return; | 772 return; |
767 } | 773 } |
768 | 774 |
769 if (candidate.alignment == closest.alignment) { | 775 if (candidate.alignment == closest.alignment) { |
770 if (candidate.distance < closest.distance) | 776 if (candidate.distance < closest.distance) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); | 917 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
912 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); | 918 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); |
913 if (container && container->isDocumentNode()) | 919 if (container && container->isDocumentNode()) |
914 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 920 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
915 } while (!consumed && container); | 921 } while (!consumed && container); |
916 | 922 |
917 return consumed; | 923 return consumed; |
918 } | 924 } |
919 | 925 |
920 } // namespace WebCore | 926 } // namespace WebCore |
OLD | NEW |