| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49 #include "core/layout/LayoutTextControlMultiLine.h" | 49 #include "core/layout/LayoutTextControlMultiLine.h" | 
| 50 #include "core/page/ChromeClient.h" | 50 #include "core/page/ChromeClient.h" | 
| 51 #include "platform/text/PlatformLocale.h" | 51 #include "platform/text/PlatformLocale.h" | 
| 52 #include "wtf/StdLibExtras.h" | 52 #include "wtf/StdLibExtras.h" | 
| 53 #include "wtf/text/StringBuilder.h" | 53 #include "wtf/text/StringBuilder.h" | 
| 54 | 54 | 
| 55 namespace blink { | 55 namespace blink { | 
| 56 | 56 | 
| 57 using namespace HTMLNames; | 57 using namespace HTMLNames; | 
| 58 | 58 | 
| 59 static const int defaultRows = 2; | 59 static const unsigned defaultRows = 2; | 
| 60 static const int defaultCols = 20; | 60 static const unsigned defaultCols = 20; | 
| 61 | 61 | 
| 62 // On submission, LF characters are converted into CRLF. | 62 // On submission, LF characters are converted into CRLF. | 
| 63 // This function returns number of characters considering this. | 63 // This function returns number of characters considering this. | 
| 64 static unsigned numberOfLineBreaks(const String& text) | 64 static unsigned numberOfLineBreaks(const String& text) | 
| 65 { | 65 { | 
| 66     unsigned length = text.length(); | 66     unsigned length = text.length(); | 
| 67     unsigned count = 0; | 67     unsigned count = 0; | 
| 68     for (unsigned i = 0; i < length; i++) { | 68     for (unsigned i = 0; i < length; i++) { | 
| 69         if (text[i] == '\n') | 69         if (text[i] == '\n') | 
| 70             count++; | 70             count++; | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 148             addPropertyToPresentationAttributeStyle(style, CSSPropertyWhiteSpace
     , CSSValuePre); | 148             addPropertyToPresentationAttributeStyle(style, CSSPropertyWhiteSpace
     , CSSValuePre); | 
| 149             addPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, 
     CSSValueNormal); | 149             addPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, 
     CSSValueNormal); | 
| 150         } | 150         } | 
| 151     } else | 151     } else | 
| 152         HTMLTextFormControlElement::collectStyleForPresentationAttribute(name, v
     alue, style); | 152         HTMLTextFormControlElement::collectStyleForPresentationAttribute(name, v
     alue, style); | 
| 153 } | 153 } | 
| 154 | 154 | 
| 155 void HTMLTextAreaElement::parseAttribute(const QualifiedName& name, const Atomic
     String& value) | 155 void HTMLTextAreaElement::parseAttribute(const QualifiedName& name, const Atomic
     String& value) | 
| 156 { | 156 { | 
| 157     if (name == rowsAttr) { | 157     if (name == rowsAttr) { | 
| 158         int rows = 0; | 158         unsigned rows = 0; | 
| 159         if (value.isEmpty() || !parseHTMLInteger(value, rows) || rows <= 0) | 159         if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, rows) || rows
      <= 0) | 
| 160             rows = defaultRows; | 160             rows = defaultRows; | 
| 161         if (m_rows != rows) { | 161         if (m_rows != rows) { | 
| 162             m_rows = rows; | 162             m_rows = rows; | 
| 163             if (layoutObject()) | 163             if (layoutObject()) | 
| 164                 layoutObject()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInv
     alidation(LayoutInvalidationReason::AttributeChanged); | 164                 layoutObject()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInv
     alidation(LayoutInvalidationReason::AttributeChanged); | 
| 165         } | 165         } | 
| 166     } else if (name == colsAttr) { | 166     } else if (name == colsAttr) { | 
| 167         int cols = 0; | 167         unsigned cols = 0; | 
| 168         if (value.isEmpty() || !parseHTMLInteger(value, cols) || cols <= 0) | 168         if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, cols) || cols
      <= 0) | 
