Changeset 256298 in webkit
- Timestamp:
- Feb 11, 2020 1:35:23 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r256230 r256298 1 2020-01-30 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [WPE] Add initial support for rendering scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=206999 5 6 Reviewed by Michael Catanzaro. 7 8 Show overlay scrollbars with a style similar to Adwaita. 9 10 * SourcesWPE.txt: Add ScrollAnimatorGeneric.cpp to the build. 11 * platform/ScrollAnimator.cpp: Switch to use ScrollAnimatorGeneric, required to show/hide the overlay scrollbars. 12 * platform/wpe/ScrollbarThemeWPE.cpp: 13 (WebCore::ScrollbarThemeWPE::scrollbarThickness): 14 (WebCore::ScrollbarThemeWPE::minimumThumbLength): 15 (WebCore::ScrollbarThemeWPE::hasButtons): 16 (WebCore::ScrollbarThemeWPE::hasThumb): 17 (WebCore::ScrollbarThemeWPE::backButtonRect): 18 (WebCore::ScrollbarThemeWPE::forwardButtonRect): 19 (WebCore::ScrollbarThemeWPE::trackRect): 20 (WebCore::ScrollbarThemeWPE::paint): 21 * platform/wpe/ScrollbarThemeWPE.h: 22 1 23 2020-02-10 Keith Rollin <krollin@apple.com> 2 24 -
trunk/Source/WebCore/SourcesWPE.txt
r254064 r256298 60 60 page/scrolling/generic/ScrollingThreadGeneric.cpp 61 61 62 platform/ScrollAnimationKinetic.cpp 62 63 platform/UserAgentQuirks.cpp 64 65 platform/generic/ScrollAnimatorGeneric.cpp 63 66 64 67 platform/graphics/GLContext.cpp -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r255957 r256298 42 42 namespace WebCore { 43 43 44 #if !ENABLE(SMOOTH_SCROLLING) && !PLATFORM(IOS_FAMILY) && !PLATFORM(MAC) 44 #if !ENABLE(SMOOTH_SCROLLING) && !PLATFORM(IOS_FAMILY) && !PLATFORM(MAC) && !PLATFORM(WPE) 45 45 std::unique_ptr<ScrollAnimator> ScrollAnimator::create(ScrollableArea& scrollableArea) 46 46 { -
trunk/Source/WebCore/platform/wpe/ScrollbarThemeWPE.cpp
r216497 r256298 27 27 #include "ScrollbarThemeWPE.h" 28 28 29 #include "NotImplemented.h" 29 #include "Color.h" 30 #include "FloatRoundedRect.h" 31 #include "GraphicsContext.h" 32 #include "PlatformMouseEvent.h" 33 #include "Scrollbar.h" 30 34 31 35 namespace WebCore { 32 36 37 static const unsigned scrollbarSize = 13; 38 static const unsigned hoveredScrollbarBorderSize = 1; 39 static const unsigned thumbBorderSize = 1; 40 static const unsigned overlayThumbSize = 5; 41 static const unsigned thumbSize = 6; 42 static const double scrollbarOpacity = 0.8; 43 static const Color scrollbarBackgroundColor = makeRGB(252, 252, 252); 44 static const Color scrollbarBorderColor = makeRGB(220, 223, 227); 45 static const Color overlayThumbBorderColor = makeRGBA(255, 255, 255, 100); 46 static const Color overlayThumbColor = makeRGBA(46, 52, 54, 100); 47 static const Color thumbHoveredColor = makeRGB(86, 91, 92); 48 static const Color thumbPressedColor = makeRGB(27, 106, 203); 49 static const Color thumbColor = makeRGB(126, 129, 130); 50 51 int ScrollbarThemeWPE::scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState) 52 { 53 return scrollbarSize; 54 } 55 56 int ScrollbarThemeWPE::minimumThumbLength(Scrollbar&) 57 { 58 return 0; 59 } 60 33 61 bool ScrollbarThemeWPE::hasButtons(Scrollbar&) 34 62 { 35 notImplemented(); 63 return false; 64 } 65 66 bool ScrollbarThemeWPE::hasThumb(Scrollbar& scrollbar) 67 { 68 return thumbLength(scrollbar) > 0; 69 } 70 71 IntRect ScrollbarThemeWPE::backButtonRect(Scrollbar&, ScrollbarPart, bool) 72 { 73 return { }; 74 } 75 76 IntRect ScrollbarThemeWPE::forwardButtonRect(Scrollbar&, ScrollbarPart, bool) 77 { 78 return { }; 79 } 80 81 IntRect ScrollbarThemeWPE::trackRect(Scrollbar& scrollbar, bool) 82 { 83 return scrollbar.frameRect(); 84 } 85 86 bool ScrollbarThemeWPE::paint(Scrollbar& scrollbar, GraphicsContext& graphicsContext, const IntRect& damageRect) 87 { 88 if (graphicsContext.paintingDisabled()) 89 return false; 90 91 if (!scrollbar.enabled()) 92 return true; 93 94 IntRect rect = scrollbar.frameRect(); 95 if (!rect.intersects(damageRect)) 96 return true; 97 98 double opacity = scrollbar.hoveredPart() == NoPart ? scrollbar.opacity() : scrollbarOpacity; 99 if (!opacity) 100 return true; 101 102 GraphicsContextStateSaver stateSaver(graphicsContext); 103 if (opacity != 1) { 104 graphicsContext.clip(damageRect); 105 graphicsContext.beginTransparencyLayer(opacity); 106 } 107 108 if (scrollbar.hoveredPart() != NoPart) { 109 graphicsContext.fillRect(rect, scrollbarBackgroundColor); 110 111 IntRect frame = rect; 112 if (scrollbar.orientation() == VerticalScrollbar) { 113 if (scrollbar.scrollableArea().shouldPlaceBlockDirectionScrollbarOnLeft()) 114 frame.move(frame.width() - hoveredScrollbarBorderSize, 0); 115 frame.setWidth(hoveredScrollbarBorderSize); 116 } else 117 frame.setHeight(hoveredScrollbarBorderSize); 118 graphicsContext.fillRect(frame, scrollbarBorderColor); 119 } 120 121 int thumbPos = thumbPosition(scrollbar); 122 int thumbLen = thumbLength(scrollbar); 123 IntRect thumb = rect; 124 if (scrollbar.hoveredPart() == NoPart) { 125 if (scrollbar.orientation() == VerticalScrollbar) { 126 if (scrollbar.scrollableArea().shouldPlaceBlockDirectionScrollbarOnLeft()) 127 thumb.move(hoveredScrollbarBorderSize, thumbPos + thumbBorderSize); 128 else 129 thumb.move(scrollbarSize - (overlayThumbSize + thumbBorderSize) + hoveredScrollbarBorderSize, thumbPos + thumbBorderSize); 130 thumb.setWidth(overlayThumbSize); 131 thumb.setHeight(thumbLen - thumbBorderSize * 2); 132 } else { 133 thumb.move(thumbPos + thumbBorderSize, scrollbarSize - (overlayThumbSize + thumbBorderSize) + hoveredScrollbarBorderSize); 134 thumb.setWidth(thumbLen - thumbBorderSize * 2); 135 thumb.setHeight(overlayThumbSize); 136 } 137 } else { 138 if (scrollbar.orientation() == VerticalScrollbar) { 139 if (scrollbar.scrollableArea().shouldPlaceBlockDirectionScrollbarOnLeft()) 140 thumb.move(scrollbarSize - (scrollbarSize / 2 + thumbSize / 2) - hoveredScrollbarBorderSize, thumbPos + thumbBorderSize); 141 else 142 thumb.move(scrollbarSize - (scrollbarSize / 2 + thumbSize / 2), thumbPos + thumbBorderSize); 143 thumb.setWidth(thumbSize); 144 thumb.setHeight(thumbLen - thumbBorderSize * 2); 145 } else { 146 thumb.move(thumbPos + thumbBorderSize, scrollbarSize - (scrollbarSize / 2 + thumbSize / 2)); 147 thumb.setWidth(thumbLen - thumbBorderSize * 2); 148 thumb.setHeight(thumbSize); 149 } 150 } 151 152 FloatSize corner(4, 4); 153 Path path; 154 if (scrollbar.hoveredPart() == NoPart) { 155 path.addRoundedRect(thumb, corner); 156 thumb.inflate(-1); 157 path.addRoundedRect(thumb, corner); 158 graphicsContext.setFillRule(WindRule::EvenOdd); 159 graphicsContext.setFillColor(overlayThumbBorderColor); 160 graphicsContext.fillPath(path); 161 path.clear(); 162 } 163 164 path.addRoundedRect(thumb, corner); 165 graphicsContext.setFillRule(WindRule::NonZero); 166 if (scrollbar.hoveredPart() == NoPart) 167 graphicsContext.setFillColor(overlayThumbColor); 168 else if (scrollbar.pressedPart() == ThumbPart) 169 graphicsContext.setFillColor(thumbPressedColor); 170 else if (scrollbar.hoveredPart() == ThumbPart) 171 graphicsContext.setFillColor(thumbHoveredColor); 172 else 173 graphicsContext.setFillColor(thumbColor); 174 graphicsContext.fillPath(path); 175 176 if (opacity != 1) 177 graphicsContext.endTransparencyLayer(); 178 36 179 return true; 37 180 } 38 181 39 bool ScrollbarThemeWPE::hasThumb(Scrollbar&) 40 { 41 notImplemented(); 42 return true; 43 } 44 45 IntRect ScrollbarThemeWPE::backButtonRect(Scrollbar&, ScrollbarPart, bool) 46 { 47 notImplemented(); 48 return IntRect(); 49 } 50 51 IntRect ScrollbarThemeWPE::forwardButtonRect(Scrollbar&, ScrollbarPart, bool) 52 { 53 notImplemented(); 54 return IntRect(); 55 } 56 57 IntRect ScrollbarThemeWPE::trackRect(Scrollbar&, bool) 58 { 59 notImplemented(); 60 return IntRect(); 182 ScrollbarButtonPressAction ScrollbarThemeWPE::handleMousePressEvent(Scrollbar&, const PlatformMouseEvent& event, ScrollbarPart pressedPart) 183 { 184 switch (pressedPart) { 185 case BackTrackPart: 186 case ForwardTrackPart: 187 // The shift key or middle/right button reverses the sense. 188 if (event.shiftKey() || event.button() != LeftButton) 189 return ScrollbarButtonPressAction::CenterOnThumb; 190 return ScrollbarButtonPressAction::Scroll; 191 case ThumbPart: 192 if (event.button() != RightButton) 193 return ScrollbarButtonPressAction::StartDrag; 194 break; 195 case BackButtonStartPart: 196 case ForwardButtonStartPart: 197 case BackButtonEndPart: 198 case ForwardButtonEndPart: 199 return ScrollbarButtonPressAction::Scroll; 200 default: 201 break; 202 } 203 204 return ScrollbarButtonPressAction::None; 61 205 } 62 206 -
trunk/Source/WebCore/platform/wpe/ScrollbarThemeWPE.h
r216497 r256298 35 35 virtual ~ScrollbarThemeWPE() = default; 36 36 37 private: 38 bool usesOverlayScrollbars() const override { return true; } 39 40 bool paint(Scrollbar&, GraphicsContext&, const IntRect&) override; 41 ScrollbarButtonPressAction handleMousePressEvent(Scrollbar&, const PlatformMouseEvent&, ScrollbarPart) override; 42 43 int scrollbarThickness(ScrollbarControlSize, ScrollbarExpansionState) override; 44 int minimumThumbLength(Scrollbar&) override; 45 37 46 bool hasButtons(Scrollbar&) override; 38 47 bool hasThumb(Scrollbar&) override;
Note: See TracChangeset
for help on using the changeset viewer.