OLD | NEW |
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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 m_autocomplete = Uninitialized; | 648 m_autocomplete = Uninitialized; |
649 else | 649 else |
650 m_autocomplete = On; | 650 m_autocomplete = On; |
651 } | 651 } |
652 } else if (name == typeAttr) | 652 } else if (name == typeAttr) |
653 updateType(); | 653 updateType(); |
654 else if (name == valueAttr) { | 654 else if (name == valueAttr) { |
655 // We only need to setChanged if the form is looking at the default valu
e right now. | 655 // We only need to setChanged if the form is looking at the default valu
e right now. |
656 if (!hasDirtyValue()) { | 656 if (!hasDirtyValue()) { |
657 updatePlaceholderVisibility(false); | 657 updatePlaceholderVisibility(false); |
658 setNeedsStyleRecalc(SubtreeStyleChange); | 658 setNeedsStyleRecalc(StyleChangeReasonForTracing::fromAttribute(value
Attr), SubtreeStyleChange); |
659 } | 659 } |
660 m_needsToUpdateViewValue = true; | 660 m_needsToUpdateViewValue = true; |
661 setNeedsValidityCheck(); | 661 setNeedsValidityCheck(); |
662 m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress; | 662 m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress; |
663 m_inputType->warnIfValueIsInvalidAndElementIsVisible(value); | 663 m_inputType->warnIfValueIsInvalidAndElementIsVisible(value); |
664 m_inputTypeView->valueAttributeChanged(); | 664 m_inputTypeView->valueAttributeChanged(); |
665 } else if (name == checkedAttr) { | 665 } else if (name == checkedAttr) { |
666 // Another radio button in the same group might be checked by state | 666 // Another radio button in the same group might be checked by state |
667 // restore. We shouldn't call setChecked() even if this has the checked | 667 // restore. We shouldn't call setChecked() even if this has the checked |
668 // attribute. So, delay the setChecked() call until | 668 // attribute. So, delay the setChecked() call until |
(...skipping 19 matching lines...) Expand all Loading... |
688 } else if (name == onsearchAttr) { | 688 } else if (name == onsearchAttr) { |
689 // Search field and slider attributes all just cause updateFromElement t
o be called through style recalcing. | 689 // Search field and slider attributes all just cause updateFromElement t
o be called through style recalcing. |
690 setAttributeEventListener(EventTypeNames::search, createAttributeEventLi
stener(this, name, value, eventParameterName())); | 690 setAttributeEventListener(EventTypeNames::search, createAttributeEventLi
stener(this, name, value, eventParameterName())); |
691 } else if (name == resultsAttr) { | 691 } else if (name == resultsAttr) { |
692 int oldResults = m_maxResults; | 692 int oldResults = m_maxResults; |
693 m_maxResults = !value.isNull() ? std::min(value.toInt(), maxSavedResults
) : -1; | 693 m_maxResults = !value.isNull() ? std::min(value.toInt(), maxSavedResults
) : -1; |
694 // FIXME: Detaching just for maxResults change is not ideal. We should
figure out the right | 694 // FIXME: Detaching just for maxResults change is not ideal. We should
figure out the right |
695 // time to relayout for this change. | 695 // time to relayout for this change. |
696 if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0)
) | 696 if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0)
) |
697 lazyReattachIfAttached(); | 697 lazyReattachIfAttached(); |
698 setNeedsStyleRecalc(SubtreeStyleChange); | 698 setNeedsStyleRecalc(StyleChangeReasonForTracing::fromAttribute(resultsAt
tr), SubtreeStyleChange); |
699 UseCounter::count(document(), UseCounter::ResultsAttribute); | 699 UseCounter::count(document(), UseCounter::ResultsAttribute); |
700 } else if (name == incrementalAttr) { | 700 } else if (name == incrementalAttr) { |
701 setNeedsStyleRecalc(SubtreeStyleChange); | 701 setNeedsStyleRecalc(StyleChangeReasonForTracing::fromAttribute(increment
alAttr), SubtreeStyleChange); |
702 UseCounter::count(document(), UseCounter::IncrementalAttribute); | 702 UseCounter::count(document(), UseCounter::IncrementalAttribute); |
703 } else if (name == minAttr) { | 703 } else if (name == minAttr) { |
704 m_inputTypeView->minOrMaxAttributeChanged(); | 704 m_inputTypeView->minOrMaxAttributeChanged(); |
705 m_inputType->sanitizeValueInResponseToMinOrMaxAttributeChange(); | 705 m_inputType->sanitizeValueInResponseToMinOrMaxAttributeChange(); |
706 setNeedsValidityCheck(); | 706 setNeedsValidityCheck(); |
707 UseCounter::count(document(), UseCounter::MinAttribute); | 707 UseCounter::count(document(), UseCounter::MinAttribute); |
708 } else if (name == maxAttr) { | 708 } else if (name == maxAttr) { |
709 m_inputTypeView->minOrMaxAttributeChanged(); | 709 m_inputTypeView->minOrMaxAttributeChanged(); |
710 setNeedsValidityCheck(); | 710 setNeedsValidityCheck(); |
711 UseCounter::count(document(), UseCounter::MaxAttribute); | 711 UseCounter::count(document(), UseCounter::MaxAttribute); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 bool HTMLInputElement::isTextField() const | 836 bool HTMLInputElement::isTextField() const |
837 { | 837 { |
838 return m_inputType->isTextField(); | 838 return m_inputType->isTextField(); |
839 } | 839 } |
840 | 840 |
841 void HTMLInputElement::setChecked(bool nowChecked, TextFieldEventBehavior eventB
ehavior) | 841 void HTMLInputElement::setChecked(bool nowChecked, TextFieldEventBehavior eventB
ehavior) |
842 { | 842 { |
843 if (checked() == nowChecked) | 843 if (checked() == nowChecked) |
844 return; | 844 return; |
845 | 845 |
| 846 const StyleChangeReasonForTracing styleChangeReason = StyleChangeReasonForTr
acing::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData:
:Checked); |
846 RefPtrWillBeRawPtr<HTMLInputElement> protector(this); | 847 RefPtrWillBeRawPtr<HTMLInputElement> protector(this); |
847 m_reflectsCheckedAttribute = false; | 848 m_reflectsCheckedAttribute = false; |
848 m_isChecked = nowChecked; | 849 m_isChecked = nowChecked; |
849 setNeedsStyleRecalc(SubtreeStyleChange); | 850 setNeedsStyleRecalc(styleChangeReason, SubtreeStyleChange); |
850 | 851 |
851 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) | 852 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) |
852 scope->updateCheckedState(this); | 853 scope->updateCheckedState(this); |
853 if (renderer() && renderer()->style()->hasAppearance()) | 854 if (renderer() && renderer()->style()->hasAppearance()) |
854 RenderTheme::theme().stateChanged(renderer(), CheckedControlState); | 855 RenderTheme::theme().stateChanged(renderer(), CheckedControlState); |
855 | 856 |
856 setNeedsValidityCheck(); | 857 setNeedsValidityCheck(); |
857 | 858 |
858 // Ideally we'd do this from the render tree (matching | 859 // Ideally we'd do this from the render tree (matching |
859 // RenderTextView), but it's not possible to do it at the moment | 860 // RenderTextView), but it's not possible to do it at the moment |
860 // because of the way the code is structured. | 861 // because of the way the code is structured. |
861 if (renderer()) { | 862 if (renderer()) { |
862 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) | 863 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) |
863 cache->checkedStateChanged(this); | 864 cache->checkedStateChanged(this); |
864 } | 865 } |
865 | 866 |
866 // Only send a change event for items in the document (avoid firing during | 867 // Only send a change event for items in the document (avoid firing during |
867 // parsing) and don't send a change event for a radio button that's getting | 868 // parsing) and don't send a change event for a radio button that's getting |
868 // unchecked to match other browsers. DOM is not a useful standard for this | 869 // unchecked to match other browsers. DOM is not a useful standard for this |
869 // because it says only to fire change events at "lose focus" time, which is | 870 // because it says only to fire change events at "lose focus" time, which is |
870 // definitely wrong in practice for these types of elements. | 871 // definitely wrong in practice for these types of elements. |
871 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS
endChangeEventAfterCheckedChanged()) { | 872 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS
endChangeEventAfterCheckedChanged()) { |
872 setTextAsOfLastFormControlChangeEvent(String()); | 873 setTextAsOfLastFormControlChangeEvent(String()); |
873 if (eventBehavior == DispatchInputAndChangeEvent) | 874 if (eventBehavior == DispatchInputAndChangeEvent) |
874 dispatchFormControlInputEvent(); | 875 dispatchFormControlInputEvent(); |
875 dispatchFormControlChangeEvent(); | 876 dispatchFormControlChangeEvent(); |
876 } | 877 } |
877 | 878 |
878 didAffectSelector(AffectedSelectorChecked); | 879 didAffectSelector(styleChangeReason, AffectedSelectorChecked); |
879 } | 880 } |
880 | 881 |
881 void HTMLInputElement::setIndeterminate(bool newValue) | 882 void HTMLInputElement::setIndeterminate(bool newValue) |
882 { | 883 { |
883 if (indeterminate() == newValue) | 884 if (indeterminate() == newValue) |
884 return; | 885 return; |
885 | 886 |
886 m_isIndeterminate = newValue; | 887 m_isIndeterminate = newValue; |
887 | 888 |
888 didAffectSelector(AffectedSelectorIndeterminate); | 889 didAffectSelector(StyleChangeReasonForTracing::createWithExtraData(StyleChan
geReason::PseudoClass, StyleChangeExtraData::Indeterminate), AffectedSelectorInd
eterminate); |
889 | 890 |
890 if (renderer() && renderer()->style()->hasAppearance()) | 891 if (renderer() && renderer()->style()->hasAppearance()) |
891 RenderTheme::theme().stateChanged(renderer(), CheckedControlState); | 892 RenderTheme::theme().stateChanged(renderer(), CheckedControlState); |
892 } | 893 } |
893 | 894 |
894 int HTMLInputElement::size() const | 895 int HTMLInputElement::size() const |
895 { | 896 { |
896 return m_size; | 897 return m_size; |
897 } | 898 } |
898 | 899 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 { | 954 { |
954 return m_suggestedValue; | 955 return m_suggestedValue; |
955 } | 956 } |
956 | 957 |
957 void HTMLInputElement::setSuggestedValue(const String& value) | 958 void HTMLInputElement::setSuggestedValue(const String& value) |
958 { | 959 { |
959 if (!m_inputType->canSetSuggestedValue()) | 960 if (!m_inputType->canSetSuggestedValue()) |
960 return; | 961 return; |
961 m_needsToUpdateViewValue = true; | 962 m_needsToUpdateViewValue = true; |
962 m_suggestedValue = sanitizeValue(value); | 963 m_suggestedValue = sanitizeValue(value); |
963 setNeedsStyleRecalc(SubtreeStyleChange); | 964 setNeedsStyleRecalc(StyleChangeReasonForTracing::create(StyleChangeReason::C
ontrolValue), SubtreeStyleChange); |
964 m_inputTypeView->updateView(); | 965 m_inputTypeView->updateView(); |
965 } | 966 } |
966 | 967 |
967 void HTMLInputElement::setEditingValue(const String& value) | 968 void HTMLInputElement::setEditingValue(const String& value) |
968 { | 969 { |
969 if (!renderer() || !isTextField()) | 970 if (!renderer() || !isTextField()) |
970 return; | 971 return; |
971 setInnerEditorValue(value); | 972 setInnerEditorValue(value); |
972 subtreeHasChanged(); | 973 subtreeHasChanged(); |
973 | 974 |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 { | 1584 { |
1584 int maxLength; | 1585 int maxLength; |
1585 if (!parseHTMLInteger(value, maxLength)) | 1586 if (!parseHTMLInteger(value, maxLength)) |
1586 maxLength = maximumLength; | 1587 maxLength = maximumLength; |
1587 if (maxLength < 0 || maxLength > maximumLength) | 1588 if (maxLength < 0 || maxLength > maximumLength) |
1588 maxLength = maximumLength; | 1589 maxLength = maximumLength; |
1589 int oldMaxLength = m_maxLength; | 1590 int oldMaxLength = m_maxLength; |
1590 m_maxLength = maxLength; | 1591 m_maxLength = maxLength; |
1591 if (oldMaxLength != maxLength) | 1592 if (oldMaxLength != maxLength) |
1592 updateValueIfNeeded(); | 1593 updateValueIfNeeded(); |
1593 setNeedsStyleRecalc(SubtreeStyleChange); | 1594 setNeedsStyleRecalc(StyleChangeReasonForTracing::fromAttribute(maxlengthAttr
), SubtreeStyleChange); |
1594 setNeedsValidityCheck(); | 1595 setNeedsValidityCheck(); |
1595 } | 1596 } |
1596 | 1597 |
1597 void HTMLInputElement::updateValueIfNeeded() | 1598 void HTMLInputElement::updateValueIfNeeded() |
1598 { | 1599 { |
1599 String newValue = sanitizeValue(m_valueIfDirty); | 1600 String newValue = sanitizeValue(m_valueIfDirty); |
1600 ASSERT(!m_valueIfDirty.isNull() || newValue.isNull()); | 1601 ASSERT(!m_valueIfDirty.isNull() || newValue.isNull()); |
1601 if (newValue != m_valueIfDirty) | 1602 if (newValue != m_valueIfDirty) |
1602 setValue(newValue); | 1603 setValue(newValue); |
1603 } | 1604 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 { | 1802 { |
1802 listAttributeTargetChanged(); | 1803 listAttributeTargetChanged(); |
1803 } | 1804 } |
1804 | 1805 |
1805 AXObject* HTMLInputElement::popupRootAXObject() | 1806 AXObject* HTMLInputElement::popupRootAXObject() |
1806 { | 1807 { |
1807 return m_inputTypeView->popupRootAXObject(); | 1808 return m_inputTypeView->popupRootAXObject(); |
1808 } | 1809 } |
1809 | 1810 |
1810 } // namespace | 1811 } // namespace |
OLD | NEW |