Bug 1472338: part 1) Add Chrome tests for the async Clipboard API. r=NeilDeakin
[gecko.git] / widget / nsNativeTheme.cpp
blobac62c44a81369883782ddda8f39cd5aaaa946483
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsNativeTheme.h"
7 #include "nsIWidget.h"
8 #include "mozilla/dom/Document.h"
9 #include "nsIContent.h"
10 #include "nsIFrame.h"
11 #include "nsIScrollableFrame.h"
12 #include "nsLayoutUtils.h"
13 #include "nsNumberControlFrame.h"
14 #include "nsPresContext.h"
15 #include "nsString.h"
16 #include "nsNameSpaceManager.h"
17 #include "nsStyleConsts.h"
18 #include "nsPIDOMWindow.h"
19 #include "nsProgressFrame.h"
20 #include "nsMeterFrame.h"
21 #include "nsMenuFrame.h"
22 #include "nsRangeFrame.h"
23 #include "nsCSSRendering.h"
24 #include "ImageContainer.h"
25 #include "mozilla/ComputedStyle.h"
26 #include "mozilla/EventStates.h"
27 #include "mozilla/dom/Element.h"
28 #include "mozilla/dom/HTMLBodyElement.h"
29 #include "mozilla/dom/HTMLInputElement.h"
30 #include "mozilla/dom/HTMLProgressElement.h"
31 #include "mozilla/PresShell.h"
32 #include "mozilla/StaticPrefs_layout.h"
33 #include "mozilla/dom/DocumentInlines.h"
34 #include "mozilla/RelativeLuminanceUtils.h"
35 #include <algorithm>
37 using namespace mozilla;
38 using namespace mozilla::dom;
40 nsNativeTheme::nsNativeTheme() : mAnimatedContentTimeout(UINT32_MAX) {}
42 NS_IMPL_ISUPPORTS(nsNativeTheme, nsITimerCallback, nsINamed)
44 /* static */ EventStates nsNativeTheme::GetContentState(
45 nsIFrame* aFrame, StyleAppearance aAppearance) {
46 if (!aFrame) {
47 return EventStates();
50 nsIContent* frameContent = aFrame->GetContent();
51 if (!frameContent || !frameContent->IsElement()) {
52 return EventStates();
55 const bool isXULElement = frameContent->IsXULElement();
56 if (isXULElement) {
57 if (aAppearance == StyleAppearance::CheckboxLabel ||
58 aAppearance == StyleAppearance::RadioLabel) {
59 aFrame = aFrame->GetParent()->GetParent();
60 frameContent = aFrame->GetContent();
61 } else if (aAppearance == StyleAppearance::Checkbox ||
62 aAppearance == StyleAppearance::Radio ||
63 aAppearance == StyleAppearance::ToolbarbuttonDropdown ||
64 aAppearance == StyleAppearance::Treeheadersortarrow ||
65 aAppearance == StyleAppearance::ButtonArrowPrevious ||
66 aAppearance == StyleAppearance::ButtonArrowNext ||
67 aAppearance == StyleAppearance::ButtonArrowUp ||
68 aAppearance == StyleAppearance::ButtonArrowDown) {
69 aFrame = aFrame->GetParent();
70 frameContent = aFrame->GetContent();
72 MOZ_ASSERT(frameContent && frameContent->IsElement());
75 EventStates flags = frameContent->AsElement()->State();
76 nsNumberControlFrame* numberControlFrame =
77 nsNumberControlFrame::GetNumberControlFrameForSpinButton(aFrame);
78 if (numberControlFrame &&
79 numberControlFrame->GetContent()->AsElement()->State().HasState(
80 NS_EVENT_STATE_DISABLED)) {
81 flags |= NS_EVENT_STATE_DISABLED;
84 if (!isXULElement) {
85 return flags;
88 if (CheckBooleanAttr(aFrame, nsGkAtoms::disabled)) {
89 flags |= NS_EVENT_STATE_DISABLED;
92 switch (aAppearance) {
93 case StyleAppearance::RadioLabel:
94 case StyleAppearance::Radio: {
95 if (CheckBooleanAttr(aFrame, nsGkAtoms::focused)) {
96 flags |= NS_EVENT_STATE_FOCUS;
97 nsPIDOMWindowOuter* window =
98 aFrame->GetContent()->OwnerDoc()->GetWindow();
99 if (window && window->ShouldShowFocusRing()) {
100 flags |= NS_EVENT_STATE_FOCUSRING;
103 if (CheckBooleanAttr(aFrame, nsGkAtoms::selected)) {
104 flags |= NS_EVENT_STATE_CHECKED;
106 break;
108 case StyleAppearance::CheckboxLabel:
109 case StyleAppearance::Checkbox: {
110 if (CheckBooleanAttr(aFrame, nsGkAtoms::checked)) {
111 flags |= NS_EVENT_STATE_CHECKED;
112 } else if (CheckBooleanAttr(aFrame, nsGkAtoms::indeterminate)) {
113 flags |= NS_EVENT_STATE_INDETERMINATE;
115 break;
117 case StyleAppearance::MenulistButton:
118 case StyleAppearance::Menulist:
119 case StyleAppearance::NumberInput:
120 case StyleAppearance::Textfield:
121 case StyleAppearance::Searchfield:
122 case StyleAppearance::Textarea: {
123 if (CheckBooleanAttr(aFrame, nsGkAtoms::focused)) {
124 flags |= NS_EVENT_STATE_FOCUS | NS_EVENT_STATE_FOCUSRING;
126 break;
128 default:
129 break;
132 return flags;
135 /* static */
136 bool nsNativeTheme::CheckBooleanAttr(nsIFrame* aFrame, nsAtom* aAtom) {
137 if (!aFrame) return false;
139 nsIContent* content = aFrame->GetContent();
140 if (!content || !content->IsElement()) return false;
142 if (content->IsHTMLElement())
143 return content->AsElement()->HasAttr(kNameSpaceID_None, aAtom);
145 // For XML/XUL elements, an attribute must be equal to the literal
146 // string "true" to be counted as true. An empty string should _not_
147 // be counted as true.
148 return content->AsElement()->AttrValueIs(kNameSpaceID_None, aAtom, u"true"_ns,
149 eCaseMatters);
152 /* static */
153 int32_t nsNativeTheme::CheckIntAttr(nsIFrame* aFrame, nsAtom* aAtom,
154 int32_t defaultValue) {
155 if (!aFrame) return defaultValue;
157 nsIContent* content = aFrame->GetContent();
158 if (!content || !content->IsElement()) return defaultValue;
160 nsAutoString attr;
161 content->AsElement()->GetAttr(kNameSpaceID_None, aAtom, attr);
162 nsresult err;
163 int32_t value = attr.ToInteger(&err);
164 if (attr.IsEmpty() || NS_FAILED(err)) return defaultValue;
166 return value;
169 /* static */
170 double nsNativeTheme::GetProgressValue(nsIFrame* aFrame) {
171 if (!aFrame || !aFrame->GetContent()->IsHTMLElement(nsGkAtoms::progress)) {
172 return 0;
175 return static_cast<HTMLProgressElement*>(aFrame->GetContent())->Value();
178 /* static */
179 double nsNativeTheme::GetProgressMaxValue(nsIFrame* aFrame) {
180 if (!aFrame || !aFrame->GetContent()->IsHTMLElement(nsGkAtoms::progress)) {
181 return 100;
184 return static_cast<HTMLProgressElement*>(aFrame->GetContent())->Max();
187 bool nsNativeTheme::IsButtonTypeMenu(nsIFrame* aFrame) {
188 if (!aFrame) return false;
190 nsIContent* content = aFrame->GetContent();
191 return content->IsXULElement(nsGkAtoms::button) &&
192 content->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
193 u"menu"_ns, eCaseMatters);
196 bool nsNativeTheme::IsPressedButton(nsIFrame* aFrame) {
197 EventStates eventState =
198 GetContentState(aFrame, StyleAppearance::Toolbarbutton);
199 if (eventState.HasState(NS_EVENT_STATE_DISABLED)) return false;
201 return IsOpenButton(aFrame) ||
202 eventState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER);
205 bool nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext,
206 nsIFrame* aFrame,
207 StyleAppearance aAppearance) {
208 // Check for specific widgets to see if HTML has overridden the style.
209 if (!aFrame) {
210 return false;
213 // Resizers have some special handling, dependent on whether in a scrollable
214 // container or not. If so, use the scrollable container's to determine
215 // whether the style is overriden instead of the resizer. This allows a
216 // non-native transparent resizer to be used instead. Otherwise, we just
217 // fall through and return false.
218 if (aAppearance == StyleAppearance::Resizer) {
219 nsIFrame* parentFrame = aFrame->GetParent();
220 if (parentFrame && parentFrame->IsScrollFrame()) {
221 // if the parent is a scrollframe, the resizer should be native themed
222 // only if the scrollable area doesn't override the widget style.
224 // note that the condition below looks a bit suspect but it's the right
225 // one. If there's no valid appearance, then we should return true, it's
226 // effectively the same as if it had overridden the appearance.
227 parentFrame = parentFrame->GetParent();
228 if (!parentFrame) {
229 return false;
231 auto parentAppearance =
232 parentFrame->StyleDisplay()->EffectiveAppearance();
233 return parentAppearance == StyleAppearance::None ||
234 IsWidgetStyled(aPresContext, parentFrame, parentAppearance);
239 * Progress bar appearance should be the same for the bar and the container
240 * frame. nsProgressFrame owns the logic and will tell us what we should do.
242 if (aAppearance == StyleAppearance::Progresschunk ||
243 aAppearance == StyleAppearance::ProgressBar) {
244 nsProgressFrame* progressFrame = do_QueryFrame(
245 aAppearance == StyleAppearance::Progresschunk ? aFrame->GetParent()
246 : aFrame);
247 if (progressFrame) {
248 return !progressFrame->ShouldUseNativeStyle();
253 * Meter bar appearance should be the same for the bar and the container
254 * frame. nsMeterFrame owns the logic and will tell us what we should do.
256 if (aAppearance == StyleAppearance::Meterchunk ||
257 aAppearance == StyleAppearance::Meter) {
258 nsMeterFrame* meterFrame = do_QueryFrame(
259 aAppearance == StyleAppearance::Meterchunk ? aFrame->GetParent()
260 : aFrame);
261 if (meterFrame) {
262 return !meterFrame->ShouldUseNativeStyle();
267 * An nsRangeFrame and its children are treated atomically when it
268 * comes to native theming (either all parts, or no parts, are themed).
269 * nsRangeFrame owns the logic and will tell us what we should do.
271 if (aAppearance == StyleAppearance::Range ||
272 aAppearance == StyleAppearance::RangeThumb) {
273 nsRangeFrame* rangeFrame = do_QueryFrame(
274 aAppearance == StyleAppearance::RangeThumb ? aFrame->GetParent()
275 : aFrame);
276 if (rangeFrame) {
277 return !rangeFrame->ShouldUseNativeStyle();
281 return nsLayoutUtils::AuthorSpecifiedBorderBackgroundDisablesTheming(
282 aAppearance) &&
283 aFrame->GetContent()->IsHTMLElement() &&
284 aFrame->Style()->HasAuthorSpecifiedBorderOrBackground();
287 /* static */
288 bool nsNativeTheme::IsFrameRTL(nsIFrame* aFrame) {
289 if (!aFrame) {
290 return false;
292 return aFrame->GetWritingMode().IsPhysicalRTL();
295 /* static */
296 bool nsNativeTheme::IsHTMLContent(nsIFrame* aFrame) {
297 if (!aFrame) {
298 return false;
300 nsIContent* content = aFrame->GetContent();
301 return content && content->IsHTMLElement();
304 // treeheadercell:
305 nsNativeTheme::TreeSortDirection nsNativeTheme::GetTreeSortDirection(
306 nsIFrame* aFrame) {
307 if (!aFrame || !aFrame->GetContent()) return eTreeSortDirection_Natural;
309 static Element::AttrValuesArray strings[] = {nsGkAtoms::descending,
310 nsGkAtoms::ascending, nullptr};
312 nsIContent* content = aFrame->GetContent();
313 if (content->IsElement()) {
314 switch (content->AsElement()->FindAttrValueIn(
315 kNameSpaceID_None, nsGkAtoms::sortDirection, strings, eCaseMatters)) {
316 case 0:
317 return eTreeSortDirection_Descending;
318 case 1:
319 return eTreeSortDirection_Ascending;
323 return eTreeSortDirection_Natural;
326 bool nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame) {
327 if (!aFrame) return false;
329 // A tree column picker is always the last header cell.
330 if (aFrame->GetContent()->IsXULElement(nsGkAtoms::treecolpicker)) return true;
332 // Find the parent tree.
333 nsIContent* parent = aFrame->GetContent()->GetParent();
334 while (parent && !parent->IsXULElement(nsGkAtoms::tree)) {
335 parent = parent->GetParent();
338 // If the column picker is visible, this can't be the last column.
339 if (parent && !parent->AsElement()->AttrValueIs(kNameSpaceID_None,
340 nsGkAtoms::hidecolumnpicker,
341 u"true"_ns, eCaseMatters))
342 return false;
344 while ((aFrame = aFrame->GetNextSibling())) {
345 if (aFrame->GetRect().Width() > 0) return false;
347 return true;
350 // tab:
351 bool nsNativeTheme::IsBottomTab(nsIFrame* aFrame) {
352 if (!aFrame) return false;
354 nsAutoString classStr;
355 if (aFrame->GetContent()->IsElement()) {
356 aFrame->GetContent()->AsElement()->GetAttr(kNameSpaceID_None,
357 nsGkAtoms::_class, classStr);
359 // FIXME: This looks bogus, shouldn't this be looking at GetClasses()?
360 return !classStr.IsEmpty() && classStr.Find("tab-bottom") != kNotFound;
363 bool nsNativeTheme::IsFirstTab(nsIFrame* aFrame) {
364 if (!aFrame) return false;
366 for (nsIFrame* first : aFrame->GetParent()->PrincipalChildList()) {
367 if (first->GetRect().Width() > 0 &&
368 first->GetContent()->IsXULElement(nsGkAtoms::tab))
369 return (first == aFrame);
371 return false;
374 bool nsNativeTheme::IsHorizontal(nsIFrame* aFrame) {
375 if (!aFrame) return false;
377 if (!aFrame->GetContent()->IsElement()) return true;
379 return !aFrame->GetContent()->AsElement()->AttrValueIs(
380 kNameSpaceID_None, nsGkAtoms::orient, nsGkAtoms::vertical, eCaseMatters);
383 bool nsNativeTheme::IsNextToSelectedTab(nsIFrame* aFrame, int32_t aOffset) {
384 if (!aFrame) return false;
386 if (aOffset == 0) return IsSelectedTab(aFrame);
388 int32_t thisTabIndex = -1, selectedTabIndex = -1;
390 nsIFrame* currentTab = aFrame->GetParent()->PrincipalChildList().FirstChild();
391 for (int32_t i = 0; currentTab; currentTab = currentTab->GetNextSibling()) {
392 if (currentTab->GetRect().Width() == 0) continue;
393 if (aFrame == currentTab) thisTabIndex = i;
394 if (IsSelectedTab(currentTab)) selectedTabIndex = i;
395 ++i;
398 if (thisTabIndex == -1 || selectedTabIndex == -1) return false;
400 return (thisTabIndex - selectedTabIndex == aOffset);
403 bool nsNativeTheme::IsVerticalProgress(nsIFrame* aFrame) {
404 if (!aFrame) {
405 return false;
407 return IsVerticalMeter(aFrame);
410 bool nsNativeTheme::IsVerticalMeter(nsIFrame* aFrame) {
411 MOZ_ASSERT(aFrame, "You have to pass a non-null aFrame");
412 switch (aFrame->StyleDisplay()->mOrient) {
413 case StyleOrient::Horizontal:
414 return false;
415 case StyleOrient::Vertical:
416 return true;
417 case StyleOrient::Inline:
418 return aFrame->GetWritingMode().IsVertical();
419 case StyleOrient::Block:
420 return !aFrame->GetWritingMode().IsVertical();
422 MOZ_ASSERT_UNREACHABLE("unexpected -moz-orient value");
423 return false;
426 // menupopup:
427 bool nsNativeTheme::IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent) {
428 if (!aFrame) return false;
430 nsIContent* parentContent = aFrame->GetContent()->GetParent();
431 if (!parentContent || !parentContent->IsXULElement(nsGkAtoms::menu))
432 return false;
434 nsIFrame* parent = aFrame;
435 while ((parent = parent->GetParent())) {
436 if (parent->GetContent() == parentContent) {
437 if (aLeftOfParent) {
438 LayoutDeviceIntRect selfBounds, parentBounds;
439 selfBounds = aFrame->GetNearestWidget()->GetScreenBounds();
440 parentBounds = parent->GetNearestWidget()->GetScreenBounds();
441 *aLeftOfParent = selfBounds.X() < parentBounds.X();
443 return true;
447 return false;
450 bool nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent,
451 uint32_t aMinimumFrameRate) {
452 NS_ASSERTION(aContent, "Null pointer!");
453 NS_ASSERTION(aMinimumFrameRate, "aMinimumFrameRate must be non-zero!");
454 NS_ASSERTION(aMinimumFrameRate <= 1000,
455 "aMinimumFrameRate must be less than 1000!");
457 uint32_t timeout = 1000 / aMinimumFrameRate;
458 timeout = std::min(mAnimatedContentTimeout, timeout);
460 if (!mAnimatedContentTimer) {
461 mAnimatedContentTimer = NS_NewTimer();
462 NS_ENSURE_TRUE(mAnimatedContentTimer, false);
465 if (mAnimatedContentList.IsEmpty() || timeout != mAnimatedContentTimeout) {
466 nsresult rv;
467 if (!mAnimatedContentList.IsEmpty()) {
468 rv = mAnimatedContentTimer->Cancel();
469 NS_ENSURE_SUCCESS(rv, false);
472 if (XRE_IsContentProcess() && NS_IsMainThread()) {
473 mAnimatedContentTimer->SetTarget(
474 aContent->OwnerDoc()->EventTargetFor(TaskCategory::Other));
476 rv = mAnimatedContentTimer->InitWithCallback(this, timeout,
477 nsITimer::TYPE_ONE_SHOT);
478 NS_ENSURE_SUCCESS(rv, false);
480 mAnimatedContentTimeout = timeout;
483 // XXX(Bug 1631371) Check if this should use a fallible operation as it
484 // pretended earlier.
485 mAnimatedContentList.AppendElement(aContent);
487 return true;
490 NS_IMETHODIMP
491 nsNativeTheme::Notify(nsITimer* aTimer) {
492 NS_ASSERTION(aTimer == mAnimatedContentTimer, "Wrong timer!");
494 // XXX Assumes that calling nsIFrame::Invalidate won't reenter
495 // QueueAnimatedContentForRefresh.
497 uint32_t count = mAnimatedContentList.Length();
498 for (uint32_t index = 0; index < count; index++) {
499 nsIFrame* frame = mAnimatedContentList[index]->GetPrimaryFrame();
500 if (frame) {
501 frame->InvalidateFrame();
505 mAnimatedContentList.Clear();
506 mAnimatedContentTimeout = UINT32_MAX;
507 return NS_OK;
510 NS_IMETHODIMP
511 nsNativeTheme::GetName(nsACString& aName) {
512 aName.AssignLiteral("nsNativeTheme");
513 return NS_OK;
516 nsIFrame* nsNativeTheme::GetAdjacentSiblingFrameWithSameAppearance(
517 nsIFrame* aFrame, bool aNextSibling) {
518 if (!aFrame) return nullptr;
520 // Find the next visible sibling.
521 nsIFrame* sibling = aFrame;
522 do {
523 sibling =
524 aNextSibling ? sibling->GetNextSibling() : sibling->GetPrevSibling();
525 } while (sibling && sibling->GetRect().Width() == 0);
527 // Check same appearance and adjacency.
528 if (!sibling ||
529 sibling->StyleDisplay()->EffectiveAppearance() !=
530 aFrame->StyleDisplay()->EffectiveAppearance() ||
531 (sibling->GetRect().XMost() != aFrame->GetRect().X() &&
532 aFrame->GetRect().XMost() != sibling->GetRect().X()))
533 return nullptr;
534 return sibling;
537 bool nsNativeTheme::IsRangeHorizontal(nsIFrame* aFrame) {
538 nsIFrame* rangeFrame = aFrame;
539 if (!rangeFrame->IsRangeFrame()) {
540 // If the thumb's frame is passed in, get its range parent:
541 rangeFrame = aFrame->GetParent();
543 if (rangeFrame->IsRangeFrame()) {
544 return static_cast<nsRangeFrame*>(rangeFrame)->IsHorizontal();
546 // Not actually a range frame - just use the ratio of the frame's size to
547 // decide:
548 return aFrame->GetSize().width >= aFrame->GetSize().height;
551 static nsIFrame* GetBodyFrame(nsIFrame* aCanvasFrame) {
552 nsIContent* body = aCanvasFrame->PresContext()->Document()->GetBodyElement();
553 if (!body) {
554 return nullptr;
556 return body->GetPrimaryFrame();
559 bool nsNativeTheme::IsDarkColor(nscolor aColor) {
560 // Given https://www.w3.org/TR/WCAG20/#contrast-ratiodef, this is the
561 // threshold that tells us whether contrast is better against white or black.
563 // Contrast ratio against black is: (L + 0.05) / 0.05
564 // Contrast ratio against white is: 1.05 / (L + 0.05)
566 // So the intersection is:
568 // (L + 0.05) / 0.05 = 1.05 / (L + 0.05)
570 // And the solution to that equation is:
572 // sqrt(1.05 * 0.05) - 0.05
574 // So we consider a color dark if the contrast is below this threshold, and
575 // it's at least half-opaque.
576 constexpr float kThreshold = 0.179129;
577 return NS_GET_A(aColor) > 127 &&
578 RelativeLuminanceUtils::Compute(aColor) < kThreshold;
581 /* static */
582 bool nsNativeTheme::IsDarkBackground(nsIFrame* aFrame) {
583 // Try to find the scrolled frame. Note that for stuff like xul <tree> there
584 // might be none.
586 nsIFrame* frame = aFrame;
587 nsIScrollableFrame* scrollFrame = nullptr;
588 while (!scrollFrame && frame) {
589 scrollFrame = frame->GetScrollTargetFrame();
590 frame = frame->GetParent();
592 if (scrollFrame) {
593 aFrame = scrollFrame->GetScrolledFrame();
594 } else {
595 // Leave aFrame untouched.
599 auto backgroundFrame = nsCSSRendering::FindNonTransparentBackgroundFrame(
600 aFrame, /* aStopAtThemed = */ false);
601 if (!backgroundFrame.mFrame) {
602 return false;
605 nscolor color = backgroundFrame.mFrame->StyleBackground()->BackgroundColor(
606 backgroundFrame.mFrame);
608 if (backgroundFrame.mIsForCanvas) {
609 // For canvas frames, prefer to look at the body first, because the body
610 // background color is most likely what will be visible as the background
611 // color of the page, even if the html element has a different background
612 // color which prevents that of the body frame to propagate to the viewport.
613 if (nsIFrame* bodyFrame = GetBodyFrame(aFrame)) {
614 nscolor bodyColor =
615 bodyFrame->StyleBackground()->BackgroundColor(bodyFrame);
616 if (NS_GET_A(bodyColor)) {
617 color = bodyColor;
622 return IsDarkColor(color);
625 /*static*/
626 bool nsNativeTheme::IsWidgetScrollbarPart(StyleAppearance aAppearance) {
627 switch (aAppearance) {
628 case StyleAppearance::ScrollbarVertical:
629 case StyleAppearance::ScrollbarHorizontal:
630 case StyleAppearance::ScrollbarbuttonUp:
631 case StyleAppearance::ScrollbarbuttonDown:
632 case StyleAppearance::ScrollbarbuttonLeft:
633 case StyleAppearance::ScrollbarbuttonRight:
634 case StyleAppearance::ScrollbarthumbVertical:
635 case StyleAppearance::ScrollbarthumbHorizontal:
636 case StyleAppearance::ScrollbartrackHorizontal:
637 case StyleAppearance::ScrollbartrackVertical:
638 case StyleAppearance::Scrollcorner:
639 return true;
640 default:
641 return false;