OLD | NEW |
1 /** | 1 /** |
2 * This file is part of the theme implementation for form controls in WebCore. | 2 * This file is part of the theme implementation for form controls in WebCore. |
3 * | 3 * |
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. | 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 #include "core/rendering/RenderTheme.h" | 23 #include "core/rendering/RenderTheme.h" |
24 | 24 |
25 #include "CSSValueKeywords.h" | 25 #include "CSSValueKeywords.h" |
26 #include "HTMLNames.h" | 26 #include "HTMLNames.h" |
| 27 #include "RuntimeEnabledFeatures.h" |
27 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
| 29 #include "core/dom/shadow/ElementShadow.h" |
28 #include "core/editing/FrameSelection.h" | 30 #include "core/editing/FrameSelection.h" |
29 #include "core/fileapi/FileList.h" | 31 #include "core/fileapi/FileList.h" |
| 32 #include "core/html/HTMLCollection.h" |
| 33 #include "core/html/HTMLDataListElement.h" |
30 #include "core/html/HTMLInputElement.h" | 34 #include "core/html/HTMLInputElement.h" |
31 #include "core/html/HTMLMeterElement.h" | 35 #include "core/html/HTMLMeterElement.h" |
| 36 #include "core/html/HTMLOptionElement.h" |
32 #include "core/html/InputTypeNames.h" | 37 #include "core/html/InputTypeNames.h" |
| 38 #include "core/html/parser/HTMLParserIdioms.h" |
33 #include "core/html/shadow/MediaControlElements.h" | 39 #include "core/html/shadow/MediaControlElements.h" |
34 #include "core/html/shadow/SpinButtonElement.h" | 40 #include "core/html/shadow/SpinButtonElement.h" |
35 #include "core/html/shadow/TextControlInnerElements.h" | 41 #include "core/html/shadow/TextControlInnerElements.h" |
36 #include "core/page/FocusController.h" | 42 #include "core/page/FocusController.h" |
37 #include "core/page/Frame.h" | 43 #include "core/page/Frame.h" |
38 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
39 #include "core/page/Settings.h" | 45 #include "core/page/Settings.h" |
40 #include "core/platform/FileSystem.h" | 46 #include "core/platform/FileSystem.h" |
41 #include "core/platform/FloatConversion.h" | 47 #include "core/platform/FloatConversion.h" |
42 #include "core/platform/LocalizedStrings.h" | 48 #include "core/platform/LocalizedStrings.h" |
43 #include "core/platform/graphics/FontSelector.h" | 49 #include "core/platform/graphics/FontSelector.h" |
44 #include "core/platform/graphics/GraphicsContextStateSaver.h" | 50 #include "core/platform/graphics/GraphicsContextStateSaver.h" |
45 #include "core/platform/graphics/StringTruncator.h" | 51 #include "core/platform/graphics/StringTruncator.h" |
46 #include "core/rendering/PaintInfo.h" | 52 #include "core/rendering/PaintInfo.h" |
47 #include "core/rendering/RenderMeter.h" | 53 #include "core/rendering/RenderMeter.h" |
48 #include "core/rendering/RenderView.h" | 54 #include "core/rendering/RenderView.h" |
49 #include "core/rendering/style/RenderStyle.h" | 55 #include "core/rendering/style/RenderStyle.h" |
50 | 56 |
51 #if ENABLE(INPUT_SPEECH) | 57 #if ENABLE(INPUT_SPEECH) |
52 #include "core/rendering/RenderInputSpeech.h" | 58 #include "core/rendering/RenderInputSpeech.h" |
53 #endif | 59 #endif |
54 | 60 |
55 #if ENABLE(DATALIST_ELEMENT) | |
56 #include "core/dom/shadow/ElementShadow.h" | |
57 #include "core/html/HTMLCollection.h" | |
58 #include "core/html/HTMLDataListElement.h" | |
59 #include "core/html/HTMLOptionElement.h" | |
60 #include "core/html/parser/HTMLParserIdioms.h" | |
61 #endif | |
62 | |
63 // The methods in this file are shared by all themes on every platform. | 61 // The methods in this file are shared by all themes on every platform. |
64 | 62 |
65 namespace WebCore { | 63 namespace WebCore { |
66 | 64 |
67 using namespace HTMLNames; | 65 using namespace HTMLNames; |
68 | 66 |
69 static Color& customFocusRingColor() | 67 static Color& customFocusRingColor() |
70 { | 68 { |
71 DEFINE_STATIC_LOCAL(Color, color, ()); | 69 DEFINE_STATIC_LOCAL(Color, color, ()); |
72 return color; | 70 return color; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 #if ENABLE(INPUT_SPEECH) | 447 #if ENABLE(INPUT_SPEECH) |
450 case InputSpeechButtonPart: | 448 case InputSpeechButtonPart: |
451 #endif | 449 #endif |
452 default: | 450 default: |
453 break; | 451 break; |
454 } | 452 } |
455 | 453 |
456 return false; | 454 return false; |
457 } | 455 } |
458 | 456 |
| 457 String RenderTheme::extraDefaultStyleSheet() |
| 458 { |
| 459 if (!RuntimeEnabledFeatures::dataListElementEnabled()) |
| 460 return String(); |
| 461 DEFINE_STATIC_LOCAL(String, dataListElementCSS, (ASCIILiteral("datalist {dis
play: none ;}"))); |
| 462 |
| 463 #if ENABLE(INPUT_TYPE_COLOR) |
| 464 StringBuilder inputTypeCSS; |
| 465 inputTypeCSS.appendLiteral("input[type=\"color\"][list] { -webkit-appearance
: menulist; width: 88px; height: 23px;}"); |
| 466 inputTypeCSS.appendLiteral("input[type=\"color\"][list]::-webkit-color-swatc
h-wrapper { padding-left: 8px; padding-right: 24px;}"); |
| 467 inputTypeCSS.appendLiteral("input[type=\"color\"][list]::-webkit-color-swatc
h { border-color: #000000;}"); |
| 468 inputTypeCSS.append(dataListElementCSS); |
| 469 return inputTypeCSS.toString(); |
| 470 #endif |
| 471 |
| 472 return dataListElementCSS; |
| 473 } |
| 474 |
459 String RenderTheme::formatMediaControlsTime(float time) const | 475 String RenderTheme::formatMediaControlsTime(float time) const |
460 { | 476 { |
461 if (!std::isfinite(time)) | 477 if (!std::isfinite(time)) |
462 time = 0; | 478 time = 0; |
463 int seconds = (int)fabsf(time); | 479 int seconds = (int)fabsf(time); |
464 int hours = seconds / (60 * 60); | 480 int hours = seconds / (60 * 60); |
465 int minutes = (seconds / 60) % 60; | 481 int minutes = (seconds / 60) % 60; |
466 seconds %= 60; | 482 seconds %= 60; |
467 if (hours) { | 483 if (hours) { |
468 if (hours > 9) | 484 if (hours > 9) |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 bool RenderTheme::supportsMeter(ControlPart) const | 900 bool RenderTheme::supportsMeter(ControlPart) const |
885 { | 901 { |
886 return false; | 902 return false; |
887 } | 903 } |
888 | 904 |
889 bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) | 905 bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) |
890 { | 906 { |
891 return true; | 907 return true; |
892 } | 908 } |
893 | 909 |
894 #if ENABLE(DATALIST_ELEMENT) | |
895 LayoutUnit RenderTheme::sliderTickSnappingThreshold() const | 910 LayoutUnit RenderTheme::sliderTickSnappingThreshold() const |
896 { | 911 { |
897 return 5; | 912 return 5; |
898 } | 913 } |
899 | 914 |
900 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo,
const IntRect& rect) | 915 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo,
const IntRect& rect) |
901 { | 916 { |
902 Node* node = o->node(); | 917 Node* node = o->node(); |
903 if (!node) | 918 if (!node) |
904 return; | 919 return; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 double tickFraction = (parsedValue - min) / (max - min); | 986 double tickFraction = (parsedValue - min) / (max - min); |
972 double tickRatio = isHorizontal && o->style()->isLeftToRightDirection()
? tickFraction : 1.0 - tickFraction; | 987 double tickRatio = isHorizontal && o->style()->isLeftToRightDirection()
? tickFraction : 1.0 - tickFraction; |
973 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic
kRatio); | 988 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic
kRatio); |
974 if (isHorizontal) | 989 if (isHorizontal) |
975 tickRect.setX(tickPosition); | 990 tickRect.setX(tickPosition); |
976 else | 991 else |
977 tickRect.setY(tickPosition); | 992 tickRect.setY(tickPosition); |
978 paintInfo.context->fillRect(tickRect); | 993 paintInfo.context->fillRect(tickRect); |
979 } | 994 } |
980 } | 995 } |
981 #endif | |
982 | 996 |
983 double RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress*) const | 997 double RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress*) const |
984 { | 998 { |
985 return 0; | 999 return 0; |
986 } | 1000 } |
987 | 1001 |
988 double RenderTheme::animationDurationForProgressBar(RenderProgress*) const | 1002 double RenderTheme::animationDurationForProgressBar(RenderProgress*) const |
989 { | 1003 { |
990 return 0; | 1004 return 0; |
991 } | 1005 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 { | 1228 { |
1215 return type == InputTypeNames::date() | 1229 return type == InputTypeNames::date() |
1216 || type == InputTypeNames::datetime() | 1230 || type == InputTypeNames::datetime() |
1217 || type == InputTypeNames::datetimelocal() | 1231 || type == InputTypeNames::datetimelocal() |
1218 || type == InputTypeNames::month() | 1232 || type == InputTypeNames::month() |
1219 || type == InputTypeNames::week(); | 1233 || type == InputTypeNames::week(); |
1220 } | 1234 } |
1221 #endif | 1235 #endif |
1222 | 1236 |
1223 } // namespace WebCore | 1237 } // namespace WebCore |
OLD | NEW |