<input type=color> Mac UI behaviour
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2013 20:47:46 +0000 (20:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2013 20:47:46 +0000 (20:47 +0000)
<rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276

Source/JavaScriptCore:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.

Source/WebCore:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

This patch turns on INPUT_TYPE_COLOR and implements it using the native
Mac color panel.

No new tests added.

Currently, there are no automated ways to test the types of changes made in this patch. (i.e. checking
which color is being displayed in the color panel, checking which color element is currently
associated to the color panel, checking the state of color elements after directing away and
being directed back to its page, etc.)

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:

* html/ColorInputType.cpp:
(WebCore::ColorInputType::handleDOMActivateEvent): Reattaches the color picker if
  a color picker has already been shown for an element
(WebCore::ColorInputType::shouldResetOnDocumentActivation): Always returns true, needed to
  detach the color picker when caching a page.
* html/ColorInputType.h:

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::documentDidResumeFromPageCache): For <input type='color'>,
  don't reset the element.
(WebCore::HTMLInputElement::documentWillSuspendForPageCache): For <input type='color'>, call detach().
* html/HTMLInputElement.h:

* platform/ColorChooser.h:
(WebCore::ColorChooser::reattachColorChooser): Added definition.

Source/WebKit/mac:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::createColorPicker): Added stub implementation.

Source/WebKit2:

Implemented <input type='color'> on Mac using the native color picker.

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

Code for WebColorPickerMac is derived from Chromium's color_chooser_mac.mm:
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/cocoa/color_chooser_mac.mm

* Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.

* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::createColorPicker): Replaced stub implementation
  and return a WebColorPickerMac object.

* UIProcess/WebColorPicker.cpp:
(WebKit::WebColorPicker::invalidate): Updated to call endChooser().
(WebKit::WebColorPicker::showColorPicker): Added stub implementation.
* UIProcess/WebColorPicker.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close): Removed invalidation of removed color picker objects.
(WebKit::WebPageProxy::showColorPicker): Updated so that it works for
  multiple <input type='color'> elements on a page.
(WebKit::WebPageProxy::didEndColorPicker): Removed cleanup of removed color picker objects.
(WebKit::WebPageProxy::resetStateAfterProcessExited): Removed cleanup of removed color picker objects.

* UIProcess/mac/WebColorPickerMac.h: Added.
* UIProcess/mac/WebColorPickerMac.mm: Added.
(WebKit::WebColorPickerMac::create):
(WebKit::WebColorPickerMac::~WebColorPickerMac):
(WebKit::WebColorPickerMac::WebColorPickerMac):
(WebKit::WebColorPickerMac::endPicker):
(WebKit::WebColorPickerMac::setSelectedColor):
(WebKit::WebColorPickerMac::didChooseColor):
(WebKit::WebColorPickerMac::showColorPicker):
WebColorPickerMac contains a reference to a WKColorPanelMac object
  and is responsible for maintaining the color picker UI.

(-[WKColorPanelMac setAndShowPicker:withColor:]):
(-[WKColorPanelMac invalidate]):
(-[WKColorPanelMac windowWillClose:]):
(-[WKColorPanelMac didChooseColor:]):
(-[WKColorPanelMac setColor:]):
WKColorPanelMac is a wrapper for a NSColorPanel object and
  is responsible for the color picker UI.

* WebKit2.xcodeproj/project.pbxproj:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createColorChooser): Updated to always create a
  WebColorChooser object.

* WebProcess/WebCoreSupport/WebColorChooser.cpp:
(WebKit::WebColorChooser::reattachColorChooser): Sets the page's
  active color chooser to the current object and pings the UIProcess
  to show the color picker.
(WebKit::WebColorChooser::setSelectedColor): Only sets the color in the
  color picker if the WebColorChooser object is the active color element.
* WebProcess/WebCoreSupport/WebColorChooser.h:

Source/WTF:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

* wtf/FeatureDefines.h: Enabled INPUT_TYPE_COLOR on Mac port.

LayoutTests:

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-31
Reviewed by Brady Eidson.

Updated tests to reflect <input type='color'> being implemented with a native color picker.

* fast/forms/color/input-color-onchange-event-expected.txt:

* platform/mac/TestExpectations: Enabled fast/form/color tests on Mac.

* platform/mac/accessibility/color-well-expected.txt:
* platform/mac/accessibility/role-subrole-roledescription-expected.txt:
* platform/mac/accessibility/role-subrole-roledescription.html:

* platform/mac/fast/forms/color/input-appearance-color-expected.txt: Updated test expectations
on Mac to reflect the fact that the list attribute for <input type='color'> is not yet supported.

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

