[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tkent at chromium.org tkent at chromium.org
Wed Dec 22 13:16:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 8e141e17f25438c2a361302d7077a202b0853cc7
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 10 05:06:45 2010 +0000

    2010-09-09  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            Apply :invalid CSS class to <input type=number> with an unacceptable value
            https://bugs.webkit.org/show_bug.cgi?id=45376
    
            * fast/forms/input-number-unacceptable-style-expected.txt: Added.
            * fast/forms/input-number-unacceptable-style.html: Added.
    2010-09-09  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            Apply :invalid CSS class to <input type=number> with an unacceptable value
            https://bugs.webkit.org/show_bug.cgi?id=45376
    
            Apply :invalid CSS class to <input type=number> elements with an
            unacceptable value in order to tell users that a value is not
            valid.
    
            Introducing Element::hasUnaccceptableValue(), and CSSStyleSelector
            applies :invalid to not only elements with !isValidFormControlElement()
            but also elements with hasUnaccceptableValue().
    
            HTMLInputElement and RenderTextControlSingleLine need some changes
            to update style and to avoid updating renderer value during style
            update.
    
            Test: fast/forms/input-number-unacceptable-style.html
    
            * css/CSSStyleSelector.cpp:
            (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
            * dom/Element.h:
            (WebCore::Element::hasUnacceptableValue):
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::handleBlurEvent):
            (WebCore::HTMLInputElement::hasUnacceptableValue):
            * html/HTMLInputElement.h:
            * rendering/RenderTextControlSingleLine.cpp:
            (WebCore::RenderTextControlSingleLine::subtreeHasChanged):
            (WebCore::RenderTextControlSingleLine::updateFromElement):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67166 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1e71be0..b77c877 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -2,6 +2,16 @@
 
         Reviewed by Dimitri Glazkov.
 
+        Apply :invalid CSS class to <input type=number> with an unacceptable value
+        https://bugs.webkit.org/show_bug.cgi?id=45376
+
+        * fast/forms/input-number-unacceptable-style-expected.txt: Added.
+        * fast/forms/input-number-unacceptable-style.html: Added.
+
+2010-09-09  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
         <input type=number> should not have an invalid number as its value
         https://bugs.webkit.org/show_bug.cgi?id=43973
 
diff --git a/LayoutTests/fast/forms/input-number-unacceptable-style-expected.txt b/LayoutTests/fast/forms/input-number-unacceptable-style-expected.txt
new file mode 100644
index 0000000..21eefc6
--- /dev/null
+++ b/LayoutTests/fast/forms/input-number-unacceptable-style-expected.txt
@@ -0,0 +1,21 @@
+A number input fields with an unacceptable string should have :invalid style.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Initial state. The elment has no value.
+PASS colorOf(number) is normalStyleColor
+Type '-'. The renderer value becomes unacceptable.
+PASS colorOf(number) is invalidStyleColor
+PASS number.validity.valid is true
+Type '1' additionally. The renderer value becomes acceptable.
+PASS colorOf(number) is normalStyleColor
+Type '+' additionally. The renderer value becomes unacceptable again.
+PASS colorOf(number) is invalidStyleColor
+The element losts focus. The unacceptable value should be purged and the style should be normal.
+PASS colorOf(number) is normalStyleColor
+PASS document.getSelection().toString() is "-1"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/input-number-unacceptable-style.html b/LayoutTests/fast/forms/input-number-unacceptable-style.html
new file mode 100644
index 0000000..a16514f
--- /dev/null
+++ b/LayoutTests/fast/forms/input-number-unacceptable-style.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<style>
+:invalid {
+  background-color: #ff0000;
+}
+</style>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id=parent>
+<input type=number id=number>
+<input id=another>
+</div>
+<script>
+description('A number input fields with an unacceptable string should have :invalid style.');
+
+function colorOf(el) {
+    return document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color');
+}
+var normalStyleColor = 'rgb(255, 255, 255)';
+var invalidStyleColor = 'rgb(255, 0, 0)';
+
+var number = document.getElementById('number');
+number.focus();
+debug('Initial state. The elment has no value.');
+shouldBe('colorOf(number)', 'normalStyleColor');
+
+debug("Type '-'. The renderer value becomes unacceptable.");
+document.execCommand('InsertText', false, '-');
+shouldBe('colorOf(number)', 'invalidStyleColor');
+shouldBeTrue('number.validity.valid');
+
+debug("Type '1' additionally. The renderer value becomes acceptable.");
+document.execCommand('InsertText', false, '1');
+shouldBe('colorOf(number)', 'normalStyleColor');
+
+debug("Type '+' additionally. The renderer value becomes unacceptable again.");
+document.execCommand('InsertText', false, '+');
+shouldBe('colorOf(number)', 'invalidStyleColor');
+
+debug("The element losts focus. The unacceptable value should be purged and the style should be normal.");
+document.getElementById('another').focus();
+shouldBe('colorOf(number)', 'normalStyleColor');
+// Visiblue value is not '-1+'.
+number.focus();
+document.execCommand('SelectAll');
+shouldBe('document.getSelection().toString()', '"-1"');
+
+document.getElementById('parent').innerHTML = '';
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index afba0ac..1f3273c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,39 @@
 
         Reviewed by Dimitri Glazkov.
 
+        Apply :invalid CSS class to <input type=number> with an unacceptable value
+        https://bugs.webkit.org/show_bug.cgi?id=45376
+
+        Apply :invalid CSS class to <input type=number> elements with an
+        unacceptable value in order to tell users that a value is not
+        valid.
+
+        Introducing Element::hasUnaccceptableValue(), and CSSStyleSelector
+        applies :invalid to not only elements with !isValidFormControlElement()
+        but also elements with hasUnaccceptableValue().
+
+        HTMLInputElement and RenderTextControlSingleLine need some changes
+        to update style and to avoid updating renderer value during style
+        update.
+
+        Test: fast/forms/input-number-unacceptable-style.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
+        * dom/Element.h:
+        (WebCore::Element::hasUnacceptableValue):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::handleBlurEvent):
+        (WebCore::HTMLInputElement::hasUnacceptableValue):
+        * html/HTMLInputElement.h:
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::subtreeHasChanged):
+        (WebCore::RenderTextControlSingleLine::updateFromElement):
+
+2010-09-09  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
         <input type=number> should not have an invalid number as its value
         https://bugs.webkit.org/show_bug.cgi?id=43973
 
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index af9a24c..8d89d33 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -2576,7 +2576,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
                 if (!e)
                     return false;
                 e->document()->setContainsValidityStyleRules();
