| 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 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 return m_lastChangeWasUserEdit; | 625 return m_lastChangeWasUserEdit; |
| 626 } | 626 } |
| 627 | 627 |
| 628 void HTMLTextFormControlElement::setInnerEditorValue(const String& value) | 628 void HTMLTextFormControlElement::setInnerEditorValue(const String& value) |
| 629 { | 629 { |
| 630 ASSERT(!openShadowRoot()); | 630 ASSERT(!openShadowRoot()); |
| 631 if (!isTextFormControl() || openShadowRoot()) | 631 if (!isTextFormControl() || openShadowRoot()) |
| 632 return; | 632 return; |
| 633 | 633 |
| 634 bool textIsChanged = value != innerEditorValue(); | 634 bool textIsChanged = value != innerEditorValue(); |
| 635 if (textIsChanged || !innerEditorElement()->hasChildren()) { | 635 HTMLElement* innerEditor = innerEditorElement(); |
| 636 if (textIsChanged && layoutObject()) { | 636 if (!textIsChanged && innerEditor->hasChildren()) |
| 637 if (AXObjectCache* cache = document().existingAXObjectCache()) | 637 return; |
| 638 cache->handleTextFormControlChanged(this); | |
| 639 } | |
| 640 innerEditorElement()->setInnerText(value, ASSERT_NO_EXCEPTION); | |
| 641 | 638 |
| 642 if (value.endsWith('\n') || value.endsWith('\r')) | 639 // If the last child is a trailing <br> that's appended below, remove it |
| 643 innerEditorElement()->appendChild(HTMLBRElement::create(document()))
; | 640 // first so as to enable setInnerText() fast path of updating a text node. |
| 641 if (isHTMLBRElement(innerEditor->lastChild())) |
| 642 innerEditor->removeChild(innerEditor->lastChild(), ASSERT_NO_EXCEPTION); |
| 643 |
| 644 innerEditor->setInnerText(value, ASSERT_NO_EXCEPTION); |
| 645 |
| 646 if (value.endsWith('\n') || value.endsWith('\r')) |
| 647 innerEditor->appendChild(HTMLBRElement::create(document())); |
| 648 |
| 649 if (textIsChanged && layoutObject()) { |
| 650 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 651 cache->handleTextFormControlChanged(this); |
| 644 } | 652 } |
| 645 } | 653 } |
| 646 | 654 |
| 647 static String finishText(StringBuilder& result) | 655 static String finishText(StringBuilder& result) |
| 648 { | 656 { |
| 649 // Remove one trailing newline; there's always one that's collapsed out by l
ayoutObject. | 657 // Remove one trailing newline; there's always one that's collapsed out by l
ayoutObject. |
| 650 size_t size = result.length(); | 658 size_t size = result.length(); |
| 651 if (size && result[size - 1] == '\n') | 659 if (size && result[size - 1] == '\n') |
| 652 result.resize(--size); | 660 result.resize(--size); |
| 653 return result.toString(); | 661 return result.toString(); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 } | 1015 } |
| 1008 | 1016 |
| 1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) | 1017 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) |
| 1010 { | 1018 { |
| 1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); | 1019 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); |
| 1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1020 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
| 1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1021 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 1014 } | 1022 } |
| 1015 | 1023 |
| 1016 } // namespace blink | 1024 } // namespace blink |
| OLD | NEW |