| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 PassRefPtr<HTMLTextAreaElement> HTMLTextAreaElement::create(const QualifiedName&
tagName, Document* document, HTMLFormElement* form) | 100 PassRefPtr<HTMLTextAreaElement> HTMLTextAreaElement::create(const QualifiedName&
tagName, Document* document, HTMLFormElement* form) |
| 101 { | 101 { |
| 102 RefPtr<HTMLTextAreaElement> textArea = adoptRef(new HTMLTextAreaElement(tagN
ame, document, form)); | 102 RefPtr<HTMLTextAreaElement> textArea = adoptRef(new HTMLTextAreaElement(tagN
ame, document, form)); |
| 103 textArea->ensureUserAgentShadowRoot(); | 103 textArea->ensureUserAgentShadowRoot(); |
| 104 return textArea.release(); | 104 return textArea.release(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void HTMLTextAreaElement::didAddUserAgentShadowRoot(ShadowRoot* root) | 107 void HTMLTextAreaElement::didAddUserAgentShadowRoot(ShadowRoot* root) |
| 108 { | 108 { |
| 109 root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO
_EXCEPTION_STATE); | 109 root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO
_EXCEPTION); |
| 110 } | 110 } |
| 111 | 111 |
| 112 const AtomicString& HTMLTextAreaElement::formControlType() const | 112 const AtomicString& HTMLTextAreaElement::formControlType() const |
| 113 { | 113 { |
| 114 DEFINE_STATIC_LOCAL(const AtomicString, textarea, ("textarea", AtomicString:
:ConstructFromLiteral)); | 114 DEFINE_STATIC_LOCAL(const AtomicString, textarea, ("textarea", AtomicString:
:ConstructFromLiteral)); |
| 115 return textarea; | 115 return textarea; |
| 116 } | 116 } |
| 117 | 117 |
| 118 FormControlState HTMLTextAreaElement::saveFormControlState() const | 118 FormControlState HTMLTextAreaElement::saveFormControlState() const |
| 119 { | 119 { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 RefPtr<Node> protectFromMutationEvents(this); | 412 RefPtr<Node> protectFromMutationEvents(this); |
| 413 | 413 |
| 414 // To preserve comments, remove only the text nodes, then add a single text
node. | 414 // To preserve comments, remove only the text nodes, then add a single text
node. |
| 415 Vector<RefPtr<Node> > textNodes; | 415 Vector<RefPtr<Node> > textNodes; |
| 416 for (Node* n = firstChild(); n; n = n->nextSibling()) { | 416 for (Node* n = firstChild(); n; n = n->nextSibling()) { |
| 417 if (n->isTextNode()) | 417 if (n->isTextNode()) |
| 418 textNodes.append(n); | 418 textNodes.append(n); |
| 419 } | 419 } |
| 420 size_t size = textNodes.size(); | 420 size_t size = textNodes.size(); |
| 421 for (size_t i = 0; i < size; ++i) | 421 for (size_t i = 0; i < size; ++i) |
| 422 removeChild(textNodes[i].get(), IGNORE_EXCEPTION_STATE); | 422 removeChild(textNodes[i].get(), IGNORE_EXCEPTION); |
| 423 | 423 |
| 424 // Normalize line endings. | 424 // Normalize line endings. |
| 425 String value = defaultValue; | 425 String value = defaultValue; |
| 426 value.replace("\r\n", "\n"); | 426 value.replace("\r\n", "\n"); |
| 427 value.replace('\r', '\n'); | 427 value.replace('\r', '\n'); |
| 428 | 428 |
| 429 insertBefore(document()->createTextNode(value), firstChild(), IGNORE_EXCEPTI
ON_STATE); | 429 insertBefore(document()->createTextNode(value), firstChild(), IGNORE_EXCEPTI
ON); |
| 430 | 430 |
| 431 if (!m_isDirty) | 431 if (!m_isDirty) |
| 432 setNonDirtyValue(value); | 432 setNonDirtyValue(value); |
| 433 } | 433 } |
| 434 | 434 |
| 435 int HTMLTextAreaElement::maxLength() const | 435 int HTMLTextAreaElement::maxLength() const |
| 436 { | 436 { |
| 437 bool ok; | 437 bool ok; |
| 438 int value = getAttribute(maxlengthAttr).string().toInt(&ok); | 438 int value = getAttribute(maxlengthAttr).string().toInt(&ok); |
| 439 return ok && value >= 0 ? value : -1; | 439 return ok && value >= 0 ? value : -1; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 bool HTMLTextAreaElement::matchesReadWritePseudoClass() const | 534 bool HTMLTextAreaElement::matchesReadWritePseudoClass() const |
| 535 { | 535 { |
| 536 return !isReadOnly(); | 536 return !isReadOnly(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void HTMLTextAreaElement::updatePlaceholderText() | 539 void HTMLTextAreaElement::updatePlaceholderText() |
| 540 { | 540 { |
| 541 String placeholderText = strippedPlaceholder(); | 541 String placeholderText = strippedPlaceholder(); |
| 542 if (placeholderText.isEmpty()) { | 542 if (placeholderText.isEmpty()) { |
| 543 if (m_placeholder) { | 543 if (m_placeholder) { |
| 544 userAgentShadowRoot()->removeChild(m_placeholder, ASSERT_NO_EXCEPTIO
N_STATE); | 544 userAgentShadowRoot()->removeChild(m_placeholder, ASSERT_NO_EXCEPTIO
N); |
| 545 m_placeholder = 0; | 545 m_placeholder = 0; |
| 546 } | 546 } |
| 547 return; | 547 return; |
| 548 } | 548 } |
| 549 if (!m_placeholder) { | 549 if (!m_placeholder) { |
| 550 RefPtr<HTMLDivElement> placeholder = HTMLDivElement::create(document()); | 550 RefPtr<HTMLDivElement> placeholder = HTMLDivElement::create(document()); |
| 551 m_placeholder = placeholder.get(); | 551 m_placeholder = placeholder.get(); |
| 552 m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", Atomi
cString::ConstructFromLiteral)); | 552 m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", Atomi
cString::ConstructFromLiteral)); |
| 553 userAgentShadowRoot()->insertBefore(m_placeholder, innerTextElement()->n
extSibling(), ASSERT_NO_EXCEPTION_STATE); | 553 userAgentShadowRoot()->insertBefore(m_placeholder, innerTextElement()->n
extSibling(), ASSERT_NO_EXCEPTION); |
| 554 } | 554 } |
| 555 m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION_STATE); | 555 m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION); |
| 556 fixPlaceholderRenderer(m_placeholder, innerTextElement()); | 556 fixPlaceholderRenderer(m_placeholder, innerTextElement()); |
| 557 } | 557 } |
| 558 | 558 |
| 559 } | 559 } |
| OLD | NEW |