| 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 // FIXME: But this only works without OOPI |
| 415 if (!m_page->mainFrame()->isLocalFrame()) |
| 416 return false; |
| 417 node = findFocusableNodeRecursively(type, FocusNavigationScope::focusNav
igationScopeOf(toLocalFrame(m_page->mainFrame())->document()), 0); |
| 415 node = findFocusableNodeDecendingDownIntoFrameDocument(type, node.get())
; | 418 node = findFocusableNodeDecendingDownIntoFrameDocument(type, node.get())
; |
| 416 | 419 |
| 417 if (!node) | 420 if (!node) |
| 418 return false; | 421 return false; |
| 419 } | 422 } |
| 420 | 423 |
| 421 ASSERT(node); | 424 ASSERT(node); |
| 422 | 425 |
| 423 if (node == document->focusedElement()) | 426 if (node == document->focusedElement()) |
| 424 // Focus wrapped around to the same node. | 427 // Focus wrapped around to the same node. |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 return true; | 716 return true; |
| 714 } | 717 } |
| 715 | 718 |
| 716 void FocusController::setActive(bool active) | 719 void FocusController::setActive(bool active) |
| 717 { | 720 { |
| 718 if (m_isActive == active) | 721 if (m_isActive == active) |
| 719 return; | 722 return; |
| 720 | 723 |
| 721 m_isActive = active; | 724 m_isActive = active; |
| 722 | 725 |
| 723 if (FrameView* view = m_page->mainFrame()->view()) | 726 if (m_page->mainFrame()->isLocalFrame()) { |
| 724 view->updateControlTints(); | 727 if (FrameView* view = toLocalFrame(m_page->mainFrame())->view()) |
| 728 view->updateControlTints(); |
| 729 } |
| 725 | 730 |
| 726 toLocalFrame(focusedOrMainFrame())->selection().pageActivationChanged(); | 731 toLocalFrame(focusedOrMainFrame())->selection().pageActivationChanged(); |
| 727 } | 732 } |
| 728 | 733 |
| 729 static void updateFocusCandidateIfNeeded(FocusType type, const FocusCandidate& c
urrent, FocusCandidate& candidate, FocusCandidate& closest) | 734 static void updateFocusCandidateIfNeeded(FocusType type, const FocusCandidate& c
urrent, FocusCandidate& candidate, FocusCandidate& closest) |
| 730 { | 735 { |
| 731 ASSERT(candidate.visibleNode->isElementNode()); | 736 ASSERT(candidate.visibleNode->isElementNode()); |
| 732 ASSERT(candidate.visibleNode->renderer()); | 737 ASSERT(candidate.visibleNode->renderer()); |
| 733 | 738 |
| 734 // Ignore iframes that don't have a src attribute | 739 // Ignore iframes that don't have a src attribute |
| (...skipping 15 matching lines...) Expand all Loading... |
| 750 closest = candidate; | 755 closest = candidate; |
| 751 return; | 756 return; |
| 752 } | 757 } |
| 753 | 758 |
| 754 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); | 759 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); |
| 755 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate
) | 760 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate
) |
| 756 && intersectionRect == candidate.rect) { | 761 && intersectionRect == candidate.rect) { |
| 757 // If 2 nodes are intersecting, do hit test to find which node in on top
. | 762 // If 2 nodes are intersecting, do hit test to find which node in on top
. |
| 758 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; | 763 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; |
| 759 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; | 764 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); | 765 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame
()) |
| 766 return; |
| 767 HitTestResult result = toLocalFrame(candidate.visibleNode->document().pa
ge()->mainFrame())->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTestR
equest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | Hit
TestRequest::ConfusingAndOftenMisusedDisallowShadowContent); |
| 761 if (candidate.visibleNode->contains(result.innerNode())) { | 768 if (candidate.visibleNode->contains(result.innerNode())) { |
| 762 closest = candidate; | 769 closest = candidate; |
| 763 return; | 770 return; |
| 764 } | 771 } |
| 765 if (closest.visibleNode->contains(result.innerNode())) | 772 if (closest.visibleNode->contains(result.innerNode())) |
| 766 return; | 773 return; |
| 767 } | 774 } |
| 768 | 775 |
| 769 if (candidate.alignment == closest.alignment) { | 776 if (candidate.alignment == closest.alignment) { |
| 770 if (candidate.distance < closest.distance) | 777 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 */); | 918 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
| 912 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); | 919 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); |
| 913 if (container && container->isDocumentNode()) | 920 if (container && container->isDocumentNode()) |
| 914 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 921 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
| 915 } while (!consumed && container); | 922 } while (!consumed && container); |
| 916 | 923 |
| 917 return consumed; | 924 return consumed; |
| 918 } | 925 } |
| 919 | 926 |
| 920 } // namespace WebCore | 927 } // namespace WebCore |
| OLD | NEW |