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

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

Issue 1280423002: CSS4: Implement :placeholder-shown pseudo class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comments Created 5 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, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 , m_isActivatedSubmit(false) 112 , m_isActivatedSubmit(false)
113 , m_autocomplete(Uninitialized) 113 , m_autocomplete(Uninitialized)
114 , m_hasNonEmptyList(false) 114 , m_hasNonEmptyList(false)
115 , m_stateRestored(false) 115 , m_stateRestored(false)
116 , m_parsingInProgress(createdByParser) 116 , m_parsingInProgress(createdByParser)
117 , m_valueAttributeWasUpdatedAfterParsing(false) 117 , m_valueAttributeWasUpdatedAfterParsing(false)
118 , m_canReceiveDroppedFiles(false) 118 , m_canReceiveDroppedFiles(false)
119 , m_hasTouchEventHandler(false) 119 , m_hasTouchEventHandler(false)
120 , m_shouldRevealPassword(false) 120 , m_shouldRevealPassword(false)
121 , m_needsToUpdateViewValue(true) 121 , m_needsToUpdateViewValue(true)
122 , m_isPlaceholderVisible(false)
122 // |m_inputType| is lazily created when constructed by the parser to avoid 123 // |m_inputType| is lazily created when constructed by the parser to avoid
123 // constructing unnecessarily a text inputType and its shadow subtree, just 124 // constructing unnecessarily a text inputType and its shadow subtree, just
124 // to destroy them when the |type| attribute gets set by the parser to 125 // to destroy them when the |type| attribute gets set by the parser to
125 // something else than 'text'. 126 // something else than 'text'.
126 , m_inputType(createdByParser ? nullptr : InputType::createText(*this)) 127 , m_inputType(createdByParser ? nullptr : InputType::createText(*this))
127 , m_inputTypeView(m_inputType) 128 , m_inputTypeView(m_inputType)
128 { 129 {
129 setHasCustomStyleCallbacks(); 130 setHasCustomStyleCallbacks();
130 } 131 }
131 132
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 if (value.isEmpty()) 694 if (value.isEmpty())
694 m_autocomplete = Uninitialized; 695 m_autocomplete = Uninitialized;
695 else 696 else
696 m_autocomplete = On; 697 m_autocomplete = On;
697 } 698 }
698 } else if (name == typeAttr) { 699 } else if (name == typeAttr) {
699 updateType(); 700 updateType();
700 } else if (name == valueAttr) { 701 } else if (name == valueAttr) {
701 // We only need to setChanged if the form is looking at the default valu e right now. 702 // We only need to setChanged if the form is looking at the default valu e right now.
702 if (!hasDirtyValue()) { 703 if (!hasDirtyValue()) {
703 updatePlaceholderVisibility(false); 704 updatePlaceholderVisibility();
704 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :fromAttribute(valueAttr)); 705 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :fromAttribute(valueAttr));
705 } 706 }
706 m_needsToUpdateViewValue = true; 707 m_needsToUpdateViewValue = true;
707 setNeedsValidityCheck(); 708 setNeedsValidityCheck();
708 m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress; 709 m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress;
709 m_inputType->warnIfValueIsInvalidAndElementIsVisible(value); 710 m_inputType->warnIfValueIsInvalidAndElementIsVisible(value);
710 m_inputTypeView->valueAttributeChanged(); 711 m_inputTypeView->valueAttributeChanged();
711 } else if (name == checkedAttr) { 712 } else if (name == checkedAttr) {
712 // Another radio button in the same group might be checked by state 713 // Another radio button in the same group might be checked by state
713 // restore. We shouldn't call setChecked() even if this has the checked 714 // restore. We shouldn't call setChecked() even if this has the checked
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 bool HTMLInputElement::supportLabels() const 1659 bool HTMLInputElement::supportLabels() const
1659 { 1660 {
1660 return m_inputType->isInteractiveContent(); 1661 return m_inputType->isInteractiveContent();
1661 } 1662 }
1662 1663
1663 bool HTMLInputElement::shouldAppearChecked() const 1664 bool HTMLInputElement::shouldAppearChecked() const
1664 { 1665 {
1665 return checked() && m_inputType->isCheckable(); 1666 return checked() && m_inputType->isCheckable();
1666 } 1667 }
1667 1668
1669 void HTMLInputElement::setPlaceholderVisibility(bool visible)
1670 {
1671 m_isPlaceholderVisible = visible;
1672 }
1673
1668 bool HTMLInputElement::supportsPlaceholder() const 1674 bool HTMLInputElement::supportsPlaceholder() const
1669 { 1675 {
1670 return m_inputType->supportsPlaceholder(); 1676 return m_inputType->supportsPlaceholder();
1671 } 1677 }
1672 1678
1673 void HTMLInputElement::updatePlaceholderText() 1679 void HTMLInputElement::updatePlaceholderText()
1674 { 1680 {
1675 return m_inputTypeView->updatePlaceholderText(); 1681 return m_inputTypeView->updatePlaceholderText();
1676 } 1682 }
1677 1683
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 void HTMLInputElement::ensurePrimaryContent() 1938 void HTMLInputElement::ensurePrimaryContent()
1933 { 1939 {
1934 m_inputTypeView->ensurePrimaryContent(); 1940 m_inputTypeView->ensurePrimaryContent();
1935 } 1941 }
1936 1942
1937 bool HTMLInputElement::hasFallbackContent() const 1943 bool HTMLInputElement::hasFallbackContent() const
1938 { 1944 {
1939 return m_inputTypeView->hasFallbackContent(); 1945 return m_inputTypeView->hasFallbackContent();
1940 } 1946 }
1941 } // namespace 1947 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698