Calendar Picker: Add capability to add platform-specific style sheet
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 May 2012 00:12:49 +0000 (00:12 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 May 2012 00:12:49 +0000 (00:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85272

Reviewed by Kentaro Hara.

Add RenderTheme::extraCalendarPickerStyleSheet(). The resultant string
of the function is inserted into the calendar picker page.

No new tests. Calendar picker apperance is not testable yet.

* Resources/calendarPicker.css: Removed styles for year-month buttons.
* Resources/calendarPickerMac.css:
Moved from calendarPicker.css, and adjust styles so that they look
standard Lion buttons.
(.year-month-button):
(.year-month-button:active):
(.year-month-button:disabled):
* WebCore.gyp/WebCore.gyp: Add a rule to produce CalendarPickerMac.{cpp,h}.
* html/shadow/CalendarPickerElement.cpp:
(WebCore::CalendarPickerElement::writeDocument):
Add extraCalendarPickerStyleSheet() result to the document.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::extraCalendarPickerStyleSheet):
Added. Returns an empty CString by default.
* rendering/RenderTheme.h:
(RenderTheme): Added extraCalendarPickerStyleSheet().
* rendering/RenderThemeChromiumMac.h: Added extraCalendarPickerStyleSheet().
* rendering/RenderThemeChromiumMac.mm:
(WebCore::RenderThemeChromiumMac::extraCalendarPickerStyleSheet):
Added. Returns the content of Resources/calendarPickerMac.css.

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

Source/WebCore/ChangeLog
Source/WebCore/Resources/calendarPicker.css
Source/WebCore/Resources/calendarPickerMac.css [new file with mode: 0644]
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/html/shadow/CalendarPickerElement.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeChromiumMac.h
Source/WebCore/rendering/RenderThemeChromiumMac.mm

index 8c84af5..db7f1f3 100644 (file)
@@ -1,3 +1,36 @@
+2012-05-01  Kent Tamura  <tkent@chromium.org>
+
+        Calendar Picker: Add capability to add platform-specific style sheet
+        https://bugs.webkit.org/show_bug.cgi?id=85272
+
+        Reviewed by Kentaro Hara.
+
+        Add RenderTheme::extraCalendarPickerStyleSheet(). The resultant string
+        of the function is inserted into the calendar picker page.
+
+        No new tests. Calendar picker apperance is not testable yet.
+
+        * Resources/calendarPicker.css: Removed styles for year-month buttons.
+        * Resources/calendarPickerMac.css:
+        Moved from calendarPicker.css, and adjust styles so that they look
+        standard Lion buttons.
+        (.year-month-button):
+        (.year-month-button:active):
+        (.year-month-button:disabled):
+        * WebCore.gyp/WebCore.gyp: Add a rule to produce CalendarPickerMac.{cpp,h}.
+        * html/shadow/CalendarPickerElement.cpp:
+        (WebCore::CalendarPickerElement::writeDocument):
+        Add extraCalendarPickerStyleSheet() result to the document.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::extraCalendarPickerStyleSheet):
+        Added. Returns an empty CString by default.
+        * rendering/RenderTheme.h:
+        (RenderTheme): Added extraCalendarPickerStyleSheet().
+        * rendering/RenderThemeChromiumMac.h: Added extraCalendarPickerStyleSheet().
+        * rendering/RenderThemeChromiumMac.mm:
+        (WebCore::RenderThemeChromiumMac::extraCalendarPickerStyleSheet):
+        Added. Returns the content of Resources/calendarPickerMac.css.
+
 2012-05-01  James Simonsen  <simonjam@chromium.org>
 
         Ensure HTMLElementStack fails gracefully if it has a non-Element.
index b0737d0..eef0b10 100644 (file)
@@ -96,34 +96,6 @@ body {
     width: 100%;
 }
 