| 169             cols = defaultCols; | 169             cols = defaultCols; | 
| 170         if (m_cols != cols) { | 170         if (m_cols != cols) { | 
| 171             m_cols = cols; | 171             m_cols = cols; | 
| 172             if (LayoutObject* layoutObject = this->layoutObject()) | 172             if (LayoutObject* layoutObject = this->layoutObject()) | 
| 173                 layoutObject->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInval
     idation(LayoutInvalidationReason::AttributeChanged); | 173                 layoutObject->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInval
     idation(LayoutInvalidationReason::AttributeChanged); | 
| 174         } | 174         } | 
| 175     } else if (name == wrapAttr) { | 175     } else if (name == wrapAttr) { | 
| 176         // The virtual/physical values were a Netscape extension of HTML 3.0, no
     w deprecated. | 176         // The virtual/physical values were a Netscape extension of HTML 3.0, no
     w deprecated. | 
| 177         // The soft/hard /off values are a recommendation for HTML 4 extension b
     y IE and NS 4. | 177         // The soft/hard /off values are a recommendation for HTML 4 extension b
     y IE and NS 4. | 
| 178         WrapMethod wrap; | 178         WrapMethod wrap; | 
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 576 bool HTMLTextAreaElement::isValidValue(const String& candidate) const | 576 bool HTMLTextAreaElement::isValidValue(const String& candidate) const | 
| 577 { | 577 { | 
| 578     return !valueMissing(&candidate) && !tooLong(&candidate, IgnoreDirtyFlag) &&
      !tooShort(&candidate, IgnoreDirtyFlag); | 578     return !valueMissing(&candidate) && !tooLong(&candidate, IgnoreDirtyFlag) &&
      !tooShort(&candidate, IgnoreDirtyFlag); | 
| 579 } | 579 } | 
| 580 | 580 | 
| 581 void HTMLTextAreaElement::accessKeyAction(bool) | 581 void HTMLTextAreaElement::accessKeyAction(bool) | 
| 582 { | 582 { | 
| 583     focus(); | 583     focus(); | 
| 584 } | 584 } | 
| 585 | 585 | 
| 586 void HTMLTextAreaElement::setCols(int cols) | 586 void HTMLTextAreaElement::setCols(unsigned cols) | 
| 587 { | 587 { | 
| 588     setIntegralAttribute(colsAttr, cols); | 588     setUnsignedIntegralAttribute(colsAttr, cols); | 
| 589 } | 589 } | 
| 590 | 590 | 
| 591 void HTMLTextAreaElement::setRows(int rows) | 591 void HTMLTextAreaElement::setRows(unsigned rows) | 
| 592 { | 592 { | 
| 593     setIntegralAttribute(rowsAttr, rows); | 593     setUnsignedIntegralAttribute(rowsAttr, rows); | 
| 594 } | 594 } | 
| 595 | 595 | 
| 596 bool HTMLTextAreaElement::matchesReadOnlyPseudoClass() const | 596 bool HTMLTextAreaElement::matchesReadOnlyPseudoClass() const | 
| 597 { | 597 { | 
| 598     return isReadOnly(); | 598     return isReadOnly(); | 
| 599 } | 599 } | 
| 600 | 600 | 
| 601 bool HTMLTextAreaElement::matchesReadWritePseudoClass() const | 601 bool HTMLTextAreaElement::matchesReadWritePseudoClass() const | 
| 602 { | 602 { | 
| 603     return !isReadOnly(); | 603     return !isReadOnly(); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 640 | 640 | 
| 641 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s
     ource) | 641 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s
     ource) | 
| 642 { | 642 { | 
| 643     const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle
     ment&>(source); | 643     const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle
     ment&>(source); | 
| 644     setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); | 644     setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); | 
| 645     m_isDirty = sourceElement.m_isDirty; | 645     m_isDirty = sourceElement.m_isDirty; | 
| 646     HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); | 646     HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); | 
| 647 } | 647 } | 
| 648 | 648 | 
| 649 } // namespace blink | 649 } // namespace blink | 
| OLD | NEW | 
|---|