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" | |
37 #include "core/html/parser/HTMLParserIdioms.h" | |
32 #include "core/html/shadow/MediaControlElements.h" | 38 #include "core/html/shadow/MediaControlElements.h" |
33 #include "core/html/shadow/SpinButtonElement.h" | 39 #include "core/html/shadow/SpinButtonElement.h" |
34 #include "core/html/shadow/TextControlInnerElements.h" | 40 #include "core/html/shadow/TextControlInnerElements.h" |
35 #include "core/page/FocusController.h" | 41 #include "core/page/FocusController.h" |
36 #include "core/page/Frame.h" | 42 #include "core/page/Frame.h" |
37 #include "core/page/Page.h" | 43 #include "core/page/Page.h" |
38 #include "core/page/Settings.h" | 44 #include "core/page/Settings.h" |
39 #include "core/platform/FileSystem.h" | 45 #include "core/platform/FileSystem.h" |
40 #include "core/platform/FloatConversion.h" | 46 #include "core/platform/FloatConversion.h" |
41 #include "core/platform/LocalizedStrings.h" | 47 #include "core/platform/LocalizedStrings.h" |
42 #include "core/platform/graphics/FontSelector.h" | 48 #include "core/platform/graphics/FontSelector.h" |
43 #include "core/platform/graphics/GraphicsContextStateSaver.h" | 49 #include "core/platform/graphics/GraphicsContextStateSaver.h" |
44 #include "core/platform/graphics/StringTruncator.h" | 50 #include "core/platform/graphics/StringTruncator.h" |
45 #include "core/rendering/PaintInfo.h" | 51 #include "core/rendering/PaintInfo.h" |
46 #include "core/rendering/RenderMeter.h" | 52 #include "core/rendering/RenderMeter.h" |
47 #include "core/rendering/RenderView.h" | 53 #include "core/rendering/RenderView.h" |
48 #include "core/rendering/style/RenderStyle.h" | 54 #include "core/rendering/style/RenderStyle.h" |
49 | 55 |
50 #if ENABLE(INPUT_SPEECH) | 56 #if ENABLE(INPUT_SPEECH) |
51 #include "core/rendering/RenderInputSpeech.h" | 57 #include "core/rendering/RenderInputSpeech.h" |
52 #endif | 58 #endif |
53 | 59 |
54 #if ENABLE(DATALIST_ELEMENT) | |
55 #include "core/dom/shadow/ElementShadow.h" | |
56 #include "core/html/HTMLCollection.h" | |
57 #include "core/html/HTMLDataListElement.h" | |
58 #include "core/html/HTMLOptionElement.h" | |
59 #include "core/html/parser/HTMLParserIdioms.h" | |
60 #endif | |
61 | |
62 // The methods in this file are shared by all themes on every platform. | 60 // The methods in this file are shared by all themes on every platform. |
63 | 61 |
64 namespace WebCore { | 62 namespace WebCore { |
65 | 63 |
66 using namespace HTMLNames; | 64 using namespace HTMLNames; |
67 | 65 |
68 static Color& customFocusRingColor() | 66 static Color& customFocusRingColor() |
69 { | 67 { |
70 DEFINE_STATIC_LOCAL(Color, color, ()); | 68 DEFINE_STATIC_LOCAL(Color, color, ()); |
71 return color; | 69 return color; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 #if ENABLE(INPUT_SPEECH) | 446 #if ENABLE(INPUT_SPEECH) |
449 case InputSpeechButtonPart: | 447 case InputSpeechButtonPart: |
450 #endif | 448 #endif |
451 default: | 449 default: |
452 break; | 450 break; |
453 } | 451 } |
454 | 452 |
455 return false; | 453 return false; |
456 } | 454 } |
457 | 455 |
456 String RenderTheme::extraDefaultStyleSheet() | |
457 { | |
458 if (!RuntimeEnabledFeature::dataListElementEnabled()) | |
459 return String(); | |
460 static String dataListElementCSS = ASCIILiteral("datalist {display: none ;}" ); | |
tkent
2013/05/22 01:46:17
Please use DEFINE_STATIC_LOCAL.
DEFINE_STATIC_LOC
| |
461 | |
462 #if ENABLE(INPUT_TYPE_COLOR) | |
463 StringBuilder inputTypeCSS; | |
464 inputTypeCSS.appendLiteral("input[type=\"color\"][list] { -webkit-appearance : menulist; width: 88px; height: 23px;}"); | |
465 inputTypeCSS.appendLiteral("input[type=\"color\"][list]::-webkit-color-swatc h-wrapper { padding-left: 8px; padding-right: 24px;}"); | |
466 inputTypeCSS.appendLiteral("input[type=\"color\"][list]::-webkit-color-swatc h { border-color: #000000;}"); | |
467 inputTypeCSS.append(dataListElementCSS); | |
468 return inputTypeCSS.toString(); | |
469 #endif | |
470 | |
471 return dataListElementCSS; | |
472 } | |
473 | |
458 String RenderTheme::formatMediaControlsTime(float time) const | 474 String RenderTheme::formatMediaControlsTime(float time) const |
459 { | 475 { |
460 if (!std::isfinite(time)) | 476 if (!std::isfinite(time)) |
461 time = 0; | 477 time = 0; |
462 int seconds = (int)fabsf(time); | 478 int seconds = (int)fabsf(time); |
463 int hours = seconds / (60 * 60); | 479 int hours = seconds / (60 * 60); |
464 int minutes = (seconds / 60) % 60; | 480 int minutes = (seconds / 60) % 60; |
465 seconds %= 60; | 481 seconds %= 60; |
466 if (hours) { | 482 if (hours) { |
467 if (hours > 9) | 483 if (hours > 9) |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 bool RenderTheme::supportsMeter(ControlPart) const | 899 bool RenderTheme::supportsMeter(ControlPart) const |
884 { | 900 { |
885 return false; | 901 return false; |
886 } | 902 } |
887 | 903 |
888 bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) | 904 bool RenderTheme::paintMeter(RenderObject*, const PaintInfo&, const IntRect&) |
889 { | 905 { |
890 return true; | 906 return true; |
891 } | 907 } |
892 | 908 |
893 #if ENABLE(DATALIST_ELEMENT) | |
894 LayoutUnit RenderTheme::sliderTickSnappingThreshold() const | 909 LayoutUnit RenderTheme::sliderTickSnappingThreshold() const |
895 { | 910 { |
896 return 0; | 911 return 0; |
897 } | 912 } |
898 | 913 |
899 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) | 914 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) |
900 { | 915 { |
901 Node* node = o->node(); | 916 Node* node = o->node(); |
902 if (!node) | 917 if (!node) |
903 return; | 918 return; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 double tickFraction = (parsedValue - min) / (max - min); | 985 double tickFraction = (parsedValue - min) / (max - min); |
971 double tickRatio = isHorizontal && o->style()->isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction; | 986 double tickRatio = isHorizontal && o->style()->isLeftToRightDirection() ? tickFraction : 1.0 - tickFraction; |
972 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic kRatio); | 987 double tickPosition = round(tickRegionSideMargin + tickRegionWidth * tic kRatio); |
973 if (isHorizontal) | 988 if (isHorizontal) |
974 tickRect.setX(tickPosition); | 989 tickRect.setX(tickPosition); |
975 else | 990 else |
976 tickRect.setY(tickPosition); | 991 tickRect.setY(tickPosition); |
977 paintInfo.context->fillRect(tickRect); | 992 paintInfo.context->fillRect(tickRect); |
978 } | 993 } |
979 } | 994 } |
980 #endif | |
981 | 995 |
982 double RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress*) const | 996 double RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress*) const |
983 { | 997 { |
984 return 0; | 998 return 0; |
985 } | 999 } |
986 | 1000 |
987 double RenderTheme::animationDurationForProgressBar(RenderProgress*) const | 1001 double RenderTheme::animationDurationForProgressBar(RenderProgress*) const |
988 { | 1002 { |
989 return 0; | 1003 return 0; |
990 } | 1004 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1186 | 1200 |
1187 return StringTruncator::centerTruncate(string, width, font, StringTruncator: :EnableRoundingHacks); | 1201 return StringTruncator::centerTruncate(string, width, font, StringTruncator: :EnableRoundingHacks); |
1188 } | 1202 } |
1189 | 1203 |
1190 bool RenderTheme::shouldOpenPickerWithF4Key() const | 1204 bool RenderTheme::shouldOpenPickerWithF4Key() const |
1191 { | 1205 { |
1192 return false; | 1206 return false; |
1193 } | 1207 } |
1194 | 1208 |
1195 } // namespace WebCore | 1209 } // namespace WebCore |
OLD | NEW |