| 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 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (!insertionPoint->inDocument()) | 76 if (!insertionPoint->inDocument()) |
| 77 return InsertionDone; | 77 return InsertionDone; |
| 78 String initialValue = value(); | 78 String initialValue = value(); |
| 79 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString()
: initialValue); | 79 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString()
: initialValue); |
| 80 return InsertionDone; | 80 return InsertionDone; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement,
WebFocusType type, InputDeviceCapabilities* sourceCapabilities) | 83 void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement,
WebFocusType type, InputDeviceCapabilities* sourceCapabilities) |
| 84 { | 84 { |
| 85 if (supportsPlaceholder()) | 85 if (supportsPlaceholder()) |
| 86 updatePlaceholderVisibility(false); | 86 updatePlaceholderVisibility(); |
| 87 handleFocusEvent(oldFocusedElement, type); | 87 handleFocusEvent(oldFocusedElement, type); |
| 88 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type,
sourceCapabilities); | 88 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type,
sourceCapabilities); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, W
ebFocusType type, InputDeviceCapabilities* sourceCapabilities) | 91 void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, W
ebFocusType type, InputDeviceCapabilities* sourceCapabilities) |
| 92 { | 92 { |
| 93 if (supportsPlaceholder()) | 93 if (supportsPlaceholder()) |
| 94 updatePlaceholderVisibility(false); | 94 updatePlaceholderVisibility(); |
| 95 handleBlurEvent(); | 95 handleBlurEvent(); |
| 96 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type,
sourceCapabilities); | 96 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type,
sourceCapabilities); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void HTMLTextFormControlElement::defaultEventHandler(Event* event) | 99 void HTMLTextFormControlElement::defaultEventHandler(Event* event) |
| 100 { | 100 { |
| 101 if (event->type() == EventTypeNames::webkitEditableContentChanged && layoutO
bject() && layoutObject()->isTextControl()) { | 101 if (event->type() == EventTypeNames::webkitEditableContentChanged && layoutO
bject() && layoutObject()->isTextControl()) { |
| 102 m_lastChangeWasUserEdit = true; | 102 m_lastChangeWasUserEdit = true; |
| 103 subtreeHasChanged(); | 103 subtreeHasChanged(); |
| 104 return; | 104 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 { | 140 { |
| 141 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); | 141 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); |
| 142 return attributeValue.string().find(isNotLineBreak) == kNotFound; | 142 return attributeValue.string().find(isNotLineBreak) == kNotFound; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const | 145 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const |
| 146 { | 146 { |
| 147 return supportsPlaceholder() | 147 return supportsPlaceholder() |
| 148 && isEmptyValue() | 148 && isEmptyValue() |
| 149 && isEmptySuggestedValue() | 149 && isEmptySuggestedValue() |
| 150 && !isPlaceholderEmpty() | 150 && !isPlaceholderEmpty(); |
| 151 && (!layoutObject() || layoutObject()->style()->visibility() == VISIBLE)
; | |
| 152 } | 151 } |
| 153 | 152 |
| 154 HTMLElement* HTMLTextFormControlElement::placeholderElement() const | 153 HTMLElement* HTMLTextFormControlElement::placeholderElement() const |
| 155 { | 154 { |
| 156 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::placeholder())); | 155 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::placeholder())); |
| 157 } | 156 } |
| 158 | 157 |
| 159 void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderVal
ueChanged) | 158 void HTMLTextFormControlElement::updatePlaceholderVisibility() |
| 160 { | 159 { |
| 161 if (!supportsPlaceholder()) | 160 HTMLElement* placeholder = placeholderElement(); |
| 161 if (!placeholder) { |
| 162 updatePlaceholderText(); |
| 162 return; | 163 return; |
| 163 if (!placeholderElement() || placeholderValueChanged) | 164 } |
| 164 updatePlaceholderText(); | 165 |
| 165 HTMLElement* placeholder = placeholderElement(); | 166 bool placeHolderWasVisible = isPlaceholderVisible(); |
| 166 if (!placeholder) | 167 setPlaceholderVisibility(placeholderShouldBeVisible()); |
| 168 if (placeHolderWasVisible == isPlaceholderVisible()) |
| 167 return; | 169 return; |
| 168 | 170 |
| 169 placeholder->setInlineStyleProperty(CSSPropertyDisplay, placeholderShouldBeV
isible() ? CSSValueBlock : CSSValueNone); | 171 pseudoStateChanged(CSSSelector::PseudoPlaceholderShown); |
| 172 placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible
() ? CSSValueBlock : CSSValueNone, true); |
| 170 } | 173 } |
| 171 | 174 |
| 172 void HTMLTextFormControlElement::setSelectionStart(int start) | 175 void HTMLTextFormControlElement::setSelectionStart(int start) |
| 173 { | 176 { |
| 174 setSelectionRange(start, std::max(start, selectionEnd()), selectionDirection
()); | 177 setSelectionRange(start, std::max(start, selectionEnd()), selectionDirection
()); |
| 175 } | 178 } |
| 176 | 179 |
| 177 void HTMLTextFormControlElement::setSelectionEnd(int end) | 180 void HTMLTextFormControlElement::setSelectionEnd(int end) |
| 178 { | 181 { |
| 179 setSelectionRange(std::min(end, selectionStart()), end, selectionDirection()
); | 182 setSelectionRange(std::min(end, selectionStart()), end, selectionDirection()
); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 event->setTarget(this); | 603 event->setTarget(this); |
| 601 document().enqueueUniqueAnimationFrameEvent(event.release()); | 604 document().enqueueUniqueAnimationFrameEvent(event.release()); |
| 602 } | 605 } |
| 603 | 606 |
| 604 void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const
AtomicString& value) | 607 void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const
AtomicString& value) |
| 605 { | 608 { |
| 606 if (name == autocapitalizeAttr) | 609 if (name == autocapitalizeAttr) |
| 607 UseCounter::count(document(), UseCounter::AutocapitalizeAttribute); | 610 UseCounter::count(document(), UseCounter::AutocapitalizeAttribute); |
| 608 | 611 |
| 609 if (name == placeholderAttr) { | 612 if (name == placeholderAttr) { |
| 610 updatePlaceholderVisibility(true); | 613 updatePlaceholderText(); |
| 614 updatePlaceholderVisibility(); |
| 611 UseCounter::count(document(), UseCounter::PlaceholderAttribute); | 615 UseCounter::count(document(), UseCounter::PlaceholderAttribute); |
| 612 } else { | 616 } else { |
| 613 HTMLFormControlElementWithState::parseAttribute(name, value); | 617 HTMLFormControlElementWithState::parseAttribute(name, value); |
| 614 } | 618 } |
| 615 } | 619 } |
| 616 | 620 |
| 617 bool HTMLTextFormControlElement::lastChangeWasUserEdit() const | 621 bool HTMLTextFormControlElement::lastChangeWasUserEdit() const |
| 618 { | 622 { |
| 619 if (!isTextFormControl()) | 623 if (!isTextFormControl()) |
| 620 return false; | 624 return false; |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 } | 1007 } |
| 1004 | 1008 |
| 1005 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) | 1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) |
| 1006 { | 1010 { |
| 1007 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); | 1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); |
| 1008 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
| 1009 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 1010 } | 1014 } |
| 1011 | 1015 |
| 1012 } // namespace blink | 1016 } // namespace blink |
| OLD | NEW |