Changeset 205853 in webkit
- Timestamp:
- Sep 12, 2016 11:15:09 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205852 r205853 1 2016-09-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Scrollbar too large 4 https://bugs.webkit.org/show_bug.cgi?id=161735 5 6 Reviewed by Michael Catanzaro. 7 8 We were not calculating the total scrollbar size correctly when the theme defines a minimum width/height. In 9 that case we need to take the extra size into account (border, margin, padding), but not adding the minimum 10 size. We were also adjusting the thumb position when rendering in indicator mode, but we really need to adjust 11 the whole rectangle. This worked in Adwaita because it uses a transparent track when in indicator mode. We are 12 also now taking into account the text direction when doing this adjustment for the indicator mode. 13 14 * platform/gtk/ScrollbarThemeGtk.cpp: 15 (WebCore::ScrollbarThemeGtk::paint): 16 (WebCore::ScrollbarThemeGtk::scrollbarThickness): 17 1 18 2016-09-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 19 -
trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
r204466 r205853 477 477 return true; 478 478 479 bool scrollbarOnLeft = scrollbar.scrollableArea().shouldPlaceBlockDirectionScrollbarOnLeft(); 480 479 481 RenderThemeGadget::Info info = { RenderThemeGadget::Type::Scrollbar, "scrollbar", scrollbarPartStateFlags(scrollbar, AllParts, true), { } }; 480 482 if (scrollbar.orientation() == VerticalScrollbar) { 481 483 info.classList.append("vertical"); 482 info.classList.append( "right");484 info.classList.append(scrollbarOnLeft ? "left" : "right"); 483 485 } else { 484 486 info.classList.append("horizontal"); … … 526 528 RenderThemeGadget* troughGadget = contentsGadget->child(troughPosition); 527 529 530 IntSize preferredSize = contentsGadget->preferredSize(); 531 std::unique_ptr<RenderThemeGadget> sliderGadget; 532 int thumbSize = thumbLength(scrollbar); 533 if (thumbSize) { 534 info.name = "slider"; 535 info.state = scrollbarPartStateFlags(scrollbar, ThumbPart); 536 sliderGadget = RenderThemeGadget::create(info, troughGadget); 537 preferredSize = preferredSize.expandedTo(sliderGadget->preferredSize()); 538 } 539 preferredSize += scrollbarGadget->preferredSize() - scrollbarGadget->minimumSize(); 540 541 FloatRect contentsRect(rect); 542 // When using overlay scrollbars we always claim the size of the scrollbar when hovered, so when 543 // drawing the indicator we need to adjust the rectangle to its actual size in indicator mode. 544 if (scrollbar.orientation() == VerticalScrollbar) { 545 if (rect.width() != preferredSize.width()) { 546 if (!scrollbarOnLeft) 547 contentsRect.move(std::abs(rect.width() - preferredSize.width()), 0); 548 contentsRect.setWidth(preferredSize.width()); 549 } 550 } else { 551 if (rect.height() != preferredSize.height()) { 552 contentsRect.move(0, std::abs(rect.height() - preferredSize.height())); 553 contentsRect.setHeight(preferredSize.height()); 554 } 555 } 556 528 557 if (opacity != 1) { 529 558 graphicsContext.save(); … … 532 561 } 533 562 534 FloatRect contentsRect; 535 scrollbarGadget->render(graphicsContext.platformContext()->cr(), rect, &contentsRect); 563 scrollbarGadget->render(graphicsContext.platformContext()->cr(), contentsRect, &contentsRect); 536 564 contentsGadget->render(graphicsContext.platformContext()->cr(), contentsRect, &contentsRect); 537 565 … … 607 635 608 636 troughGadget->render(graphicsContext.platformContext()->cr(), contentsRect, &contentsRect); 609 610 if (int thumbSize = thumbLength(scrollbar)) { 611 info.name = "slider"; 612 info.state = scrollbarPartStateFlags(scrollbar, ThumbPart); 613 auto sliderGadget = RenderThemeGadget::create(info, troughGadget); 614 615 // When using overlay scrollbars we always claim the size of the scrollbar when hovered, so when 616 // drawing the indicator we need to adjust the rectangle to its actual size in indicator mode. 617 bool isIndicator = m_usesOverlayScrollbars && scrollbar.hoveredPart() == NoPart; 637 if (sliderGadget) { 618 638 if (scrollbar.orientation() == VerticalScrollbar) { 619 int sliderWidth = sliderGadget->preferredSize().width(); 620 contentsRect.move(isIndicator ? contentsRect.width() - sliderWidth : 0, thumbPosition(scrollbar)); 621 contentsRect.setWidth(sliderWidth); 639 contentsRect.move(0, thumbPosition(scrollbar)); 640 contentsRect.setWidth(sliderGadget->preferredSize().width()); 622 641 contentsRect.setHeight(thumbSize); 623 642 } else { 624 int sliderHeight = sliderGadget->preferredSize().height(); 625 contentsRect.move(thumbPosition(scrollbar), isIndicator ? contentsRect.height() - sliderHeight : 0); 643 contentsRect.move(thumbPosition(scrollbar), 0); 626 644 contentsRect.setWidth(thumbSize); 627 contentsRect.setHeight(slider Height);645 contentsRect.setHeight(sliderGadget->preferredSize().height()); 628 646 } 629 647 if (contentsRect.intersects(damageRect)) … … 851 869 info.name = "slider"; 852 870 auto sliderGadget = RenderThemeGadget::create(info, contentsGadget->child(troughPositon)); 853 IntSize preferredSize = scrollbarGadget->preferredSize();854 871 IntSize contentsPreferredSize = contentsGadget->preferredSize(); 855 872 contentsPreferredSize = contentsPreferredSize.expandedTo(sliderGadget->preferredSize()); 856 preferredSize += contentsPreferredSize;873 IntSize preferredSize = contentsPreferredSize + scrollbarGadget->preferredSize() - scrollbarGadget->minimumSize(); 857 874 858 875 return preferredSize.width();
Note: See TracChangeset
for help on using the changeset viewer.