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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 ASSERT(!frameView->needsLayout()); | 299 ASSERT(!frameView->needsLayout()); |
300 | 300 |
301 LayoutRect containerViewportRect = frameView->visibleContentRect(); | 301 LayoutRect containerViewportRect = frameView->visibleContentRect(); |
302 // We want to select a node if it is currently off screen, but will be | 302 // We want to select a node if it is currently off screen, but will be |
303 // exposed after we scroll. Adjust the viewport to post-scrolling position. | 303 // exposed after we scroll. Adjust the viewport to post-scrolling position. |
304 // If the container has overflow:hidden, we cannot scroll, so we do not pass
direction | 304 // If the container has overflow:hidden, we cannot scroll, so we do not pass
direction |
305 // and we do not adjust for scrolling. | 305 // and we do not adjust for scrolling. |
306 switch (direction) { | 306 switch (direction) { |
307 case FocusDirectionLeft: | 307 case FocusDirectionLeft: |
308 containerViewportRect.setX(containerViewportRect.x() - Scrollbar::pixels
PerLineStep()); | 308 containerViewportRect.setX(containerViewportRect.x() - ScrollableArea::p
ixelsPerLineStep()); |
309 containerViewportRect.setWidth(containerViewportRect.width() + Scrollbar
::pixelsPerLineStep()); | 309 containerViewportRect.setWidth(containerViewportRect.width() + Scrollabl
eArea::pixelsPerLineStep()); |
310 break; | 310 break; |
311 case FocusDirectionRight: | 311 case FocusDirectionRight: |
312 containerViewportRect.setWidth(containerViewportRect.width() + Scrollbar
::pixelsPerLineStep()); | 312 containerViewportRect.setWidth(containerViewportRect.width() + Scrollabl
eArea::pixelsPerLineStep()); |
313 break; | 313 break; |
314 case FocusDirectionUp: | 314 case FocusDirectionUp: |
315 containerViewportRect.setY(containerViewportRect.y() - Scrollbar::pixels
PerLineStep()); | 315 containerViewportRect.setY(containerViewportRect.y() - ScrollableArea::p
ixelsPerLineStep()); |
316 containerViewportRect.setHeight(containerViewportRect.height() + Scrollb
ar::pixelsPerLineStep()); | 316 containerViewportRect.setHeight(containerViewportRect.height() + Scrolla
bleArea::pixelsPerLineStep()); |
317 break; | 317 break; |
318 case FocusDirectionDown: | 318 case FocusDirectionDown: |
319 containerViewportRect.setHeight(containerViewportRect.height() + Scrollb
ar::pixelsPerLineStep()); | 319 containerViewportRect.setHeight(containerViewportRect.height() + Scrolla
bleArea::pixelsPerLineStep()); |
320 break; | 320 break; |
321 default: | 321 default: |
322 break; | 322 break; |
323 } | 323 } |
324 | 324 |
325 RenderObject* render = node->renderer(); | 325 RenderObject* render = node->renderer(); |
326 if (!render) | 326 if (!render) |
327 return true; | 327 return true; |
328 | 328 |
329 LayoutRect rect(render->absoluteClippedOverflowRect()); | 329 LayoutRect rect(render->absoluteClippedOverflowRect()); |
330 if (rect.isEmpty()) | 330 if (rect.isEmpty()) |
331 return true; | 331 return true; |
332 | 332 |
333 return !containerViewportRect.intersects(rect); | 333 return !containerViewportRect.intersects(rect); |
334 } | 334 } |
335 | 335 |
336 bool scrollInDirection(Frame* frame, FocusDirection direction) | 336 bool scrollInDirection(Frame* frame, FocusDirection direction) |
337 { | 337 { |
338 ASSERT(frame); | 338 ASSERT(frame); |
339 | 339 |
340 if (frame && canScrollInDirection(frame->document(), direction)) { | 340 if (frame && canScrollInDirection(frame->document(), direction)) { |
341 LayoutUnit dx = 0; | 341 LayoutUnit dx = 0; |
342 LayoutUnit dy = 0; | 342 LayoutUnit dy = 0; |
343 switch (direction) { | 343 switch (direction) { |
344 case FocusDirectionLeft: | 344 case FocusDirectionLeft: |
345 dx = - Scrollbar::pixelsPerLineStep(); | 345 dx = - ScrollableArea::pixelsPerLineStep(); |
346 break; | 346 break; |
347 case FocusDirectionRight: | 347 case FocusDirectionRight: |
348 dx = Scrollbar::pixelsPerLineStep(); | 348 dx = ScrollableArea::pixelsPerLineStep(); |
349 break; | 349 break; |
350 case FocusDirectionUp: | 350 case FocusDirectionUp: |
351 dy = - Scrollbar::pixelsPerLineStep(); | 351 dy = - ScrollableArea::pixelsPerLineStep(); |
352 break; | 352 break; |
353 case FocusDirectionDown: | 353 case FocusDirectionDown: |
354 dy = Scrollbar::pixelsPerLineStep(); | 354 dy = ScrollableArea::pixelsPerLineStep(); |
355 break; | 355 break; |
356 default: | 356 default: |
357 ASSERT_NOT_REACHED(); | 357 ASSERT_NOT_REACHED(); |
358 return false; | 358 return false; |
359 } | 359 } |
360 | 360 |
361 frame->view()->scrollBy(IntSize(dx, dy)); | 361 frame->view()->scrollBy(IntSize(dx, dy)); |
362 return true; | 362 return true; |
363 } | 363 } |
364 return false; | 364 return false; |
365 } | 365 } |
366 | 366 |
367 bool scrollInDirection(Node* container, FocusDirection direction) | 367 bool scrollInDirection(Node* container, FocusDirection direction) |
368 { | 368 { |
369 ASSERT(container); | 369 ASSERT(container); |
370 if (container->isDocumentNode()) | 370 if (container->isDocumentNode()) |
371 return scrollInDirection(toDocument(container)->frame(), direction); | 371 return scrollInDirection(toDocument(container)->frame(), direction); |
372 | 372 |
373 if (!container->renderBox()) | 373 if (!container->renderBox()) |
374 return false; | 374 return false; |
375 | 375 |
376 if (canScrollInDirection(container, direction)) { | 376 if (canScrollInDirection(container, direction)) { |
377 LayoutUnit dx = 0; | 377 LayoutUnit dx = 0; |
378 LayoutUnit dy = 0; | 378 LayoutUnit dy = 0; |
379 switch (direction) { | 379 switch (direction) { |
380 case FocusDirectionLeft: | 380 case FocusDirectionLeft: |
381 dx = - min<LayoutUnit>(Scrollbar::pixelsPerLineStep(), container->re
nderBox()->scrollLeft()); | 381 dx = - min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), containe
r->renderBox()->scrollLeft()); |
382 break; | 382 break; |
383 case FocusDirectionRight: | 383 case FocusDirectionRight: |
384 ASSERT(container->renderBox()->scrollWidth() > (container->renderBox
()->scrollLeft() + container->renderBox()->clientWidth())); | 384 ASSERT(container->renderBox()->scrollWidth() > (container->renderBox
()->scrollLeft() + container->renderBox()->clientWidth())); |
385 dx = min<LayoutUnit>(Scrollbar::pixelsPerLineStep(), container->rend
erBox()->scrollWidth() - (container->renderBox()->scrollLeft() + container->rend
erBox()->clientWidth())); | 385 dx = min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), container-
>renderBox()->scrollWidth() - (container->renderBox()->scrollLeft() + container-
>renderBox()->clientWidth())); |
386 break; | 386 break; |
387 case FocusDirectionUp: | 387 case FocusDirectionUp: |
388 dy = - min<LayoutUnit>(Scrollbar::pixelsPerLineStep(), container->re
nderBox()->scrollTop()); | 388 dy = - min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), containe
r->renderBox()->scrollTop()); |
389 break; | 389 break; |
390 case FocusDirectionDown: | 390 case FocusDirectionDown: |
391 ASSERT(container->renderBox()->scrollHeight() - (container->renderBo
x()->scrollTop() + container->renderBox()->clientHeight())); | 391 ASSERT(container->renderBox()->scrollHeight() - (container->renderBo
x()->scrollTop() + container->renderBox()->clientHeight())); |
392 dy = min<LayoutUnit>(Scrollbar::pixelsPerLineStep(), container->rend
erBox()->scrollHeight() - (container->renderBox()->scrollTop() + container->rend
erBox()->clientHeight())); | 392 dy = min<LayoutUnit>(ScrollableArea::pixelsPerLineStep(), container-
>renderBox()->scrollHeight() - (container->renderBox()->scrollTop() + container-
>renderBox()->clientHeight())); |
393 break; | 393 break; |
394 default: | 394 default: |
395 ASSERT_NOT_REACHED(); | 395 ASSERT_NOT_REACHED(); |
396 return false; | 396 return false; |
397 } | 397 } |
398 | 398 |
399 container->renderBox()->enclosingLayer()->scrollByRecursively(IntSize(dx
, dy)); | 399 container->renderBox()->enclosingLayer()->scrollByRecursively(IntSize(dx
, dy)); |
400 return true; | 400 return true; |
401 } | 401 } |
402 | 402 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 LayoutRect rect = virtualRectForDirection(direction, rectToAbsoluteCoordinat
es(area->document()->frame(), area->computeRect(area->imageElement()->renderer()
)), 1); | 730 LayoutRect rect = virtualRectForDirection(direction, rectToAbsoluteCoordinat
es(area->document()->frame(), area->computeRect(area->imageElement()->renderer()
)), 1); |
731 return rect; | 731 return rect; |
732 } | 732 } |
733 | 733 |
734 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) | 734 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate) |
735 { | 735 { |
736 return candidate.isFrameOwnerElement() ? static_cast<HTMLFrameOwnerElement*>
(candidate.visibleNode) : 0; | 736 return candidate.isFrameOwnerElement() ? static_cast<HTMLFrameOwnerElement*>
(candidate.visibleNode) : 0; |
737 }; | 737 }; |
738 | 738 |
739 } // namespace WebCore | 739 } // namespace WebCore |
OLD | NEW |