Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: Source/core/rendering/RenderListBox.cpp

Issue 138543008: Vertical scrollbar width becomes zero in case of overlay scrollbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added NeedsRebaseline for Mac Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/platform/linux/fast/forms/select-multiple-rtl-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 int firstIndex = select->activeSelectionStartListIndex(); 205 int firstIndex = select->activeSelectionStartListIndex();
206 if (firstIndex >= 0 && !listIndexIsVisible(select->activeSelectionEndListInd ex())) 206 if (firstIndex >= 0 && !listIndexIsVisible(select->activeSelectionEndListInd ex()))
207 scrollToRevealElementAtListIndex(firstIndex); 207 scrollToRevealElementAtListIndex(firstIndex);
208 } 208 }
209 209
210 void RenderListBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, L ayoutUnit& maxLogicalWidth) const 210 void RenderListBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, L ayoutUnit& maxLogicalWidth) const
211 { 211 {
212 maxLogicalWidth = m_optionsWidth + 2 * optionsSpacingHorizontal; 212 maxLogicalWidth = m_optionsWidth + 2 * optionsSpacingHorizontal;
213 if (m_vBar) 213 if (m_vBar)
214 maxLogicalWidth += m_vBar->width(); 214 maxLogicalWidth += verticalScrollbarWidth();
215 if (!style()->width().isPercent()) 215 if (!style()->width().isPercent())
216 minLogicalWidth = maxLogicalWidth; 216 minLogicalWidth = maxLogicalWidth;
217 } 217 }
218 218
219 void RenderListBox::computePreferredLogicalWidths() 219 void RenderListBox::computePreferredLogicalWidths()
220 { 220 {
221 ASSERT(!m_optionsChanged); 221 ASSERT(!m_optionsChanged);
222 222
223 m_minPreferredLogicalWidth = 0; 223 m_minPreferredLogicalWidth = 0;
224 m_maxPreferredLogicalWidth = 0; 224 m_maxPreferredLogicalWidth = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 277 }
278 278
279 int RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, L ineDirectionMode lineDirection, LinePositionMode linePositionMode) const 279 int RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, L ineDirectionMode lineDirection, LinePositionMode linePositionMode) const
280 { 280 {
281 return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, l inePositionMode) - baselineAdjustment; 281 return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, l inePositionMode) - baselineAdjustment;
282 } 282 }
283 283
284 LayoutRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffse t, int index) 284 LayoutRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffse t, int index)
285 { 285 {
286 // For RTL, items start after the left-side vertical scrollbar. 286 // For RTL, items start after the left-side vertical scrollbar.
287 int scrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogicalLe ft() ? m_vBar->width() : 0; 287 int scrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogicalLe ft() ? verticalScrollbarWidth() : 0;
288 return LayoutRect(additionalOffset.x() + borderLeft() + paddingLeft() + scro llbarOffset, 288 return LayoutRect(additionalOffset.x() + borderLeft() + paddingLeft() + scro llbarOffset,
289 additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (inde x - m_indexOffset), 289 additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (inde x - m_indexOffset),
290 contentWidth(), itemHeight()); 290 contentWidth(), itemHeight());
291 } 291 }
292 292
293 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 293 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
294 { 294 {
295 if (style()->visibility() != VISIBLE) 295 if (style()->visibility() != VISIBLE)
296 return; 296 return;
297 297
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 358 }
359 } 359 }
360 } 360 }
361 361
362 int RenderListBox::scrollbarLeft() const 362 int RenderListBox::scrollbarLeft() const
363 { 363 {
364 int scrollbarLeft = 0; 364 int scrollbarLeft = 0;
365 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 365 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
366 scrollbarLeft = borderLeft(); 366 scrollbarLeft = borderLeft();
367 else 367 else
368 scrollbarLeft = width() - borderRight() - m_vBar->width(); 368 scrollbarLeft = width() - borderRight() - verticalScrollbarWidth();
369 return scrollbarLeft; 369 return scrollbarLeft;
370 } 370 }
371 371
372 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain tOffset) 372 void RenderListBox::paintScrollbar(PaintInfo& paintInfo, const LayoutPoint& pain tOffset)
373 { 373 {
374 if (m_vBar) { 374 if (m_vBar) {
375 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + scrollbarLeft (), 375 IntRect scrollRect = pixelSnappedIntRect(paintOffset.x() + scrollbarLeft (),
376 paintOffset.y() + borderTop(), 376 paintOffset.y() + borderTop(),
377 m_vBar->width(), 377 verticalScrollbarWidth(),
378 height() - (borderTop() + borderBottom())); 378 height() - (borderTop() + borderBottom()));
379 m_vBar->setFrameRect(scrollRect); 379 m_vBar->setFrameRect(scrollRect);
380 m_vBar->paint(paintInfo.context, paintInfo.rect); 380 m_vBar->paint(paintInfo.context, paintInfo.rect);
381 } 381 }
382 } 382 }
383 383
384 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle , Font itemFont, LayoutRect itemBoudingBox) 384 static LayoutSize itemOffsetForAlignment(TextRun textRun, RenderStyle* itemStyle , Font itemFont, LayoutRect itemBoudingBox)
385 { 385 {
386 ETextAlign actualAlignment = itemStyle->textAlign(); 386 ETextAlign actualAlignment = itemStyle->textAlign();
387 // FIXME: Firefox doesn't respect JUSTIFY. Should we? 387 // FIXME: Firefox doesn't respect JUSTIFY. Should we?
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 477 }
478 } 478 }
479 479
480 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout Point& locationInContainer, const LayoutPoint& accumulatedOffset) 480 bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const Layout Point& locationInContainer, const LayoutPoint& accumulatedOffset)
481 { 481 {
482 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting()) 482 if (!m_vBar || !m_vBar->shouldParticipateInHitTesting())
483 return false; 483 return false;
484 484
485 LayoutRect vertRect(accumulatedOffset.x() + scrollbarLeft(), 485 LayoutRect vertRect(accumulatedOffset.x() + scrollbarLeft(),
486 accumulatedOffset.y() + borderTop(), 486 accumulatedOffset.y() + borderTop(),
487 m_vBar->width(), 487 verticalScrollbarWidth(),
488 height() - borderTop() - borderBottom()); 488 height() - borderTop() - borderBottom());
489 489
490 if (vertRect.contains(locationInContainer)) { 490 if (vertRect.contains(locationInContainer)) {
491 result.setScrollbar(m_vBar.get()); 491 result.setScrollbar(m_vBar.get());
492 return true; 492 return true;
493 } 493 }
494 return false; 494 return false;
495 } 495 }
496 496
497 int RenderListBox::listIndexAtOffset(const LayoutSize& offset) 497 int RenderListBox::listIndexAtOffset(const LayoutSize& offset)
498 { 498 {
499 if (!numItems()) 499 if (!numItems())
500 return -1; 500 return -1;
501 501
502 if (offset.height() < borderTop() + paddingTop() || offset.height() > height () - paddingBottom() - borderBottom()) 502 if (offset.height() < borderTop() + paddingTop() || offset.height() > height () - paddingBottom() - borderBottom())
503 return -1; 503 return -1;
504 504
505 int scrollbarWidth = m_vBar ? m_vBar->width() : 0; 505 int scrollbarWidth = verticalScrollbarWidth();
506 int rightScrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogi calLeft() ? scrollbarWidth : 0; 506 int rightScrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogi calLeft() ? scrollbarWidth : 0;
507 int leftScrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogic alLeft() ? 0 : scrollbarWidth; 507 int leftScrollbarOffset = style()->shouldPlaceBlockDirectionScrollbarOnLogic alLeft() ? 0 : scrollbarWidth;
508 if (offset.width() < borderLeft() + paddingLeft() + rightScrollbarOffset 508 if (offset.width() < borderLeft() + paddingLeft() + rightScrollbarOffset
509 || offset.width() > width() - borderRight() - paddingRight() - leftScrol lbarOffset) 509 || offset.width() > width() - borderRight() - paddingRight() - leftScrol lbarOffset)
510 return -1; 510 return -1;
511 511
512 int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight( ) + m_indexOffset; 512 int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight( ) + m_indexOffset;
513 return newOffset < numItems() ? newOffset : -1; 513 return newOffset < numItems() ? newOffset : -1;
514 } 514 }
515 515
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 731 }
732 } 732 }
733 733
734 return true; 734 return true;
735 } 735 }
736 736
737 LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) c onst 737 LayoutRect RenderListBox::controlClipRect(const LayoutPoint& additionalOffset) c onst
738 { 738 {
739 LayoutRect clipRect = contentBoxRect(); 739 LayoutRect clipRect = contentBoxRect();
740 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 740 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
741 clipRect.moveBy(additionalOffset + LayoutPoint(m_vBar->width(), 0)); 741 clipRect.moveBy(additionalOffset + LayoutPoint(verticalScrollbarWidth(), 0));
742 else 742 else
743 clipRect.moveBy(additionalOffset); 743 clipRect.moveBy(additionalOffset);
744 return clipRect; 744 return clipRect;
745 } 745 }
746 746
747 bool RenderListBox::isActive() const 747 bool RenderListBox::isActive() const
748 { 748 {
749 Page* page = frame()->page(); 749 Page* page = frame()->page();
750 return page && page->focusController().isActive(); 750 return page && page->focusController().isActive();
751 } 751 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 937
938 if (m_vBar) 938 if (m_vBar)
939 m_vBar->styleChanged(); 939 m_vBar->styleChanged();
940 940
941 // Force an update since we know the scrollbars have changed things. 941 // Force an update since we know the scrollbars have changed things.
942 if (document().hasAnnotatedRegions()) 942 if (document().hasAnnotatedRegions())
943 document().setAnnotatedRegionsDirty(true); 943 document().setAnnotatedRegionsDirty(true);
944 } 944 }
945 945
946 } // namespace WebCore 946 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/platform/linux/fast/forms/select-multiple-rtl-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698