bool SVGAElement::isMouseFocusable() const { if (isLink()) return supportsFocus(); return SVGElement::isMouseFocusable(); }
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; }
bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { wxWindow* window = o->view()->frameView()->nativeWindow(); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); wxASSERT(dc->IsOk()); int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; EAppearance appearance = o->style()->appearance(); if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if (appearance == PushButtonAppearance || appearance == ButtonAppearance) wxRendererNative::Get().DrawPushButton(window, *dc, r, flags); // TODO: add a radio button rendering API to wx //else if(appearance == RadioAppearance) else if(appearance == CheckboxAppearance) { if (isChecked(o)) flags |= wxCONTROL_CHECKED; wxRendererNative::Get().DrawCheckBox(window, *dc, r, flags); } return false; }
bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { wxScrolledWindow* window = o->view()->frameView()->nativeWindow(); wxPaintDC dc((wxWindow*)window); window->DoPrepareDC(dc); int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; EAppearance appearance = o->style()->appearance(); if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if(appearance == PushButtonAppearance || appearance == ButtonAppearance) wxRendererNative::Get().DrawPushButton(window, dc, r, flags); // TODO: add a radio button rendering API to wx //else if(appearance == RadioAppearance) // wxRendererNative::Get(). else if(appearance == CheckboxAppearance) wxRendererNative::Get().DrawCheckBox(window, dc, r, flags); return false; }
bool RenderThemeWx::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) { wxWindow* window = nativeWindowForRenderObject(o); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); LocalDC localDC(dc, r); IntRect rect = r; int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; #if wxCHECK_VERSION(2,9,0) wxRendererNative::Get().DrawChoice(window, *localDC.context(), rect, flags); #else wxRenderer_DrawChoice(window, *localDC.context(), rect, flags); #endif return false; }
bool HTMLAreaElement::rendererIsFocusable() const { HTMLImageElement* image = imageElement(); if (!image || !image->renderer() || image->renderer()->style()->visibility() != VISIBLE) return false; return supportsFocus() && Element::tabIndex() >= 0; }
EAppearance RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const { // Default bits: no focus, no mouse over option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); if (!isEnabled(o)) option.state &= ~QStyle::State_Enabled; if (isReadOnlyControl(o)) // Readonly is supported on textfields. option.state |= QStyle::State_ReadOnly; if (supportsFocus(o->style()->appearance()) && isFocused(o)) option.state |= QStyle::State_HasFocus; if (isHovered(o)) option.state |= QStyle::State_MouseOver; EAppearance result = o->style()->appearance(); switch (result) { case PushButtonAppearance: case SquareButtonAppearance: case ButtonAppearance: case ButtonBevelAppearance: case ListItemAppearance: case MenulistButtonAppearance: case ScrollbarButtonLeftAppearance: case ScrollbarButtonRightAppearance: case ScrollbarTrackHorizontalAppearance: case ScrollbarTrackVerticalAppearance: case ScrollbarThumbHorizontalAppearance: case ScrollbarThumbVerticalAppearance: case SearchFieldResultsButtonAppearance: case SearchFieldCancelButtonAppearance: { if (isPressed(o)) option.state |= QStyle::State_Sunken; else if (result == PushButtonAppearance) option.state |= QStyle::State_Raised; break; } } if(result == RadioAppearance || result == CheckboxAppearance) option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); // If the webview has a custom palette, use it Page *page = o->document()->page(); if (page) { QWidget *view = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage->view(); if (view) option.palette = view->palette(); } return result; }
unsigned RenderThemeChromiumWin::determineSliderThumbState(RenderObject* o) { unsigned result = TUS_NORMAL; if (!isEnabled(o->parent())) result = TUS_DISABLED; else if (supportsFocus(o->style()->appearance()) && isFocused(o->parent())) result = TUS_FOCUSED; else if (static_cast<RenderSlider*>(o->parent())->inDragMode()) result = TUS_PRESSED; else if (isHovered(o)) result = TUS_HOT; return result; }
void HTMLElement::handleKeypressEvent(KeyboardEvent* event) { if (!isSpatialNavigationEnabled(document().frame()) || !supportsFocus()) return; // if the element is a text form control (like <input type=text> or <textarea>) // or has contentEditable attribute on, we should enter a space or newline // even in spatial navigation mode instead of handling it as a "click" action. if (isTextFormControl() || isContentEditable()) return; int charCode = event->charCode(); if (charCode == '\r' || charCode == ' ') { dispatchSimulatedClick(event); event->setDefaultHandled(); } }
EAppearance RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const { // Default bits: no focus, no mouse over option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); if (!isEnabled(o)) option.state &= ~QStyle::State_Enabled; if (isReadOnlyControl(o)) // Readonly is supported on textfields. option.state |= QStyle::State_ReadOnly; if (supportsFocus(o->style()->appearance()) && isFocused(o)) option.state |= QStyle::State_HasFocus; if (isHovered(o)) option.state |= QStyle::State_MouseOver; EAppearance result = o->style()->appearance(); switch (result) { case PushButtonAppearance: case SquareButtonAppearance: case ButtonAppearance: case ButtonBevelAppearance: case ListItemAppearance: case MenulistButtonAppearance: case ScrollbarButtonLeftAppearance: case ScrollbarButtonRightAppearance: case ScrollbarTrackHorizontalAppearance: case ScrollbarTrackVerticalAppearance: case ScrollbarThumbHorizontalAppearance: case ScrollbarThumbVerticalAppearance: case SearchFieldResultsButtonAppearance: case SearchFieldCancelButtonAppearance: { if (isPressed(o)) option.state |= QStyle::State_Sunken; else if (result == PushButtonAppearance) option.state |= QStyle::State_Raised; break; } } if(result == RadioAppearance || result == CheckboxAppearance) option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); return result; }
unsigned RenderThemeGdk::determineState(RenderObject* o) { unsigned result = TS_NORMAL; if (!isEnabled(o)) result = TS_DISABLED; else if (isReadOnlyControl(o)) result = TFS_READONLY; // Readonly is supported on textfields. else if (supportsFocus(o->style()->appearance()) && isFocused(o)) result = TS_FOCUSED; else if (isPressed(o)) result = TS_ACTIVE; else if (isHovered(o)) result = TS_HOVER; if (isChecked(o)) result += 4; // 4 unchecked states, 4 checked states. return result; }
unsigned RenderThemeChromiumWin::determineState(RenderObject* o) { unsigned result = TS_NORMAL; ControlPart appearance = o->style()->appearance(); if (!isEnabled(o)) result = TS_DISABLED; else if (isReadOnlyControl(o) && (TextFieldPart == appearance || TextAreaPart == appearance || SearchFieldPart == appearance)) result = ETS_READONLY; // Readonly is supported on textfields. else if (isPressed(o)) // Active overrides hover and focused. result = TS_PRESSED; else if (supportsFocus(appearance) && isFocused(o)) result = ETS_FOCUSED; else if (isHovered(o)) result = TS_HOT; if (isChecked(o)) result += 4; // 4 unchecked states, 4 checked states. return result; }
bool RenderThemeWx::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r) { wxWindow* window = nativeWindowForRenderObject(o); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); LocalDC localDC(dc, r); int flags = 0; IntRect rect = r; ControlPart part = o->style()->appearance(); if (supportsFocus(part) && isFocused(o)) flags |= wxCONTROL_FOCUSED; #if wxCHECK_VERSION(2,9,0) wxRendererNative::Get().DrawTextCtrl(window, *localDC.context(), rect, flags); #else wxRenderer_DrawTextCtrl(window, *localDC.context(), r, 0); #endif return false; }
bool RenderThemeWx::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r) { wxWindow* window = nativeWindowForRenderObject(o); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); LocalDC localDC(dc, r); int flags = 0; IntRect rect = r; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; ControlPart part = o->style()->appearance(); if (supportsFocus(part) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if (part == PushButtonPart || part == ButtonPart) wxRendererNative::Get().DrawPushButton(window, *localDC.context(), rect, flags); else if(part == RadioPart) { if (isChecked(o)) flags |= wxCONTROL_CHECKED; #if wxCHECK_VERSION(2,9,1) wxRendererNative::Get().DrawRadioBitmap(window, *localDC.context(), rect, flags); #elif wxCHECK_VERSION(2,9,0) wxRendererNative::Get().DrawRadioButton(window, *localDC.context(), rect, flags); #else wxRenderer_DrawRadioButton(window, *localDC.context(), rect, flags); #endif } else if(part == CheckboxPart) { if (isChecked(o)) flags |= wxCONTROL_CHECKED; wxRendererNative::Get().DrawCheckBox(window, *localDC.context(), rect, flags); } return false; }
void Element::focus(bool restorePreviousSelection) { Document* doc = document(); if (doc->focusedNode() == this) return; doc->updateLayoutIgnorePendingStylesheets(); if (!supportsFocus()) return; if (Page* page = doc->page()) page->focusController()->setFocusedNode(this, doc->frame()); if (!isFocusable()) { ensureRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(true); return; } cancelFocusAppearanceUpdate(); updateFocusAppearance(restorePreviousSelection); }
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; }
short SVGElement::tabIndex() const { if (supportsFocus()) return Element::tabIndex(); return -1; }
bool RenderThemeGtk::supportsFocusRing(const RenderStyle& style) const { return supportsFocus(style.appearance()); }
bool HTMLOptionElement::isFocusable() const { // Option elements do not have a renderer so we check the renderStyle instead. return supportsFocus() && renderStyle() && renderStyle()->display() != NONE; }
void HTMLElement::handleKeypressEvent(KeyboardEvent* event) { if (!document()->settings() || !document()->settings()->spatialNavigationEnabled() || !supportsFocus()) return; int charCode = event->charCode(); if (charCode == '\r' || charCode == ' ') { dispatchSimulatedClick(event); event->setDefaultHandled(); } }
bool RenderThemeQt::supportsFocusRing(const RenderStyle* style) const { return supportsFocus(style->appearance()); }