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

Unified Diff: third_party/WebKit/Source/core/html/HTMLLabelElement.cpp

Issue 1802263002: Add three UseCounters for LABEL element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp b/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
index d474a6f561b5ac41f302afb2d1a36d3633fdcb12..95712d3b6d8f9bfada160f969265b573bb6eec7b 100644
--- a/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
@@ -34,6 +34,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
#include "core/html/FormAssociatedElement.h"
+#include "core/html/HTMLFormControlElement.h"
#include "core/input/EventHandler.h"
#include "core/layout/LayoutObject.h"
@@ -62,15 +63,21 @@ LabelableElement* HTMLLabelElement::control() const
// per http://dev.w3.org/html5/spec/Overview.html#the-label-element
// the form element must be "labelable form-associated element".
for (LabelableElement& element : Traversal<LabelableElement>::descendantsOf(*this)) {
- if (element.supportLabels())
+ if (element.supportLabels()) {
+ if (!element.isFormControlElement())
+ UseCounter::count(document(), UseCounter::HTMLLabelElementControlForNonFormAssociatedElement);
return &element;
+ }
}
return nullptr;
}
if (Element* element = treeScope().getElementById(controlId)) {
- if (isLabelableElement(*element) && toLabelableElement(*element).supportLabels())
+ if (isLabelableElement(*element) && toLabelableElement(*element).supportLabels()) {
+ if (!element->isFormControlElement())
+ UseCounter::count(document(), UseCounter::HTMLLabelElementControlForNonFormAssociatedElement);
return toLabelableElement(element);
+ }
}
return nullptr;
@@ -81,6 +88,21 @@ HTMLFormElement* HTMLLabelElement::formOwner() const
return FormAssociatedElement::form();
}
+HTMLFormElement* HTMLLabelElement::formForBinding() const
+{
+ HTMLFormElement* formOwner = FormAssociatedElement::form();
+ HTMLFormElement* controlForm = nullptr;
+ if (LabelableElement* control = this->control()) {
+ if (control->isFormControlElement())
+ controlForm = toHTMLFormControlElement(control)->form();
+ }
+ if (formOwner != controlForm)
+ UseCounter::count(document(), UseCounter::HTMLLabelElementFormIsDifferentFromControlForm);
+ if (!controlForm && formOwner && formOwner == findFormAncestor())
+ UseCounter::count(document(), UseCounter::HTMLLabelElementHasNoControlAndFormIsAncestor);
+ return formOwner;
+}
+
void HTMLLabelElement::setActive(bool down)
{
if (down != active()) {
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLLabelElement.h ('k') | third_party/WebKit/Source/core/html/HTMLLabelElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698