Commit 5f93b7ae authored by Rob Dodson's avatar Rob Dodson Committed by Commit Bot

Replace was_focused_by_mouse_ flag.

Removes the was_focused_by_mouse_ flag implemented by a number of form elements,
and replaces it with a check for Node::WasFocusedByMouse().

R=tkent@chromium.org

Bug: 817199
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ibd8477732d5646f928c010a5c1cef853bafc38ee
Reviewed-on: https://chromium-review.googlesource.com/988352
Commit-Queue: Rob Dodson <robdodson@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548223}
parent 821174db
...@@ -51,7 +51,6 @@ HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tag_name, ...@@ -51,7 +51,6 @@ HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tag_name,
Document& document) Document& document)
: HTMLElement(tag_name, document), : HTMLElement(tag_name, document),
link_relations_(0), link_relations_(0),
was_focused_by_mouse_(false),
cached_visited_link_hash_(0), cached_visited_link_hash_(0),
rel_list_(RelList::Create(this)) {} rel_list_(RelList::Create(this)) {}
...@@ -74,27 +73,7 @@ bool HTMLAnchorElement::MatchesEnabledPseudoClass() const { ...@@ -74,27 +73,7 @@ bool HTMLAnchorElement::MatchesEnabledPseudoClass() const {
} }
bool HTMLAnchorElement::ShouldHaveFocusAppearance() const { bool HTMLAnchorElement::ShouldHaveFocusAppearance() const {
return !was_focused_by_mouse_ || HTMLElement::SupportsFocus(); return !WasFocusedByMouse() || HTMLElement::SupportsFocus();
}
void HTMLAnchorElement::DispatchFocusEvent(
Element* old_focused_element,
WebFocusType type,
InputDeviceCapabilities* source_capabilities) {
if (type != kWebFocusTypePage)
was_focused_by_mouse_ = type == kWebFocusTypeMouse;
HTMLElement::DispatchFocusEvent(old_focused_element, type,
source_capabilities);
}
void HTMLAnchorElement::DispatchBlurEvent(
Element* new_focused_element,
WebFocusType type,
InputDeviceCapabilities* source_capabilities) {
if (type != kWebFocusTypePage)
was_focused_by_mouse_ = false;
HTMLElement::DispatchBlurEvent(new_focused_element, type,
source_capabilities);
} }
bool HTMLAnchorElement::IsMouseFocusable() const { bool HTMLAnchorElement::IsMouseFocusable() const {
......
...@@ -105,13 +105,6 @@ class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils { ...@@ -105,13 +105,6 @@ class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
private: private:
void AttributeChanged(const AttributeModificationParams&) override; void AttributeChanged(const AttributeModificationParams&) override;
bool ShouldHaveFocusAppearance() const final; bool ShouldHaveFocusAppearance() const final;
void DispatchFocusEvent(
Element* old_focused_element,
WebFocusType,
InputDeviceCapabilities* source_capabilities) override;
void DispatchBlurEvent(Element* new_focused_element,
WebFocusType,
InputDeviceCapabilities* source_capabilities) override;
bool IsMouseFocusable() const override; bool IsMouseFocusable() const override;
bool IsKeyboardFocusable() const override; bool IsKeyboardFocusable() const override;
void DefaultEventHandler(Event*) final; void DefaultEventHandler(Event*) final;
...@@ -128,7 +121,6 @@ class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils { ...@@ -128,7 +121,6 @@ class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
void HandleClick(Event*); void HandleClick(Event*);
unsigned link_relations_ : 31; unsigned link_relations_ : 31;
unsigned was_focused_by_mouse_ : 1;
mutable LinkHash cached_visited_link_hash_; mutable LinkHash cached_visited_link_hash_;
TraceWrapperMember<RelList> rel_list_; TraceWrapperMember<RelList> rel_list_;
}; };
......
...@@ -61,7 +61,6 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tag_name, ...@@ -61,7 +61,6 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tag_name,
will_validate_(true), will_validate_(true),
is_valid_(true), is_valid_(true),
validity_is_dirty_(false), validity_is_dirty_(false),
was_focused_by_mouse_(false),
blocks_form_submission_(false) { blocks_form_submission_(false) {
SetHasCustomStyleCallbacks(); SetHasCustomStyleCallbacks();
} }
...@@ -409,33 +408,21 @@ bool HTMLFormControlElement::ShouldShowFocusRingOnMouseFocus() const { ...@@ -409,33 +408,21 @@ bool HTMLFormControlElement::ShouldShowFocusRingOnMouseFocus() const {
} }
bool HTMLFormControlElement::ShouldHaveFocusAppearance() const { bool HTMLFormControlElement::ShouldHaveFocusAppearance() const {
return !was_focused_by_mouse_ || ShouldShowFocusRingOnMouseFocus(); return !WasFocusedByMouse() || ShouldShowFocusRingOnMouseFocus();
}
void HTMLFormControlElement::DispatchFocusEvent(
Element* old_focused_element,
WebFocusType type,
InputDeviceCapabilities* source_capabilities) {
if (type != kWebFocusTypePage)
was_focused_by_mouse_ = type == kWebFocusTypeMouse;
// ContainerNode::handleStyleChangeOnFocusStateChange() will inform
// LayoutTheme about the focus state change.
HTMLElement::DispatchFocusEvent(old_focused_element, type,
source_capabilities);
} }
void HTMLFormControlElement::WillCallDefaultEventHandler(const Event& event) { void HTMLFormControlElement::WillCallDefaultEventHandler(const Event& event) {
if (!was_focused_by_mouse_) if (!WasFocusedByMouse())
return; return;
if (!event.IsKeyboardEvent() || event.type() != EventTypeNames::keydown) if (!event.IsKeyboardEvent() || event.type() != EventTypeNames::keydown)
return; return;
bool old_should_have_focus_appearance = ShouldHaveFocusAppearance(); bool old_should_have_focus_appearance = ShouldHaveFocusAppearance();
was_focused_by_mouse_ = false; SetWasFocusedByMouse(false);
// Change of m_wasFocusByMouse may affect shouldHaveFocusAppearance() and // Changes to WasFocusedByMouse may affect ShouldHaveFocusAppearance() and
// LayoutTheme::isFocused(). Inform LayoutTheme if // LayoutTheme::IsFocused(). Inform LayoutTheme if
// shouldHaveFocusAppearance() changes. // ShouldHaveFocusAppearance() changes.
if (old_should_have_focus_appearance != ShouldHaveFocusAppearance() && if (old_should_have_focus_appearance != ShouldHaveFocusAppearance() &&
GetLayoutObject()) { GetLayoutObject()) {
GetLayoutObject()->InvalidateIfControlStateChanged(kFocusControlState); GetLayoutObject()->InvalidateIfControlStateChanged(kFocusControlState);
...@@ -654,8 +641,6 @@ void HTMLFormControlElement::DispatchBlurEvent( ...@@ -654,8 +641,6 @@ void HTMLFormControlElement::DispatchBlurEvent(
Element* new_focused_element, Element* new_focused_element,
WebFocusType type, WebFocusType type,
InputDeviceCapabilities* source_capabilities) { InputDeviceCapabilities* source_capabilities) {
if (type != kWebFocusTypePage)
was_focused_by_mouse_ = false;
HTMLElement::DispatchBlurEvent(new_focused_element, type, HTMLElement::DispatchBlurEvent(new_focused_element, type,
source_capabilities); source_capabilities);
HideVisibleValidationMessage(); HideVisibleValidationMessage();
......
...@@ -162,10 +162,6 @@ class CORE_EXPORT HTMLFormControlElement : public LabelableElement, ...@@ -162,10 +162,6 @@ class CORE_EXPORT HTMLFormControlElement : public LabelableElement,
void DispatchBlurEvent(Element* new_focused_element, void DispatchBlurEvent(Element* new_focused_element,
WebFocusType, WebFocusType,
InputDeviceCapabilities* source_capabilities) override; InputDeviceCapabilities* source_capabilities) override;
void DispatchFocusEvent(
Element* old_focused_element,
WebFocusType,
InputDeviceCapabilities* source_capabilities) override;
void WillCallDefaultEventHandler(const Event&) final; void WillCallDefaultEventHandler(const Event&) final;
void DidRecalcStyle(StyleRecalcChange) override; void DidRecalcStyle(StyleRecalcChange) override;
...@@ -216,7 +212,6 @@ class CORE_EXPORT HTMLFormControlElement : public LabelableElement, ...@@ -216,7 +212,6 @@ class CORE_EXPORT HTMLFormControlElement : public LabelableElement,
bool is_valid_ : 1; bool is_valid_ : 1;
bool validity_is_dirty_ : 1; bool validity_is_dirty_ : 1;
bool was_focused_by_mouse_ : 1;
bool blocks_form_submission_ : 1; bool blocks_form_submission_ : 1;
}; };
......
...@@ -52,8 +52,7 @@ using namespace HTMLNames; ...@@ -52,8 +52,7 @@ using namespace HTMLNames;
inline SVGAElement::SVGAElement(Document& document) inline SVGAElement::SVGAElement(Document& document)
: SVGGraphicsElement(SVGNames::aTag, document), : SVGGraphicsElement(SVGNames::aTag, document),
SVGURIReference(this), SVGURIReference(this),
svg_target_(SVGAnimatedString::Create(this, SVGNames::targetAttr)), svg_target_(SVGAnimatedString::Create(this, SVGNames::targetAttr)) {
was_focused_by_mouse_(false) {
AddToPropertyMap(svg_target_); AddToPropertyMap(svg_target_);
} }
...@@ -164,29 +163,7 @@ bool SVGAElement::SupportsFocus() const { ...@@ -164,29 +163,7 @@ bool SVGAElement::SupportsFocus() const {
} }
bool SVGAElement::ShouldHaveFocusAppearance() const { bool SVGAElement::ShouldHaveFocusAppearance() const {
return !was_focused_by_mouse_ || SVGGraphicsElement::SupportsFocus(); return !WasFocusedByMouse() || SVGGraphicsElement::SupportsFocus();
}
// TODO(lanwei): Will add the InputDeviceCapabilities when SVGAElement gets
// focus later, see https://crbug.com/476530.
void SVGAElement::DispatchFocusEvent(
Element* old_focused_element,
WebFocusType type,
InputDeviceCapabilities* source_capabilities) {
if (type != kWebFocusTypePage)
was_focused_by_mouse_ = type == kWebFocusTypeMouse;
SVGGraphicsElement::DispatchFocusEvent(old_focused_element, type,
source_capabilities);
}
void SVGAElement::DispatchBlurEvent(
Element* new_focused_element,
WebFocusType type,
InputDeviceCapabilities* source_capabilities) {
if (type != kWebFocusTypePage)
was_focused_by_mouse_ = false;
SVGGraphicsElement::DispatchBlurEvent(new_focused_element, type,
source_capabilities);
} }
bool SVGAElement::IsURLAttribute(const Attribute& attribute) const { bool SVGAElement::IsURLAttribute(const Attribute& attribute) const {
......
...@@ -55,13 +55,6 @@ class CORE_EXPORT SVGAElement final : public SVGGraphicsElement, ...@@ -55,13 +55,6 @@ class CORE_EXPORT SVGAElement final : public SVGGraphicsElement,
bool SupportsFocus() const override; bool SupportsFocus() const override;
bool ShouldHaveFocusAppearance() const final; bool ShouldHaveFocusAppearance() const final;
void DispatchFocusEvent(
Element* old_focused_element,
WebFocusType,
InputDeviceCapabilities* source_capabilities) override;
void DispatchBlurEvent(Element* new_focused_element,
WebFocusType,
InputDeviceCapabilities* source_capabilities) override;
bool IsMouseFocusable() const override; bool IsMouseFocusable() const override;
bool IsKeyboardFocusable() const override; bool IsKeyboardFocusable() const override;
bool IsURLAttribute(const Attribute&) const override; bool IsURLAttribute(const Attribute&) const override;
...@@ -71,7 +64,6 @@ class CORE_EXPORT SVGAElement final : public SVGGraphicsElement, ...@@ -71,7 +64,6 @@ class CORE_EXPORT SVGAElement final : public SVGGraphicsElement,
bool WillRespondToMouseClickEvents() override; bool WillRespondToMouseClickEvents() override;
Member<SVGAnimatedString> svg_target_; Member<SVGAnimatedString> svg_target_;
bool was_focused_by_mouse_;
}; };
} // namespace blink } // namespace blink
......
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