2011-03-15 Ilya Sherman <isherman@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2011 18:02:55 +0000 (18:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2011 18:02:55 +0000 (18:02 +0000)
        Reviewed by Tony Chang.

        Autofilled form elements are assigned fixed background color but not text color
        https://bugs.webkit.org/show_bug.cgi?id=48382

        * fast/forms/input-autofilled-expected.txt: Added.
        * fast/forms/input-autofilled.html: Added.
        * platform/win/fast/forms/input-autofilled-expected.txt: Added.
2011-03-15  Ilya Sherman  <isherman@chromium.org>

        Reviewed by Tony Chang.

        Autofilled form elements are assigned fixed background color but not text color
        https://bugs.webkit.org/show_bug.cgi?id=48382

        Test: fast/forms/input-autofilled.html

        * css/html.css:
        (input:-webkit-autofill): Added foreground color: #000000
        * css/wml.css:
        (input:-webkit-autofill): Added foreground color: #000000
2011-03-15  Ilya Sherman  <isherman@chromium.org>

        Reviewed by Tony Chang.

        Autofilled form elements are assigned fixed background color but not text color
        https://bugs.webkit.org/show_bug.cgi?id=48382

        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
        (DumpRenderTreeSupportGtk::setAutofilled): Added.
        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
2011-03-15  Ilya Sherman  <isherman@chromium.org>

        Reviewed by Tony Chang.

        Autofilled form elements are assigned fixed background color but not text color
        https://bugs.webkit.org/show_bug.cgi?id=48382

        * DOM/WebDOMOperations.mm:
        (-[DOMHTMLInputElement _setAutofilled:]): Added (wrapper).
        * DOM/WebDOMOperationsPrivate.h:
2011-03-15  Ilya Sherman  <isherman@chromium.org>

        Reviewed by Tony Chang.

        Autofilled form elements are assigned fixed background color but not text color
        https://bugs.webkit.org/show_bug.cgi?id=48382

        * DumpRenderTree/LayoutTestController.cpp:
        (setAutofilledCallback): Added.
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::setAutofilled): Added.
        * DumpRenderTree/chromium/LayoutTestController.h:
        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::setAutofilled): Added.
        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
        (LayoutTestController::setAutofilled): Added.
        (LayoutTestController::setValueForUser): Style tweak.
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::setAutofilled): Added (stub).
        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
        (LayoutTestController::setAutofilled): Added (stub).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@81155 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/input-autofilled-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/input-autofilled.html [new file with mode: 0644]
LayoutTests/platform/win/fast/forms/input-autofilled-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/html.css
Source/WebCore/css/wml.css
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/WebDOMOperations.mm
Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h
Tools/ChangeLog
Tools/DumpRenderTree/LayoutTestController.cpp
Tools/DumpRenderTree/LayoutTestController.h
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm
Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp
Tools/DumpRenderTree/wx/LayoutTestControllerWx.cpp

index 551a7df..0fc0a27 100644 (file)
@@ -1,3 +1,14 @@
+2011-03-15  Ilya Sherman  <isherman@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Autofilled form elements are assigned fixed background color but not text color
+        https://bugs.webkit.org/show_bug.cgi?id=48382
+
+        * fast/forms/input-autofilled-expected.txt: Added.
+        * fast/forms/input-autofilled.html: Added.
+        * platform/win/fast/forms/input-autofilled-expected.txt: Added.
+
 2011-03-15  Adam Roben  <aroben@apple.com>
 
         Update WebKit2 Skipped file for some new tests that rely on unimplemented features
