Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLInputElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp |
| index 23f071a0b8da839e20580bcdea31d4f25a35651b..6739253b0635f0753b3d5290ebdf20ba56606473 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp |
| @@ -36,6 +36,7 @@ |
| #include "core/InputTypeNames.h" |
| #include "core/dom/AXObjectCache.h" |
| #include "core/dom/Document.h" |
| +#include "core/dom/ElementVisibilityObserver.h" |
| #include "core/dom/ExecutionContextTask.h" |
| #include "core/dom/IdTargetObserver.h" |
| #include "core/dom/StyleChangeReason.h" |
| @@ -139,6 +140,7 @@ DEFINE_TRACE(HTMLInputElement) |
| visitor->trace(m_inputTypeView); |
| visitor->trace(m_listAttributeTargetObserver); |
| visitor->trace(m_imageLoader); |
| + visitor->trace(m_passwordVisibilityObserver); |
| HTMLTextFormControlElement::trace(visitor); |
| } |
| @@ -422,6 +424,8 @@ void HTMLInputElement::initializeTypeInParsing() |
| m_inputTypeView->updateView(); |
| setTextAsOfLastFormControlChangeEvent(value()); |
| setChangedSinceLastFormControlChangeEvent(false); |
| + |
| + updateVisibilityObserver(newTypeName); |
| } |
| void HTMLInputElement::updateType() |
| @@ -449,6 +453,8 @@ void HTMLInputElement::updateType() |
| setNeedsWillValidateCheck(); |
| + updateVisibilityObserver(newTypeName); |
| + |
| bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); |
| if (didStoreValue && !willStoreValue && hasDirtyValue()) { |
| @@ -1890,6 +1896,24 @@ bool HTMLInputElement::shouldDispatchFormControlChangeEvent(String& oldValue, St |
| return m_inputType->shouldDispatchFormControlChangeEvent(oldValue, newValue); |
| } |
| +void HTMLInputElement::updateVisibilityObserver(const AtomicString& newTypeName) |
| +{ |
| + if (newTypeName == "password") { |
| + m_passwordVisibilityObserver = new ElementVisibilityObserver(this, WTF::bind(&HTMLInputElement::onVisibilityChangedForPasswordInput, wrapWeakPersistent(this))); |
|
esprehn
2016/09/27 23:32:35
Lets make this a member of the PasswordManagerType
|
| + m_passwordVisibilityObserver->start(); |
| + } else if (m_passwordVisibilityObserver) { |
| + m_passwordVisibilityObserver->stop(); |
| + m_passwordVisibilityObserver = nullptr; |
| + } |
| +} |
| + |
| +void HTMLInputElement::onVisibilityChangedForPasswordInput(bool isVisible) |
| +{ |
| + if (!isVisible) |
| + return; |
| + document().frameHost()->chromeClient().passwordFieldBecameVisible(*this); |
| +} |
| + |
| void HTMLInputElement::didNotifySubtreeInsertionsToDocument() |
| { |
| listAttributeTargetChanged(); |