| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 : HTMLTextFormControlElement(textareaTag, document, form) | 80 : HTMLTextFormControlElement(textareaTag, document, form) |
| 81 , m_rows(defaultRows) | 81 , m_rows(defaultRows) |
| 82 , m_cols(defaultCols) | 82 , m_cols(defaultCols) |
| 83 , m_wrap(SoftWrap) | 83 , m_wrap(SoftWrap) |
| 84 , m_isDirty(false) | 84 , m_isDirty(false) |
| 85 , m_valueIsUpToDate(true) | 85 , m_valueIsUpToDate(true) |
| 86 , m_isPlaceholderVisible(false) | 86 , m_isPlaceholderVisible(false) |
| 87 { | 87 { |
| 88 } | 88 } |
| 89 | 89 |
| 90 PassRefPtrWillBeRawPtr<HTMLTextAreaElement> HTMLTextAreaElement::create(Document
& document, HTMLFormElement* form) | 90 RawPtr<HTMLTextAreaElement> HTMLTextAreaElement::create(Document& document, HTML
FormElement* form) |
| 91 { | 91 { |
| 92 RefPtrWillBeRawPtr<HTMLTextAreaElement> textArea = adoptRefWillBeNoop(new HT
MLTextAreaElement(document, form)); | 92 RawPtr<HTMLTextAreaElement> textArea = (new HTMLTextAreaElement(document, fo
rm)); |
| 93 textArea->ensureUserAgentShadowRoot(); | 93 textArea->ensureUserAgentShadowRoot(); |
| 94 return textArea.release(); | 94 return textArea.release(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void HTMLTextAreaElement::didAddUserAgentShadowRoot(ShadowRoot& root) | 97 void HTMLTextAreaElement::didAddUserAgentShadowRoot(ShadowRoot& root) |
| 98 { | 98 { |
| 99 root.appendChild(TextControlInnerEditorElement::create(document())); | 99 root.appendChild(TextControlInnerEditorElement::create(document())); |
| 100 } | 100 } |
| 101 | 101 |
| 102 const AtomicString& HTMLTextAreaElement::formControlType() const | 102 const AtomicString& HTMLTextAreaElement::formControlType() const |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 339 } |
| 340 | 340 |
| 341 String HTMLTextAreaElement::value() const | 341 String HTMLTextAreaElement::value() const |
| 342 { | 342 { |
| 343 updateValue(); | 343 updateValue(); |
| 344 return m_value; | 344 return m_value; |
| 345 } | 345 } |
| 346 | 346 |
| 347 void HTMLTextAreaElement::setValue(const String& value, TextFieldEventBehavior e
ventBehavior) | 347 void HTMLTextAreaElement::setValue(const String& value, TextFieldEventBehavior e
ventBehavior) |
| 348 { | 348 { |
| 349 RefPtrWillBeRawPtr<HTMLTextAreaElement> protector(this); | 349 RawPtr<HTMLTextAreaElement> protector(this); |
| 350 setValueCommon(value, eventBehavior); | 350 setValueCommon(value, eventBehavior); |
| 351 m_isDirty = true; | 351 m_isDirty = true; |
| 352 if (document().focusedElement() == this) | 352 if (document().focusedElement() == this) |
| 353 document().frameHost()->chromeClient().didUpdateTextOfFocusedElementByNo
nUserInput(); | 353 document().frameHost()->chromeClient().didUpdateTextOfFocusedElementByNo
nUserInput(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void HTMLTextAreaElement::setNonDirtyValue(const String& value) | 356 void HTMLTextAreaElement::setNonDirtyValue(const String& value) |
| 357 { | 357 { |
| 358 setValueCommon(value, DispatchNoEvent, SetSeletion); | 358 setValueCommon(value, DispatchNoEvent, SetSeletion); |
| 359 m_isDirty = false; | 359 m_isDirty = false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 for (Node* n = firstChild(); n; n = n->nextSibling()) { | 421 for (Node* n = firstChild(); n; n = n->nextSibling()) { |
| 422 if (n->isTextNode()) | 422 if (n->isTextNode()) |
| 423 value.append(toText(n)->data()); | 423 value.append(toText(n)->data()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 return value.toString(); | 426 return value.toString(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) | 429 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) |
| 430 { | 430 { |
| 431 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); | 431 RawPtr<Node> protectFromMutationEvents(this); |
| 432 | 432 |
| 433 // To preserve comments, remove only the text nodes, then add a single text
node. | 433 // To preserve comments, remove only the text nodes, then add a single text
node. |
| 434 WillBeHeapVector<RefPtrWillBeMember<Node>> textNodes; | 434 HeapVector<Member<Node>> textNodes; |
| 435 for (Node* n = firstChild(); n; n = n->nextSibling()) { | 435 for (Node* n = firstChild(); n; n = n->nextSibling()) { |
| 436 if (n->isTextNode()) | 436 if (n->isTextNode()) |
| 437 textNodes.append(n); | 437 textNodes.append(n); |
| 438 } | 438 } |
| 439 size_t size = textNodes.size(); | 439 size_t size = textNodes.size(); |
| 440 for (size_t i = 0; i < size; ++i) | 440 for (size_t i = 0; i < size; ++i) |
| 441 removeChild(textNodes[i].get(), IGNORE_EXCEPTION); | 441 removeChild(textNodes[i].get(), IGNORE_EXCEPTION); |
| 442 | 442 |
| 443 // Normalize line endings. | 443 // Normalize line endings. |
| 444 String value = defaultValue; | 444 String value = defaultValue; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 void HTMLTextAreaElement::updatePlaceholderText() | 615 void HTMLTextAreaElement::updatePlaceholderText() |
| 616 { | 616 { |
| 617 HTMLElement* placeholder = placeholderElement(); | 617 HTMLElement* placeholder = placeholderElement(); |
| 618 const AtomicString& placeholderText = fastGetAttribute(placeholderAttr); | 618 const AtomicString& placeholderText = fastGetAttribute(placeholderAttr); |
| 619 if (placeholderText.isEmpty()) { | 619 if (placeholderText.isEmpty()) { |
| 620 if (placeholder) | 620 if (placeholder) |
| 621 userAgentShadowRoot()->removeChild(placeholder); | 621 userAgentShadowRoot()->removeChild(placeholder); |
| 622 return; | 622 return; |
| 623 } | 623 } |
| 624 if (!placeholder) { | 624 if (!placeholder) { |
| 625 RefPtrWillBeRawPtr<HTMLDivElement> newElement = HTMLDivElement::create(d
ocument()); | 625 RawPtr<HTMLDivElement> newElement = HTMLDivElement::create(document()); |
| 626 placeholder = newElement.get(); | 626 placeholder = newElement.get(); |
| 627 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder",
AtomicString::ConstructFromLiteral)); | 627 placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder",
AtomicString::ConstructFromLiteral)); |
| 628 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); | 628 placeholder->setAttribute(idAttr, ShadowElementNames::placeholder()); |
| 629 placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVis
ible() ? CSSValueBlock : CSSValueNone, true); | 629 placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVis
ible() ? CSSValueBlock : CSSValueNone, true); |
| 630 userAgentShadowRoot()->insertBefore(placeholder, innerEditorElement()); | 630 userAgentShadowRoot()->insertBefore(placeholder, innerEditorElement()); |
| 631 } | 631 } |
| 632 placeholder->setTextContent(placeholderText); | 632 placeholder->setTextContent(placeholderText); |
| 633 } | 633 } |
| 634 | 634 |
| 635 bool HTMLTextAreaElement::isInteractiveContent() const | 635 bool HTMLTextAreaElement::isInteractiveContent() const |
| (...skipping 14 matching lines...) Expand all Loading... |
| 650 | 650 |
| 651 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s
ource) | 651 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s
ource) |
| 652 { | 652 { |
| 653 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle
ment&>(source); | 653 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle
ment&>(source); |
| 654 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); | 654 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); |
| 655 m_isDirty = sourceElement.m_isDirty; | 655 m_isDirty = sourceElement.m_isDirty; |
| 656 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); | 656 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 657 } | 657 } |
| 658 | 658 |
| 659 } // namespace blink | 659 } // namespace blink |
| OLD | NEW |