diff --git a/LayoutTests/fast/forms/input-autofilled-expected.txt b/LayoutTests/fast/forms/input-autofilled-expected.txt
new file mode 100644 (file)
index 0000000..32c250f
--- /dev/null
@@ -0,0 +1,4 @@
+This tests that foreground and background colors properly change for autofilled inputs. It can only be run using DumpRenderTree.
+
+PASS 
+
diff --git a/LayoutTests/fast/forms/input-autofilled.html b/LayoutTests/fast/forms/input-autofilled.html
new file mode 100644 (file)
index 0000000..61ae360
--- /dev/null
@@ -0,0 +1,65 @@
+<html>
+<head>
+    <script src="../js/resources/js-test-pre.js"></script>
+    <script>
+    function test() {
+        if (window.layoutTestController) {
+            layoutTestController.dumpAsText();
+        }
+
+        var tf = document.getElementById('tf');
+        var computedStyle = document.defaultView.getComputedStyle(tf);
+        var originalForeground = computedStyle.color;
+        var originalBackground = computedStyle.backgroundColor;
+
+        if (window.layoutTestController) {
+            layoutTestController.setAutofilled(tf, true);
+        }
+
+        // Both the foreground and background colors should change.
+        computedStyle = document.defaultView.getComputedStyle(tf);
+        var autofilledForeground = computedStyle.color;
+        var autofilledBackground = computedStyle.backgroundColor;
+        if (autofilledForeground == originalForeground) {
+            testFailed('Foreground color did not change when autofilled.');
+            return;
+        }
+        if (autofilledBackground == originalBackground) {
+            testFailed('Background color did not change when autofilled.');
+            return;
+        }
+
+        if (window.layoutTestController) {
+            layoutTestController.setAutofilled(tf, false);
+        }
+
+        // Colors should be restored.
+        computedStyle = document.defaultView.getComputedStyle(tf);
+        if (computedStyle.color != originalForeground) {
+            testFailed('Foreground color did not revert when un-autofilled.');
+            return;
+        }
+        if (computedStyle.backgroundColor != originalBackground) {
+            testFailed('Background color did not revert when un-autofilled.');
+            return;
+        }
+
+        testPassed('');
+    }
+    </script>
+
+    <style>
+    #tf {
+      color: #FFFFFF;
+      background-color: #FFFFFF;
+    }
+    </style>
+</head>
+<body onload="test()">
+    This tests that foreground and background colors properly change for autofilled inputs.  It can only be run using DumpRenderTree.<br>
+    <form name="fm">
+        <input type="text" id="tf" value="Field value" />
+    </form>
+    <div id="console"></div>
+</body>
+</html>
diff --git a/LayoutTests/platform/win/fast/forms/input-autofilled-expected.txt b/LayoutTests/platform/win/fast/forms/input-autofilled-expected.txt
new file mode 100644 (file)
index 0000000..98559fd
--- /dev/null
@@ -0,0 +1,4 @@
+This tests that foreground and background colors properly change for autofilled inputs. It can only be run using DumpRenderTree.
+
+FAIL Foreground color did not change when autofilled.
+
index 88e1ccf..f55a765 100644 (file)
@@ -1,3 +1,17 @@
+2011-03-15  Ilya Sherman  <isherman@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Autofilled form elements are assigned fixed background color but not text color
+        https://bugs.webkit.org/show_bug.cgi?id=48382
+
+        Test: fast/forms/input-autofilled.html
+
+        * css/html.css:
+        (input:-webkit-autofill): Added foreground color: #000000
+        * css/wml.css:
+        (input:-webkit-autofill): Added foreground color: #000000
+
 2011-03-15  Alexis Menard  <alexis.menard@openbossa.org>
 
         Reviewed by Eric Carlson.
