Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 namespace blink { | 56 namespace blink { |
| 57 | 57 |
| 58 using namespace HTMLNames; | 58 using namespace HTMLNames; |
| 59 | 59 |
| 60 HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagN ame, Document& doc, HTMLFormElement* form) | 60 HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagN ame, Document& doc, HTMLFormElement* form) |
| 61 : HTMLFormControlElementWithState(tagName, doc, form) | 61 : HTMLFormControlElementWithState(tagName, doc, form) |
| 62 , m_lastChangeWasUserEdit(false) | 62 , m_lastChangeWasUserEdit(false) |
| 63 , m_cachedSelectionStart(0) | 63 , m_cachedSelectionStart(0) |
| 64 , m_cachedSelectionEnd(0) | 64 , m_cachedSelectionEnd(0) |
| 65 , m_cachedSelectionDirection(SelectionHasNoDirection) | 65 , m_cachedSelectionDirection(SelectionHasNoDirection) |
| 66 , m_isPlaceholderVisible(false) | |
|
esprehn
2015/08/21 10:18:10
remove
ramya.v
2015/08/25 10:24:45
Done.
| |
| 66 { | 67 { |
| 67 } | 68 } |
| 68 | 69 |
| 69 HTMLTextFormControlElement::~HTMLTextFormControlElement() | 70 HTMLTextFormControlElement::~HTMLTextFormControlElement() |
| 70 { | 71 { |
| 71 } | 72 } |
| 72 | 73 |
| 73 Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(Cont ainerNode* insertionPoint) | 74 Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(Cont ainerNode* insertionPoint) |
| 74 { | 75 { |
| 75 HTMLFormControlElementWithState::insertedInto(insertionPoint); | 76 HTMLFormControlElementWithState::insertedInto(insertionPoint); |
| 76 if (!insertionPoint->inDocument()) | 77 if (!insertionPoint->inDocument()) |
| 77 return InsertionDone; | 78 return InsertionDone; |
| 78 String initialValue = value(); | 79 String initialValue = value(); |
| 79 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue); | 80 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue); |
| 80 return InsertionDone; | 81 return InsertionDone; |
| 81 } | 82 } |
| 82 | 83 |
| 83 void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDevice* sourceDevice) | 84 void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDevice* sourceDevice) |
| 84 { | 85 { |
| 85 if (supportsPlaceholder()) | 86 if (supportsPlaceholder()) |
| 86 updatePlaceholderVisibility(false); | 87 updatePlaceholderVisibility(); |
| 87 handleFocusEvent(oldFocusedElement, type); | 88 handleFocusEvent(oldFocusedElement, type); |
| 88 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type, sourceDevice); | 89 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type, sourceDevice); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, W ebFocusType type, InputDevice* sourceDevice) | 92 void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, W ebFocusType type, InputDevice* sourceDevice) |
| 92 { | 93 { |
| 93 if (supportsPlaceholder()) | 94 if (supportsPlaceholder()) |
| 94 updatePlaceholderVisibility(false); | 95 updatePlaceholderVisibility(); |
| 95 handleBlurEvent(); | 96 handleBlurEvent(); |
| 96 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type, sourceDevice); | 97 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type, sourceDevice); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void HTMLTextFormControlElement::defaultEventHandler(Event* event) | 100 void HTMLTextFormControlElement::defaultEventHandler(Event* event) |
| 100 { | 101 { |
| 101 if (event->type() == EventTypeNames::webkitEditableContentChanged && layoutO bject() && layoutObject()->isTextControl()) { | 102 if (event->type() == EventTypeNames::webkitEditableContentChanged && layoutO bject() && layoutObject()->isTextControl()) { |
| 102 m_lastChangeWasUserEdit = true; | 103 m_lastChangeWasUserEdit = true; |
| 103 subtreeHasChanged(); | 104 subtreeHasChanged(); |
| 104 return; | 105 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 { | 141 { |
| 141 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); | 142 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); |
| 142 return attributeValue.string().find(isNotLineBreak) == kNotFound; | 143 return attributeValue.string().find(isNotLineBreak) == kNotFound; |
| 143 } | 144 } |
| 144 | 145 |
| 145 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const | 146 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const |
| 146 { | 147 { |
| 147 return supportsPlaceholder() | 148 return supportsPlaceholder() |
| 148 && isEmptyValue() | 149 && isEmptyValue() |
| 149 && isEmptySuggestedValue() | 150 && isEmptySuggestedValue() |
| 150 && !isPlaceholderEmpty() | 151 && !isPlaceholderEmpty(); |
|
esprehn
2015/08/21 10:18:10
This is a behavior change, can you explain why you
ramya.v
2015/08/25 10:24:45
In Webkit patch, below point is mentioned.
Remove
| |
| 151 && (!layoutObject() || layoutObject()->style()->visibility() == VISIBLE) ; | |
| 152 } | 152 } |
| 153 | 153 |
| 154 HTMLElement* HTMLTextFormControlElement::placeholderElement() const | 154 HTMLElement* HTMLTextFormControlElement::placeholderElement() const |
| 155 { | 155 { |
| 156 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::placeholder())); | 156 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::placeholder())); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderVal ueChanged) | 159 void HTMLTextFormControlElement::updatePlaceholderVisibility() |
| 160 { | 160 { |
| 161 if (!supportsPlaceholder()) | 161 HTMLElement* placeholder = placeholderElement(); |
| 162 if (!placeholder) { | |
| 163 updatePlaceholderText(); | |
| 162 return; | 164 return; |
| 163 if (!placeholderElement() || placeholderValueChanged) | 165 } |
| 164 updatePlaceholderText(); | 166 |
| 165 HTMLElement* placeholder = placeholderElement(); | 167 bool placeHolderWasVisible = m_isPlaceholderVisible; |
| 166 if (!placeholder) | 168 m_isPlaceholderVisible = placeholderShouldBeVisible(); |
| 169 if (placeHolderWasVisible == m_isPlaceholderVisible) | |
| 167 return; | 170 return; |
| 168 | 171 |
| 169 placeholder->setInlineStyleProperty(CSSPropertyDisplay, placeholderShouldBeV isible() ? CSSValueBlock : CSSValueNone); | 172 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::PseudoClass)); |
|
esprehn
2015/08/21 10:18:10
This should use the StyleInvalidator, you need to
ramya.v
2015/08/25 10:24:45
Done.
| |
| 173 placeholder->setInlineStyleProperty(CSSPropertyDisplay, m_isPlaceholderVisib le ? CSSValueBlock : CSSValueNone, true); | |
| 170 } | 174 } |
| 171 | 175 |
| 172 void HTMLTextFormControlElement::setSelectionStart(int start) | 176 void HTMLTextFormControlElement::setSelectionStart(int start) |
| 173 { | 177 { |
| 174 setSelectionRange(start, std::max(start, selectionEnd()), selectionDirection ()); | 178 setSelectionRange(start, std::max(start, selectionEnd()), selectionDirection ()); |
| 175 } | 179 } |
| 176 | 180 |
| 177 void HTMLTextFormControlElement::setSelectionEnd(int end) | 181 void HTMLTextFormControlElement::setSelectionEnd(int end) |
| 178 { | 182 { |
| 179 setSelectionRange(std::min(end, selectionStart()), end, selectionDirection() ); | 183 setSelectionRange(std::min(end, selectionStart()), end, selectionDirection() ); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 event->setTarget(this); | 604 event->setTarget(this); |
| 601 document().enqueueUniqueAnimationFrameEvent(event.release()); | 605 document().enqueueUniqueAnimationFrameEvent(event.release()); |
| 602 } | 606 } |
| 603 | 607 |
| 604 void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const AtomicString& value) | 608 void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const AtomicString& value) |
| 605 { | 609 { |
| 606 if (name == autocapitalizeAttr) | 610 if (name == autocapitalizeAttr) |
| 607 UseCounter::count(document(), UseCounter::AutocapitalizeAttribute); | 611 UseCounter::count(document(), UseCounter::AutocapitalizeAttribute); |
| 608 | 612 |
| 609 if (name == placeholderAttr) { | 613 if (name == placeholderAttr) { |
| 610 updatePlaceholderVisibility(true); | 614 updatePlaceholderText(); |
| 615 updatePlaceholderVisibility(); | |
| 611 UseCounter::count(document(), UseCounter::PlaceholderAttribute); | 616 UseCounter::count(document(), UseCounter::PlaceholderAttribute); |
| 612 } else { | 617 } else { |
| 613 HTMLFormControlElementWithState::parseAttribute(name, value); | 618 HTMLFormControlElementWithState::parseAttribute(name, value); |
| 614 } | 619 } |
| 615 } | 620 } |
| 616 | 621 |
| 617 bool HTMLTextFormControlElement::lastChangeWasUserEdit() const | 622 bool HTMLTextFormControlElement::lastChangeWasUserEdit() const |
| 618 { | 623 { |
| 619 if (!isTextFormControl()) | 624 if (!isTextFormControl()) |
| 620 return false; | 625 return false; |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 } | 1008 } |
| 1004 | 1009 |
| 1005 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) | 1010 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) |
| 1006 { | 1011 { |
| 1007 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); | 1012 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); |
| 1008 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1013 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
| 1009 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1014 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 1010 } | 1015 } |
| 1011 | 1016 |
| 1012 } // namespace blink | 1017 } // namespace blink |
| OLD | NEW |