OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return kMinFractionToStepWhenPaging; | 67 return kMinFractionToStepWhenPaging; |
68 } | 68 } |
69 | 69 |
70 int ScrollableArea::maxOverlapBetweenPages() { | 70 int ScrollableArea::maxOverlapBetweenPages() { |
71 static int maxOverlapBetweenPages = | 71 static int maxOverlapBetweenPages = |
72 ScrollbarTheme::theme().maxOverlapBetweenPages(); | 72 ScrollbarTheme::theme().maxOverlapBetweenPages(); |
73 return maxOverlapBetweenPages; | 73 return maxOverlapBetweenPages; |
74 } | 74 } |
75 | 75 |
76 ScrollableArea::ScrollableArea() | 76 ScrollableArea::ScrollableArea() |
77 : m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault), | 77 : m_scrollbarOverlayColorTheme(ScrollbarOverlayColorThemeDark), |
78 m_scrollOriginChanged(false), | 78 m_scrollOriginChanged(false), |
79 m_horizontalScrollbarNeedsPaintInvalidation(false), | 79 m_horizontalScrollbarNeedsPaintInvalidation(false), |
80 m_verticalScrollbarNeedsPaintInvalidation(false), | 80 m_verticalScrollbarNeedsPaintInvalidation(false), |
81 m_scrollCornerNeedsPaintInvalidation(false) {} | 81 m_scrollCornerNeedsPaintInvalidation(false) {} |
82 | 82 |
83 ScrollableArea::~ScrollableArea() {} | 83 ScrollableArea::~ScrollableArea() {} |
84 | 84 |
85 void ScrollableArea::clearScrollAnimators() { | 85 void ScrollableArea::clearScrollAnimators() { |
86 #if OS(MACOSX) | 86 #if OS(MACOSX) |
87 if (m_scrollAnimator) | 87 if (m_scrollAnimator) |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 void ScrollableArea::didAddScrollbar(Scrollbar& scrollbar, | 357 void ScrollableArea::didAddScrollbar(Scrollbar& scrollbar, |
358 ScrollbarOrientation orientation) { | 358 ScrollbarOrientation orientation) { |
359 if (orientation == VerticalScrollbar) | 359 if (orientation == VerticalScrollbar) |
360 scrollAnimator().didAddVerticalScrollbar(scrollbar); | 360 scrollAnimator().didAddVerticalScrollbar(scrollbar); |
361 else | 361 else |
362 scrollAnimator().didAddHorizontalScrollbar(scrollbar); | 362 scrollAnimator().didAddHorizontalScrollbar(scrollbar); |
363 | 363 |
364 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you | 364 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you |
365 // attach a scrollbar | 365 // attach a scrollbar |
366 setScrollbarOverlayStyle(getScrollbarOverlayStyle()); | 366 setScrollbarOverlayColorTheme(getScrollbarOverlayColorTheme()); |
367 } | 367 } |
368 | 368 |
369 void ScrollableArea::willRemoveScrollbar(Scrollbar& scrollbar, | 369 void ScrollableArea::willRemoveScrollbar(Scrollbar& scrollbar, |
370 ScrollbarOrientation orientation) { | 370 ScrollbarOrientation orientation) { |
371 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) { | 371 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) { |
372 if (orientation == VerticalScrollbar) | 372 if (orientation == VerticalScrollbar) |
373 scrollAnimator->willRemoveVerticalScrollbar(scrollbar); | 373 scrollAnimator->willRemoveVerticalScrollbar(scrollbar); |
374 else | 374 else |
375 scrollAnimator->willRemoveHorizontalScrollbar(scrollbar); | 375 scrollAnimator->willRemoveHorizontalScrollbar(scrollbar); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 void ScrollableArea::contentsResized() { | 379 void ScrollableArea::contentsResized() { |
380 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 380 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
381 scrollAnimator->contentsResized(); | 381 scrollAnimator->contentsResized(); |
382 } | 382 } |
383 | 383 |
384 bool ScrollableArea::hasOverlayScrollbars() const { | 384 bool ScrollableArea::hasOverlayScrollbars() const { |
385 Scrollbar* vScrollbar = verticalScrollbar(); | 385 Scrollbar* vScrollbar = verticalScrollbar(); |
386 if (vScrollbar && vScrollbar->isOverlayScrollbar()) | 386 if (vScrollbar && vScrollbar->isOverlayScrollbar()) |
387 return true; | 387 return true; |
388 Scrollbar* hScrollbar = horizontalScrollbar(); | 388 Scrollbar* hScrollbar = horizontalScrollbar(); |
389 return hScrollbar && hScrollbar->isOverlayScrollbar(); | 389 return hScrollbar && hScrollbar->isOverlayScrollbar(); |
390 } | 390 } |
391 | 391 |
392 void ScrollableArea::setScrollbarOverlayStyle( | 392 void ScrollableArea::setScrollbarOverlayColorTheme( |
393 ScrollbarOverlayStyle overlayStyle) { | 393 ScrollbarOverlayColorTheme overlayTheme) { |
394 m_scrollbarOverlayStyle = overlayStyle; | 394 m_scrollbarOverlayColorTheme = overlayTheme; |
395 | 395 |
396 if (Scrollbar* scrollbar = horizontalScrollbar()) { | 396 if (Scrollbar* scrollbar = horizontalScrollbar()) { |
397 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 397 ScrollbarTheme::theme().updateScrollbarOverlayColorTheme(*scrollbar); |
398 scrollbar->setNeedsPaintInvalidation(AllParts); | 398 scrollbar->setNeedsPaintInvalidation(AllParts); |
399 } | 399 } |
400 | 400 |
401 if (Scrollbar* scrollbar = verticalScrollbar()) { | 401 if (Scrollbar* scrollbar = verticalScrollbar()) { |
402 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 402 ScrollbarTheme::theme().updateScrollbarOverlayColorTheme(*scrollbar); |
403 scrollbar->setNeedsPaintInvalidation(AllParts); | 403 scrollbar->setNeedsPaintInvalidation(AllParts); |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor) { | 407 void ScrollableArea::recalculateScrollbarOverlayColorTheme( |
408 ScrollbarOverlayStyle oldOverlayStyle = getScrollbarOverlayStyle(); | 408 Color backgroundColor) { |
409 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; | 409 ScrollbarOverlayColorTheme oldOverlayTheme = getScrollbarOverlayColorTheme(); |
| 410 ScrollbarOverlayColorTheme overlayTheme = ScrollbarOverlayColorThemeDark; |
410 | 411 |
411 // Reduce the background color from RGB to a lightness value | 412 // Reduce the background color from RGB to a lightness value |
412 // and determine which scrollbar style to use based on a lightness | 413 // and determine which scrollbar style to use based on a lightness |
413 // heuristic. | 414 // heuristic. |
414 double hue, saturation, lightness; | 415 double hue, saturation, lightness; |
415 backgroundColor.getHSL(hue, saturation, lightness); | 416 backgroundColor.getHSL(hue, saturation, lightness); |
416 if (lightness <= .5) | 417 if (lightness <= .5) |
417 overlayStyle = ScrollbarOverlayStyleLight; | 418 overlayTheme = ScrollbarOverlayColorThemeLight; |
418 | 419 |
419 if (oldOverlayStyle != overlayStyle) | 420 if (oldOverlayTheme != overlayTheme) |
420 setScrollbarOverlayStyle(overlayStyle); | 421 setScrollbarOverlayColorTheme(overlayTheme); |
421 } | 422 } |
422 | 423 |
423 void ScrollableArea::setScrollbarNeedsPaintInvalidation( | 424 void ScrollableArea::setScrollbarNeedsPaintInvalidation( |
424 ScrollbarOrientation orientation) { | 425 ScrollbarOrientation orientation) { |
425 if (orientation == HorizontalScrollbar) { | 426 if (orientation == HorizontalScrollbar) { |
426 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { | 427 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { |
427 graphicsLayer->setNeedsDisplay(); | 428 graphicsLayer->setNeedsDisplay(); |
428 graphicsLayer->setContentsNeedsDisplay(); | 429 graphicsLayer->setContentsNeedsDisplay(); |
429 } | 430 } |
430 m_horizontalScrollbarNeedsPaintInvalidation = true; | 431 m_horizontalScrollbarNeedsPaintInvalidation = true; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), | 592 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), |
592 std::max(0, size.height() - horizontalScrollbarHeight())); | 593 std::max(0, size.height() - horizontalScrollbarHeight())); |
593 } | 594 } |
594 | 595 |
595 DEFINE_TRACE(ScrollableArea) { | 596 DEFINE_TRACE(ScrollableArea) { |
596 visitor->trace(m_scrollAnimator); | 597 visitor->trace(m_scrollAnimator); |
597 visitor->trace(m_programmaticScrollAnimator); | 598 visitor->trace(m_programmaticScrollAnimator); |
598 } | 599 } |
599 | 600 |
600 } // namespace blink | 601 } // namespace blink |
OLD | NEW |