index 61178d0..b9be50e 100644 (file)
@@ -476,6 +476,7 @@ input[type="file"] {
 input:-webkit-autofill {
     background-color: #FAFFBD !important;
     background-image:none !important;
+    color: #000000 !important;
 }
 
 input[type="radio"], input[type="checkbox"] {
index 4bcf08f..38169fc 100644 (file)
@@ -147,6 +147,7 @@ input[type="password"] {
 input:-webkit-autofill {
     background-color: #FAFFBD !important;
     background-image:none !important;
+    color: #000000 !important;
 }
 
 do:disabled, select:disabled, optgroup:disabled, option:disabled {
index 581ded8..c2df771 100644 (file)
@@ -1,3 +1,14 @@
+2011-03-15  Ilya Sherman  <isherman@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Autofilled form elements are assigned fixed background color but not text color
+        https://bugs.webkit.org/show_bug.cgi?id=48382
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::setAutofilled): Added.
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
+
 2011-03-14  Ryuan Choi  <ryuan.choi@samsung.com>
 
         Reviewed by Martin Robinson.
index f0000b8..0ce9876 100644 (file)
@@ -34,6 +34,7 @@
 #include "FrameView.h"
 #include "GCController.h"
 #include "GraphicsContext.h"
+#include "HTMLInputElement.h"
 #include "InputElement.h"
 #include "JSDOMWindow.h"
 #include "JSDocument.h"
@@ -666,6 +667,19 @@ void DumpRenderTreeSupportGtk::setMinimumTimerInterval(WebKitWebView* webView, d
     core(webView)->settings()->setMinDOMTimerInterval(interval);
 }
 
+void DumpRenderTreeSupportGtk::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool autofilled)
+{
+    JSC::ExecState* exec = toJS(context);
+    Element* element = toElement(toJS(exec, nodeObject));
+    if (!element)
+        return;
+    InputElement* inputElement = element->toInputElement();
+    if (!inputElement)
+        return;
+
+    static_cast<HTMLInputElement*>(inputElement)->setAutofilled(autofilled);
+}
+
 void DumpRenderTreeSupportGtk::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
 {
     JSC::ExecState* exec = toJS(context);
index bc4544f..7ad5af6 100644 (file)
@@ -84,6 +84,7 @@ public:
     static AtkObject* getFocusedAccessibleElement(WebKitWebFrame*);
     static AtkObject* getRootAccessibleElement(WebKitWebFrame*);
     static void layoutFrame(WebKitWebFrame*);
+    static void setAutofilled(JSContextRef, JSValueRef, bool);
     static void setValueForUser(JSContextRef, JSValueRef, JSStringRef);
 
     // WebKitWebView
index 11d1f4e..b315e1c 100644 (file)
@@ -1,3 +1,14 @@
+2011-03-15  Ilya Sherman  <isherman@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Autofilled form elements are assigned fixed background color but not text color
+        https://bugs.webkit.org/show_bug.cgi?id=48382
+
+        * DOM/WebDOMOperations.mm:
+        (-[DOMHTMLInputElement _setAutofilled:]): Added (wrapper).
+        * DOM/WebDOMOperationsPrivate.h:
+
 2011-03-15  Adam Roben  <aroben@apple.com>
 
         Fix a leak in WebStorageTrackerClient::dispatchDidModifyOrigin
index eee4919..979433d 100644 (file)
@@ -197,6 +197,11 @@ using namespace JSC;
 
 @implementation DOMHTMLInputElement (WebDOMHTMLInputElementOperationsPrivate)
 
+- (void)_setAutofilled:(BOOL)autofilled
+{
+    static_cast<HTMLInputElement*>(core((DOMElement *)self))->setAutofilled(autofilled);
+}
+
 - (void)_setValueForUser:(NSString *)value
 {
     static_cast<HTMLInputElement*>(core((DOMElement *)self))->setValueForUser(value);
index dc1aaf8..b579a6f 100644 (file)
@@ -39,6 +39,7 @@
 @end
 
 @interface DOMHTMLInputElement (WebDOMHTMLInputElementOperationsPrivate)
+- (void)_setAutofilled:(BOOL)autofilled;
 - (void)_setValueForUser:(NSString *)value;
 @end
 
index 4c7e64a..dd6f87d 100644 (file)
@@ -1,3 +1,28 @@
+2011-03-15  Ilya Sherman  <isherman@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Autofilled form elements are assigned fixed background color but not text color
+        https://bugs.webkit.org/show_bug.cgi?id=48382
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (setAutofilledCallback): Added.
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::setAutofilled): Added.
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::setAutofilled): Added.
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::setAutofilled): Added.
+        (LayoutTestController::setValueForUser): Style tweak.
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::setAutofilled): Added (stub).
+        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+        (LayoutTestController::setAutofilled): Added (stub).
+
 2011-03-15  Dan Bernstein  <mitz@apple.com>
 
         Build fix after r81135.
index 52d4247..0ce9b78 100644 (file)
@@ -1099,6 +1099,17 @@ static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JS
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount != 2 || !arguments[0])
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1]));
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has Mac implementation.
@@ -2168,6 +2179,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setAutofilled", setAutofilledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -2205,7 +2217,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeDontDelete },
+        { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index 2552b11..fe7a09e 100644 (file)
@@ -90,6 +90,7 @@ public:
     void setAppCacheMaximumSize(unsigned long long quota);
     void setApplicationCacheOriginQuota(unsigned long long quota);
     void setAuthorAndUserStylesEnabled(bool);
+    void setAutofilled(JSContextRef, JSValueRef nodeObject, bool autofilled);
     void setCacheModel(int);
     void setCustomPolicyDelegate(bool setDelegate, bool permissive);
     void setDatabaseQuota(unsigned long long quota);
index 01c9407..1a1a780 100644 (file)
@@ -138,6 +138,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setAllowUniversalAccessFromFileURLs", &LayoutTestController::setAllowUniversalAccessFromFileURLs);
     bindMethod("setAlwaysAcceptCookies", &LayoutTestController::setAlwaysAcceptCookies);
     bindMethod("setAuthorAndUserStylesEnabled", &LayoutTestController::setAuthorAndUserStylesEnabled);
+    bindMethod("setAutofilled", &LayoutTestController::setAutofilled);
     bindMethod("setCanOpenWindows", &LayoutTestController::setCanOpenWindows);
     bindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setCloseRemainingWindowsWhenComplete);
     bindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate);
