Commit f5d7e4c2 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[cleanup] Remove LayoutTheme::ControlStatesForNode

There was only one caller for this within:
ThemePainterDefault::PaintInnerSpinButton
This replaces that one caller with the equivilent logic.

Removes other auxillary methods only used within ControlStatesForNode,
e.g. LayoutTheme::IsFocused

There should be no behaviour change.

Change-Id: I0717e4fe9dd5c0ec9448f916e38671b2a37b8539
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363325Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799893}
parent 9c215b93
...@@ -453,45 +453,6 @@ bool LayoutTheme::ControlStateChanged(const Node* node, ...@@ -453,45 +453,6 @@ bool LayoutTheme::ControlStateChanged(const Node* node,
return true; return true;
} }
ControlStates LayoutTheme::ControlStatesForNode(const Node* node,
const ComputedStyle& style) {
ControlStates result = 0;
if (IsHovered(node)) {
result |= kHoverControlState;
if (IsSpinUpButtonPartHovered(node))
result |= kSpinUpControlState;
}
if (IsPressed(node)) {
result |= kPressedControlState;
if (IsSpinUpButtonPartPressed(node))
result |= kSpinUpControlState;
}
if (IsFocused(node) && style.OutlineStyleIsAuto())
result |= kFocusControlState;
if (IsEnabled(node))
result |= kEnabledControlState;
if (IsChecked(node))
result |= kCheckedControlState;
if (IsReadOnlyControl(node))
result |= kReadOnlyControlState;
if (!IsActive(node))
result |= kWindowInactiveControlState;
if (IsIndeterminate(node))
result |= kIndeterminateControlState;
return result;
}
bool LayoutTheme::IsActive(const Node* node) {
if (!node)
return false;
Page* page = node->GetDocument().GetPage();
if (!page)
return false;
return page->GetFocusController().IsActive();
}
bool LayoutTheme::IsChecked(const Node* node) { bool LayoutTheme::IsChecked(const Node* node) {
if (auto* input = DynamicTo<HTMLInputElement>(node)) if (auto* input = DynamicTo<HTMLInputElement>(node))
return input->ShouldAppearChecked(); return input->ShouldAppearChecked();
...@@ -511,31 +472,12 @@ bool LayoutTheme::IsEnabled(const Node* node) { ...@@ -511,31 +472,12 @@ bool LayoutTheme::IsEnabled(const Node* node) {
return !element->IsDisabledFormControl(); return !element->IsDisabledFormControl();
} }
bool LayoutTheme::IsFocused(const Node* node) {
if (!node)
return false;
node = node->FocusDelegate();
Document& document = node->GetDocument();
LocalFrame* frame = document.GetFrame();
return node == document.FocusedElement() && node->IsFocused() &&
node->ShouldHaveFocusAppearance() && frame &&
frame->Selection().FrameIsFocusedAndActive();
}
bool LayoutTheme::IsPressed(const Node* node) { bool LayoutTheme::IsPressed(const Node* node) {
if (!node) if (!node)
return false; return false;
return node->IsActive(); return node->IsActive();
} }
bool LayoutTheme::IsSpinUpButtonPartPressed(const Node* node) {
const auto* element = DynamicTo<SpinButtonElement>(node);
if (!element || !element->IsActive())
return false;
return element->GetUpDownState() == SpinButtonElement::kUp;
}
bool LayoutTheme::IsReadOnlyControl(const Node* node) { bool LayoutTheme::IsReadOnlyControl(const Node* node) {
auto* form_control_element = DynamicTo<HTMLFormControlElement>(node); auto* form_control_element = DynamicTo<HTMLFormControlElement>(node);
return form_control_element && form_control_element->IsReadOnly(); return form_control_element && form_control_element->IsReadOnly();
...@@ -547,13 +489,6 @@ bool LayoutTheme::IsHovered(const Node* node) { ...@@ -547,13 +489,6 @@ bool LayoutTheme::IsHovered(const Node* node) {
return node->IsHovered(); return node->IsHovered();
} }
bool LayoutTheme::IsSpinUpButtonPartHovered(const Node* node) {
const auto* element = DynamicTo<SpinButtonElement>(node);
if (!element)
return false;
return element->GetUpDownState() == SpinButtonElement::kUp;
}
void LayoutTheme::AdjustCheckboxStyle(ComputedStyle& style) const { void LayoutTheme::AdjustCheckboxStyle(ComputedStyle& style) const {
// A summary of the rules for checkbox designed to match WinIE: // A summary of the rules for checkbox designed to match WinIE:
// width/height - honored (WinIE actually scales its control for small widths, // width/height - honored (WinIE actually scales its control for small widths,
......
...@@ -254,16 +254,11 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> { ...@@ -254,16 +254,11 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> {
public: public:
// Methods for state querying // Methods for state querying
static ControlStates ControlStatesForNode(const Node*, const ComputedStyle&);
static bool IsActive(const Node*);
static bool IsChecked(const Node*); static bool IsChecked(const Node*);
static bool IsIndeterminate(const Node*); static bool IsIndeterminate(const Node*);
static bool IsEnabled(const Node*); static bool IsEnabled(const Node*);
static bool IsFocused(const Node*);
static bool IsPressed(const Node*); static bool IsPressed(const Node*);
static bool IsSpinUpButtonPartPressed(const Node*);
static bool IsHovered(const Node*); static bool IsHovered(const Node*);
static bool IsSpinUpButtonPartHovered(const Node*);
static bool IsReadOnlyControl(const Node*); static bool IsReadOnlyControl(const Node*);
protected: protected:
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "third_party/blink/public/resources/grit/blink_image_resources.h" #include "third_party/blink/public/resources/grit/blink_image_resources.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/spin_button_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_progress.h" #include "third_party/blink/renderer/core/layout/layout_progress.h"
...@@ -421,8 +422,14 @@ bool ThemePainterDefault::PaintInnerSpinButton(const Node* node, ...@@ -421,8 +422,14 @@ bool ThemePainterDefault::PaintInnerSpinButton(const Node* node,
const IntRect& rect) { const IntRect& rect) {
WebThemeEngine::ExtraParams extra_params; WebThemeEngine::ExtraParams extra_params;
cc::PaintCanvas* canvas = paint_info.context.Canvas(); cc::PaintCanvas* canvas = paint_info.context.Canvas();
extra_params.inner_spin.spin_up =
(LayoutTheme::ControlStatesForNode(node, style) & kSpinUpControlState); bool spin_up = false;
if (const auto* element = DynamicTo<SpinButtonElement>(node)) {
if (element->GetUpDownState() == SpinButtonElement::kUp)
spin_up = node->IsHovered() || node->IsActive();
}
extra_params.inner_spin.spin_up = spin_up;
extra_params.inner_spin.read_only = LayoutTheme::IsReadOnlyControl(node); extra_params.inner_spin.read_only = LayoutTheme::IsReadOnlyControl(node);
Platform::Current()->ThemeEngine()->Paint( Platform::Current()->ThemeEngine()->Paint(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment