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