| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) |
| 3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org> | 3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org> |
| 4 * | 4 * |
| 5 * All rights reserved. | 5 * All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "core/page/SpatialNavigation.h" | 29 #include "core/page/SpatialNavigation.h" |
| 30 | 30 |
| 31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
| 32 #include "core/dom/NodeTraversal.h" |
| 32 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 33 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 34 #include "core/frame/Settings.h" | 35 #include "core/frame/Settings.h" |
| 35 #include "core/html/HTMLAreaElement.h" | 36 #include "core/html/HTMLAreaElement.h" |
| 36 #include "core/html/HTMLFrameOwnerElement.h" | 37 #include "core/html/HTMLFrameOwnerElement.h" |
| 37 #include "core/html/HTMLImageElement.h" | 38 #include "core/html/HTMLImageElement.h" |
| 38 #include "core/layout/LayoutBox.h" | 39 #include "core/layout/LayoutBox.h" |
| 39 #include "core/page/FrameTree.h" | 40 #include "core/page/FrameTree.h" |
| 40 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
| 41 #include "platform/geometry/IntRect.h" | 42 #include "platform/geometry/IntRect.h" |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 double overlap = (intersectionRect.width() * intersectionRect.height()).toDo
uble(); | 575 double overlap = (intersectionRect.width() * intersectionRect.height()).toDo
uble(); |
| 575 | 576 |
| 576 // Distance calculation is based on http://www.w3.org/TR/WICD/#focus-handlin
g | 577 // Distance calculation is based on http://www.w3.org/TR/WICD/#focus-handlin
g |
| 577 candidate.distance = sqrt(euclidianDistancePow2) + navigationAxisDistance +
weightedOrthogonalAxisDistance - sqrt(overlap); | 578 candidate.distance = sqrt(euclidianDistancePow2) + navigationAxisDistance +
weightedOrthogonalAxisDistance - sqrt(overlap); |
| 578 } | 579 } |
| 579 | 580 |
| 580 bool canBeScrolledIntoView(WebFocusType type, const FocusCandidate& candidate) | 581 bool canBeScrolledIntoView(WebFocusType type, const FocusCandidate& candidate) |
| 581 { | 582 { |
| 582 ASSERT(candidate.visibleNode && candidate.isOffscreen); | 583 ASSERT(candidate.visibleNode && candidate.isOffscreen); |
| 583 LayoutRect candidateRect = candidate.rect; | 584 LayoutRect candidateRect = candidate.rect; |
| 584 for (Node* parentNode = candidate.visibleNode->parentNode(); parentNode; par
entNode = parentNode->parentNode()) { | 585 for (Node& parentNode : NodeTraversal::ancestorsOf(*candidate.visibleNode))
{ |
| 585 LayoutRect parentRect = nodeRectInAbsoluteCoordinates(parentNode); | 586 LayoutRect parentRect = nodeRectInAbsoluteCoordinates(&parentNode); |
| 586 if (!candidateRect.intersects(parentRect)) { | 587 if (!candidateRect.intersects(parentRect)) { |
| 587 if (((type == WebFocusTypeLeft || type == WebFocusTypeRight) && pare
ntNode->layoutObject()->style()->overflowX() == OverflowHidden) | 588 if (((type == WebFocusTypeLeft || type == WebFocusTypeRight) && pare
ntNode.layoutObject()->style()->overflowX() == OverflowHidden) |
| 588 || ((type == WebFocusTypeUp || type == WebFocusTypeDown) && pare
ntNode->layoutObject()->style()->overflowY() == OverflowHidden)) | 589 || ((type == WebFocusTypeUp || type == WebFocusTypeDown) && pare
ntNode.layoutObject()->style()->overflowY() == OverflowHidden)) |
| 589 return false; | 590 return false; |
| 590 } | 591 } |
| 591 if (parentNode == candidate.enclosingScrollableBox) | 592 if (parentNode == candidate.enclosingScrollableBox) |
| 592 return canScrollInDirection(parentNode, type); | 593 return canScrollInDirection(&parentNode, type); |
| 593 } | 594 } |
| 594 return true; | 595 return true; |
| 595 } | 596 } |
| 596 | 597 |
| 597 // The starting rect is the rect of the focused node, in document coordinates. | 598 // The starting rect is the rect of the focused node, in document coordinates. |
| 598 // Compose a virtual starting rect if there is no focused node or if it is off s
creen. | 599 // Compose a virtual starting rect if there is no focused node or if it is off s
creen. |
| 599 // The virtual rect is the edge of the container or frame. We select which | 600 // The virtual rect is the edge of the container or frame. We select which |
| 600 // edge depending on the direction of the navigation. | 601 // edge depending on the direction of the navigation. |
| 601 LayoutRect virtualRectForDirection(WebFocusType type, const LayoutRect& starting
Rect, LayoutUnit width) | 602 LayoutRect virtualRectForDirection(WebFocusType type, const LayoutRect& starting
Rect, LayoutUnit width) |
| 602 { | 603 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 631 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar
ea.document().frame(), area.computeAbsoluteRect(area.imageElement()->layoutObjec
t())), LayoutUnit(1)); | 632 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar
ea.document().frame(), area.computeAbsoluteRect(area.imageElement()->layoutObjec
t())), LayoutUnit(1)); |
| 632 return rect; | 633 return rect; |
| 633 } | 634 } |
| 634 | 635 |
| 635 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) | 636 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) |
| 636 { | 637 { |
| 637 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v
isibleNode) : nullptr; | 638 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v
isibleNode) : nullptr; |
| 638 }; | 639 }; |
| 639 | 640 |
| 640 } // namespace blink | 641 } // namespace blink |
| OLD | NEW |