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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 return; | 739 return; |
740 | 740 |
741 // Ignore off screen child nodes of containers that do not scroll (overflow:
hidden) | 741 // Ignore off screen child nodes of containers that do not scroll (overflow:
hidden) |
742 if (candidate.isOffscreen && !canBeScrolledIntoView(type, candidate)) | 742 if (candidate.isOffscreen && !canBeScrolledIntoView(type, candidate)) |
743 return; | 743 return; |
744 | 744 |
745 distanceDataForNode(type, current, candidate); | 745 distanceDataForNode(type, current, candidate); |
746 if (candidate.distance == maxDistance()) | 746 if (candidate.distance == maxDistance()) |
747 return; | 747 return; |
748 | 748 |
749 if (candidate.isOffscreenAfterScrolling && candidate.alignment < Full) | 749 if (candidate.isOffscreenAfterScrolling) |
750 return; | 750 return; |
751 | 751 |
752 if (closest.isNull()) { | 752 if (closest.isNull()) { |
753 closest = candidate; | 753 closest = candidate; |
754 return; | 754 return; |
755 } | 755 } |
756 | 756 |
757 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); | 757 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); |
758 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate
) | 758 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate
) |
759 && intersectionRect == candidate.rect) { | 759 && intersectionRect == candidate.rect) { |
760 // If 2 nodes are intersecting, do hit test to find which node in on top
. | 760 // If 2 nodes are intersecting, do hit test to find which node in on top
. |
761 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; | 761 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; |
762 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; | 762 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; |
763 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame
()) | 763 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame
()) |
764 return; | 764 return; |
765 HitTestResult result = candidate.visibleNode->document().page()->depreca
tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest
Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping); | 765 HitTestResult result = candidate.visibleNode->document().page()->depreca
tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest
Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping); |
766 if (candidate.visibleNode->contains(result.innerNode())) { | 766 if (candidate.visibleNode->contains(result.innerNode())) { |
767 closest = candidate; | 767 closest = candidate; |
768 return; | 768 return; |
769 } | 769 } |
770 if (closest.visibleNode->contains(result.innerNode())) | 770 if (closest.visibleNode->contains(result.innerNode())) |
771 return; | 771 return; |
772 } | 772 } |
773 | 773 |
774 if (candidate.alignment == closest.alignment) { | 774 if (candidate.distance < closest.distance) |
775 if (candidate.distance < closest.distance) | |
776 closest = candidate; | |
777 return; | |
778 } | |
779 | |
780 if (candidate.alignment > closest.alignment) | |
781 closest = candidate; | 775 closest = candidate; |
782 } | 776 } |
783 | 777 |
784 void FocusController::findFocusCandidateInContainer(Node& container, const Layou
tRect& startingRect, FocusType type, FocusCandidate& closest) | 778 void FocusController::findFocusCandidateInContainer(Node& container, const Layou
tRect& startingRect, FocusType type, FocusCandidate& closest) |
785 { | 779 { |
786 Element* focusedElement = (focusedFrame() && toLocalFrame(focusedFrame())->d
ocument()) ? toLocalFrame(focusedFrame())->document()->focusedElement() : nullpt
r; | 780 Element* focusedElement = (focusedFrame() && toLocalFrame(focusedFrame())->d
ocument()) ? toLocalFrame(focusedFrame())->document()->focusedElement() : nullpt
r; |
787 | 781 |
788 Element* element = ElementTraversal::firstWithin(container); | 782 Element* element = ElementTraversal::firstWithin(container); |
789 FocusCandidate current; | 783 FocusCandidate current; |
790 current.rect = startingRect; | 784 current.rect = startingRect; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 return consumed; | 916 return consumed; |
923 } | 917 } |
924 | 918 |
925 void FocusController::trace(Visitor* visitor) | 919 void FocusController::trace(Visitor* visitor) |
926 { | 920 { |
927 visitor->trace(m_page); | 921 visitor->trace(m_page); |
928 visitor->trace(m_focusedFrame); | 922 visitor->trace(m_focusedFrame); |
929 } | 923 } |
930 | 924 |
931 } // namespace blink | 925 } // namespace blink |
OLD | NEW |