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

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: rebaseline 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return; 762 return;
763 763
764 // Ignore off screen child nodes of containers that do not scroll (overflow: hidden) 764 // Ignore off screen child nodes of containers that do not scroll (overflow: hidden)
765 if (candidate.isOffscreen && !canBeScrolledIntoView(type, candidate)) 765 if (candidate.isOffscreen && !canBeScrolledIntoView(type, candidate))
766 return; 766 return;
767 767
768 distanceDataForNode(type, current, candidate); 768 distanceDataForNode(type, current, candidate);
769 if (candidate.distance == maxDistance()) 769 if (candidate.distance == maxDistance())
770 return; 770 return;
771 771
772 if (candidate.isOffscreenAfterScrolling && candidate.alignment < Full) 772 if (candidate.isOffscreenAfterScrolling)
773 return; 773 return;
774 774
775 if (closest.isNull()) { 775 if (closest.isNull()) {
776 closest = candidate; 776 closest = candidate;
777 return; 777 return;
778 } 778 }
779 779
780 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect); 780 LayoutRect intersectionRect = intersection(candidate.rect, closest.rect);
781 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate ) 781 if (!intersectionRect.isEmpty() && !areElementsOnSameLine(closest, candidate )
782 && intersectionRect == candidate.rect) { 782 && intersectionRect == candidate.rect) {
783 // If 2 nodes are intersecting, do hit test to find which node in on top . 783 // If 2 nodes are intersecting, do hit test to find which node in on top .
784 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2; 784 LayoutUnit x = intersectionRect.x() + intersectionRect.width() / 2;
785 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2; 785 LayoutUnit y = intersectionRect.y() + intersectionRect.height() / 2;
786 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame ()) 786 if (!candidate.visibleNode->document().page()->mainFrame()->isLocalFrame ())
787 return; 787 return;
788 HitTestResult result = candidate.visibleNode->document().page()->depreca tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping); 788 HitTestResult result = candidate.visibleNode->document().page()->depreca tedLocalMainFrame()->eventHandler().hitTestResultAtPoint(IntPoint(x, y), HitTest Request::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping);
789 if (candidate.visibleNode->contains(result.innerNode())) { 789 if (candidate.visibleNode->contains(result.innerNode())) {
790 closest = candidate; 790 closest = candidate;
791 return; 791 return;
792 } 792 }
793 if (closest.visibleNode->contains(result.innerNode())) 793 if (closest.visibleNode->contains(result.innerNode()))
794 return; 794 return;
795 } 795 }
796 796
797 if (candidate.alignment == closest.alignment) { 797 if (candidate.distance < closest.distance)
798 if (candidate.distance < closest.distance)
799 closest = candidate;
800 return;
801 }
802
803 if (candidate.alignment > closest.alignment)
804 closest = candidate; 798 closest = candidate;
805 } 799 }
806 800
807 void FocusController::findFocusCandidateInContainer(Node& container, const Layou tRect& startingRect, WebFocusType type, FocusCandidate& closest) 801 void FocusController::findFocusCandidateInContainer(Node& container, const Layou tRect& startingRect, WebFocusType type, FocusCandidate& closest)
808 { 802 {
809 Element* focusedElement = (focusedFrame() && toLocalFrame(focusedFrame())->d ocument()) ? toLocalFrame(focusedFrame())->document()->focusedElement() : nullpt r; 803 Element* focusedElement = (focusedFrame() && toLocalFrame(focusedFrame())->d ocument()) ? toLocalFrame(focusedFrame())->document()->focusedElement() : nullpt r;
810 804
811 Element* element = ElementTraversal::firstWithin(container); 805 Element* element = ElementTraversal::firstWithin(container);
812 FocusCandidate current; 806 FocusCandidate current;
813 current.rect = startingRect; 807 current.rect = startingRect;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 return consumed; 939 return consumed;
946 } 940 }
947 941
948 void FocusController::trace(Visitor* visitor) 942 void FocusController::trace(Visitor* visitor)
949 { 943 {
950 visitor->trace(m_page); 944 visitor->trace(m_page);
951 visitor->trace(m_focusedFrame); 945 visitor->trace(m_focusedFrame);
952 } 946 }
953 947
954 } // namespace blink 948 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/spatial-navigation/snav-symmetrically-positioned-expected.txt ('k') | Source/core/page/SpatialNavigation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698