Chromium Code Reviews| 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 return LayoutRect(additionalOffset.x() + borderLeft() + paddingLeft() + (sty le()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? m_vBar->width() : 0), |
|
eseidel
2013/10/22 05:59:21
Same here. Can we help explain to the reader what
pals
2013/10/22 08:45:19
Done.
| |
| 278 additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (inde x - m_indexOffset), | 278 additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (inde x - m_indexOffset), |
| 279 contentWidth(), itemHeight()); | 279 contentWidth(), itemHeight()); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) | 282 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) |
| 283 { | 283 { |
| 284 if (style()->visibility() != VISIBLE) | 284 if (style()->visibility() != VISIBLE) |
| 285 return; | 285 return; |
| 286 | 286 |
| 287 int listItemsSize = numItems(); | 287 int listItemsSize = numItems(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 const Vector<HTMLElement*>& listItems = select->listItems(); | 341 const Vector<HTMLElement*>& listItems = select->listItems(); |
| 342 for (int i = 0; i < size; ++i) { | 342 for (int i = 0; i < size; ++i) { |
| 343 HTMLElement* element = listItems[i]; | 343 HTMLElement* element = listItems[i]; |
| 344 if (element->hasTagName(optionTag) && !element->isDisabledFormControl()) { | 344 if (element->hasTagName(optionTag) && !element->isDisabledFormControl()) { |
| 345 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffse t, i))); | 345 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffse t, i))); |
| 346 return; | 346 return; |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 int RenderListBox::scrollbarLeft() const | |
| 352 { | |
| 353 int scrollbarLeft = 0; | |
| 354 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | |
| 355 scrollbarLeft = borderLeft(); | |
| 356 else | |
| 357 scrollbarLeft = width() - borderRight() - m_vBar->width(); | |
| 358 return scrollbarLeft; | |
| 359 } | |
| 360 | |
| 351 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain tOffset) | 361 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain tOffset) |
| 352 { | 362 { |
| 353 if (m_vBar) { | 363 if (m_vBar) { |
| 354 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + width() - bor derRight() - m_vBar->width(), | 364 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + scrollbarLeft (), |
| 355 paintOffset.y() + borderTop(), | 365 paintOffset.y() + borderTop(), |
| 356 m_vBar->width(), | 366 m_vBar->width(), |
| 357 height() - (borderTop() + borderBottom())); | 367 height() - (borderTop() + borderBottom())); |
| 358 m_vBar->setFrameRect(scrollRect); | 368 m_vBar->setFrameRect(scrollRect); |
| 359 m_vBar->paint(paintInfo.context, paintInfo.rect); | 369 m_vBar->paint(paintInfo.context, paintInfo.rect); |
| 360 } | 370 } |
| 361 } | 371 } |
| 362 | 372 |
| 363 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle , Font itemFont, LayoutRect itemBoudingBox) | 373 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle , Font itemFont, LayoutRect itemBoudingBox) |
| 364 { | 374 { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 itemRect.intersect(controlClipRect(paintOffset)); | 464 itemRect.intersect(controlClipRect(paintOffset)); |
| 455 paintInfo.context->fillRect(pixelSnappedIntRect(itemRect), backColor); | 465 paintInfo.context->fillRect(pixelSnappedIntRect(itemRect), backColor); |
| 456 } | 466 } |
| 457 } | 467 } |
| 458 | 468 |
| 459 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout Point& locationInContainer, const LayoutPoint& accumulatedOffset) | 469 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout Point& locationInContainer, const LayoutPoint& accumulatedOffset) |
| 460 { | 470 { |
| 461 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) | 471 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) |
| 462 return false; | 472 return false; |
| 463 | 473 |
| 464 LayoutRect vertRect(accumulatedOffset.x() + width() - borderRight() - m_vBar ->width(), | 474 LayoutRect vertRect(accumulatedOffset.x() + scrollbarLeft(), |
| 465 accumulatedOffset.y() + borderTop(), | 475 accumulatedOffset.y() + borderTop(), |
| 466 m_vBar->width(), | 476 m_vBar->width(), |
| 467 height() - borderTop() - borderBottom()); | 477 height() - borderTop() - borderBottom()); |
| 468 | 478 |
| 469 if (vertRect.contains(locationInContainer)) { | 479 if (vertRect.contains(locationInContainer)) { |
| 470 result.setScrollbar(m_vBar.get()); | 480 result.setScrollbar(m_vBar.get()); |
| 471 return true; | 481 return true; |
| 472 } | 482 } |
| 473 return false; | 483 return false; |
| 474 } | 484 } |
| 475 | 485 |
| 476 int RenderListBox::listIndexAtOffset(const LayoutSize& offset) | 486 int RenderListBox::listIndexAtOffset(const LayoutSize& offset) |
| 477 { | 487 { |
| 478 if (!numItems()) | 488 if (!numItems()) |
| 479 return -1; | 489 return -1; |
| 480 | 490 |
| 481 if (offset.height() < borderTop() + paddingTop() || offset.height() > height () - paddingBottom() - borderBottom()) | 491 if (offset.height() < borderTop() + paddingTop() || offset.height() > height () - paddingBottom() - borderBottom()) |
| 482 return -1; | 492 return -1; |
| 483 | 493 |
| 484 int scrollbarWidth = m_vBar ? m_vBar->width() : 0; | 494 int scrollbarWidth = m_vBar ? m_vBar->width() : 0; |
| 485 if (offset.width() < borderLeft() + paddingLeft() || offset.width() > width( ) - borderRight() - paddingRight() - scrollbarWidth) | 495 if (offset.width() < borderLeft() + paddingLeft() + (style()->shouldPlaceBlo ckDirectionScrollbarOnLogicalLeft() ? scrollbarWidth : 0) || offset.width() > wi dth() - borderRight() - paddingRight() - (style()->shouldPlaceBlockDirectionScro llbarOnLogicalLeft() ? 0 : scrollbarWidth)) |
|
eseidel
2013/10/22 05:59:21
This is pretty ugly. Can we use local variables t
pals
2013/10/22 08:45:19
Done.
| |
| 486 return -1; | 496 return -1; |
| 487 | 497 |
| 488 int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight( ) + m_indexOffset; | 498 int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight( ) + m_indexOffset; |
| 489 return newOffset < numItems() ? newOffset : -1; | 499 return newOffset < numItems() ? newOffset : -1; |
| 490 } | 500 } |
| 491 | 501 |
| 492 void RenderListBox::panScroll(const IntPoint& panStartMousePosition) | 502 void RenderListBox::panScroll(const IntPoint& panStartMousePosition) |
| 493 { | 503 { |
| 494 const int maxSpeed = 20; | 504 const int maxSpeed = 20; |
| 495 const int iconRadius = 7; | 505 const int iconRadius = 7; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 } | 716 } |
| 707 } | 717 } |
| 708 } | 718 } |
| 709 | 719 |
| 710 return true; | 720 return true; |
| 711 } | 721 } |
| 712 | 722 |
| 713 LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) c onst | 723 LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) c onst |
| 714 { | 724 { |
| 715 LayoutRect clipRect = contentBoxRect(); | 725 LayoutRect clipRect = contentBoxRect(); |
| 716 clipRect.moveBy(additionalOffset); | 726 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 727 clipRect.moveBy(additionalOffset + LayoutPoint(m_vBar->width(), 0)); | |
| 728 else | |
| 729 clipRect.moveBy(additionalOffset); | |
| 717 return clipRect; | 730 return clipRect; |
| 718 } | 731 } |
| 719 | 732 |
| 720 bool RenderListBox::isActive() const | 733 bool RenderListBox::isActive() const |
| 721 { | 734 { |
| 722 Page* page = frame()->page(); | 735 Page* page = frame()->page(); |
| 723 return page && page->focusController().isActive(); | 736 return page && page->focusController().isActive(); |
| 724 } | 737 } |
| 725 | 738 |
| 726 void RenderListBox::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) | 739 void RenderListBox::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) |
| 727 { | 740 { |
| 728 IntRect scrollRect = rect; | 741 IntRect scrollRect = rect; |
| 729 scrollRect.move(width() - borderRight() - scrollbar->width(), borderTop()); | 742 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 743 scrollRect.move(borderLeft(), borderTop()); | |
| 744 else | |
| 745 scrollRect.move(width() - borderRight() - scrollbar->width(), borderTop( )); | |
| 730 repaintRectangle(scrollRect); | 746 repaintRectangle(scrollRect); |
| 731 } | 747 } |
| 732 | 748 |
| 733 IntRect RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* scr ollbar, const IntRect& scrollbarRect) const | 749 IntRect RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* scr ollbar, const IntRect& scrollbarRect) const |
| 734 { | 750 { |
| 735 RenderView* view = this->view(); | 751 RenderView* view = this->view(); |
| 736 if (!view) | 752 if (!view) |
| 737 return scrollbarRect; | 753 return scrollbarRect; |
| 738 | 754 |
| 739 IntRect rect = scrollbarRect; | 755 IntRect rect = scrollbarRect; |
| 740 | 756 |
| 741 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
| 742 int scrollbarTop = borderTop(); | 757 int scrollbarTop = borderTop(); |
| 743 rect.move(scrollbarLeft, scrollbarTop); | 758 rect.move(scrollbarLeft(), scrollbarTop); |
| 744 | 759 |
| 745 return view->frameView()->convertFromRenderer(this, rect); | 760 return view->frameView()->convertFromRenderer(this, rect); |
| 746 } | 761 } |
| 747 | 762 |
| 748 IntRect RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* scr ollbar, const IntRect& parentRect) const | 763 IntRect RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* scr ollbar, const IntRect& parentRect) const |
| 749 { | 764 { |
| 750 RenderView* view = this->view(); | 765 RenderView* view = this->view(); |
| 751 if (!view) | 766 if (!view) |
| 752 return parentRect; | 767 return parentRect; |
| 753 | 768 |
| 754 IntRect rect = view->frameView()->convertToRenderer(this, parentRect); | 769 IntRect rect = view->frameView()->convertToRenderer(this, parentRect); |
| 755 | 770 |
| 756 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
| 757 int scrollbarTop = borderTop(); | 771 int scrollbarTop = borderTop(); |
| 758 rect.move(-scrollbarLeft, -scrollbarTop); | 772 rect.move(-scrollbarLeft(), -scrollbarTop); |
| 759 return rect; | 773 return rect; |
| 760 } | 774 } |
| 761 | 775 |
| 762 IntPoint RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* sc rollbar, const IntPoint& scrollbarPoint) const | 776 IntPoint RenderListBox::convertFromScrollbarToContainingView(const Scrollbar* sc rollbar, const IntPoint& scrollbarPoint) const |
| 763 { | 777 { |
| 764 RenderView* view = this->view(); | 778 RenderView* view = this->view(); |
| 765 if (!view) | 779 if (!view) |
| 766 return scrollbarPoint; | 780 return scrollbarPoint; |
| 767 | 781 |
| 768 IntPoint point = scrollbarPoint; | 782 IntPoint point = scrollbarPoint; |
| 769 | 783 |
| 770 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
| 771 int scrollbarTop = borderTop(); | 784 int scrollbarTop = borderTop(); |
| 772 point.move(scrollbarLeft, scrollbarTop); | 785 point.move(scrollbarLeft(), scrollbarTop); |
| 773 | 786 |
| 774 return view->frameView()->convertFromRenderer(this, point); | 787 return view->frameView()->convertFromRenderer(this, point); |
| 775 } | 788 } |
| 776 | 789 |
| 777 IntPoint RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* sc rollbar, const IntPoint& parentPoint) const | 790 IntPoint RenderListBox::convertFromContainingViewToScrollbar(const Scrollbar* sc rollbar, const IntPoint& parentPoint) const |
| 778 { | 791 { |
| 779 RenderView* view = this->view(); | 792 RenderView* view = this->view(); |
| 780 if (!view) | 793 if (!view) |
| 781 return parentPoint; | 794 return parentPoint; |
| 782 | 795 |
| 783 IntPoint point = view->frameView()->convertToRenderer(this, parentPoint); | 796 IntPoint point = view->frameView()->convertToRenderer(this, parentPoint); |
| 784 | 797 |
| 785 int scrollbarLeft = width() - borderRight() - scrollbar->width(); | |
| 786 int scrollbarTop = borderTop(); | 798 int scrollbarTop = borderTop(); |
| 787 point.move(-scrollbarLeft, -scrollbarTop); | 799 point.move(-scrollbarLeft(), -scrollbarTop); |
| 788 return point; | 800 return point; |
| 789 } | 801 } |
| 790 | 802 |
| 791 IntSize RenderListBox::contentsSize() const | 803 IntSize RenderListBox::contentsSize() const |
| 792 { | 804 { |
| 793 return IntSize(scrollWidth(), scrollHeight()); | 805 return IntSize(scrollWidth(), scrollHeight()); |
| 794 } | 806 } |
| 795 | 807 |
| 796 int RenderListBox::visibleHeight() const | 808 int RenderListBox::visibleHeight() const |
| 797 { | 809 { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 | 923 |
| 912 if (m_vBar) | 924 if (m_vBar) |
| 913 m_vBar->styleChanged(); | 925 m_vBar->styleChanged(); |
| 914 | 926 |
| 915 // Force an update since we know the scrollbars have changed things. | 927 // Force an update since we know the scrollbars have changed things. |
| 916 if (document().hasAnnotatedRegions()) | 928 if (document().hasAnnotatedRegions()) |
| 917 document().setAnnotatedRegionsDirty(true); | 929 document().setAnnotatedRegionsDirty(true); |
| 918 } | 930 } |
| 919 | 931 |
| 920 } // namespace WebCore | 932 } // namespace WebCore |
| OLD | NEW |