OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 m_scrollableArea->mouseEnteredScrollbar(*this); | 455 m_scrollableArea->mouseEnteredScrollbar(*this); |
456 } | 456 } |
457 | 457 |
458 void Scrollbar::mouseExited() { | 458 void Scrollbar::mouseExited() { |
459 if (m_scrollableArea) | 459 if (m_scrollableArea) |
460 m_scrollableArea->mouseExitedScrollbar(*this); | 460 m_scrollableArea->mouseExitedScrollbar(*this); |
461 setHoveredPart(NoPart); | 461 setHoveredPart(NoPart); |
462 } | 462 } |
463 | 463 |
464 void Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) { | 464 void Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) { |
| 465 bool isCaptured = m_pressedPart == ThumbPart; |
465 setPressedPart(NoPart); | 466 setPressedPart(NoPart); |
466 m_pressedPos = 0; | 467 m_pressedPos = 0; |
467 m_draggingDocument = false; | 468 m_draggingDocument = false; |
468 stopTimerIfNeeded(); | 469 stopTimerIfNeeded(); |
469 | 470 |
470 if (m_scrollableArea) { | 471 if (m_scrollableArea) { |
| 472 if (isCaptured) |
| 473 m_scrollableArea->mouseReleasedScrollbar(); |
| 474 |
471 // m_hoveredPart won't be updated until the next mouseMoved or mouseDown, so | 475 // m_hoveredPart won't be updated until the next mouseMoved or mouseDown, so |
472 // we have to hit test to really know if the mouse has exited the scrollbar | 476 // we have to hit test to really know if the mouse has exited the scrollbar |
473 // on a mouseUp. | 477 // on a mouseUp. |
474 ScrollbarPart part = theme().hitTest(*this, mouseEvent.position()); | 478 ScrollbarPart part = theme().hitTest(*this, mouseEvent.position()); |
475 if (part == NoPart) | 479 if (part == NoPart) |
476 m_scrollableArea->mouseExitedScrollbar(*this); | 480 m_scrollableArea->mouseExitedScrollbar(*this); |
477 } | 481 } |
478 } | 482 } |
479 | 483 |
480 void Scrollbar::mouseDown(const PlatformMouseEvent& evt) { | 484 void Scrollbar::mouseDown(const PlatformMouseEvent& evt) { |
(...skipping 14 matching lines...) Expand all Loading... |
495 int thumbLen = theme().thumbLength(*this); | 499 int thumbLen = theme().thumbLength(*this); |
496 int desiredPos = pressedPos; | 500 int desiredPos = pressedPos; |
497 // Set the pressed position to the middle of the thumb so that when we do | 501 // Set the pressed position to the middle of the thumb so that when we do |
498 // the move, the delta will be from the current pixel position of the thumb | 502 // the move, the delta will be from the current pixel position of the thumb |
499 // to the new desired position for the thumb. | 503 // to the new desired position for the thumb. |
500 m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + | 504 m_pressedPos = theme().trackPosition(*this) + theme().thumbPosition(*this) + |
501 thumbLen / 2; | 505 thumbLen / 2; |
502 moveThumb(desiredPos); | 506 moveThumb(desiredPos); |
503 return; | 507 return; |
504 } | 508 } |
505 if (m_pressedPart == ThumbPart) | 509 if (m_pressedPart == ThumbPart) { |
506 m_dragOrigin = m_currentPos; | 510 m_dragOrigin = m_currentPos; |
| 511 if (m_scrollableArea) |
| 512 m_scrollableArea->mouseCapturedScrollbar(); |
| 513 } |
507 | 514 |
508 m_pressedPos = pressedPos; | 515 m_pressedPos = pressedPos; |
509 | 516 |
510 autoscrollPressedPart(theme().initialAutoscrollTimerDelay()); | 517 autoscrollPressedPart(theme().initialAutoscrollTimerDelay()); |
511 } | 518 } |
512 | 519 |
513 void Scrollbar::visibilityChanged() { | 520 void Scrollbar::setScrollbarsHidden(bool hidden) { |
514 if (m_scrollableArea) | 521 if (m_scrollableArea) |
515 m_scrollableArea->scrollbarVisibilityChanged(); | 522 m_scrollableArea->setScrollbarsHidden(hidden); |
516 } | 523 } |
517 | 524 |
518 void Scrollbar::setEnabled(bool e) { | 525 void Scrollbar::setEnabled(bool e) { |
519 if (m_enabled == e) | 526 if (m_enabled == e) |
520 return; | 527 return; |
521 m_enabled = e; | 528 m_enabled = e; |
522 theme().updateEnabledState(*this); | 529 theme().updateEnabledState(*this); |
523 setNeedsPaintInvalidation(AllParts); | 530 setNeedsPaintInvalidation(AllParts); |
524 } | 531 } |
525 | 532 |
526 int Scrollbar::scrollbarThickness() const { | 533 int Scrollbar::scrollbarThickness() const { |
527 int thickness = orientation() == HorizontalScrollbar ? height() : width(); | 534 int thickness = orientation() == HorizontalScrollbar ? height() : width(); |
528 if (!thickness || !m_hostWindow) | 535 if (!thickness || !m_hostWindow) |
529 return thickness; | 536 return thickness; |
530 return m_hostWindow->windowToViewportScalar(m_themeScrollbarThickness); | 537 return m_hostWindow->windowToViewportScalar(m_themeScrollbarThickness); |
531 } | 538 } |
532 | 539 |
533 bool Scrollbar::isOverlayScrollbar() const { | 540 bool Scrollbar::isOverlayScrollbar() const { |
534 return m_theme.usesOverlayScrollbars(); | 541 return m_theme.usesOverlayScrollbars(); |
535 } | 542 } |
536 | 543 |
537 bool Scrollbar::shouldParticipateInHitTesting() { | 544 bool Scrollbar::shouldParticipateInHitTesting() { |
538 // Non-overlay scrollbars should always participate in hit testing. | 545 // Non-overlay scrollbars should always participate in hit testing. |
539 if (!isOverlayScrollbar()) | 546 if (!isOverlayScrollbar()) |
540 return true; | 547 return true; |
541 return m_scrollableArea->scrollAnimator() | 548 return !m_scrollableArea->scrollbarsHidden(); |
542 .shouldScrollbarParticipateInHitTesting(*this); | |
543 } | 549 } |
544 | 550 |
545 bool Scrollbar::isWindowActive() const { | 551 bool Scrollbar::isWindowActive() const { |
546 return m_scrollableArea && m_scrollableArea->isActive(); | 552 return m_scrollableArea && m_scrollableArea->isActive(); |
547 } | 553 } |
548 | 554 |
549 IntRect Scrollbar::convertToContainingWidget(const IntRect& localRect) const { | 555 IntRect Scrollbar::convertToContainingWidget(const IntRect& localRect) const { |
550 if (m_scrollableArea) | 556 if (m_scrollableArea) |
551 return m_scrollableArea->convertFromScrollbarToContainingWidget(*this, | 557 return m_scrollableArea->convertFromScrollbarToContainingWidget(*this, |
552 localRect); | 558 localRect); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 invalidParts = AllParts; | 623 invalidParts = AllParts; |
618 if (invalidParts & ~ThumbPart) | 624 if (invalidParts & ~ThumbPart) |
619 m_trackNeedsRepaint = true; | 625 m_trackNeedsRepaint = true; |
620 if (invalidParts & ThumbPart) | 626 if (invalidParts & ThumbPart) |
621 m_thumbNeedsRepaint = true; | 627 m_thumbNeedsRepaint = true; |
622 if (m_scrollableArea) | 628 if (m_scrollableArea) |
623 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 629 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
624 } | 630 } |
625 | 631 |
626 } // namespace blink | 632 } // namespace blink |
OLD | NEW |