Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: Source/core/page/FocusController.cpp

Issue 797463003: spatnav: Allow focus move to a close-by not-fully-aligned node over a distant but fully-aligned nod… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix not-aligned node issue Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 return; 745 return;
746 746
747 // Ignore off screen child nodes of containers that do not scroll (overflow: hidden) 747 // Ignore off screen child nodes of containers that do not scroll (overflow: hidden)
748 if (candidate.isOffscreen && !canBeScrolledIntoView(type, candidate)) 748 if (candidate.isOffscreen && !canBeScrolledIntoView(type, candidate))
749 return; 749 return;
750 750
751 distanceDataForNode(type, current, candidate); 751 distanceDataForNode(type, current, candidate);
752 if (candidate.distance == maxDistance()) 752 if (candidate.distance == maxDistance())
753 return; 753 return;
754 754
755 if (candidate.isOffscreenAfterScrolling && candidate.alignment < Full) 755 if (candidate.isOffscreenAfterScrolling)
756 return; 756 return;
757 757
758 if (closest.isNull()) { 758 if (closest.isNull()) {
759 closest = candidate; 759 closest = candidate;
760 return; 760 return;
761 } 761 }
762 762
763 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); 763 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect);
764 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate ) 764 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate )
765 && intersectionRect == candidate.rect) { 765 && intersectionRect == candidate.rect) {
766 // If 2 nodes are intersecting, do hit test to find which node in on top . 766 // If 2 nodes are intersecting, do hit test to find which node in on top .
767 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; 767 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2;
768 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; 768 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2;
769 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame ()) 769 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame ())
770 return; 770 return;
771 HitTestResult result = candidate.visibleNode->document().page()->depreca tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping); 771 HitTestResult result = candidate.visibleNode->document().page()->depreca tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping);
772 if (candidate.visibleNode->contains(result.innerNode())) { 772 if (candidate.visibleNode->contains(result.innerNode())) {
773 closest = candidate; 773 closest = candidate;
774 return; 774 return;
775 } 775 }
776 if (closest.visibleNode->contains(result.innerNode())) 776 if (closest.visibleNode->contains(result.innerNode()))
777 return; 777 return;
778 } 778 }
779 779
780 if (candidate.alignment == closest.alignment) { 780 if (candidate.distance < closest.distance)
781 if (candidate.distance < closest.distance)
782 closest = candidate;
783 return;
784 }
785
786 if (candidate.alignment > closest.alignment)
787 closest = candidate; 781 closest = candidate;
788 } 782 }
789 783
790 void FocusController::findFocusCandidateInContainer(Node& container, const Layou tRect& startingRect, FocusType type, FocusCandidate& closest) 784 void FocusController::findFocusCandidateInContainer(Node& container, const Layou tRect& startingRect, FocusType type, FocusCandidate& closest)
791 { 785 {
792 Element* focusedElement = (focusedFrame() && toLocalFrame(focusedFrame())->d ocument()) ? toLocalFrame(focusedFrame())->document()->focusedElement() : nullpt r; 786 Element* focusedElement = (focusedFrame() && toLocalFrame(focusedFrame())->d ocument()) ? toLocalFrame(focusedFrame())->document()->focusedElement() : nullpt r;
793 787
794 Element* element = ElementTraversal::firstWithin(container); 788 Element* element = ElementTraversal::firstWithin(container);
795 FocusCandidate current; 789 FocusCandidate current;
796 current.rect = startingRect; 790 current.rect = startingRect;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 return consumed; 922 return consumed;
929 } 923 }
930 924
931 void FocusController::trace(Visitor* visitor) 925 void FocusController::trace(Visitor* visitor)
932 { 926 {
933 visitor->trace(m_page); 927 visitor->trace(m_page);
934 visitor->trace(m_focusedFrame); 928 visitor->trace(m_focusedFrame);
935 } 929 }
936 930
937 } // namespace blink 931 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698