ControlStates::States RenderTheme::extractControlStatesForRenderer(const RenderObject& o) const { ControlStates::States states = 0; if (isHovered(o)) { states |= ControlStates::HoverState; if (isSpinUpButtonPartHovered(o)) states |= ControlStates::SpinUpState; } if (isPressed(o)) { states |= ControlStates::PressedState; if (isSpinUpButtonPartPressed(o)) states |= ControlStates::SpinUpState; } if (isFocused(o) && o.style().outlineStyleIsAuto()) states |= ControlStates::FocusState; if (isEnabled(o)) states |= ControlStates::EnabledState; if (isChecked(o)) states |= ControlStates::CheckedState; if (isDefault(o)) states |= ControlStates::DefaultState; if (!isActive(o)) states |= ControlStates::WindowInactiveState; if (isIndeterminate(o)) states |= ControlStates::IndeterminateState; return states; }
ControlStates RenderTheme::controlStatesForRenderer(const RenderObject* o) const { ControlStates result = 0; if (isHovered(o)) { result |= HoverState; if (isSpinUpButtonPartHovered(o)) result |= SpinUpState; } if (isPressed(o)) { result |= PressedState; if (isSpinUpButtonPartPressed(o)) result |= SpinUpState; } if (isFocused(o) && o->style()->outlineStyleIsAuto()) result |= FocusState; if (isEnabled(o)) result |= EnabledState; if (isChecked(o)) result |= CheckedState; if (isReadOnlyControl(o)) result |= ReadOnlyState; if (isDefault(o)) result |= DefaultState; if (!isActive(o)) result |= WindowInactiveState; if (isIndeterminate(o)) result |= IndeterminateState; return result; }
unsigned RenderThemeChromiumWin::determineState(RenderObject* o, ControlSubPart subPart) { unsigned result = TS_NORMAL; ControlPart appearance = o->style()->appearance(); if (!isEnabled(o)) result = TS_DISABLED; else if (isReadOnlyControl(o)) result = (appearance == TextFieldPart || appearance == TextAreaPart || appearance == SearchFieldPart) ? ETS_READONLY : TS_DISABLED; // Active overrides hover and focused. else if (isPressed(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartPressed(o)) result = TS_PRESSED; else if (supportsFocus(appearance) && isFocused(o)) result = ETS_FOCUSED; else if (isHovered(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartHovered(o)) result = TS_HOT; // CBS_UNCHECKED*: 1-4 // CBS_CHECKED*: 5-8 // CBS_MIXED*: 9-12 if (isIndeterminate(o)) result += 8; else if (isChecked(o)) result += 4; return result; }
ControlStates LayoutTheme::controlStatesForLayoutObject(const LayoutObject& o) { ControlStates result = 0; if (isHovered(o)) { result |= HoverControlState; if (isSpinUpButtonPartHovered(o)) result |= SpinUpControlState; } if (isPressed(o)) { result |= PressedControlState; if (isSpinUpButtonPartPressed(o)) result |= SpinUpControlState; } if (isFocused(o) && o.style()->outlineStyleIsAuto()) result |= FocusControlState; if (isEnabled(o)) result |= EnabledControlState; if (isChecked(o)) result |= CheckedControlState; if (isReadOnlyControl(o)) result |= ReadOnlyControlState; if (!isActive(o)) result |= WindowInactiveControlState; if (isIndeterminate(o)) result |= IndeterminateControlState; return result; }
bool RenderThemeNix::paintInnerSpinButton(RenderObject* o, const PaintInfo& i, const IntRect& rect) { WebKit::WebThemeEngine::InnerSpinButtonExtraParams extraParams; extraParams.spinUp = isSpinUpButtonPartPressed(o); extraParams.readOnly = isReadOnlyControl(o); themeEngine()->paintInnerSpinButton(webCanvas(i), getWebThemeState(this, o), WebKit::WebRect(rect), extraParams); return false; }
unsigned RenderThemeChromiumWin::determineClassicState(RenderObject* o, ControlSubPart subPart) { unsigned result = 0; ControlPart part = o->style()->appearance(); // Sliders are always in the normal state. if (part == SliderHorizontalPart || part == SliderVerticalPart) return result; // So are readonly text fields. if (isReadOnlyControl(o) && (part == TextFieldPart || part == TextAreaPart || part == SearchFieldPart)) return result; if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) { if (!isEnabled(o->parent())) result = DFCS_INACTIVE; else if (toRenderSlider(o->parent())->inDragMode()) // Active supersedes hover result = DFCS_PUSHED; else if (isHovered(o)) result = DFCS_HOT; } else { if (!isEnabled(o) || isReadOnlyControl(o)) result = DFCS_INACTIVE; // Active supersedes hover else if (isPressed(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartPressed(o)) result = DFCS_PUSHED; else if (supportsFocus(part) && isFocused(o)) // So does focused result = 0; else if (isHovered(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartHovered(o)) result = DFCS_HOT; // Classic theme can't represent indeterminate states. Use unchecked appearance. if (isChecked(o) && !isIndeterminate(o)) result |= DFCS_CHECKED; } return result; }
bool RenderThemeGtk::paintInnerSpinButton(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) { // We expand the painted area by 2 pixels on the top and bottom and 2 pixels on the right. This // is because GTK+ themes want to draw over the text box borders, but WebCore renders the inner // spin button inside the text box. IntRect expandedRect(rect); expandedRect.inflateY(2); expandedRect.setWidth(rect.width() + 2); WidgetRenderingContext widgetContext(paintInfo.context, expandedRect); GtkWidget* widget = gtkSpinButton(); gtk_widget_set_direction(widget, gtkTextDirection(renderObject->style().direction())); IntRect fullSpinButtonRect(IntPoint(), expandedRect.size()); widgetContext.gtkPaintBox(fullSpinButtonRect, widget, GTK_STATE_NORMAL, GTK_SHADOW_IN, "spinbutton"); bool upPressed = isSpinUpButtonPartPressed(renderObject); bool upHovered = isSpinUpButtonPartHovered(renderObject); bool controlActive = isEnabled(renderObject) && !isReadOnlyControl(renderObject); GtkShadowType shadowType = upPressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; GtkStateType stateType = GTK_STATE_INSENSITIVE; if (controlActive) { if (isPressed(renderObject) && upPressed) stateType = GTK_STATE_ACTIVE; else if (isHovered(renderObject) && upHovered) stateType = GTK_STATE_PRELIGHT; else stateType = GTK_STATE_NORMAL; } IntRect topRect(IntPoint(), expandedRect.size()); topRect.setHeight(expandedRect.height() / 2); widgetContext.gtkPaintBox(topRect, widget, stateType, shadowType, "spinbutton_up"); // The arrow size/position calculation here is based on the arbitrary gymnastics that happen // in gtkspinbutton.c. It isn't pretty there and it isn't pretty here. This manages to make // the button look native for many themes though. IntRect arrowRect; int arrowSize = (expandedRect.width() - 3) / 2; arrowSize -= (arrowSize % 2) - 1; // Force odd. arrowRect.setWidth(arrowSize); arrowRect.setHeight(arrowSize); arrowRect.move((expandedRect.width() - arrowRect.width()) / 2, (topRect.height() - arrowRect.height()) / 2 + 1); widgetContext.gtkPaintArrow(arrowRect, widget, stateType, shadowType, GTK_ARROW_UP, "spinbutton"); shadowType = isPressed(renderObject) && !upPressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; if (controlActive) { if (isPressed(renderObject) && !upPressed) stateType = GTK_STATE_ACTIVE; else if (isHovered(renderObject) && !upHovered) stateType = GTK_STATE_PRELIGHT; else stateType = GTK_STATE_NORMAL; } IntRect bottomRect(IntPoint(0, expandedRect.height() / 2), expandedRect.size()); bottomRect.setHeight(expandedRect.height() - bottomRect.y()); widgetContext.gtkPaintBox(bottomRect, widget, stateType, shadowType, "spinbutton_down"); arrowRect.setY(arrowRect.y() + bottomRect.y() - 1); widgetContext.gtkPaintArrow(arrowRect, widget, stateType, shadowType, GTK_ARROW_DOWN, "spinbutton"); return false; }