| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "platform/graphics/Color.h" | 35 #include "platform/graphics/Color.h" |
| 36 #include "wtf/Allocator.h" | 36 #include "wtf/Allocator.h" |
| 37 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
| 38 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class GraphicsContext; | 42 class GraphicsContext; |
| 43 class ScrollableArea; | 43 class ScrollableArea; |
| 44 | 44 |
| 45 // Unlike other platform classes, Theme does extensively use virtual functions.
This design allows a platform to switch between multiple themes at runtime. | 45 // Unlike other platform classes, Theme does extensively use virtual functions. |
| 46 // This design allows a platform to switch between multiple themes at runtime. |
| 46 class PLATFORM_EXPORT Theme { | 47 class PLATFORM_EXPORT Theme { |
| 47 USING_FAST_MALLOC(Theme); | 48 USING_FAST_MALLOC(Theme); |
| 48 WTF_MAKE_NONCOPYABLE(Theme); | 49 WTF_MAKE_NONCOPYABLE(Theme); |
| 49 | 50 |
| 50 public: | 51 public: |
| 51 Theme() {} | 52 Theme() {} |
| 52 virtual ~Theme() {} | 53 virtual ~Theme() {} |
| 53 | 54 |
| 54 // A method to obtain the baseline position adjustment for a "leaf" control.
This will only be used if a baseline | 55 // A method to obtain the baseline position adjustment for a "leaf" control. |
| 55 // position cannot be determined by examining child content. Checkboxes and ra
dio buttons are examples of | 56 // This will only be used if a baseline position cannot be determined by |
| 56 // controls that need to do this. The adjustment is an offset that adds to th
e baseline, e.g., marginTop() + height() + |offset|. | 57 // examining child content. Checkboxes and radio buttons are examples of |
| 58 // controls that need to do this. The adjustment is an offset that adds to |
| 59 // the baseline, e.g., marginTop() + height() + |offset|. |
| 57 // The offset is not zoomed. | 60 // The offset is not zoomed. |
| 58 virtual int baselinePositionAdjustment(ControlPart) const { return 0; } | 61 virtual int baselinePositionAdjustment(ControlPart) const { return 0; } |
| 59 | 62 |
| 60 // A method asking if the control changes its appearance when the window is in
active. | 63 // A method asking if the control changes its appearance when the window is |
| 64 // inactive. |
| 61 virtual bool controlHasInactiveAppearance(ControlPart) const { return false; } | 65 virtual bool controlHasInactiveAppearance(ControlPart) const { return false; } |
| 62 | 66 |
| 63 // General methods for whether or not any of the controls in the theme change
appearance when the window is inactive or | 67 // General methods for whether or not any of the controls in the theme change |
| 64 // when hovered over. | 68 // appearance when the window is inactive or when hovered over. |
| 65 virtual bool controlsCanHaveInactiveAppearance() const { return false; } | 69 virtual bool controlsCanHaveInactiveAppearance() const { return false; } |
| 66 virtual bool controlsCanHaveHoveredAppearance() const { return false; } | 70 virtual bool controlsCanHaveHoveredAppearance() const { return false; } |
| 67 | 71 |
| 68 // Used by LayoutTheme::isControlStyled to figure out if the native look and f
eel should be turned off. | 72 // Used by LayoutTheme::isControlStyled to figure out if the native look and |
| 73 // feel should be turned off. |
| 69 virtual bool controlDrawsBorder(ControlPart) const { return true; } | 74 virtual bool controlDrawsBorder(ControlPart) const { return true; } |
| 70 virtual bool controlDrawsBackground(ControlPart) const { return true; } | 75 virtual bool controlDrawsBackground(ControlPart) const { return true; } |
| 71 virtual bool controlDrawsFocusOutline(ControlPart) const { return true; } | 76 virtual bool controlDrawsFocusOutline(ControlPart) const { return true; } |
| 72 | 77 |
| 73 // Methods for obtaining platform-specific colors. | 78 // Methods for obtaining platform-specific colors. |
| 74 virtual Color selectionColor(ControlPart, ControlState, SelectionPart) const { | 79 virtual Color selectionColor(ControlPart, ControlState, SelectionPart) const { |
| 75 return Color(); | 80 return Color(); |
| 76 } | 81 } |
| 77 virtual Color textSearchHighlightColor() const { return Color(); } | 82 virtual Color textSearchHighlightColor() const { return Color(); } |
| 78 | 83 |
| 79 // CSS system colors and fonts | 84 // CSS system colors and fonts |
| 80 virtual Color systemColor(ThemeColor) const { return Color(); } | 85 virtual Color systemColor(ThemeColor) const { return Color(); } |
| 81 | 86 |
| 82 // How fast the caret blinks in text fields. | 87 // How fast the caret blinks in text fields. |
| 83 virtual double caretBlinkInterval() const { return 0.5; } | 88 virtual double caretBlinkInterval() const { return 0.5; } |
| 84 | 89 |
| 85 // Methods used to adjust the ComputedStyles of controls. | 90 // Methods used to adjust the ComputedStyles of controls. |
| 86 | 91 |
| 87 // The font description result should have a zoomed font size. | 92 // The font description result should have a zoomed font size. |
| 88 virtual FontDescription controlFont(ControlPart, | 93 virtual FontDescription controlFont(ControlPart, |
| 89 const FontDescription& fontDescription, | 94 const FontDescription& fontDescription, |
| 90 float /*zoomFactor*/) const { | 95 float /*zoomFactor*/) const { |
| 91 return fontDescription; | 96 return fontDescription; |
| 92 } | 97 } |
| 93 | 98 |
| 94 // The size here is in zoomed coordinates already. If a new size is returned,
it also needs to be in zoomed coordinates. | 99 // The size here is in zoomed coordinates already. If a new size is returned, |
| 100 // it also needs to be in zoomed coordinates. |
| 95 virtual LengthSize controlSize(ControlPart, | 101 virtual LengthSize controlSize(ControlPart, |
| 96 const FontDescription&, | 102 const FontDescription&, |
| 97 const LengthSize& zoomedSize, | 103 const LengthSize& zoomedSize, |
| 98 float /*zoomFactor*/) const { | 104 float /*zoomFactor*/) const { |
| 99 return zoomedSize; | 105 return zoomedSize; |
| 100 } | 106 } |
| 101 | 107 |
| 102 // Returns the minimum size for a control in zoomed coordinates. | 108 // Returns the minimum size for a control in zoomed coordinates. |
| 103 virtual LengthSize minimumControlSize(ControlPart, | 109 virtual LengthSize minimumControlSize(ControlPart, |
| 104 const FontDescription&, | 110 const FontDescription&, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 120 virtual bool controlRequiresPreWhiteSpace(ControlPart) const { return false; } | 126 virtual bool controlRequiresPreWhiteSpace(ControlPart) const { return false; } |
| 121 | 127 |
| 122 // Method for painting a control. The rect is in zoomed coordinates. | 128 // Method for painting a control. The rect is in zoomed coordinates. |
| 123 virtual void paint(ControlPart, | 129 virtual void paint(ControlPart, |
| 124 ControlStates, | 130 ControlStates, |
| 125 GraphicsContext&, | 131 GraphicsContext&, |
| 126 const IntRect& /*zoomedRect*/, | 132 const IntRect& /*zoomedRect*/, |
| 127 float /*zoomFactor*/, | 133 float /*zoomFactor*/, |
| 128 ScrollableArea*) const {} | 134 ScrollableArea*) const {} |
| 129 | 135 |
| 130 // Add visual overflow (e.g., the check on an OS X checkbox). The rect passed
in is in zoomed coordinates so | 136 // Add visual overflow (e.g., the check on an OS X checkbox). The rect passed |
| 131 // the inflation should take that into account and make sure the inflation amo
unt is also scaled by the zoomFactor. | 137 // in is in zoomed coordinates so the inflation should take that into account |
| 138 // and make sure the inflation amount is also scaled by the zoomFactor. |
| 132 virtual void addVisualOverflow(ControlPart, | 139 virtual void addVisualOverflow(ControlPart, |
| 133 ControlStates, | 140 ControlStates, |
| 134 float zoomFactor, | 141 float zoomFactor, |
| 135 IntRect& borderBox) const {} | 142 IntRect& borderBox) const {} |
| 136 | 143 |
| 137 private: | 144 private: |
| 138 mutable Color m_activeSelectionColor; | 145 mutable Color m_activeSelectionColor; |
| 139 mutable Color m_inactiveSelectionColor; | 146 mutable Color m_inactiveSelectionColor; |
| 140 }; | 147 }; |
| 141 | 148 |
| 142 PLATFORM_EXPORT Theme* platformTheme(); | 149 PLATFORM_EXPORT Theme* platformTheme(); |
| 143 | 150 |
| 144 } // namespace blink | 151 } // namespace blink |
| 145 | 152 |
| 146 #endif // Theme_h | 153 #endif // Theme_h |
| OLD | NEW |