| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the select element renderer in WebCore. | 2 * This file is part of the select element renderer in WebCore. |
| 3 * | 3 * |
| 4 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 5 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 5 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 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 * | 10 * |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 return false; | 493 return false; |
| 494 | 494 |
| 495 int newOffset; | 495 int newOffset; |
| 496 if (index < m_indexOffset) | 496 if (index < m_indexOffset) |
| 497 newOffset = index; | 497 newOffset = index; |
| 498 else | 498 else |
| 499 newOffset = index - numVisibleItems() + 1; | 499 newOffset = index - numVisibleItems() + 1; |
| 500 | 500 |
| 501 m_indexOffset = newOffset; | 501 m_indexOffset = newOffset; |
| 502 if (m_vBar) | 502 if (m_vBar) |
| 503 m_vBar->setValue(m_indexOffset); | 503 m_vBar->setValue(m_indexOffset, Scrollbar::NotFromScrollAnimator); |
| 504 | 504 |
| 505 return true; | 505 return true; |
| 506 } | 506 } |
| 507 | 507 |
| 508 bool RenderListBox::listIndexIsVisible(int index) | 508 bool RenderListBox::listIndexIsVisible(int index) |
| 509 { | 509 { |
| 510 return index >= m_indexOffset && index < m_indexOffset + numVisibleItems(); | 510 return index >= m_indexOffset && index < m_indexOffset + numVisibleItems(); |
| 511 } | 511 } |
| 512 | 512 |
| 513 bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granular
ity, float multiplier, Node**) | 513 bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granular
ity, float multiplier, Node**) |
| 514 { | 514 { |
| 515 return m_vBar && m_vBar->scroll(direction, granularity, multiplier); | 515 return m_vBar && m_vBar->scroll(direction, granularity, multiplier); |
| 516 } | 516 } |
| 517 | 517 |
| 518 void RenderListBox::valueChanged(unsigned listIndex) | 518 void RenderListBox::valueChanged(unsigned listIndex) |
| 519 { | 519 { |
| 520 Element* element = static_cast<Element*>(node()); | 520 Element* element = static_cast<Element*>(node()); |
| 521 SelectElement* select = toSelectElement(element); | 521 SelectElement* select = toSelectElement(element); |
| 522 select->setSelectedIndex(select->listToOptionIndex(listIndex)); | 522 select->setSelectedIndex(select->listToOptionIndex(listIndex)); |
| 523 element->dispatchFormControlChangeEvent(); | 523 element->dispatchFormControlChangeEvent(); |
| 524 } | 524 } |
| 525 | 525 |
| 526 int RenderListBox::scrollSize(ScrollbarOrientation orientation) const |
| 527 { |
| 528 return ((orientation == VerticalScrollbar) && m_vBar) ? (m_vBar->totalSize()
- m_vBar->visibleSize()) : 0; |
| 529 } |
| 530 |
| 531 void RenderListBox::setScrollOffsetFromAnimation(const IntPoint& offset) |
| 532 { |
| 533 if (m_vBar) |
| 534 m_vBar->setValue(offset.y(), Scrollbar::FromScrollAnimator); |
| 535 } |
| 536 |
| 526 void RenderListBox::valueChanged(Scrollbar*) | 537 void RenderListBox::valueChanged(Scrollbar*) |
| 527 { | 538 { |
| 528 int newOffset = m_vBar->value(); | 539 int newOffset = m_vBar->value(); |
| 529 if (newOffset != m_indexOffset) { | 540 if (newOffset != m_indexOffset) { |
| 530 m_indexOffset = newOffset; | 541 m_indexOffset = newOffset; |
| 531 repaint(); | 542 repaint(); |
| 532 node()->dispatchEvent(Event::create(eventNames().scrollEvent, false, fal
se)); | 543 node()->dispatchEvent(Event::create(eventNames().scrollEvent, false, fal
se)); |
| 533 } | 544 } |
| 534 } | 545 } |
| 535 | 546 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 582 } |
| 572 | 583 |
| 573 void RenderListBox::setScrollTop(int newTop) | 584 void RenderListBox::setScrollTop(int newTop) |
| 574 { | 585 { |
| 575 // Determine an index and scroll to it. | 586 // Determine an index and scroll to it. |
| 576 int index = newTop / itemHeight(); | 587 int index = newTop / itemHeight(); |
| 577 if (index < 0 || index >= numItems() || index == m_indexOffset) | 588 if (index < 0 || index >= numItems() || index == m_indexOffset) |
| 578 return; | 589 return; |
| 579 m_indexOffset = index; | 590 m_indexOffset = index; |
| 580 if (m_vBar) | 591 if (m_vBar) |
| 581 m_vBar->setValue(index); | 592 m_vBar->setValue(index, Scrollbar::NotFromScrollAnimator); |
| 582 } | 593 } |
| 583 | 594 |
| 584 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, int x, int y, int tx, int ty, HitTestAction hitTestAction) | 595 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, int x, int y, int tx, int ty, HitTestAction hitTestAction) |
| 585 { | 596 { |
| 586 if (!RenderBlock::nodeAtPoint(request, result, x, y, tx, ty, hitTestAction)) | 597 if (!RenderBlock::nodeAtPoint(request, result, x, y, tx, ty, hitTestAction)) |
| 587 return false; | 598 return false; |
| 588 const Vector<Element*>& listItems = toSelectElement(static_cast<Element*>(no
de()))->listItems(); | 599 const Vector<Element*>& listItems = toSelectElement(static_cast<Element*>(no
de()))->listItems(); |
| 589 int size = numItems(); | 600 int size = numItems(); |
| 590 tx += this->x(); | 601 tx += this->x(); |
| 591 ty += this->y(); | 602 ty += this->y(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 m_vBar->styleChanged(); | 729 m_vBar->styleChanged(); |
| 719 | 730 |
| 720 #if ENABLE(DASHBOARD_SUPPORT) | 731 #if ENABLE(DASHBOARD_SUPPORT) |
| 721 // Force an update since we know the scrollbars have changed things. | 732 // Force an update since we know the scrollbars have changed things. |
| 722 if (document()->hasDashboardRegions()) | 733 if (document()->hasDashboardRegions()) |
| 723 document()->setDashboardRegionsDirty(true); | 734 document()->setDashboardRegionsDirty(true); |
| 724 #endif | 735 #endif |
| 725 } | 736 } |
| 726 | 737 |
| 727 } // namespace WebCore | 738 } // namespace WebCore |
| OLD | NEW |