@@ -1620,6 +1621,23 @@ void LayoutTestController::setMinimumTimerInterval(const CppArgumentList& argume
     m_shell->webView()->settings()->setMinimumTimerInterval(arguments[0].toDouble());
 }
 
+void LayoutTestController::setAutofilled(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    if (arguments.size() != 2 || !arguments[1].isBool())
+        return;
+
+    WebElement element;
+    if (!WebBindings::getElement(arguments[0].value.objectValue, &element))
+        return;
+
+    WebInputElement* input = toWebInputElement(&element);
+    if (!input)
+        return;
+
+    input->setAutofilled(arguments[1].value.boolValue);
+}
+
 void LayoutTestController::setValueForUser(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
@@ -1661,5 +1679,3 @@ void LayoutTestController::syncLocalStorage(const CppArgumentList&, CppVariant*)
 {
     // Not Implemented
 }
-
-
index 87ccc97..f31bc15 100644 (file)
@@ -339,6 +339,10 @@ public:
 
     void setMinimumTimerInterval(const CppArgumentList&, CppVariant*);
 
+    // Expects the first argument to be an input element and the second argument to be a boolean.
+    // Forwards the setAutofilled() call to the element.
+    void setAutofilled(const CppArgumentList&, CppVariant*);
+
     // Expects the first argument to be an input element and the second argument to be a string value.
     // Forwards the setValueForUser() call to the element.
     void setValueForUser(const CppArgumentList&, CppVariant*);
index 2e98679..230ed3c 100644 (file)
@@ -458,6 +458,11 @@ void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
     // FIXME: implement
 }
 
+void LayoutTestController::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool isAutofilled)
+{
+    DumpRenderTreeSupportGtk::setAutofilled(context, nodeObject, isAutofilled);
+}
+
 void LayoutTestController::disableImageLoading()
 {
     // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896
index 7a0bf97..827f0a7 100644 (file)
@@ -368,6 +368,15 @@ void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
     [[[mainFrame webView] preferences] setAuthorAndUserStylesEnabled:flag];
 }
 
+void LayoutTestController::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool autofilled)
+{
+    DOMElement *element = [DOMElement _DOMElementFromJSContext:context value:nodeObject];
+    if (!element || ![element isKindOfClass:[DOMHTMLInputElement class]])
+        return;
+
+    [(DOMHTMLInputElement *)element _setAutofilled:autofilled];
+}
+
 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
 {
     if (setDelegate) {
@@ -532,7 +541,7 @@ void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef node
     DOMElement *element = [DOMElement _DOMElementFromJSContext:context value:nodeObject];
     if (!element || ![element isKindOfClass:[DOMHTMLInputElement class]])
         return;
-    
+
     RetainPtr<CFStringRef> valueCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, value));
     [(DOMHTMLInputElement *)element _setValueForUser:(NSString *)valueCF.get()];
 }
index db6988a..f8b0cb8 100644 (file)
@@ -374,6 +374,11 @@ void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
     prefsPrivate->setAuthorAndUserStylesEnabled(flag);
 }
 
+void LayoutTestController::setAutofilled(JSContextRef, JSValueRef element, bool isAutofilled)
+{
+    // FIXME: implement
+}
+
 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
 {
     COMPtr<IWebView> webView;
index c5e0eab..cd87b9b 100644 (file)
@@ -207,6 +207,11 @@ void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
     // FIXME: implement
 }
 
+void LayoutTestController::setAutofilled(JSContextRef, JSValueRef element, bool isAutofilled)
+{
+    // FIXME: implement
+}
+
 void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled)
 {
     // FIXME: implement