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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (!frameView) | 152 if (!frameView) |
153 return true; | 153 return true; |
154 | 154 |
155 ASSERT(!frameView->needsLayout()); | 155 ASSERT(!frameView->needsLayout()); |
156 | 156 |
157 LayoutRect containerViewportRect(frameView->visibleContentRect()); | 157 LayoutRect containerViewportRect(frameView->visibleContentRect()); |
158 // We want to select a node if it is currently off screen, but will be | 158 // We want to select a node if it is currently off screen, but will be |
159 // exposed after we scroll. Adjust the viewport to post-scrolling position. | 159 // exposed after we scroll. Adjust the viewport to post-scrolling position. |
160 // If the container has overflow:hidden, we cannot scroll, so we do not pass
direction | 160 // If the container has overflow:hidden, we cannot scroll, so we do not pass
direction |
161 // and we do not adjust for scrolling. | 161 // and we do not adjust for scrolling. |
162 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frameView->hostWin
dow()); | 162 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frameView->getHost
Window()); |
163 switch (type) { | 163 switch (type) { |
164 case WebFocusTypeLeft: | 164 case WebFocusTypeLeft: |
165 containerViewportRect.setX(containerViewportRect.x() - pixelsPerLineStep
); | 165 containerViewportRect.setX(containerViewportRect.x() - pixelsPerLineStep
); |
166 containerViewportRect.setWidth(containerViewportRect.width() + pixelsPer
LineStep); | 166 containerViewportRect.setWidth(containerViewportRect.width() + pixelsPer
LineStep); |
167 break; | 167 break; |
168 case WebFocusTypeRight: | 168 case WebFocusTypeRight: |
169 containerViewportRect.setWidth(containerViewportRect.width() + pixelsPer
LineStep); | 169 containerViewportRect.setWidth(containerViewportRect.width() + pixelsPer
LineStep); |
170 break; | 170 break; |
171 case WebFocusTypeUp: | 171 case WebFocusTypeUp: |
172 containerViewportRect.setY(containerViewportRect.y() - pixelsPerLineStep
); | 172 containerViewportRect.setY(containerViewportRect.y() - pixelsPerLineStep
); |
(...skipping 17 matching lines...) Expand all Loading... |
190 return !containerViewportRect.intersects(rect); | 190 return !containerViewportRect.intersects(rect); |
191 } | 191 } |
192 | 192 |
193 bool scrollInDirection(LocalFrame* frame, WebFocusType type) | 193 bool scrollInDirection(LocalFrame* frame, WebFocusType type) |
194 { | 194 { |
195 ASSERT(frame); | 195 ASSERT(frame); |
196 | 196 |
197 if (frame && canScrollInDirection(frame->document(), type)) { | 197 if (frame && canScrollInDirection(frame->document(), type)) { |
198 int dx = 0; | 198 int dx = 0; |
199 int dy = 0; | 199 int dy = 0; |
200 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frame->view()-
>hostWindow()); | 200 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frame->view()-
>getHostWindow()); |
201 switch (type) { | 201 switch (type) { |
202 case WebFocusTypeLeft: | 202 case WebFocusTypeLeft: |
203 dx = - pixelsPerLineStep; | 203 dx = - pixelsPerLineStep; |
204 break; | 204 break; |
205 case WebFocusTypeRight: | 205 case WebFocusTypeRight: |
206 dx = pixelsPerLineStep; | 206 dx = pixelsPerLineStep; |
207 break; | 207 break; |
208 case WebFocusTypeUp: | 208 case WebFocusTypeUp: |
209 dy = - pixelsPerLineStep; | 209 dy = - pixelsPerLineStep; |
210 break; | 210 break; |
(...skipping 18 matching lines...) Expand all Loading... |
229 return scrollInDirection(toDocument(container)->frame(), type); | 229 return scrollInDirection(toDocument(container)->frame(), type); |
230 | 230 |
231 if (!container->layoutBox()) | 231 if (!container->layoutBox()) |
232 return false; | 232 return false; |
233 | 233 |
234 if (canScrollInDirection(container, type)) { | 234 if (canScrollInDirection(container, type)) { |
235 int dx = 0; | 235 int dx = 0; |
236 int dy = 0; | 236 int dy = 0; |
237 // TODO(leviw): Why are these values truncated (toInt) instead of roundi
ng? | 237 // TODO(leviw): Why are these values truncated (toInt) instead of roundi
ng? |
238 FrameView* frameView = container->document().view(); | 238 FrameView* frameView = container->document().view(); |
239 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frameView ? fr
ameView->hostWindow() : nullptr); | 239 int pixelsPerLineStep = ScrollableArea::pixelsPerLineStep(frameView ? fr
ameView->getHostWindow() : nullptr); |
240 switch (type) { | 240 switch (type) { |
241 case WebFocusTypeLeft: | 241 case WebFocusTypeLeft: |
242 dx = - std::min(pixelsPerLineStep, container->layoutBox()->scrollLef
t().toInt()); | 242 dx = - std::min(pixelsPerLineStep, container->layoutBox()->scrollLef
t().toInt()); |
243 break; | 243 break; |
244 case WebFocusTypeRight: | 244 case WebFocusTypeRight: |
245 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox
()->scrollLeft() + container->layoutBox()->clientWidth())); | 245 ASSERT(container->layoutBox()->scrollWidth() > (container->layoutBox
()->scrollLeft() + container->layoutBox()->clientWidth())); |
246 dx = std::min(pixelsPerLineStep, | 246 dx = std::min(pixelsPerLineStep, |
247 (container->layoutBox()->scrollWidth() - (container->layoutBox()
->scrollLeft() + container->layoutBox()->clientWidth())).toInt()); | 247 (container->layoutBox()->scrollWidth() - (container->layoutBox()
->scrollLeft() + container->layoutBox()->clientWidth())).toInt()); |
248 break; | 248 break; |
249 case WebFocusTypeUp: | 249 case WebFocusTypeUp: |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar
ea.document().frame(), area.computeRect(area.imageElement()->layoutObject())), L
ayoutUnit(1)); | 631 LayoutRect rect = virtualRectForDirection(type, rectToAbsoluteCoordinates(ar
ea.document().frame(), area.computeRect(area.imageElement()->layoutObject())), L
ayoutUnit(1)); |
632 return rect; | 632 return rect; |
633 } | 633 } |
634 | 634 |
635 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) | 635 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) |
636 { | 636 { |
637 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v
isibleNode) : nullptr; | 637 return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.v
isibleNode) : nullptr; |
638 }; | 638 }; |
639 | 639 |
640 } // namespace blink | 640 } // namespace blink |
OLD | NEW |