-                return e->willValidate() && !e->isValidFormControlElement();
+                return e->willValidate() && !e->isValidFormControlElement() || e->hasUnacceptableValue();
             } case CSSSelector::PseudoChecked: {
                 if (!e || !e->isFormControlElement())
                     break;
diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h
index d13d483..d9a5085 100644
--- a/WebCore/dom/Element.h
+++ b/WebCore/dom/Element.h
@@ -282,6 +282,7 @@ public:
     virtual bool isDefaultButtonForForm() const { return false; }
     virtual bool willValidate() const { return false; }
     virtual bool isValidFormControlElement() { return false; }
+    virtual bool hasUnacceptableValue() const { return false; }
 
     virtual bool formControlValueMatchesRenderer() const { return false; }
     virtual void setFormControlValueMatchesRenderer(bool) { }
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index f9cf522..a169918 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -828,8 +828,14 @@ void HTMLInputElement::handleFocusEvent()
 
 void HTMLInputElement::handleBlurEvent()
 {
-    // Reset the renderer value, which might be unmatched with the element value.
-    setFormControlValueMatchesRenderer(false);
+    if (inputType() == NUMBER) {
+        // Reset the renderer value, which might be unmatched with the element value.
+        setFormControlValueMatchesRenderer(false);
+        // We need to reset the renderer value explicitly because an unacceptable
+        // renderer value should be purged before style calculation.
+        if (renderer())
+            renderer()->updateFromElement();
+    }
     InputElement::dispatchBlurEvent(this, this);
 }
 
@@ -2691,6 +2697,11 @@ String HTMLInputElement::sanitizeValue(const String& proposedValue) const
     return proposedValue;
 }
 
+bool HTMLInputElement::hasUnacceptableValue() const
+{
+    return inputType() == NUMBER && renderer() && !isAcceptableValue(toRenderTextControl(renderer())->text());
+}
+
 bool HTMLInputElement::needsActivationCallback()
 {
     return inputType() == PASSWORD || m_autocomplete == Off;
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 4de121d..e023796 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -283,6 +283,7 @@ private:
 
     virtual bool isAcceptableValue(const String&) const;
     virtual String sanitizeValue(const String&) const;
+    virtual bool hasUnacceptableValue() const;
 
     virtual void documentDidBecomeActive();
 
diff --git a/WebCore/rendering/RenderTextControlSingleLine.cpp b/WebCore/rendering/RenderTextControlSingleLine.cpp
index c9d6d43..17ab65a 100644
--- a/WebCore/rendering/RenderTextControlSingleLine.cpp
+++ b/WebCore/rendering/RenderTextControlSingleLine.cpp
@@ -173,6 +173,10 @@ void RenderTextControlSingleLine::subtreeHasChanged()
     String value = text();
     if (input->isAcceptableValue(value))
         input->setValueFromRenderer(input->sanitizeValue(value));
+    if (node()->isHTMLElement()) {
+        // Recalc for :invalid and hasUnacceptableValue() change.
+        static_cast<HTMLInputElement*>(input)->setNeedsStyleRecalc();
+    }
 
     if (m_cancelButton)
         updateCancelButtonVisibility();
@@ -679,7 +683,10 @@ void RenderTextControlSingleLine::updateFromElement()
     } else {
         if (!inputElement()->suggestedValue().isNull())
             setInnerTextValue(inputElement()->suggestedValue());
-        else
+        else if (!node()->isHTMLElement() || !static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer())
+            // For HTMLInputElement, update the renderer value only if the
+            // formControlValueMatchesRenderer() flag is false. It protects an
+            // unacceptable renderer value from being overwritten with the DOM value.
             setInnerTextValue(inputElement()->value());
     }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list