OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 RenderBox::computeLogicalHeight(height, logicalTop, computedValues); | 267 RenderBox::computeLogicalHeight(height, logicalTop, computedValues); |
268 } | 268 } |
269 | 269 |
270 int RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, L
ineDirectionMode lineDirection, LinePositionMode linePositionMode) const | 270 int RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, L
ineDirectionMode lineDirection, LinePositionMode linePositionMode) const |
271 { | 271 { |
272 return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, l
inePositionMode) - baselineAdjustment; | 272 return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, l
inePositionMode) - baselineAdjustment; |
273 } | 273 } |
274 | 274 |
275 LayoutRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffse
t, int index) | 275 LayoutRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffse
t, int index) |
276 { | 276 { |
277 return LayoutRect(additionalOffset.x() + borderLeft() + paddingLeft(), | 277 // For RTL, items start after the left-side vertical scrollbar. |
| 278 int scrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogicalLe
ft() ? m_vBar->width() : 0; |
| 279 return LayoutRect(additionalOffset.x() + borderLeft() + paddingLeft() + scro
llbarOffset, |
278 additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (inde
x - m_indexOffset), | 280 additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (inde
x - m_indexOffset), |
279 contentWidth(), itemHeight()); | 281 contentWidth(), itemHeight()); |
280 } | 282 } |
281 | 283 |
282 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) | 284 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) |
283 { | 285 { |
284 if (style()->visibility() != VISIBLE) | 286 if (style()->visibility() != VISIBLE) |
285 return; | 287 return; |
286 | 288 |
287 int listItemsSize = numItems(); | 289 int listItemsSize = numItems(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 const Vector<HTMLElement*>& listItems = select->listItems(); | 343 const Vector<HTMLElement*>& listItems = select->listItems(); |
342 for (int i = 0; i < size; ++i) { | 344 for (int i = 0; i < size; ++i) { |
343 HTMLElement* element = listItems[i]; | 345 HTMLElement* element = listItems[i]; |
344 if (element->hasTagName(optionTag) && !element->isDisabledFormControl())
{ | 346 if (element->hasTagName(optionTag) && !element->isDisabledFormControl())
{ |
345 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffse
t, i))); | 347 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffse
t, i))); |
346 return; | 348 return; |
347 } | 349 } |
348 } | 350 } |
349 } | 351 } |
350 | 352 |
| 353 int RenderListBox::scrollbarLeft() const |
| 354 { |
| 355 int scrollbarLeft = 0; |
| 356 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 357 scrollbarLeft = borderLeft(); |
| 358 else |
| 359 scrollbarLeft = width() - borderRight() - m_vBar->width(); |
| 360 return scrollbarLeft; |
| 361 } |
| 362 |
351 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) | 363 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) |
352 { | 364 { |
353 if (m_vBar) { | 365 if (m_vBar) { |
354 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + width() - bor
derRight() - m_vBar->width(), | 366 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + scrollbarLeft
(), |
355 paintOffset.y() + borderTop(), | 367 paintOffset.y() + borderTop(), |
356 m_vBar->width(), | 368 m_vBar->width(), |
357 height() - (borderTop() + borderBottom())); | 369 height() - (borderTop() + borderBottom())); |
358 m_vBar->setFrameRect(scrollRect); | 370 m_vBar->setFrameRect(scrollRect); |
359 m_vBar->paint(paintInfo.context, paintInfo.rect); | 371 m_vBar->paint(paintInfo.context, paintInfo.rect); |
360 } | 372 } |
361 } | 373 } |
362 | 374 |
363 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle
, Font itemFont, LayoutRect itemBoudingBox) | 375 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle
, Font itemFont, LayoutRect itemBoudingBox) |
364 { | 376 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 itemRect.intersect(controlClipRect(paintOffset)); | 466 itemRect.intersect(controlClipRect(paintOffset)); |
455 paintInfo.context->fillRect(pixelSnappedIntRect(itemRect), backColor); | 467 paintInfo.context->fillRect(pixelSnappedIntRect(itemRect), backColor); |
456 } | 468 } |
457 } | 469 } |
458 | 470 |
459 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout
Point& locationInContainer, const LayoutPoint& accumulatedOffset) | 471 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout
Point& locationInContainer, const LayoutPoint& accumulatedOffset) |
460 { | 472 { |
461 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) | 473 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) |
462 return false; | 474 return false; |
463 | 475 |
464 LayoutRect vertRect(accumulatedOffset.x() + width() - borderRight() - m_vBar
->width(), | 476 LayoutRect vertRect(accumulatedOffset.x() + scrollbarLeft(), |
465 accumulatedOffset.y() + borderTop(), | 477 accumulatedOffset.y() + borderTop(), |
466 m_vBar->width(), | 478 m_vBar->width(), |
467 height() - borderTop() - borderBottom()); | 479 height() - borderTop() - borderBottom()); |
468 | 480 |
469 if (vertRect.contains(locationInContainer)) { | 481 if (vertRect.contains(locationInContainer)) { |
470 result.setScrollbar(m_vBar.get()); | 482 result.setScrollbar(m_vBar.get()); |
471 return true; | 483 return true; |
472 } | 484 } |
473 return false; | 485 return false; |
474 } | 486 } |
475 | 487 |
476 int RenderListBox::listIndexAtOffset(const LayoutSize& offset) | 488 int RenderListBox::listIndexAtOffset(const LayoutSize& offset) |
477 { | 489 { |
478 if (!numItems()) | 490 if (!numItems()) |
479 return -1; | 491 return -1; |
480 | 492 |
481 if (offset.height() < borderTop() + paddingTop() || offset.height() > height
() - paddingBottom() - borderBottom()) | 493 if (offset.height() < borderTop() + paddingTop() || offset.height() > height
() - paddingBottom() - borderBottom()) |
482 return -1; | 494 return -1; |
483 | 495 |
484 int scrollbarWidth = m_vBar ? m_vBar->width() : 0; | 496 int scrollbarWidth = m_vBar ? m_vBar->width() : 0; |
485 if (offset.width() < borderLeft() + paddingLeft() || offset.width() > width(
) - borderRight() - paddingRight() - scrollbarWidth) | 497 int rightScrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogi
calLeft() ? scrollbarWidth : 0; |
| 498 int leftScrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogic
alLeft() ? 0 : scrollbarWidth; |
| 499 if (offset.width() < borderLeft() + paddingLeft() + rightScrollbarOffset |
| 500 || offset.width() > width() - borderRight() - paddingRight() - leftScrol
lbarOffset) |
486 return -1; | 501 return -1; |
487 | 502 |
488 int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight(
) + m_indexOffset; | 503 int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight(
) + m_indexOffset; |
489 return newOffset < numItems() ? newOffset : -1; | 504 return newOffset < numItems() ? newOffset : -1; |
490 } | 505 } |
491 | 506 |
492 void RenderListBox::panScroll(const IntPoint& panStartMousePosition) | 507 void RenderListBox::panScroll(const IntPoint& panStartMousePosition) |
493 { | 508 { |
494 const int maxSpeed = 20; | 509 const int maxSpeed = 20; |
495 const int iconRadius = 7; | 510 const int iconRadius = 7; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 } | 721 } |
707 } | 722 } |
708 } | 723 } |
709 | 724 |
710 return true; | 725 return true; |
711 } | 726 } |
712 | 727 |
713 LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) c
onst | 728 LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) c
onst |
714 { | 729 { |
715 LayoutRect clipRect = contentBoxRect(); | 730 LayoutRect clipRect = contentBoxRect(); |
716 clipRect.moveBy(additionalOffset); | 731 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 732 clipRect.moveBy(additionalOffset + LayoutPoint(m_vBar->width(), 0)); |
| 733 else |
| 734 clipRect.moveBy(additionalOffset); |
717 return clipRect; | 735 return clipRect; |
718 } | 736 } |
719 | 737 |
720 bool RenderListBox::isActive() const | 738 bool RenderListBox::isActive() const |
721 { | 739 { |
722 Page* page = frame()->page(); | 740 Page* page = frame()->page(); |
723 return page && page->focusController().isActive(); | 741 return page && page->focusController().isActive(); |
724 } | 742 } |
725 | 743 |
726 void RenderListBox::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect&
rect) | 744 void RenderListBox::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect&
rect) |
727 { | 745 { |
728 IntRect scrollRect = rect; | 746 IntRect scrollRect = rect; |
729 scrollRect.move(width() - borderRight() - scrollbar->width(), borderTop()); | 747 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 748 scrollRect.move(borderLeft(), borderTop()); |
| 749 else |
| 750 scrollRect.move(width() - borderRight() - scrollbar->width(), borderTop(
)); |
730 repaintRectangle(scrollRect); | 751 repaintRectangle(scrollRect); |
731 } | 752 } |
732 | 753 |
733 IntRect RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* scr
ollbar, const IntRect& scrollbarRect) const | 754 IntRect RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* scr
ollbar, const IntRect& scrollbarRect) const |
734 { | 755 { |
735 RenderView* view = this->view(); | 756 RenderView* view = this->view(); |
736 if (!view) | 757 if (!view) |
737 return scrollbarRect; | 758 return scrollbarRect; |
738 | 759 |
739 IntRect rect = scrollbarRect; | 760 IntRect rect = scrollbarRect; |
740 | 761 |
741 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
742 int scrollbarTop = borderTop(); | 762 int scrollbarTop = borderTop(); |
743 rect.move(scrollbarLeft, scrollbarTop); | 763 rect.move(scrollbarLeft(), scrollbarTop); |
744 | 764 |
745 return view->frameView()->convertFromRenderer(this, rect); | 765 return view->frameView()->convertFromRenderer(this, rect); |
746 } | 766 } |
747 | 767 |
748 IntRect RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* scr
ollbar, const IntRect& parentRect) const | 768 IntRect RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* scr
ollbar, const IntRect& parentRect) const |
749 { | 769 { |
750 RenderView* view = this->view(); | 770 RenderView* view = this->view(); |
751 if (!view) | 771 if (!view) |
752 return parentRect; | 772 return parentRect; |
753 | 773 |
754 IntRect rect = view->frameView()->convertToRenderer(this, parentRect); | 774 IntRect rect = view->frameView()->convertToRenderer(this, parentRect); |
755 | 775 |
756 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
757 int scrollbarTop = borderTop(); | 776 int scrollbarTop = borderTop(); |
758 rect.move(-scrollbarLeft, -scrollbarTop); | 777 rect.move(-scrollbarLeft(), -scrollbarTop); |
759 return rect; | 778 return rect; |
760 } | 779 } |
761 | 780 |
762 IntPoint RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* sc
rollbar, const IntPoint& scrollbarPoint) const | 781 IntPoint RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* sc
rollbar, const IntPoint& scrollbarPoint) const |
763 { | 782 { |
764 RenderView* view = this->view(); | 783 RenderView* view = this->view(); |
765 if (!view) | 784 if (!view) |
766 return scrollbarPoint; | 785 return scrollbarPoint; |
767 | 786 |
768 IntPoint point = scrollbarPoint; | 787 IntPoint point = scrollbarPoint; |
769 | 788 |
770 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
771 int scrollbarTop = borderTop(); | 789 int scrollbarTop = borderTop(); |
772 point.move(scrollbarLeft, scrollbarTop); | 790 point.move(scrollbarLeft(), scrollbarTop); |
773 | 791 |
774 return view->frameView()->convertFromRenderer(this, point); | 792 return view->frameView()->convertFromRenderer(this, point); |
775 } | 793 } |
776 | 794 |
777 IntPoint RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* sc
rollbar, const IntPoint& parentPoint) const | 795 IntPoint RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* sc
rollbar, const IntPoint& parentPoint) const |
778 { | 796 { |
779 RenderView* view = this->view(); | 797 RenderView* view = this->view(); |
780 if (!view) | 798 if (!view) |
781 return parentPoint; | 799 return parentPoint; |
782 | 800 |
783 IntPoint point = view->frameView()->convertToRenderer(this, parentPoint); | 801 IntPoint point = view->frameView()->convertToRenderer(this, parentPoint); |
784 | 802 |
785 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
786 int scrollbarTop = borderTop(); | 803 int scrollbarTop = borderTop(); |
787 point.move(-scrollbarLeft, -scrollbarTop); | 804 point.move(-scrollbarLeft(), -scrollbarTop); |
788 return point; | 805 return point; |
789 } | 806 } |
790 | 807 |
791 IntSize RenderListBox::contentsSize() const | 808 IntSize RenderListBox::contentsSize() const |
792 { | 809 { |
793 return IntSize(scrollWidth(), scrollHeight()); | 810 return IntSize(scrollWidth(), scrollHeight()); |
794 } | 811 } |
795 | 812 |
796 int RenderListBox::visibleHeight() const | 813 int RenderListBox::visibleHeight() const |
797 { | 814 { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 | 928 |
912 if (m_vBar) | 929 if (m_vBar) |
913 m_vBar->styleChanged(); | 930 m_vBar->styleChanged(); |
914 | 931 |
915 // Force an update since we know the scrollbars have changed things. | 932 // Force an update since we know the scrollbars have changed things. |
916 if (document().hasAnnotatedRegions()) | 933 if (document().hasAnnotatedRegions()) |
917 document().setAnnotatedRegionsDirty(true); | 934 document().setAnnotatedRegionsDirty(true); |
918 } | 935 } |
919 | 936 |
920 } // namespace WebCore | 937 } // namespace WebCore |
OLD | NEW |