OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. | 2 * Copyright (C) 2007 Apple Inc. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2008 Collabora Ltd. | 4 * Copyright (C) 2008 Collabora Ltd. |
5 * Copyright (C) 2008, 2009 Google Inc. | 5 * Copyright (C) 2008, 2009 Google Inc. |
6 * Copyright (C) 2009 Kenneth Rohde Christiansen | 6 * Copyright (C) 2009 Kenneth Rohde Christiansen |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 10 matching lines...) Expand all Loading... |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/layout/LayoutThemeDefault.h" | 26 #include "core/layout/LayoutThemeDefault.h" |
27 | 27 |
28 #include "core/CSSValueKeywords.h" | 28 #include "core/CSSValueKeywords.h" |
29 #include "core/layout/LayoutMediaControls.h" | 29 #include "core/layout/LayoutMediaControls.h" |
30 #include "core/layout/LayoutObject.h" | 30 #include "core/layout/LayoutObject.h" |
| 31 #include "core/layout/LayoutProgress.h" |
31 #include "core/layout/LayoutThemeFontProvider.h" | 32 #include "core/layout/LayoutThemeFontProvider.h" |
32 #include "core/layout/PaintInfo.h" | 33 #include "core/layout/PaintInfo.h" |
33 #include "core/rendering/RenderProgress.h" | |
34 #include "platform/LayoutTestSupport.h" | 34 #include "platform/LayoutTestSupport.h" |
35 #include "platform/PlatformResourceLoader.h" | 35 #include "platform/PlatformResourceLoader.h" |
36 #include "platform/graphics/Color.h" | 36 #include "platform/graphics/Color.h" |
37 #include "platform/graphics/GraphicsContext.h" | 37 #include "platform/graphics/GraphicsContext.h" |
38 #include "platform/graphics/GraphicsContextStateSaver.h" | 38 #include "platform/graphics/GraphicsContextStateSaver.h" |
39 #include "platform/scroll/ScrollbarTheme.h" | 39 #include "platform/scroll/ScrollbarTheme.h" |
40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
41 #include "public/platform/WebRect.h" | 41 #include "public/platform/WebRect.h" |
42 #include "public/platform/WebThemeEngine.h" | 42 #include "public/platform/WebThemeEngine.h" |
43 #include "wtf/StdLibExtras.h" | 43 #include "wtf/StdLibExtras.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 484 |
485 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS
pinButton, getWebThemeState(this, o), WebRect(rect), &extraParams); | 485 Platform::current()->themeEngine()->paint(canvas, WebThemeEngine::PartInnerS
pinButton, getWebThemeState(this, o), WebRect(rect), &extraParams); |
486 return false; | 486 return false; |
487 } | 487 } |
488 | 488 |
489 bool LayoutThemeDefault::paintProgressBar(LayoutObject* o, const PaintInfo& i, c
onst IntRect& rect) | 489 bool LayoutThemeDefault::paintProgressBar(LayoutObject* o, const PaintInfo& i, c
onst IntRect& rect) |
490 { | 490 { |
491 if (!o->isProgress()) | 491 if (!o->isProgress()) |
492 return true; | 492 return true; |
493 | 493 |
494 RenderProgress* renderProgress = toRenderProgress(o); | 494 LayoutProgress* renderProgress = toLayoutProgress(o); |
495 IntRect valueRect = progressValueRectFor(renderProgress, rect); | 495 IntRect valueRect = progressValueRectFor(renderProgress, rect); |
496 | 496 |
497 WebThemeEngine::ExtraParams extraParams; | 497 WebThemeEngine::ExtraParams extraParams; |
498 extraParams.progressBar.determinate = renderProgress->isDeterminate(); | 498 extraParams.progressBar.determinate = renderProgress->isDeterminate(); |
499 extraParams.progressBar.valueRectX = valueRect.x(); | 499 extraParams.progressBar.valueRectX = valueRect.x(); |
500 extraParams.progressBar.valueRectY = valueRect.y(); | 500 extraParams.progressBar.valueRectY = valueRect.y(); |
501 extraParams.progressBar.valueRectWidth = valueRect.width(); | 501 extraParams.progressBar.valueRectWidth = valueRect.width(); |
502 extraParams.progressBar.valueRectHeight = valueRect.height(); | 502 extraParams.progressBar.valueRectHeight = valueRect.height(); |
503 | 503 |
504 DirectionFlippingScope scope(o, i, rect); | 504 DirectionFlippingScope scope(o, i, rect); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 return true; | 808 return true; |
809 } | 809 } |
810 | 810 |
811 // | 811 // |
812 // Following values are come from default of GTK+ | 812 // Following values are come from default of GTK+ |
813 // | 813 // |
814 static const int progressActivityBlocks = 5; | 814 static const int progressActivityBlocks = 5; |
815 static const int progressAnimationFrames = 10; | 815 static const int progressAnimationFrames = 10; |
816 static const double progressAnimationInterval = 0.125; | 816 static const double progressAnimationInterval = 0.125; |
817 | 817 |
818 IntRect LayoutThemeDefault::determinateProgressValueRectFor(RenderProgress* rend
erProgress, const IntRect& rect) const | 818 IntRect LayoutThemeDefault::determinateProgressValueRectFor(LayoutProgress* rend
erProgress, const IntRect& rect) const |
819 { | 819 { |
820 int dx = rect.width() * renderProgress->position(); | 820 int dx = rect.width() * renderProgress->position(); |
821 return IntRect(rect.x(), rect.y(), dx, rect.height()); | 821 return IntRect(rect.x(), rect.y(), dx, rect.height()); |
822 } | 822 } |
823 | 823 |
824 IntRect LayoutThemeDefault::indeterminateProgressValueRectFor(RenderProgress* re
nderProgress, const IntRect& rect) const | 824 IntRect LayoutThemeDefault::indeterminateProgressValueRectFor(LayoutProgress* re
nderProgress, const IntRect& rect) const |
825 { | 825 { |
826 | 826 |
827 int valueWidth = rect.width() / progressActivityBlocks; | 827 int valueWidth = rect.width() / progressActivityBlocks; |
828 int movableWidth = rect.width() - valueWidth; | 828 int movableWidth = rect.width() - valueWidth; |
829 if (movableWidth <= 0) | 829 if (movableWidth <= 0) |
830 return IntRect(); | 830 return IntRect(); |
831 | 831 |
832 double progress = renderProgress->animationProgress(); | 832 double progress = renderProgress->animationProgress(); |
833 if (progress < 0.5) | 833 if (progress < 0.5) |
834 return IntRect(rect.x() + progress * 2 * movableWidth, rect.y(), valueWi
dth, rect.height()); | 834 return IntRect(rect.x() + progress * 2 * movableWidth, rect.y(), valueWi
dth, rect.height()); |
835 return IntRect(rect.x() + (1.0 - progress) * 2 * movableWidth, rect.y(), val
ueWidth, rect.height()); | 835 return IntRect(rect.x() + (1.0 - progress) * 2 * movableWidth, rect.y(), val
ueWidth, rect.height()); |
836 } | 836 } |
837 | 837 |
838 double LayoutThemeDefault::animationRepeatIntervalForProgressBar(RenderProgress*
) const | 838 double LayoutThemeDefault::animationRepeatIntervalForProgressBar(LayoutProgress*
) const |
839 { | 839 { |
840 return progressAnimationInterval; | 840 return progressAnimationInterval; |
841 } | 841 } |
842 | 842 |
843 double LayoutThemeDefault::animationDurationForProgressBar(RenderProgress* rende
rProgress) const | 843 double LayoutThemeDefault::animationDurationForProgressBar(LayoutProgress* rende
rProgress) const |
844 { | 844 { |
845 return progressAnimationInterval * progressAnimationFrames * 2; // "2" for b
ack and forth | 845 return progressAnimationInterval * progressAnimationFrames * 2; // "2" for b
ack and forth |
846 } | 846 } |
847 | 847 |
848 IntRect LayoutThemeDefault::progressValueRectFor(RenderProgress* renderProgress,
const IntRect& rect) const | 848 IntRect LayoutThemeDefault::progressValueRectFor(LayoutProgress* renderProgress,
const IntRect& rect) const |
849 { | 849 { |
850 return renderProgress->isDeterminate() ? determinateProgressValueRectFor(ren
derProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect); | 850 return renderProgress->isDeterminate() ? determinateProgressValueRectFor(ren
derProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect); |
851 } | 851 } |
852 | 852 |
853 LayoutThemeDefault::DirectionFlippingScope::DirectionFlippingScope(LayoutObject*
renderer, const PaintInfo& paintInfo, const IntRect& rect) | 853 LayoutThemeDefault::DirectionFlippingScope::DirectionFlippingScope(LayoutObject*
renderer, const PaintInfo& paintInfo, const IntRect& rect) |
854 : m_needsFlipping(!renderer->style()->isLeftToRightDirection()) | 854 : m_needsFlipping(!renderer->style()->isLeftToRightDirection()) |
855 , m_paintInfo(paintInfo) | 855 , m_paintInfo(paintInfo) |
856 { | 856 { |
857 if (!m_needsFlipping) | 857 if (!m_needsFlipping) |
858 return; | 858 return; |
859 m_paintInfo.context->save(); | 859 m_paintInfo.context->save(); |
860 m_paintInfo.context->translate(2 * rect.x() + rect.width(), 0); | 860 m_paintInfo.context->translate(2 * rect.x() + rect.width(), 0); |
861 m_paintInfo.context->scale(-1, 1); | 861 m_paintInfo.context->scale(-1, 1); |
862 } | 862 } |
863 | 863 |
864 LayoutThemeDefault::DirectionFlippingScope::~DirectionFlippingScope() | 864 LayoutThemeDefault::DirectionFlippingScope::~DirectionFlippingScope() |
865 { | 865 { |
866 if (!m_needsFlipping) | 866 if (!m_needsFlipping) |
867 return; | 867 return; |
868 m_paintInfo.context->restore(); | 868 m_paintInfo.context->restore(); |
869 } | 869 } |
870 | 870 |
871 } // namespace blink | 871 } // namespace blink |
OLD | NEW |