Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 455223002: Make anchors mouse-focusable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 16 matching lines...) Expand all
27 27
28 #include "core/events/Event.h" 28 #include "core/events/Event.h"
29 #include "core/html/HTMLDataListElement.h" 29 #include "core/html/HTMLDataListElement.h"
30 #include "core/html/HTMLFieldSetElement.h" 30 #include "core/html/HTMLFieldSetElement.h"
31 #include "core/html/HTMLFormElement.h" 31 #include "core/html/HTMLFormElement.h"
32 #include "core/html/HTMLInputElement.h" 32 #include "core/html/HTMLInputElement.h"
33 #include "core/html/HTMLLegendElement.h" 33 #include "core/html/HTMLLegendElement.h"
34 #include "core/html/ValidityState.h" 34 #include "core/html/ValidityState.h"
35 #include "core/frame/UseCounter.h" 35 #include "core/frame/UseCounter.h"
36 #include "core/inspector/ConsoleMessage.h" 36 #include "core/inspector/ConsoleMessage.h"
37 #include "core/page/FocusController.h"
37 #include "core/page/Page.h" 38 #include "core/page/Page.h"
38 #include "core/page/ValidationMessageClient.h" 39 #include "core/page/ValidationMessageClient.h"
39 #include "core/rendering/RenderBox.h" 40 #include "core/rendering/RenderBox.h"
40 #include "core/rendering/RenderTheme.h" 41 #include "core/rendering/RenderTheme.h"
41 #include "platform/text/BidiTextRun.h" 42 #include "platform/text/BidiTextRun.h"
42 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 using namespace HTMLNames; 47 using namespace HTMLNames;
47 48
48 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument& document, HTMLFormElement* form) 49 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument& document, HTMLFormElement* form)
49 : LabelableElement(tagName, document) 50 : LabelableElement(tagName, document)
50 , m_disabled(false) 51 , m_disabled(false)
51 , m_isAutofilled(false) 52 , m_isAutofilled(false)
52 , m_isReadOnly(false) 53 , m_isReadOnly(false)
53 , m_isRequired(false) 54 , m_isRequired(false)
54 , m_hasValidationMessage(false) 55 , m_hasValidationMessage(false)
55 , m_ancestorDisabledState(AncestorDisabledStateUnknown) 56 , m_ancestorDisabledState(AncestorDisabledStateUnknown)
56 , m_dataListAncestorState(Unknown) 57 , m_dataListAncestorState(Unknown)
57 , m_willValidateInitialized(false) 58 , m_willValidateInitialized(false)
58 , m_willValidate(true) 59 , m_willValidate(true)
59 , m_isValid(true) 60 , m_isValid(true)
60 , m_wasChangedSinceLastFormControlChangeEvent(false) 61 , m_wasChangedSinceLastFormControlChangeEvent(false)
61 , m_wasFocusedByMouse(false)
62 { 62 {
63 setHasCustomStyleCallbacks(); 63 setHasCustomStyleCallbacks();
64 associateByParser(form); 64 associateByParser(form);
65 } 65 }
66 66
67 HTMLFormControlElement::~HTMLFormControlElement() 67 HTMLFormControlElement::~HTMLFormControlElement()
68 { 68 {
69 #if !ENABLE(OILPAN) 69 #if !ENABLE(OILPAN)
70 setForm(0); 70 setForm(0);
71 #endif 71 #endif
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 { 326 {
327 // Skip tabIndex check in a parent class. 327 // Skip tabIndex check in a parent class.
328 return isFocusable(); 328 return isFocusable();
329 } 329 }
330 330
331 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const 331 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const
332 { 332 {
333 return false; 333 return false;
334 } 334 }
335 335
336 void HTMLFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, Focu sType type)
337 {
338 if (type != FocusTypePage)
339 m_wasFocusedByMouse = type == FocusTypeMouse;
340 HTMLElement::dispatchFocusEvent(oldFocusedElement, type);
341 }
342
343 bool HTMLFormControlElement::shouldHaveFocusAppearance() const 336 bool HTMLFormControlElement::shouldHaveFocusAppearance() const
344 { 337 {
345 ASSERT(focused()); 338 ASSERT(focused());
346 return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse; 339 return shouldShowFocusRingOnMouseFocus() || !document().page()->focusControl ler().wasFocusedByMouse();
347 } 340 }
348 341
349 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event)
350 {
351 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown)
352 return;
353 if (!m_wasFocusedByMouse)
354 return;
355 m_wasFocusedByMouse = false;
356 if (renderer())
357 renderer()->setShouldDoFullPaintInvalidation(true);
358 }
359
360
361 short HTMLFormControlElement::tabIndex() const 342 short HTMLFormControlElement::tabIndex() const
362 { 343 {
363 // Skip the supportsFocus check in HTMLElement. 344 // Skip the supportsFocus check in HTMLElement.
364 return Element::tabIndex(); 345 return Element::tabIndex();
365 } 346 }
366 347
367 bool HTMLFormControlElement::recalcWillValidate() const 348 bool HTMLFormControlElement::recalcWillValidate() const
368 { 349 {
369 if (m_dataListAncestorState == Unknown) { 350 if (m_dataListAncestorState == Unknown) {
370 if (Traversal<HTMLDataListElement>::firstAncestor(*this)) 351 if (Traversal<HTMLDataListElement>::firstAncestor(*this))
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 528
548 void HTMLFormControlElement::setFocus(bool flag) 529 void HTMLFormControlElement::setFocus(bool flag)
549 { 530 {
550 LabelableElement::setFocus(flag); 531 LabelableElement::setFocus(flag);
551 532
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 533 if (!flag && wasChangedSinceLastFormControlChangeEvent())
553 dispatchFormControlChangeEvent(); 534 dispatchFormControlChangeEvent();
554 } 535 }
555 536
556 } // namespace Webcore 537 } // namespace Webcore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698