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 27 matching lines...) Expand all Loading... | |
| 38 #include "core/editing/SpellChecker.h" | 38 #include "core/editing/SpellChecker.h" |
| 39 #include "core/editing/TextIterator.h" | 39 #include "core/editing/TextIterator.h" |
| 40 #include "core/events/BeforeTextInsertedEvent.h" | 40 #include "core/events/BeforeTextInsertedEvent.h" |
| 41 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
| 42 #include "core/events/ThreadLocalEventNames.h" | 42 #include "core/events/ThreadLocalEventNames.h" |
| 43 #include "core/html/FormDataList.h" | 43 #include "core/html/FormDataList.h" |
| 44 #include "core/html/forms/FormController.h" | 44 #include "core/html/forms/FormController.h" |
| 45 #include "core/html/shadow/ShadowElementNames.h" | 45 #include "core/html/shadow/ShadowElementNames.h" |
| 46 #include "core/html/shadow/TextControlInnerElements.h" | 46 #include "core/html/shadow/TextControlInnerElements.h" |
| 47 #include "core/frame/Frame.h" | 47 #include "core/frame/Frame.h" |
| 48 #include "core/frame/FrameHost.h" | |
| 49 #include "core/page/Chrome.h" | |
| 50 #include "core/page/ChromeClient.h" | |
| 48 #include "core/rendering/RenderTextControlMultiLine.h" | 51 #include "core/rendering/RenderTextControlMultiLine.h" |
| 49 #include "platform/text/PlatformLocale.h" | 52 #include "platform/text/PlatformLocale.h" |
| 50 #include "wtf/StdLibExtras.h" | 53 #include "wtf/StdLibExtras.h" |
| 51 #include "wtf/text/StringBuilder.h" | 54 #include "wtf/text/StringBuilder.h" |
| 52 | 55 |
| 53 namespace WebCore { | 56 namespace WebCore { |
| 54 | 57 |
| 55 using namespace HTMLNames; | 58 using namespace HTMLNames; |
| 56 | 59 |
| 57 static const int defaultRows = 2; | 60 static const int defaultRows = 2; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 { | 273 { |
| 271 setChangedSinceLastFormControlChangeEvent(true); | 274 setChangedSinceLastFormControlChangeEvent(true); |
| 272 setFormControlValueMatchesRenderer(false); | 275 setFormControlValueMatchesRenderer(false); |
| 273 setNeedsValidityCheck(); | 276 setNeedsValidityCheck(); |
| 274 | 277 |
| 275 if (!focused()) | 278 if (!focused()) |
| 276 return; | 279 return; |
| 277 | 280 |
| 278 // When typing in a textarea, childrenChanged is not called, so we need to f orce the directionality check. | 281 // When typing in a textarea, childrenChanged is not called, so we need to f orce the directionality check. |
| 279 calculateAndAdjustDirectionality(); | 282 calculateAndAdjustDirectionality(); |
| 283 | |
| 284 ASSERT(document().isActive()); | |
| 285 document().frameHost()->chrome().client().didChangeValueInTextField(*this); | |
| 280 } | 286 } |
| 281 | 287 |
| 282 void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const | 288 void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const |
| 283 { | 289 { |
| 284 ASSERT(event); | 290 ASSERT(event); |
| 285 ASSERT(renderer()); | 291 ASSERT(renderer()); |
| 286 int signedMaxLength = maxLength(); | 292 int signedMaxLength = maxLength(); |
| 287 if (signedMaxLength < 0) | 293 if (signedMaxLength < 0) |
| 288 return; | 294 return; |
| 289 unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength); | 295 unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 } | 435 } |
| 430 | 436 |
| 431 String HTMLTextAreaElement::suggestedValue() const | 437 String HTMLTextAreaElement::suggestedValue() const |
| 432 { | 438 { |
| 433 return m_suggestedValue; | 439 return m_suggestedValue; |
| 434 } | 440 } |
| 435 | 441 |
| 436 void HTMLTextAreaElement::setSuggestedValue(const String& value) | 442 void HTMLTextAreaElement::setSuggestedValue(const String& value) |
| 437 { | 443 { |
| 438 m_suggestedValue = value; | 444 m_suggestedValue = value; |
| 439 setInnerTextValue(m_suggestedValue); | |
| 440 updatePlaceholderVisibility(false); | |
| 441 setNeedsStyleRecalc(SubtreeStyleChange); | 445 setNeedsStyleRecalc(SubtreeStyleChange); |
| 442 setFormControlValueMatchesRenderer(true); | 446 if (!value.isNull()) { |
| 447 setInnerTextValue(m_suggestedValue); | |
| 448 updatePlaceholderVisibility(false); | |
| 449 } else { | |
| 450 setInnerTextValue(m_value); | |
| 451 updatePlaceholderVisibility(false); | |
|
tkent
2014/02/06 00:05:45
nit: we can merge updatePlaceholderVisibility call
ziran.sun
2014/02/06 10:32:17
Done.
| |
| 452 } | |
| 443 } | 453 } |
| 444 | 454 |
| 445 String HTMLTextAreaElement::validationMessage() const | 455 String HTMLTextAreaElement::validationMessage() const |
| 446 { | 456 { |
| 447 if (!willValidate()) | 457 if (!willValidate()) |
| 448 return String(); | 458 return String(); |
| 449 | 459 |
| 450 if (customError()) | 460 if (customError()) |
| 451 return customValidationMessage(); | 461 return customValidationMessage(); |
| 452 | 462 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 { | 550 { |
| 541 return true; | 551 return true; |
| 542 } | 552 } |
| 543 | 553 |
| 544 bool HTMLTextAreaElement::supportsAutofocus() const | 554 bool HTMLTextAreaElement::supportsAutofocus() const |
| 545 { | 555 { |
| 546 return true; | 556 return true; |
| 547 } | 557 } |
| 548 | 558 |
| 549 } | 559 } |
| OLD | NEW |