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, 2008, 2010 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. |
| 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 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 if (LocalFrame* frame = document().frame()) | 267 if (LocalFrame* frame = document().frame()) |
| 268 frame->spellChecker().didBeginEditing(this); | 268 frame->spellChecker().didBeginEditing(this); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void HTMLTextAreaElement::subtreeHasChanged() | 271 void HTMLTextAreaElement::subtreeHasChanged() |
| 272 { | 272 { |
| 273 setChangedSinceLastFormControlChangeEvent(true); | 273 setChangedSinceLastFormControlChangeEvent(true); |
| 274 m_valueIsUpToDate = false; | 274 m_valueIsUpToDate = false; |
| 275 setNeedsValidityCheck(); | 275 setNeedsValidityCheck(); |
| 276 setAutofilled(false); | 276 setAutofilled(false); |
| 277 updatePlaceholderVisibility(false); | 277 updatePlaceholderVisibility(); |
| 278 | 278 |
| 279 if (!focused()) | 279 if (!focused()) |
| 280 return; | 280 return; |
| 281 | 281 |
| 282 // When typing in a textarea, childrenChanged is not called, so we need to f orce the directionality check. | 282 // When typing in a textarea, childrenChanged is not called, so we need to f orce the directionality check. |
| 283 calculateAndAdjustDirectionality(); | 283 calculateAndAdjustDirectionality(); |
| 284 | 284 |
| 285 ASSERT(document().isActive()); | 285 ASSERT(document().isActive()); |
| 286 document().frameHost()->chromeClient().didChangeValueInTextField(*this); | 286 document().frameHost()->chromeClient().didChangeValueInTextField(*this); |
| 287 } | 287 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 | 325 |
| 326 void HTMLTextAreaElement::updateValue() const | 326 void HTMLTextAreaElement::updateValue() const |
| 327 { | 327 { |
| 328 if (m_valueIsUpToDate) | 328 if (m_valueIsUpToDate) |
| 329 return; | 329 return; |
| 330 | 330 |
| 331 m_value = innerEditorValue(); | 331 m_value = innerEditorValue(); |
| 332 const_cast<HTMLTextAreaElement*>(this)->m_valueIsUpToDate = true; | 332 const_cast<HTMLTextAreaElement*>(this)->m_valueIsUpToDate = true; |
| 333 const_cast<HTMLTextAreaElement*>(this)->notifyFormStateChanged(); | 333 const_cast<HTMLTextAreaElement*>(this)->notifyFormStateChanged(); |
| 334 m_isDirty = true; | 334 m_isDirty = true; |
| 335 const_cast<HTMLTextAreaElement*>(this)->updatePlaceholderVisibility(false); | 335 const_cast<HTMLTextAreaElement*>(this)->updatePlaceholderVisibility(); |
| 336 } | 336 } |
| 337 | 337 |
| 338 String HTMLTextAreaElement::value() const | 338 String HTMLTextAreaElement::value() const |
| 339 { | 339 { |
| 340 updateValue(); | 340 updateValue(); |
| 341 return m_value; | 341 return m_value; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void HTMLTextAreaElement::setValue(const String& value, TextFieldEventBehavior e ventBehavior) | 344 void HTMLTextAreaElement::setValue(const String& value, TextFieldEventBehavior e ventBehavior) |
| 345 { | 345 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 setSelectionRange(endOfString, endOfString, SelectionHasNoDirect ion, NotDispatchSelectEvent, ChangeSelectionIfFocused); | 377 setSelectionRange(endOfString, endOfString, SelectionHasNoDirect ion, NotDispatchSelectEvent, ChangeSelectionIfFocused); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 return; | 380 return; |
| 381 } | 381 } |
| 382 | 382 |
| 383 m_value = normalizedValue; | 383 m_value = normalizedValue; |
| 384 setInnerEditorValue(m_value); | 384 setInnerEditorValue(m_value); |
| 385 if (eventBehavior == DispatchNoEvent) | 385 if (eventBehavior == DispatchNoEvent) |
| 386 setLastChangeWasNotUserEdit(); | 386 setLastChangeWasNotUserEdit(); |
| 387 updatePlaceholderVisibility(false); | 387 updatePlaceholderVisibility(); |
| 388 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); | 388 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); |
| 389 m_suggestedValue = String(); | 389 m_suggestedValue = String(); |
| 390 setNeedsValidityCheck(); | 390 setNeedsValidityCheck(); |
| 391 if (isFinishedParsingChildren()) { | 391 if (isFinishedParsingChildren()) { |
| 392 // Set the caret to the end of the text value except for initialize. | 392 // Set the caret to the end of the text value except for initialize. |
| 393 unsigned endOfString = m_value.length(); | 393 unsigned endOfString = m_value.length(); |
| 394 setSelectionRange(endOfString, endOfString, SelectionHasNoDirection, Not DispatchSelectEvent, ChangeSelectionIfFocused); | 394 setSelectionRange(endOfString, endOfString, SelectionHasNoDirection, Not DispatchSelectEvent, ChangeSelectionIfFocused); |
| 395 } | 395 } |
| 396 | 396 |
| 397 notifyFormStateChanged(); | 397 notifyFormStateChanged(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 } | 492 } |
| 493 | 493 |
| 494 void HTMLTextAreaElement::setSuggestedValue(const String& value) | 494 void HTMLTextAreaElement::setSuggestedValue(const String& value) |
| 495 { | 495 { |
| 496 m_suggestedValue = value; | 496 m_suggestedValue = value; |
| 497 | 497 |
| 498 if (!value.isNull()) | 498 if (!value.isNull()) |
| 499 setInnerEditorValue(m_suggestedValue); | 499 setInnerEditorValue(m_suggestedValue); |
| 500 else | 500 else |
| 501 setInnerEditorValue(m_value); | 501 setInnerEditorValue(m_value); |
| 502 updatePlaceholderVisibility(false); | 502 updatePlaceholderVisibility(); |
| 503 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); | 503 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 String HTMLTextAreaElement::validationMessage() const | 506 String HTMLTextAreaElement::validationMessage() const |
| 507 { | 507 { |
| 508 if (!willValidate()) | 508 if (!willValidate()) |
| 509 return String(); | 509 return String(); |
| 510 | 510 |
| 511 if (customError()) | 511 if (customError()) |
| 512 return customValidationMessage(); | 512 return customValidationMessage(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 if (placeholderText.isEmpty()) { | 611 if (placeholderText.isEmpty()) { |
| 612 if (placeholder) | 612 if (placeholder) |
| 613 userAgentShadowRoot()->removeChild(placeholder); | 613 userAgentShadowRoot()->removeChild(placeholder); |
| 614 return; | 614 return; |
| 615 } | 615 } |
| 616 if (!placeholder) { | 616 if (!placeholder) { |
| 617 RefPtrWillBeRawPtr<HTMLDivElement> newElement = HTMLDivElement::create(d ocument()); | 617 RefPtrWillBeRawPtr<HTMLDivElement> newElement = HTMLDivElement::create(d ocument()); |
| 618 placeholder = newElement.get(); | 618 placeholder = newElement.get(); |
| 619 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); | 619 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); |
| 620 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); | 620 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); |
| 621 placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVis ible() ? CSSValueBlock : CSSValueNone, true); | |
|
esprehn
2015/08/21 10:18:10
Just call updatePlaceholderVisibility() here, no r
ramya.v
2015/08/25 10:24:45
updatePlaceholderText is called from inside update
| |
| 621 userAgentShadowRoot()->insertBefore(placeholder, innerEditorElement()->n extSibling()); | 622 userAgentShadowRoot()->insertBefore(placeholder, innerEditorElement()->n extSibling()); |
| 622 } | 623 } |
| 623 placeholder->setTextContent(placeholderText); | 624 placeholder->setTextContent(placeholderText); |
| 624 } | 625 } |
| 625 | 626 |
| 626 bool HTMLTextAreaElement::isInteractiveContent() const | 627 bool HTMLTextAreaElement::isInteractiveContent() const |
| 627 { | 628 { |
| 628 return true; | 629 return true; |
| 629 } | 630 } |
| 630 | 631 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 641 | 642 |
| 642 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s ource) | 643 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s ource) |
| 643 { | 644 { |
| 644 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle ment&>(source); | 645 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle ment&>(source); |
| 645 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); | 646 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); |
| 646 m_isDirty = sourceElement.m_isDirty; | 647 m_isDirty = sourceElement.m_isDirty; |
| 647 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); | 648 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 648 } | 649 } |
| 649 | 650 |
| 650 } // namespace blink | 651 } // namespace blink |
| OLD | NEW |