| 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 | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 return m_value; | 376 return m_value; |
| 377 } | 377 } |
| 378 | 378 |
| 379 void HTMLTextAreaElement::setValue(const String& value, | 379 void HTMLTextAreaElement::setValue(const String& value, |
| 380 TextFieldEventBehavior eventBehavior) { | 380 TextFieldEventBehavior eventBehavior) { |
| 381 setValueCommon(value, eventBehavior); | 381 setValueCommon(value, eventBehavior); |
| 382 m_isDirty = true; | 382 m_isDirty = true; |
| 383 } | 383 } |
| 384 | 384 |
| 385 void HTMLTextAreaElement::setNonDirtyValue(const String& value) { | 385 void HTMLTextAreaElement::setNonDirtyValue(const String& value) { |
| 386 setValueCommon(value, DispatchNoEvent, SetSeletion); | 386 setValueCommon(value, DispatchNoEvent); |
| 387 m_isDirty = false; | 387 m_isDirty = false; |
| 388 } | 388 } |
| 389 | 389 |
| 390 void HTMLTextAreaElement::setValueCommon(const String& newValue, | 390 void HTMLTextAreaElement::setValueCommon(const String& newValue, |
| 391 TextFieldEventBehavior eventBehavior, | 391 TextFieldEventBehavior eventBehavior) { |
| 392 SetValueCommonOption setValueOption) { | |
| 393 // Code elsewhere normalizes line endings added by the user via the keyboard | 392 // Code elsewhere normalizes line endings added by the user via the keyboard |
| 394 // or pasting. We normalize line endings coming from JavaScript here. | 393 // or pasting. We normalize line endings coming from JavaScript here. |
| 395 String normalizedValue = newValue.isNull() ? "" : newValue; | 394 String normalizedValue = newValue.isNull() ? "" : newValue; |
| 396 normalizedValue.replace("\r\n", "\n"); | 395 normalizedValue.replace("\r\n", "\n"); |
| 397 normalizedValue.replace('\r', '\n'); | 396 normalizedValue.replace('\r', '\n'); |
| 398 | 397 |
| 399 // Return early because we don't want to trigger other side effects | 398 // Return early because we don't want to trigger other side effects when the |
| 400 // when the value isn't changing. | 399 // value isn't changing. This is interoperable though the specification |
| 401 // FIXME: Simple early return doesn't match the Firefox ever. | 400 // doesn't define so. |
| 402 // Remove these lines. | 401 // https://github.com/whatwg/html/issues/2412 |
| 403 if (normalizedValue == value()) { | 402 if (normalizedValue == value()) |
| 404 if (setValueOption == SetSeletion) { | |
| 405 setNeedsValidityCheck(); | |
| 406 if (isFinishedParsingChildren()) { | |
| 407 // Set the caret to the end of the text value except for initialize. | |
| 408 unsigned endOfString = m_value.length(); | |
| 409 setSelectionRange(endOfString, endOfString); | |
| 410 } | |
| 411 } | |
| 412 return; | 403 return; |
| 413 } | |
| 414 | 404 |
| 415 m_value = normalizedValue; | 405 m_value = normalizedValue; |
| 416 setInnerEditorValue(m_value); | 406 setInnerEditorValue(m_value); |
| 417 if (eventBehavior == DispatchNoEvent) | 407 if (eventBehavior == DispatchNoEvent) |
| 418 setLastChangeWasNotUserEdit(); | 408 setLastChangeWasNotUserEdit(); |
| 419 updatePlaceholderVisibility(); | 409 updatePlaceholderVisibility(); |
| 420 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( | 410 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( |
| 421 StyleChangeReason::ControlValue)); | 411 StyleChangeReason::ControlValue)); |
| 422 m_suggestedValue = String(); | 412 m_suggestedValue = String(); |
| 423 setNeedsValidityCheck(); | 413 setNeedsValidityCheck(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 625 |
| 636 const AtomicString& HTMLTextAreaElement::defaultAutocapitalize() const { | 626 const AtomicString& HTMLTextAreaElement::defaultAutocapitalize() const { |
| 637 DEFINE_STATIC_LOCAL(const AtomicString, sentences, ("sentences")); | 627 DEFINE_STATIC_LOCAL(const AtomicString, sentences, ("sentences")); |
| 638 return sentences; | 628 return sentences; |
| 639 } | 629 } |
| 640 | 630 |
| 641 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement( | 631 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement( |
| 642 const Element& source) { | 632 const Element& source) { |
| 643 const HTMLTextAreaElement& sourceElement = | 633 const HTMLTextAreaElement& sourceElement = |
| 644 static_cast<const HTMLTextAreaElement&>(source); | 634 static_cast<const HTMLTextAreaElement&>(source); |
| 645 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); | 635 setValueCommon(sourceElement.value(), DispatchNoEvent); |
| 646 m_isDirty = sourceElement.m_isDirty; | 636 m_isDirty = sourceElement.m_isDirty; |
| 647 TextControlElement::copyNonAttributePropertiesFromElement(source); | 637 TextControlElement::copyNonAttributePropertiesFromElement(source); |
| 648 } | 638 } |
| 649 | 639 |
| 650 } // namespace blink | 640 } // namespace blink |
| OLD | NEW |