-/* FIXME: We'd like to use the standard button appearance for non-Mac. */
-.year-month-button {
-    -webkit-appearance: none;
-    background: -webkit-gradient(linear, left top, left bottom, from(#eee), color-stop(0.4, #fff), color-stop(0.6, #dddddd), to(#eee));
-    border: solid 1px #444;
-    border-radius: 3px;
-    box-shadow: inset 1px 1px 1px rgba(255,255,255,0.4), inset -1px -1px 1px rgba(255,255,255,0.4);
-    padding-left: 3px;
-    padding-right: 3px;
-}
-
-.year-month-button:hover {
-    background: -webkit-gradient(linear, left top, left bottom, from(#e0f0ff), color-stop(0.4, #e0f0ff), color-stop(0.6, #b0e0ff), to(#b0e0ff));
-    border: solid 1px #448;
-}
-
-.year-month-button:active {
-    border: solid 1px black;
-    box-shadow: inset 1px 1px 1px rgba(0,0,0,0.3), inset -1px -1px 1px rgba(0,0,0,0.3);
-}
-
-.year-month-button:disabled {
-    color: #888;
-    background: -webkit-gradient(linear, left top, left bottom, from(#eee), color-stop(0.4, #fff), color-stop(0.6, #dddddd), to(#eee));
-    border: solid 1px #ccc;
-    box-shadow: inset 1px 1px 1px rgba(255,255,255,0.4), inset -1px -1px 1px rgba(255,255,255,0.4);
-}
-
 .year-month-button-left {
     display: inline-block;
 }
diff --git a/Source/WebCore/Resources/calendarPickerMac.css b/Source/WebCore/Resources/calendarPickerMac.css
new file mode 100644 (file)
index 0000000..4144645
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ */
+
+.year-month-button {
+    -webkit-appearance: none;
+    background: -webkit-gradient(linear, left top, left bottom, from(#fff), color-stop(0.3, #fff), color-stop(0.35, #f7f7f7), color-stop(0.49, #f7f7f7), color-stop(0.5, #ededed), to(#ededed));
+    border: solid 1px #a6a6a6;
+    border-radius: 4px;
+    box-shadow: inset 1px 1px 1px rgba(255,255,255,0.4), inset -1px -1px 1px rgba(255,255,255,0.4);
+    padding-left: 3px;
+    padding-right: 3px;
+}
+
+.year-month-button:active {
+    background: -webkit-gradient(linear, left top, left bottom, from(#a3bfef), color-stop(0.49,  #6ba3ef), color-stop(0.5, #4491ef), to(#a3d1ef));
+    border: solid 1px #4d4d50;
+}
+
+.year-month-button:disabled {
+    color: #888;
+    border: solid 1px #d1d1d1;
+}
index b0e02ca..556c123 100644 (file)
           ],
         },
         {
+          'action_name': 'CalendarPickerMac',
+          'inputs': [
+            '../Resources/calendarPickerMac.css',
+          ],
+          'outputs': [
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/CalendarPickerMac.h',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/CalendarPickerMac.cpp',
+          ],
+          'action': [
+            'python',
+            '../make-file-arrays.py',
+            '--condition=ENABLE(CALENDAR_PICKER)',
+            '--out-h=<(SHARED_INTERMEDIATE_DIR)/webkit/CalendarPickerMac.h',
+            '--out-cpp=<(SHARED_INTERMEDIATE_DIR)/webkit/CalendarPickerMac.cpp',
+            '<@(_inputs)',
+          ],
+        },
+        {
           'action_name': 'XLinkNames',
           'inputs': [
             '../dom/make_names.pl',
           'include_dirs': [
             '<(chromium_src_dir)/third_party/apple_webkit',
           ],
+          'sources': [
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/CalendarPickerMac.cpp',
+          ],
         }],
         ['OS=="win"', {
           'defines': [
index 79d6c68..75eeef6 100644 (file)
@@ -47,6 +47,7 @@
 #include "LocalizedStrings.h"
 #include "Page.h"
 #include "RenderDetailsMarker.h"
+#include "RenderTheme.h"
 #include <wtf/text/StringBuilder.h>
 
 using namespace WTF::Unicode;
@@ -208,6 +209,11 @@ void CalendarPickerElement::writeDocument(DocumentWriter& writer)
 
     addLiteral("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer);
     writer.addData(calendarPickerCss, sizeof(calendarPickerCss));
+    if (document()->page()) {
+        CString extraStyle = document()->page()->theme()->extraCalendarPickerStyleSheet();
+        if (extraStyle.length())
+            writer.addData(extraStyle.data(), extraStyle.length());
+    }
     addLiteral("</style></head><body><div id=main>Loading...</div><script>\n"
                "window.dialogArguments = {\n", writer);
     addProperty("min", minString, writer);
index 4c41fb3..585385f 100644 (file)
@@ -613,6 +613,13 @@ Color RenderTheme::platformInactiveListBoxSelectionForegroundColor() const
     return platformInactiveSelectionForegroundColor();
 }
 
+#if ENABLE(CALENDAR_PICKER)
+CString RenderTheme::extraCalendarPickerStyleSheet()
+{
+    return CString();
+}
+#endif
+
 LayoutUnit RenderTheme::baselinePosition(const RenderObject* o) const
 {
     if (!o->isBox())
index 7030b55..e3e7147 100644 (file)
@@ -94,6 +94,9 @@ public:
 #if ENABLE(FULLSCREEN_API)
     virtual String extraFullScreenStyleSheet() { return String(); };
 #endif
+#if ENABLE(CALENDAR_PICKER)
+    virtual CString extraCalendarPickerStyleSheet();
+#endif
 
     // A method to obtain the baseline position for a "leaf" control.  This will only be used if a baseline
     // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
index e767d42..2b4c8c6 100644 (file)
@@ -67,6 +67,9 @@ private:
     virtual Color disabledTextColor(const Color& textColor, const Color&) const OVERRIDE { return textColor; }
     virtual void updateActiveState(NSCell*, const RenderObject*);
     virtual String extraDefaultStyleSheet();
+#if ENABLE(CALENDAR_PICKER)
+    virtual CString extraCalendarPickerStyleSheet() OVERRIDE;
+#endif
     virtual bool shouldShowPlaceholderWhenFocused() const OVERRIDE;
 };
 
index 6afd9d1..a778228 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 #import "config.h"
+
+#import "CalendarPickerMac.h"
 #import "LocalCurrentGraphicsContext.h"
 #import "RenderThemeChromiumMac.h"
 #import "PaintInfo.h"
@@ -195,6 +197,12 @@ String RenderThemeChromiumMac::extraDefaultStyleSheet()
            String(themeChromiumUserAgentStyleSheet, sizeof(themeChromiumUserAgentStyleSheet));
 }
 
+#if ENABLE(CALENDAR_PICKER)
+CString RenderThemeChromiumMac::extraCalendarPickerStyleSheet()
+{
+    return CString(calendarPickerMacCss, WTF_ARRAY_LENGTH(calendarPickerMacCss));
+}
+#endif
 
 bool RenderThemeChromiumMac::paintMediaVolumeSliderContainer(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
 {