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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 default: | 104 default: |
105 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
106 return false; | 106 return false; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 // Return true if rect |a| is below |b|. False otherwise. | 110 // Return true if rect |a| is below |b|. False otherwise. |
111 // For overlapping rects, |a| is considered to be below |b| | 111 // For overlapping rects, |a| is considered to be below |b| |
112 // if both edges of |a| are below the respective ones of |b| | 112 // if both edges of |a| are below the respective ones of |b| |
113 static inline bool below(const LayoutRect& a, const LayoutRect& b) { | 113 static inline bool below(const LayoutRect& a, const LayoutRect& b) { |
114 return a.y() >= b.maxY() || (a.y() >= b.y() && a.maxY() > b.maxY() && | 114 return a.y() >= b.maxY() || |
115 a.x() < b.maxX() && a.maxX() > b.x()); | 115 (a.y() >= b.y() && a.maxY() > b.maxY() && a.x() < b.maxX() && |
| 116 a.maxX() > b.x()); |
116 } | 117 } |
117 | 118 |
118 // Return true if rect |a| is on the right of |b|. False otherwise. | 119 // Return true if rect |a| is on the right of |b|. False otherwise. |
119 // For overlapping rects, |a| is considered to be on the right of |b| | 120 // For overlapping rects, |a| is considered to be on the right of |b| |
120 // if both edges of |a| are on the right of the respective ones of |b| | 121 // if both edges of |a| are on the right of the respective ones of |b| |
121 static inline bool rightOf(const LayoutRect& a, const LayoutRect& b) { | 122 static inline bool rightOf(const LayoutRect& a, const LayoutRect& b) { |
122 return a.x() >= b.maxX() || (a.x() >= b.x() && a.maxX() > b.maxX() && | 123 return a.x() >= b.maxX() || |
123 a.y() < b.maxY() && a.maxY() > b.y()); | 124 (a.x() >= b.x() && a.maxX() > b.maxX() && a.y() < b.maxY() && |
| 125 a.maxY() > b.y()); |
124 } | 126 } |
125 | 127 |
126 static bool isRectInDirection(WebFocusType type, | 128 static bool isRectInDirection(WebFocusType type, |
127 const LayoutRect& curRect, | 129 const LayoutRect& curRect, |
128 const LayoutRect& targetRect) { | 130 const LayoutRect& targetRect) { |
129 switch (type) { | 131 switch (type) { |
130 case WebFocusTypeLeft: | 132 case WebFocusTypeLeft: |
131 return rightOf(curRect, targetRect); | 133 return rightOf(curRect, targetRect); |
132 case WebFocusTypeRight: | 134 case WebFocusTypeRight: |
133 return rightOf(targetRect, curRect); | 135 return rightOf(targetRect, curRect); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 return virtualStartingRect; | 671 return virtualStartingRect; |
670 } | 672 } |
671 | 673 |
672 LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement& area, | 674 LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement& area, |
673 WebFocusType type) { | 675 WebFocusType type) { |
674 ASSERT(area.imageElement()); | 676 ASSERT(area.imageElement()); |
675 // Area elements tend to overlap more than other focusable elements. We | 677 // Area elements tend to overlap more than other focusable elements. We |
676 // flatten the rect of the area elements to minimize the effect of overlapping | 678 // flatten the rect of the area elements to minimize the effect of overlapping |
677 // areas. | 679 // areas. |
678 LayoutRect rect = virtualRectForDirection( | 680 LayoutRect rect = virtualRectForDirection( |
679 type, rectToAbsoluteCoordinates( | 681 type, |
680 area.document().frame(), | 682 rectToAbsoluteCoordinates( |
681 area.computeAbsoluteRect(area.imageElement()->layoutObject())), | 683 area.document().frame(), |
| 684 area.computeAbsoluteRect(area.imageElement()->layoutObject())), |
682 LayoutUnit(1)); | 685 LayoutUnit(1)); |
683 return rect; | 686 return rect; |
684 } | 687 } |
685 | 688 |
686 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) { | 689 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) { |
687 return candidate.isFrameOwnerElement() | 690 return candidate.isFrameOwnerElement() |
688 ? toHTMLFrameOwnerElement(candidate.visibleNode) | 691 ? toHTMLFrameOwnerElement(candidate.visibleNode) |
689 : nullptr; | 692 : nullptr; |
690 }; | 693 }; |
691 | 694 |
692 } // namespace blink | 695 } // namespace blink |
OLD | NEW |