36 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/color/input-color-onchange-event-expected.txt
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/mac/accessibility/color-well-expected.txt
LayoutTests/platform/mac/accessibility/role-subrole-roledescription-expected.txt
LayoutTests/platform/mac/accessibility/role-subrole-roledescription.html
LayoutTests/platform/mac/fast/forms/color/input-appearance-color-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/ColorInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/platform/ColorChooser.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/FeatureDefines.xcconfig
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/FeatureDefines.xcconfig
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/WebColorPicker.cpp
Source/WebKit2/UIProcess/WebColorPicker.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/mac/WebColorPickerMac.h [new file with mode: 0644]
Source/WebKit2/UIProcess/mac/WebColorPickerMac.mm [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebColorChooser.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebColorChooser.h

index e370287..bc3a03b 100644 (file)
@@ -1,3 +1,23 @@
+2013-07-31  Ruth Fong  <ruth_fong@apple.com>
+
+        <input type=color> Mac UI behaviour
+        <rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276
+
+        Reviewed by Brady Eidson.
+
+        Updated tests to reflect <input type='color'> being implemented with a native color picker.
+
+        * fast/forms/color/input-color-onchange-event-expected.txt:
+
+        * platform/mac/TestExpectations: Enabled fast/form/color tests on Mac.
+
+        * platform/mac/accessibility/color-well-expected.txt:
+        * platform/mac/accessibility/role-subrole-roledescription-expected.txt:
+        * platform/mac/accessibility/role-subrole-roledescription.html:
+
+        * platform/mac/fast/forms/color/input-appearance-color-expected.txt: Updated test expectations
+        on Mac to reflect the fact that the list attribute for <input type='color'> is not yet supported.
+
 2013-07-31  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         DFG doesn't account for inlining of functions with switch statements that haven't been executed by the baseline JIT
index a1cd685..c879a0b 100644 (file)
@@ -1,4 +1,5 @@
-Test if change event fires properly when color chooser changes. Bug 66848
+Test if change event fires properly when color chooser changes. Bug 66848 
+To manually test this, click on the input color element in the top left corner and change the value from the color chooser. See if the number of "value changed" messages matches the number of times you changed the color.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
index 5ddc8d4..0922745 100644 (file)
@@ -157,9 +157,6 @@ webkit.org/b/61827 fast/events/drag-image-filename.html
 # Datalist is not yet enabled.
 fast/forms/datalist
 
-# Color input is not yet enabled.
-fast/forms/color
-
 # Times out only in non-wk2 Mac, possibly because of platform-specific behavior
 # interfering with how the test is executed.
 webkit.org/b/113220 fast/forms/select/popup-closes-on-blur.html [ Timeout Pass ]
index bf82e88..82675c4 100644 (file)
@@ -4,10 +4,10 @@ This test checks the role of ColorWellRolean input with type=color
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-Role of input type=color is: AXRole: AXTextField
-Value of empty color well: AXValue: 
-Value of good color well: AXValue: #ff0000
-Value of bad color well: AXValue: purple
+Role of input type=color is: AXRole: AXColorWell
+Value of empty color well: AXValue: rgb 0.00000 0.00000 0.00000 1
+Value of good color well: AXValue: rgb 1.00000 0.00000 0.00000 1
+Value of bad color well: AXValue: rgb 0.00000 0.00000 0.00000 1
 PASS successfullyParsed is true
 
 TEST COMPLETE
index a56e0ca..364d2a3 100644 (file)
@@ -205,9 +205,9 @@ PASS: input[type='button']
       AXRoleDescription: button
       
 PASS: input[type='color']
-      AXRole: AXTextField
+      AXRole: AXColorWell
       AXSubrole: 
-      AXRoleDescription: text field
+      AXRoleDescription: color well
       
 PASS: input[type='checkbox']
       AXRole: AXCheckBox
index 2458c41..07e88bc 100644 (file)
@@ -61,7 +61,7 @@
 <img data-role="AXImage" data-subrole="" data-roledescription="image" class="ex" alt="X" data-note="[alt='X']">
 <input type="button" value="X" data-role="AXButton" data-subrole="" data-roledescription="button" class="ex" data-note="[type='button']">
 <!-- skipped <menu><input type="button"></menu> -->
-<!-- http://webkit.org/b/109017 --><input type="color" value="X" data-role="AXTextField" data-subrole="" data-roledescription="text field" class="ex" data-note="[type='color']">
+<!-- http://webkit.org/b/109017 --><input type="color" value="X" data-role="AXColorWell" data-subrole="" data-roledescription="color well" class="ex" data-note="[type='color']">
 <input type="checkbox" data-role="AXCheckBox" data-subrole="" data-roledescription="check box" class="ex" data-note="[type='checkbox']">
 <!-- skipped <menu><input type="checkbox"></menu> -->
 <!-- http://webkit.org/b/109017 --><input type="date" value="X" data-role="AXTextField" data-subrole="" data-roledescription="text field" class="ex" data-note="[type='date']">
index f8dd856..56485f2 100644 (file)
@@ -10,106 +10,106 @@ layer at (0,0) size 800x600
         RenderText {#text} at (0,0) size 456x18
           text run at (0,0) width 456: "List color controls have different appearance if ENABLE(DATALIST)."
         RenderBR {BR} at (456,14) size 0x0
-        RenderBlock {INPUT} at (0,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderBlock {INPUT} at (0,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#000000] [border: (1px solid #777777)]
+        RenderBlock {INPUT} at (44,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#000000] [border: (1px solid #777777)]
-        RenderBlock {INPUT} at (44,23) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#000000] [border: (1px solid #000000)]
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {H3} at (0,99) size 784x22
         RenderText {#text} at (0,0) size 160x22
           text run at (0,0) width 160: "Different Font Sizes"
-      RenderBlock (anonymous) at (0,139) size 784x45
+      RenderBlock (anonymous) at (0,139) size 784x41
         RenderText {#text} at (0,0) size 577x18
           text run at (0,0) width 577: "List color controls have different sizes depending on font sizes. Normal color controls don't."
         RenderBR {BR} at (577,14) size 0x0
-        RenderBlock {INPUT} at (0,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderBlock {INPUT} at (0,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
-        RenderText {#text} at (44,27) size 4x18
-          text run at (44,27) width 4: " "
-        RenderBlock {INPUT} at (48,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderText {#text} at (44,21) size 4x18
+          text run at (44,21) width 4: " "
+        RenderBlock {INPUT} at (48,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
-        RenderText {#text} at (92,27) size 4x18
-          text run at (92,27) width 4: " "
-        RenderBlock {INPUT} at (96,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderText {#text} at (92,21) size 4x18
+          text run at (92,21) width 4: " "
+        RenderBlock {INPUT} at (96,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
+        RenderText {#text} at (140,21) size 4x18
+          text run at (140,21) width 4: " "
+        RenderBlock {INPUT} at (144,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
+        RenderText {#text} at (188,21) size 4x18
+          text run at (188,21) width 4: " "
+        RenderBlock {INPUT} at (192,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
+        RenderText {#text} at (236,21) size 4x18
+          text run at (236,21) width 4: " "
+        RenderBlock {INPUT} at (240,18) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
-        RenderText {#text} at (140,27) size 4x18
-          text run at (140,27) width 4: " "
-        RenderBlock {INPUT} at (144,20) size 88x21 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x21
-            RenderBlock {DIV} at (8,4) size 56x13 [bgcolor=#00FF00] [border: (1px solid #000000)]
-        RenderText {#text} at (232,27) size 4x18
-          text run at (232,27) width 4: " "
-        RenderBlock {INPUT} at (236,23) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#00FF00] [border: (1px solid #000000)]
-        RenderText {#text} at (324,27) size 4x18
-          text run at (324,27) width 4: " "
-        RenderBlock {INPUT} at (328,26) size 88x15 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x15
-            RenderBlock {DIV} at (8,4) size 56x7 [bgcolor=#00FF00] [border: (1px solid #000000)]
         RenderText {#text} at (0,0) size 0x0
-      RenderBlock {H3} at (0,202) size 784x22
+      RenderBlock {H3} at (0,198) size 784x22
         RenderText {#text} at (0,0) size 124x22
           text run at (0,0) width 124: "Various Colors"
-      RenderBlock (anonymous) at (0,242) size 784x27
-        RenderBlock {INPUT} at (0,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+      RenderBlock (anonymous) at (0,238) size 784x23
+        RenderBlock {INPUT} at (0,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#FF0000] [border: (1px solid #777777)]
+        RenderText {#text} at (44,3) size 4x18
+          text run at (44,3) width 4: " "
+        RenderBlock {INPUT} at (48,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
+        RenderText {#text} at (92,3) size 4x18
+          text run at (92,3) width 4: " "
+        RenderBlock {INPUT} at (96,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#0000FF] [border: (1px solid #777777)]
+        RenderText {#text} at (140,3) size 4x18
+          text run at (140,3) width 4: " "
+        RenderBlock {INPUT} at (144,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#EC008C] [border: (1px solid #777777)]
+        RenderText {#text} at (188,3) size 4x18
+          text run at (188,3) width 4: " "
+        RenderBlock {INPUT} at (192,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,1) size 38x21
+            RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#40E0D0] [border: (1px solid #777777)]
+        RenderText {#text} at (236,3) size 4x18
+          text run at (236,3) width 4: " "
+        RenderBlock {INPUT} at (240,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#FF0000] [border: (1px solid #777777)]
-        RenderText {#text} at (44,9) size 4x18
-          text run at (44,9) width 4: " "
-        RenderBlock {INPUT} at (48,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderText {#text} at (284,3) size 4x18
+          text run at (284,3) width 4: " "
+        RenderBlock {INPUT} at (288,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#00FF00] [border: (1px solid #777777)]
-        RenderText {#text} at (92,9) size 4x18
-          text run at (92,9) width 4: " "
-        RenderBlock {INPUT} at (96,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderText {#text} at (332,3) size 4x18
+          text run at (332,3) width 4: " "
+        RenderBlock {INPUT} at (336,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#0000FF] [border: (1px solid #777777)]
-        RenderText {#text} at (140,9) size 4x18
-          text run at (140,9) width 4: " "
-        RenderBlock {INPUT} at (144,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderText {#text} at (380,3) size 4x18
+          text run at (380,3) width 4: " "
+        RenderBlock {INPUT} at (384,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#EC008C] [border: (1px solid #777777)]
-        RenderText {#text} at (188,9) size 4x18
-          text run at (188,9) width 4: " "
-        RenderBlock {INPUT} at (192,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+        RenderText {#text} at (428,3) size 4x18
+          text run at (428,3) width 4: " "
+        RenderBlock {INPUT} at (432,0) size 44x23 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 38x21
             RenderBlock {DIV} at (2,4) size 34x13 [bgcolor=#40E0D0] [border: (1px solid #777777)]
-        RenderText {#text} at (236,9) size 4x18
-          text run at (236,9) width 4: " "
-        RenderBlock {INPUT} at (240,5) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#FF0000] [border: (1px solid #000000)]
-        RenderText {#text} at (328,9) size 4x18
-          text run at (328,9) width 4: " "
-        RenderBlock {INPUT} at (332,5) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#00FF00] [border: (1px solid #000000)]
-        RenderText {#text} at (420,9) size 4x18
-          text run at (420,9) width 4: " "
-        RenderBlock {INPUT} at (424,5) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#0000FF] [border: (1px solid #000000)]
-        RenderText {#text} at (512,9) size 4x18
-          text run at (512,9) width 4: " "
-        RenderBlock {INPUT} at (516,5) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#EC008C] [border: (1px solid #000000)]
-        RenderText {#text} at (604,9) size 4x18
-          text run at (604,9) width 4: " "
-        RenderBlock {INPUT} at (608,5) size 88x18 [bgcolor=#FFFFFF]
-          RenderFlexibleBox {DIV} at (0,0) size 88x18
-            RenderBlock {DIV} at (8,4) size 56x10 [bgcolor=#40E0D0] [border: (1px solid #000000)]
         RenderText {#text} at (0,0) size 0x0
-      RenderBlock {H3} at (0,287) size 784x22
+      RenderBlock {H3} at (0,279) size 784x22
         RenderText {#text} at (0,0) size 117x22
           text run at (0,0) width 117: "Arbitrary Size"
-      RenderBlock (anonymous) at (0,327) size 784x30
-        RenderBlock {INPUT} at (0,0) size 100x30 [bgcolor=#FFFFFF] [border: (2px inset #000000) none (2px inset #000000)]
+      RenderBlock (anonymous) at (0,319) size 784x30
+        RenderBlock {INPUT} at (0,0) size 100x30 [bgcolor=#FFFFFF] [border: none (2px inset #000000) none (2px inset #000000)]
           RenderFlexibleBox {DIV} at (3,1) size 94x28
             RenderBlock {DIV} at (2,4) size 90x20 [bgcolor=#FF0000] [border: (1px solid #777777)]
index a1acc16..839d0fe 100644 (file)
@@ -1,3 +1,12 @@
+2013-07-31  Ruth Fong  <ruth_fong@apple.com>
+
+        <input type=color> Mac UI behaviour
+        <rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276
+
+        Reviewed by Brady Eidson.
+
+        * Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
+
 2013-07-31  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         DFG doesn't account for inlining of functions with switch statements that haven't been executed by the baseline JIT
index 9d6f772..3cc92ca 100644 (file)
@@ -98,7 +98,7 @@ ENABLE_ICONDATABASE_macosx = ENABLE_ICONDATABASE;
 ENABLE_IFRAME_SEAMLESS = ENABLE_IFRAME_SEAMLESS;
 ENABLE_INDEXED_DATABASE = ;
 ENABLE_INPUT_SPEECH = ;
-ENABLE_INPUT_TYPE_COLOR = ;
+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR;
 ENABLE_INPUT_TYPE_DATE = $(ENABLE_INPUT_TYPE_DATE_$(PLATFORM_NAME));
 ENABLE_INPUT_TYPE_DATE_iphoneos = ENABLE_INPUT_TYPE_DATE;
 ENABLE_INPUT_TYPE_DATE_iphonesimulator = $(ENABLE_INPUT_TYPE_DATE_iphoneos);
index 2a33091..411312a 100644 (file)
@@ -1,3 +1,12 @@
+2013-07-31  Ruth Fong  <ruth_fong@apple.com>
+
+        <input type=color> Mac UI behaviour
+        <rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276
+
+        Reviewed by Brady Eidson.
+
+        * wtf/FeatureDefines.h: Enabled INPUT_TYPE_COLOR on Mac port.
+
 2013-07-31  Andreas Kling  <akling@apple.com>
 
         Shrink Vectors with inline capacity.
index 7329c95..d261606 100644 (file)
 #define ENABLE_CURSOR_VISIBILITY 1
 #endif
 
+#if !defined(ENABLE_INPUT_TYPE_COLOR)
+#define ENABLE_INPUT_TYPE_COLOR 1
+#endif
+
 #endif /* PLATFORM(MAC) && !PLATFORM(IOS) */
 
 /* --------- Apple Windows port --------- */
index 9b961c3..eafc0d7 100644 (file)
@@ -1,3 +1,40 @@
+2013-07-31  Ruth Fong  <ruth_fong@apple.com>
+
+        <input type=color> Mac UI behaviour
+        <rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276
+
+        Reviewed by Brady Eidson.
+
+        This patch turns on INPUT_TYPE_COLOR and implements it using the native
+        Mac color panel.
+
+        No new tests added.
+    
+        Currently, there are no automated ways to test the types of changes made in this patch. (i.e. checking 
+        which color is being displayed in the color panel, checking which color element is currently 
+        associated to the color panel, checking the state of color elements after directing away and 
+        being directed back to its page, etc.)
+
+        * Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::handleDOMActivateEvent): Reattaches the color picker if
+          a color picker has already been shown for an element
+        (WebCore::ColorInputType::shouldResetOnDocumentActivation): Always returns true, needed to
+          detach the color picker when caching a page.
+        * html/ColorInputType.h:
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::documentDidResumeFromPageCache): For <input type='color'>,
+          don't reset the element.
+        (WebCore::HTMLInputElement::documentWillSuspendForPageCache): For <input type='color'>, call detach().
+        * html/HTMLInputElement.h:
+
+        * platform/ColorChooser.h:
+        (WebCore::ColorChooser::reattachColorChooser): Added definition.
+
 2013-07-30  Gavin Barraclough  <barraclough@apple.com>
 
         Some cleanup in JSValue::get
index 694b019..78c94f5 100644 (file)
@@ -99,7 +99,7 @@ ENABLE_IFRAME_SEAMLESS = ENABLE_IFRAME_SEAMLESS;
 ENABLE_INDEXED_DATABASE = ;
 ENABLE_INDIE_UI = ENABLE_INDIE_UI;
 ENABLE_INPUT_SPEECH = ;
-ENABLE_INPUT_TYPE_COLOR = ;
+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR;
 ENABLE_INPUT_TYPE_DATE = $(ENABLE_INPUT_TYPE_DATE_$(PLATFORM_NAME));
 ENABLE_INPUT_TYPE_DATE_iphoneos = ENABLE_INPUT_TYPE_DATE;
 ENABLE_INPUT_TYPE_DATE_iphonesimulator = $(ENABLE_INPUT_TYPE_DATE_iphoneos);
index a6aedaa..4f2c707 100644 (file)
@@ -2518,7 +2518,9 @@ __ZNK7WebCore12IconDatabase9isEnabledEv
 #endif // ENABLE(ICONDATABASE)
 
 #if ENABLE(INPUT_TYPE_COLOR)
+__ZN7WebCore5ColorC1EP7CGColor
 __ZN7WebCore5ColorC1ERKN3WTF6StringE
+__ZN7WebCore14ColorInputType6createEPNS_16HTMLInputElementE
 __ZN7WebCore16HTMLInputElement25selectColorInColorChooserERKNS_5ColorE
 #endif
 
index cba3126..b3734b2 100644 (file)
                7AF11A5A12E727490061F23C /* InspectorRuntimeAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF11A5912E727490061F23C /* InspectorRuntimeAgent.h */; };
                7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
                7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */; };
                7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
                7CE30DA9171B63D200EC33E1 /* FrameSnapshottingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CE30DA7171B63D200EC33E1 /* FrameSnapshottingMac.mm */; };
                85136CA60AED665900F90A3D /* southWestResizeCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 85136C960AED665900F90A3D /* southWestResizeCursor.png */; };
                85136CA70AED665900F90A3D /* waitCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 85136C970AED665900F90A3D /* waitCursor.png */; };
                85136CA80AED665900F90A3D /* westResizeCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 85136C980AED665900F90A3D /* westResizeCursor.png */; };
+               85174EC2BCCAF17EAE3F46F8 /* JSSVGGraphicsElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5A91469E8E9F8485C37A2876 /* JSSVGGraphicsElement.cpp */; };
                85183B420AA6926100F19FA3 /* DOMHTMLBRElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85183B380AA6926100F19FA3 /* DOMHTMLBRElement.h */; };
                85183B430AA6926100F19FA3 /* DOMHTMLBRElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85183B390AA6926100F19FA3 /* DOMHTMLBRElement.mm */; };
                85183B440AA6926100F19FA3 /* DOMHTMLHeadingElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85183B3A0AA6926100F19FA3 /* DOMHTMLHeadingElement.h */; };
                B2FA3D9B0AB75A6F000E5AC4 /* JSSVGGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B2FA3CB30AB75A6E000E5AC4 /* JSSVGGElement.h */; };
                B2FA3D9C0AB75A6F000E5AC4 /* JSSVGGradientElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2FA3CB40AB75A6E000E5AC4 /* JSSVGGradientElement.cpp */; };
                B2FA3D9D0AB75A6F000E5AC4 /* JSSVGGradientElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B2FA3CB50AB75A6E000E5AC4 /* JSSVGGradientElement.h */; };
-               85174EC2BCCAF17EAE3F46F8 /* JSSVGGraphicsElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5A91469E8E9F8485C37A2876 /* JSSVGGraphicsElement.cpp */; };
-               7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
                B2FA3D9E0AB75A6F000E5AC4 /* JSSVGImageElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2FA3CB60AB75A6E000E5AC4 /* JSSVGImageElement.cpp */; };
                B2FA3D9F0AB75A6F000E5AC4 /* JSSVGImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B2FA3CB70AB75A6E000E5AC4 /* JSSVGImageElement.h */; };
                B2FA3DA00AB75A6F000E5AC4 /* JSSVGLength.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2FA3CB80AB75A6E000E5AC4 /* JSSVGLength.cpp */; };
                BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC274B30140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp */; };
                BC275B7911C5D1C300C9206C /* JSWebKitPointCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC275B7811C5D1C300C9206C /* JSWebKitPointCustom.cpp */; };
                BC275CB311C5E85C00C9206C /* JSArrayBufferCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC275CB211C5E85C00C9206C /* JSArrayBufferCustom.cpp */; };
+               BC29935D17A1DD5800BCE880 /* ColorInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC29935C17A1DD5800BCE880 /* ColorInputType.cpp */; };
                BC2CBF4E140F1ABD003879BE /* JSWebGLContextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2CBF4B140F1A65003879BE /* JSWebGLContextEvent.h */; };
                BC2CBF7B140F1D58003879BE /* JSWebGLContextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2CBF7A140F1D58003879BE /* JSWebGLContextEvent.cpp */; };
                BC2CC8DF0F32881000A9DF26 /* RenderObjectChildList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2CC8DE0F32881000A9DF26 /* RenderObjectChildList.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FD06DFA5134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */; };
                FD06DFA6134A4DEF006F5D7D /* DefaultAudioDestinationNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD06DFA4134A4DEF006F5D7D /* DefaultAudioDestinationNode.h */; };
                FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1660A413787C6D001FFA7B /* DenormalDisabler.h */; };
-               FD1AF1501656F15100C6D4F7 /* ShapeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1AF14E1656F12100C6D4F7 /* ShapeValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FD1762DF176686D900D836A8 /* UpSampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD1762DD176686D900D836A8 /* UpSampler.cpp */; };
                FD1762E0176686D900D836A8 /* UpSampler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1762DE176686D900D836A8 /* UpSampler.h */; };
                FD1762E3176686EA00D836A8 /* DownSampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD1762E1176686EA00D836A8 /* DownSampler.cpp */; };
                FD1762E4176686EA00D836A8 /* DownSampler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1762E2176686EA00D836A8 /* DownSampler.h */; };
+               FD1AF1501656F15100C6D4F7 /* ShapeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1AF14E1656F12100C6D4F7 /* ShapeValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FD23A12513F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */; };
                FD23A12613F5FA5900F67001 /* JSMediaElementAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */; };
                FD2DBF1212B048A300ED98C6 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */; };
                5A574F23131DB93900471B88 /* RenderQuote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderQuote.h; sourceTree = "<group>"; };
                5A574F26131DB96D00471B88 /* QuotesData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = QuotesData.cpp; path = style/QuotesData.cpp; sourceTree = "<group>"; };
                5A574F27131DB96D00471B88 /* QuotesData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuotesData.h; path = style/QuotesData.h; sourceTree = "<group>"; };
+               5A91469E8E9F8485C37A2876 /* JSSVGGraphicsElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGGraphicsElement.cpp; sourceTree = "<group>"; };
                5D21A80013ECE5DF00BB7064 /* WebVTTParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTParser.cpp; sourceTree = "<group>"; };
                5D21A80113ECE5DF00BB7064 /* WebVTTParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTParser.h; sourceTree = "<group>"; };
                5D4B8C5211E52C8B00BBB62F /* WebCore.exp.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebCore.exp.in; sourceTree = "<group>"; };
                93F9B79E0BA6032600854064 /* JSCDATASection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCDATASection.cpp; sourceTree = "<group>"; };
                93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; };
                93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; };
+               950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGGraphicsElement.h; sourceTree = "<group>"; };
                96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGLCommon.cpp; sourceTree = "<group>"; };
                97059973107D975200A50A7C /* PolicyCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyCallback.cpp; sourceTree = "<group>"; };
                97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };
                B2FA3CB30AB75A6E000E5AC4 /* JSSVGGElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGGElement.h; sourceTree = "<group>"; };
                B2FA3CB40AB75A6E000E5AC4 /* JSSVGGradientElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGGradientElement.cpp; sourceTree = "<group>"; };
                B2FA3CB50AB75A6E000E5AC4 /* JSSVGGradientElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGGradientElement.h; sourceTree = "<group>"; };
-               5A91469E8E9F8485C37A2876 /* JSSVGGraphicsElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGGraphicsElement.cpp; sourceTree = "<group>"; };
-               950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGGraphicsElement.h; sourceTree = "<group>"; };
                B2FA3CB60AB75A6E000E5AC4 /* JSSVGImageElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGImageElement.cpp; sourceTree = "<group>"; };
                B2FA3CB70AB75A6E000E5AC4 /* JSSVGImageElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGImageElement.h; sourceTree = "<group>"; };
                B2FA3CB80AB75A6E000E5AC4 /* JSSVGLength.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLength.cpp; sourceTree = "<group>"; };
                BC274B30140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSBorderImageSliceValue.cpp; sourceTree = "<group>"; };
                BC275B7811C5D1C300C9206C /* JSWebKitPointCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitPointCustom.cpp; sourceTree = "<group>"; };
                BC275CB211C5E85C00C9206C /* JSArrayBufferCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferCustom.cpp; sourceTree = "<group>"; };
+               BC29935C17A1DD5800BCE880 /* ColorInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorInputType.cpp; sourceTree = "<group>"; };
                BC2CBF4B140F1A65003879BE /* JSWebGLContextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextEvent.h; sourceTree = "<group>"; };
                BC2CBF7A140F1D58003879BE /* JSWebGLContextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextEvent.cpp; sourceTree = "<group>"; };
                BC2CC8DE0F32881000A9DF26 /* RenderObjectChildList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderObjectChildList.h; sourceTree = "<group>"; };
                FD08A886175D3926002CD360 /* ShapeOutsideInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeOutsideInfo.cpp; sourceTree = "<group>"; };
                FD08A887175D3926002CD360 /* ShapeOutsideInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeOutsideInfo.h; sourceTree = "<group>"; };
                FD1660A413787C6D001FFA7B /* DenormalDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DenormalDisabler.h; sourceTree = "<group>"; };
-               FD1AF14E1656F12100C6D4F7 /* ShapeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ShapeValue.h; path = style/ShapeValue.h; sourceTree = "<group>"; };
                FD1762DD176686D900D836A8 /* UpSampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UpSampler.cpp; sourceTree = "<group>"; };
                FD1762DE176686D900D836A8 /* UpSampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpSampler.h; sourceTree = "<group>"; };
                FD1762E1176686EA00D836A8 /* DownSampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownSampler.cpp; sourceTree = "<group>"; };
                FD1762E2176686EA00D836A8 /* DownSampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownSampler.h; sourceTree = "<group>"; };
+               FD1AF14E1656F12100C6D4F7 /* ShapeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ShapeValue.h; path = style/ShapeValue.h; sourceTree = "<group>"; };
                FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaElementAudioSourceNode.cpp; sourceTree = "<group>"; };
                FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaElementAudioSourceNode.h; sourceTree = "<group>"; };
                FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = /System/Library/Frameworks/Accelerate.framework; sourceTree = "<absolute>"; };
                                4ACBC0BC12713CBD0094F9B2 /* ClassList.cpp */,
                                4ACBC0BD12713CBD0094F9B2 /* ClassList.h */,
                                93C441FF0F813AE100C1A634 /* CollectionType.h */,
+                               BC29935C17A1DD5800BCE880 /* ColorInputType.cpp */,
                                F55B3D801251F12D003EF269 /* ColorInputType.h */,
                                F55B3D811251F12D003EF269 /* DateInputType.cpp */,
                                F55B3D821251F12D003EF269 /* DateInputType.h */,
                                49E911CC0EF86D47009D0CAF /* SkewTransformOperation.cpp in Sources */,
                                4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */,
                                4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */,
+                               BC29935D17A1DD5800BCE880 /* ColorInputType.cpp in Sources */,
                                E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */,
                                E4AFD00D0DAF335500F5F55C /* SMILTimeContainer.cpp in Sources */,
                                510D4A33103165EE0049EA54 /* SocketStreamErrorBase.cpp in Sources */,
index 7bc9d0c..a6bae70 100644 (file)
@@ -150,9 +150,12 @@ void ColorInputType::handleDOMActivateEvent(Event* event)
     if (!ScriptController::processingUserGesture())
         return;
 
-    Chrome* chrome = this->chrome();
-    if (chrome && !m_chooser)
-        m_chooser = chrome->createColorChooser(this, valueAsColor());
+    if (Chrome* chrome = this->chrome()) {
+        if (!m_chooser)
+            m_chooser = chrome->createColorChooser(this, valueAsColor());
+        else
+            m_chooser->reattachColorChooser(valueAsColor());
+    }
 
     event->setDefaultHandled();
 }
@@ -172,6 +175,11 @@ bool ColorInputType::typeMismatchFor(const String& value) const
     return !isValidColorString(value);
 }
 
+bool ColorInputType::shouldResetOnDocumentActivation()
+{
+    return true;
+}
+
 void ColorInputType::didChooseColor(const Color& color)
 {
     if (element()->isDisabledOrReadOnly() || color == valueAsColor())
index ec21912..84015b2 100644 (file)
@@ -64,6 +64,7 @@ private:
     virtual void detach() OVERRIDE;
     virtual bool shouldRespectListAttribute() OVERRIDE;
     virtual bool typeMismatchFor(const String&) const OVERRIDE;
+    virtual bool shouldResetOnDocumentActivation() OVERRIDE;
 
     Color valueAsColor() const;
     void endColorChooser();
index f01cbf2..bbc5bbf 100644 (file)
@@ -1482,9 +1482,26 @@ void HTMLInputElement::updateClearButtonVisibility()
 void HTMLInputElement::documentDidResumeFromPageCache()
 {
     ASSERT(needsSuspensionCallback());
+
+#if ENABLE(INPUT_TYPE_COLOR)
+    // <input type=color> uses documentWillSuspendForPageCache to detach the color picker UI,
+    // so it should not be reset when being loaded from page cache.
+    if (isColorControl()) 
+        return;
+#endif // ENABLE(INPUT_TYPE_COLOR)
     reset();
 }
 
+#if ENABLE(INPUT_TYPE_COLOR)
+void HTMLInputElement::documentWillSuspendForPageCache()
+{
+    if (!isColorControl())
+        return;
+    m_inputType->detach();
+}
+#endif // ENABLE(INPUT_TYPE_COLOR)
+
+
 void HTMLInputElement::willChangeForm()
 {
     removeFromRadioButtonGroup();
index 2271dd9..3ce6d8b 100644 (file)
@@ -367,6 +367,9 @@ private:
     virtual bool isOutOfRange() const;
 
     virtual void documentDidResumeFromPageCache();
+#if ENABLE(INPUT_TYPE_COLOR)
+    virtual void documentWillSuspendForPageCache() OVERRIDE;
+#endif
 
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
 
index 7c23b1b..c06c225 100644 (file)
@@ -40,6 +40,7 @@ class ColorChooser {
 public:
     virtual ~ColorChooser() { }
 
+    virtual void reattachColorChooser(const Color&) { }
     virtual void setSelectedColor(const Color&) { }
     virtual void endChooser() { }
 };
index e6e40a8..be5b0b5 100644 (file)
@@ -1,3 +1,15 @@
+2013-07-31  Ruth Fong  <ruth_fong@apple.com>
+
+        <input type=color> Mac UI behaviour
+        <rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276
+
+        Reviewed by Brady Eidson.
+
+        * Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
+        * WebCoreSupport/WebChromeClient.h:
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::createColorPicker): Added stub implementation.
+
 2013-07-26  Dean Jackson  <dino@apple.com>
 
         Allow new transitions to run even when controller is suspended
index 6235600..b05d03b 100644 (file)
@@ -98,7 +98,7 @@ ENABLE_ICONDATABASE_macosx = ENABLE_ICONDATABASE;
 ENABLE_IFRAME_SEAMLESS = ENABLE_IFRAME_SEAMLESS;
 ENABLE_INDEXED_DATABASE = ;
 ENABLE_INPUT_SPEECH = ;
-ENABLE_INPUT_TYPE_COLOR = ;
+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR;
 ENABLE_INPUT_TYPE_DATE = $(ENABLE_INPUT_TYPE_DATE_$(PLATFORM_NAME));
 ENABLE_INPUT_TYPE_DATE_iphoneos = ENABLE_INPUT_TYPE_DATE;
 ENABLE_INPUT_TYPE_DATE_iphonesimulator = $(ENABLE_INPUT_TYPE_DATE_iphoneos);
index 8ef8c23..c569f9a 100644 (file)
@@ -129,6 +129,10 @@ public:
     virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& lineRect) OVERRIDE;
     virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect, bool behindText, bool entireLine) OVERRIDE;
 
+#if ENABLE(INPUT_TYPE_COLOR)
+    virtual PassOwnPtr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) OVERRIDE;
+#endif
+
     virtual WebCore::KeyboardUIMode keyboardUIMode() OVERRIDE;
 
     virtual NSResponder *firstResponder() OVERRIDE;
index 7a9c865..49206b8 100644 (file)
@@ -54,6 +54,7 @@
 #import "WebViewInternal.h"
 #import <Foundation/Foundation.h>
 #import <WebCore/BlockExceptions.h>
+#import <WebCore/ColorChooser.h>
 #import <WebCore/Console.h>
 #import <WebCore/ContextMenu.h>
 #import <WebCore/ContextMenuController.h>
@@ -721,6 +722,15 @@ void WebChromeClient::paintCustomHighlight(Node* node, const AtomicString& type,
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
+#if ENABLE(INPUT_TYPE_COLOR)
+PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient* client, const Color& initialColor)
+{
+    // FIXME: Implement <input type='color'> for WK1 (Bug 119094).
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+#endif
+
 void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
index b2f3130..a30929f 100644 (file)
@@ -1,3 +1,67 @@
+2013-07-31  Ruth Fong  <ruth_fong@apple.com>
+
+        <input type=color> Mac UI behaviour
+        <rdar://problem/10269922> and https://bugs.webkit.org/show_bug.cgi?id=61276
+
+        Implemented <input type='color'> on Mac using the native color picker. 
+
+        Reviewed by Brady Eidson.
+
+        Code for WebColorPickerMac is derived from Chromium's color_chooser_mac.mm:
+        https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/cocoa/color_chooser_mac.mm
+
+        * Configurations/FeatureDefines.xcconfig: Enabled INPUT_TYPE_COLOR.
+
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::createColorPicker): Replaced stub implementation
+          and return a WebColorPickerMac object.
+
+        * UIProcess/WebColorPicker.cpp:
+        (WebKit::WebColorPicker::invalidate): Updated to call endChooser().
+        (WebKit::WebColorPicker::showColorPicker): Added stub implementation.
+        * UIProcess/WebColorPicker.h:
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close): Removed invalidation of removed color picker objects.
+        (WebKit::WebPageProxy::showColorPicker): Updated so that it works for
+          multiple <input type='color'> elements on a page.
+        (WebKit::WebPageProxy::didEndColorPicker): Removed cleanup of removed color picker objects.
+        (WebKit::WebPageProxy::resetStateAfterProcessExited): Removed cleanup of removed color picker objects.
+
+        * UIProcess/mac/WebColorPickerMac.h: Added.
+        * UIProcess/mac/WebColorPickerMac.mm: Added.
+        (WebKit::WebColorPickerMac::create):
+        (WebKit::WebColorPickerMac::~WebColorPickerMac):
+        (WebKit::WebColorPickerMac::WebColorPickerMac):
+        (WebKit::WebColorPickerMac::endPicker):
+        (WebKit::WebColorPickerMac::setSelectedColor):
+        (WebKit::WebColorPickerMac::didChooseColor):
+        (WebKit::WebColorPickerMac::showColorPicker):
+        WebColorPickerMac contains a reference to a WKColorPanelMac object
+          and is responsible for maintaining the color picker UI.
+
+        (-[WKColorPanelMac setAndShowPicker:withColor:]):
+        (-[WKColorPanelMac invalidate]):
+        (-[WKColorPanelMac windowWillClose:]):
+        (-[WKColorPanelMac didChooseColor:]):
+        (-[WKColorPanelMac setColor:]):
+        WKColorPanelMac is a wrapper for a NSColorPanel object and 
+          is responsible for the color picker UI.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::createColorChooser): Updated to always create a 
+          WebColorChooser object.
+
+        * WebProcess/WebCoreSupport/WebColorChooser.cpp:
+        (WebKit::WebColorChooser::reattachColorChooser): Sets the page's 
+          active color chooser to the current object and pings the UIProcess
+          to show the color picker.
+        (WebKit::WebColorChooser::setSelectedColor): Only sets the color in the
+          color picker if the WebColorChooser object is the active color element.
+        * WebProcess/WebCoreSupport/WebColorChooser.h:
+
 2013-07-30  Gavin Barraclough  <barraclough@apple.com>
 
         Some cleanup in JSValue::get
index 6235600..b05d03b 100644 (file)
@@ -98,7 +98,7 @@ ENABLE_ICONDATABASE_macosx = ENABLE_ICONDATABASE;
 ENABLE_IFRAME_SEAMLESS = ENABLE_IFRAME_SEAMLESS;
 ENABLE_INDEXED_DATABASE = ;
 ENABLE_INPUT_SPEECH = ;
-ENABLE_INPUT_TYPE_COLOR = ;
+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR;
 ENABLE_INPUT_TYPE_DATE = $(ENABLE_INPUT_TYPE_DATE_$(PLATFORM_NAME));
 ENABLE_INPUT_TYPE_DATE_iphoneos = ENABLE_INPUT_TYPE_DATE;
 ENABLE_INPUT_TYPE_DATE_iphonesimulator = $(ENABLE_INPUT_TYPE_DATE_iphoneos);
index 3d93314..4cccaba 100644 (file)
@@ -39,6 +39,7 @@
 #import "WKStringCF.h"
 #import "WKViewInternal.h"
 #import "StringUtilities.h"
+#import "WebColorPickerMac.h"
 #import "WebContextMenuProxyMac.h"
 #import "WebEditCommandProxy.h"
 #import "WebPopupMenuProxyMac.h"
@@ -393,10 +394,9 @@ PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPagePr
 }
 
 #if ENABLE(INPUT_TYPE_COLOR)
-PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color&,  const WebCore::IntRect&)
+PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& initialColor,  const WebCore::IntRect&)
 {
-    notImplemented();
-    return 0;
+    return WebColorPickerMac::create(page, initialColor);
 }
 #endif
 
index dc0fe66..110f64a 100644 (file)
@@ -39,6 +39,12 @@ WebColorPicker::~WebColorPicker()
 {
 }
 
+void WebColorPicker::invalidate()
+{
+    endPicker();
+    m_client = 0;
+}
+
 void WebColorPicker::endPicker()
 {
     if (!m_client)
@@ -55,6 +61,12 @@ void WebColorPicker::setSelectedColor(const WebCore::Color& color)
     m_client->didChooseColor(color);
 }
 
+void WebColorPicker::showColorPicker(const WebCore::Color& color)
+{
+    ASSERT_NOT_REACHED();
+    return;
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(INPUT_TYPE_COLOR)
index ae8fc2e..5400ddc 100644 (file)
@@ -57,10 +57,11 @@ public:
 
     virtual ~WebColorPicker();
 
-    void invalidate() { m_client = 0; }
+    void invalidate();
 
     virtual void endPicker();
     virtual void setSelectedColor(const WebCore::Color&);
+    virtual void showColorPicker(const WebCore::Color&);
 
 protected:
     explicit WebColorPicker(Client*);
index 800dc43..5e18dd2 100644 (file)
@@ -581,11 +581,6 @@ void WebPageProxy::close()
         m_colorPicker->invalidate();
         m_colorPicker = nullptr;
     }
-
-    if (m_colorPickerResultListener) {
-        m_colorPickerResultListener->invalidate();
-        m_colorPickerResultListener = nullptr;
-    }
 #endif
 
 #if ENABLE(GEOLOCATION)
@@ -2928,22 +2923,9 @@ void WebPageProxy::needTouchEvents(bool needTouchEvents)
 #if ENABLE(INPUT_TYPE_COLOR)
 void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect)
 {
-    ASSERT(!m_colorPicker);
-
-    if (m_colorPickerResultListener) {
-        m_colorPickerResultListener->invalidate();
-        m_colorPickerResultListener = nullptr;
-    }
-
-    m_colorPickerResultListener = WebColorPickerResultListenerProxy::create(this);
-    m_colorPicker = WebColorPicker::create(this);
-
-    if (m_uiClient.showColorPicker(this, initialColor.serialized(), m_colorPickerResultListener.get()))
-        return;
-
-    m_colorPicker = m_pageClient->createColorPicker(this, initialColor, elementRect);
     if (!m_colorPicker)
-        didEndColorPicker();
+        m_colorPicker = m_pageClient->createColorPicker(this, initialColor, elementRect);
+    m_colorPicker->showColorPicker(initialColor);
 }
 
 void WebPageProxy::setColorPickerColor(const WebCore::Color& color)
@@ -2979,11 +2961,6 @@ void WebPageProxy::didEndColorPicker()
     }
 
     m_process->send(Messages::WebPage::DidEndColorPicker(), m_pageID);
-
-    m_colorPickerResultListener->invalidate();
-    m_colorPickerResultListener = nullptr;
-
-    m_uiClient.hideColorPicker(this);
 }
 #endif
 
@@ -3848,11 +3825,6 @@ void WebPageProxy::resetStateAfterProcessExited()
         m_colorPicker->invalidate();
         m_colorPicker = nullptr;
     }
-
-    if (m_colorPickerResultListener) {
-        m_colorPickerResultListener->invalidate();
-        m_colorPickerResultListener = nullptr;
-    }
 #endif
 
 #if ENABLE(GEOLOCATION)
diff --git a/Source/WebKit2/UIProcess/mac/WebColorPickerMac.h b/Source/WebKit2/UIProcess/mac/WebColorPickerMac.h
new file mode 100644 (file)
index 0000000..c4b3674
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *    * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebColorPickerMac_h
+#define WebColorPickerMac_h
+
+#if ENABLE(INPUT_TYPE_COLOR)
+
+#if USE(APPKIT)
+
+#import "WebColorPicker.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS NSColorWell;
+OBJC_CLASS WKColorPanelMac;
+
+namespace WebCore {
+class Color;
+}
+
+namespace WebKit {
+    
+class WebColorPickerMac : public WebColorPicker {
+public:        
+    static PassRefPtr<WebColorPickerMac> create(WebColorPicker::Client*, const WebCore::Color&);
+    ~WebColorPickerMac();
+
+    virtual void endPicker() OVERRIDE;
+    virtual void setSelectedColor(const WebCore::Color&) OVERRIDE;
+    virtual void showColorPicker(const WebCore::Color&) OVERRIDE;
+    
+    void didChooseColor(const WebCore::Color&);
+
+private:
+    WebColorPickerMac(WebColorPicker::Client*, const WebCore::Color&);
+    RetainPtr<WKColorPanelMac> m_panel;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_TYPE_COLOR)
+
+#endif // USE(APPKIT)
+
+#endif // WebContextMenuProxyMac_h
diff --git a/Source/WebKit2/UIProcess/mac/WebColorPickerMac.mm b/Source/WebKit2/UIProcess/mac/WebColorPickerMac.mm
new file mode 100644 (file)
index 0000000..1abb932
--- /dev/null
@@ -0,0 +1,178 @@
+/* 
+ * Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *    * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebColorPickerMac.h"
+
+#if ENABLE(INPUT_TYPE_COLOR)
+
+#if USE(APPKIT)
+
+#import <WebCore/ColorMac.h>
+
+using namespace WebKit;
+
+// A listener class to act as a event target for NSColorPanel and send
+// the results to the C++ class, WebColorPickerMac.
+@interface WKColorPanelMac : NSObject<NSWindowDelegate> {
+@private
+    BOOL _lastChangedByUser;
+    WebColorPickerMac* _picker;
+}
+
+- (id)init;
+- (void)setAndShowPicker:(WebKit::WebColorPickerMac*)picker withColor:(NSColor *)color;
+- (void)didChooseColor:(NSColorPanel *)panel;
+- (void)invalidate;
+
+// Sets color to the NSColorPanel as a non user change.
+- (void)setColor:(NSColor *)color;
+
+@end
+
+namespace WebKit {
+
+PassRefPtr<WebColorPickerMac> WebColorPickerMac::create(WebColorPicker::Client* client, const WebCore::Color& initialColor)
+{
+    return adoptRef(new WebColorPickerMac(client, initialColor));
+}
+
+WebColorPickerMac::~WebColorPickerMac()
+{
+    ASSERT(!m_panel);
+}
+
+WebColorPickerMac::WebColorPickerMac(WebColorPicker::Client* client, const WebCore::Color& initialColor)
+    : WebColorPicker(client)
+{
+    m_panel = adoptNS([[WKColorPanelMac alloc] init]);
+}
+
+void WebColorPickerMac::endPicker()
+{
+    [m_panel invalidate];
+    m_panel = nullptr;
+}
+
+void WebColorPickerMac::setSelectedColor(const WebCore::Color& color)
+{
+    if (!m_client || !m_panel)
+        return;
+    
+    [m_panel setColor:nsColor(color)];
+}
+
+void WebColorPickerMac::didChooseColor(const WebCore::Color& color)
+{
+    if (!m_client)
+        return;
+    
+    m_client->didChooseColor(color);
+}
+void WebColorPickerMac::showColorPicker(const WebCore::Color& color)
+{
+    if (!m_client)
+        return;
+
+    if (!m_panel)
+        m_panel = adoptNS([[WKColorPanelMac alloc] init]);
+
+    [m_panel setAndShowPicker:this withColor:nsColor(color)];
+}
+
+} // namespace WebKit
+
+using namespace WebKit;
+
+@implementation WKColorPanelMac
+
+- (id)init
+{
+    self = [super init];
+    return self;
+}
+
+- (void)setAndShowPicker:(WebColorPickerMac*)picker withColor:(NSColor *)color
+{
+    _picker = picker;
+
+    NSColorPanel *panel = [NSColorPanel sharedColorPanel];
+
+    [panel setShowsAlpha:NO];
+    [panel setDelegate:self];
+    [panel setTarget:self];
+
+    [panel setColor:color];
+
+    _lastChangedByUser = YES;
+    [panel setAction:@selector(didChooseColor:)];
+    [panel makeKeyAndOrderFront:nil];
+}
+
+- (void)invalidate
+{
+    NSColorPanel *panel = [NSColorPanel sharedColorPanel];
+    if ([panel delegate] == self) {
+        [panel setDelegate:nil];
+        [panel setTarget:nil];
+        [panel setAction:nil];
+    }
+    _picker = nil;
+}
+
+- (void)windowWillClose:(NSNotification *)notification
+{
+    _lastChangedByUser = YES;
+    _picker->endPicker();
+}
+
+- (void)didChooseColor:(NSColorPanel *)panel
+{
+    // Handle the case where the <input type='color'> value is programmatically set.
+    if (!_lastChangedByUser) {
+        _lastChangedByUser = YES;
+        return;
+    }
+
+    _picker->didChooseColor(WebCore::colorFromNSColor([panel color]));
+}
+
+- (void)setColor:(NSColor *)color
+{
+    _lastChangedByUser = NO;
+    [[NSColorPanel sharedColorPanel] setColor:color];
+}
+
+@end
+
+#endif // USE(APPKIT)
+
+#endif // ENABLE(INPUT_TYPE_COLOR)
index 81a284c..f045ff5 100644 (file)
                659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
                65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 728E86EF1795188C0087879E /* WebColorPickerMac.h */; };
+               728E86F21795188C0087879E /* WebColorPickerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 728E86F01795188C0087879E /* WebColorPickerMac.mm */; };
                762B748D120BC75C00819339 /* WKPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 762B7484120BBA2D00819339 /* WKPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7801C099142290C400FAF9AF /* WebHitTestResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7801C095142290C400FAF9AF /* WebHitTestResult.cpp */; };
                7801C09A142290C400FAF9AF /* WebHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 7801C096142290C400FAF9AF /* WebHitTestResult.h */; };
                65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
                6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebProcess.sb.in; path = WebProcess/com.apple.WebProcess.sb.in; sourceTree = "<group>"; };
                6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKInspectorPrivateMac.h; path = mac/WKInspectorPrivateMac.h; sourceTree = "<group>"; };
+               728E86EF1795188C0087879E /* WebColorPickerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPickerMac.h; sourceTree = "<group>"; };
+               728E86F01795188C0087879E /* WebColorPickerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebColorPickerMac.mm; sourceTree = "<group>"; };
                762B7481120BBA0100819339 /* FontSmoothingLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSmoothingLevel.h; sourceTree = "<group>"; };
                762B7484120BBA2D00819339 /* WKPreferencesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreferencesPrivate.h; sourceTree = "<group>"; };
                7801C095142290C400FAF9AF /* WebHitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebHitTestResult.cpp; sourceTree = "<group>"; };
                                1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */,
                                1AF05D8514688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h */,
                                1AF05D8414688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm */,
+                               728E86EF1795188C0087879E /* WebColorPickerMac.h */,
+                               728E86F01795188C0087879E /* WebColorPickerMac.mm */,
                                1A1C648611F415B700553C19 /* WebContextMac.mm */,
                                51ACBB9E127A8F2C00D203B9 /* WebContextMenuProxyMac.h */,
                                51ACBB9F127A8F2C00D203B9 /* WebContextMenuProxyMac.mm */,
                                BC04EFFC16E65AFB00E336F0 /* WKWebProcessPlugInPrivate.h in Headers */,
                                BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */,
                                BCBECDE816B6416800047A1A /* XPCServiceEntryPoint.h in Headers */,
+                               728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,
                                BC0092F8115837A300E0AE2A /* WorkQueueMac.cpp in Sources */,
                                BCBECDE716B6416800047A1A /* XPCServiceEntryPoint.mm in Sources */,
+                               728E86F21795188C0087879E /* WebColorPickerMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 7e9fc91..64b1db6 100644 (file)
@@ -661,9 +661,6 @@ bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const In
 #if ENABLE(INPUT_TYPE_COLOR)
 PassOwnPtr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient* client, const Color& initialColor)
 {
-    if (m_page->activeColorChooser())
-        return nullptr;
-
     return adoptPtr(new WebColorChooser(m_page, client, initialColor));
 }
 #endif
index 8ad3cd9..b779182 100644 (file)
@@ -69,10 +69,22 @@ void WebColorChooser::disconnectFromPage()
     m_page = 0;
 }
 
+void WebColorChooser::reattachColorChooser(const Color& color)
+{
+    ASSERT(m_page);
+    m_page->setActiveColorChooser(this);
+
+    ASSERT(m_colorChooserClient);
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebPageProxy::ShowColorPicker(color, m_colorChooserClient->elementRectRelativeToRootView()), m_page->pageID());
+}
+
 void WebColorChooser::setSelectedColor(const Color& color)
 {
     if (!m_page)
         return;
+    
+    if (m_page->activeColorChooser() != this)
+        return;
 
     WebProcess::shared().parentProcessConnection()->send(Messages::WebPageProxy::SetColorPickerColor(color), m_page->pageID());
 }
index 1e6feee..e5a714f 100644 (file)
@@ -48,6 +48,7 @@ public:
     void didEndChooser();
     void disconnectFromPage();
 
+    virtual void reattachColorChooser(const WebCore::Color&) OVERRIDE;
     virtual void setSelectedColor(const WebCore::Color&) OVERRIDE;
     virtual void endChooser() OVERRIDE;