OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 | 1063 |
1064 static WTF::Optional<StyleableMarker::Thickness> ThicknessFrom( | 1064 static WTF::Optional<StyleableMarker::Thickness> ThicknessFrom( |
1065 const String& thickness) { | 1065 const String& thickness) { |
1066 if (EqualIgnoringASCIICase(thickness, "thin")) | 1066 if (EqualIgnoringASCIICase(thickness, "thin")) |
1067 return StyleableMarker::Thickness::kThin; | 1067 return StyleableMarker::Thickness::kThin; |
1068 if (EqualIgnoringASCIICase(thickness, "thick")) | 1068 if (EqualIgnoringASCIICase(thickness, "thick")) |
1069 return StyleableMarker::Thickness::kThick; | 1069 return StyleableMarker::Thickness::kThick; |
1070 return WTF::nullopt; | 1070 return WTF::nullopt; |
1071 } | 1071 } |
1072 | 1072 |
1073 void Internals::addCompositionMarker(const Range* range, | 1073 namespace { |
1074 const String& underline_color_value, | 1074 |
1075 const String& thickness_value, | 1075 void addStyleableMarkerHelper( |
1076 const String& background_color_value, | 1076 const Range* range, |
1077 ExceptionState& exception_state) { | 1077 const String& underline_color_value, |
| 1078 const String& thickness_value, |
| 1079 const String& background_color_value, |
| 1080 ExceptionState& exception_state, |
| 1081 std::function< |
| 1082 void(const EphemeralRange&, Color, StyleableMarker::Thickness, Color)> |
| 1083 create_marker) { |
1078 DCHECK(range); | 1084 DCHECK(range); |
1079 range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | 1085 range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
1080 | 1086 |
1081 WTF::Optional<StyleableMarker::Thickness> thickness = | 1087 WTF::Optional<StyleableMarker::Thickness> thickness = |
1082 ThicknessFrom(thickness_value); | 1088 ThicknessFrom(thickness_value); |
1083 if (!thickness) { | 1089 if (!thickness) { |
1084 exception_state.ThrowDOMException( | 1090 exception_state.ThrowDOMException( |
1085 kSyntaxError, | 1091 kSyntaxError, |
1086 "The thickness provided ('" + thickness_value + "') is invalid."); | 1092 "The thickness provided ('" + thickness_value + "') is invalid."); |
1087 return; | 1093 return; |
1088 } | 1094 } |
1089 | 1095 |
1090 Color underline_color; | 1096 Color underline_color; |
1091 Color background_color; | 1097 Color background_color; |
1092 if (ParseColor(underline_color_value, underline_color, exception_state, | 1098 if (ParseColor(underline_color_value, underline_color, exception_state, |
1093 "Invalid underline color.") && | 1099 "Invalid underline color.") && |
1094 ParseColor(background_color_value, background_color, exception_state, | 1100 ParseColor(background_color_value, background_color, exception_state, |
1095 "Invalid background color.")) { | 1101 "Invalid background color.")) { |
1096 range->OwnerDocument().Markers().AddCompositionMarker( | 1102 create_marker(EphemeralRange(range), underline_color, thickness.value(), |
1097 EphemeralRange(range), underline_color, thickness.value(), | 1103 background_color); |
1098 background_color); | |
1099 } | 1104 } |
1100 } | 1105 } |
1101 | 1106 |
| 1107 } // namespace |
| 1108 |
| 1109 void Internals::addCompositionMarker(const Range* range, |
| 1110 const String& underline_color_value, |
| 1111 const String& thickness_value, |
| 1112 const String& background_color_value, |
| 1113 ExceptionState& exception_state) { |
| 1114 DocumentMarkerController& document_marker_controller = |
| 1115 range->OwnerDocument().Markers(); |
| 1116 addStyleableMarkerHelper( |
| 1117 range, underline_color_value, thickness_value, background_color_value, |
| 1118 exception_state, |
| 1119 [&document_marker_controller]( |
| 1120 const EphemeralRange& range, Color underline_color, |
| 1121 StyleableMarker::Thickness thickness, Color background_color) { |
| 1122 document_marker_controller.AddCompositionMarker( |
| 1123 range, underline_color, thickness, background_color); |
| 1124 }); |
| 1125 } |
| 1126 |
| 1127 void Internals::addActiveSuggestionMarker(const Range* range, |
| 1128 const String& underline_color_value, |
| 1129 const String& thickness_value, |
| 1130 const String& background_color_value, |
| 1131 ExceptionState& exception_state) { |
| 1132 DocumentMarkerController& document_marker_controller = |
| 1133 range->OwnerDocument().Markers(); |
| 1134 addStyleableMarkerHelper( |
| 1135 range, underline_color_value, thickness_value, background_color_value, |
| 1136 exception_state, |
| 1137 [&document_marker_controller]( |
| 1138 const EphemeralRange& range, Color underline_color, |
| 1139 StyleableMarker::Thickness thickness, Color background_color) { |
| 1140 document_marker_controller.AddActiveSuggestionMarker( |
| 1141 range, underline_color, thickness, background_color); |
| 1142 }); |
| 1143 } |
| 1144 |
1102 void Internals::setTextMatchMarkersActive(Node* node, | 1145 void Internals::setTextMatchMarkersActive(Node* node, |
1103 unsigned start_offset, | 1146 unsigned start_offset, |
1104 unsigned end_offset, | 1147 unsigned end_offset, |
1105 bool active) { | 1148 bool active) { |
1106 DCHECK(node); | 1149 DCHECK(node); |
1107 node->GetDocument().Markers().SetTextMatchMarkersActive(node, start_offset, | 1150 node->GetDocument().Markers().SetTextMatchMarkersActive(node, start_offset, |
1108 end_offset, active); | 1151 end_offset, active); |
1109 } | 1152 } |
1110 | 1153 |
1111 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, | 1154 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, |
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 | 3381 |
3339 void Internals::crash() { | 3382 void Internals::crash() { |
3340 CHECK(false) << "Intentional crash"; | 3383 CHECK(false) << "Intentional crash"; |
3341 } | 3384 } |
3342 | 3385 |
3343 void Internals::setIsLowEndDevice(bool is_low_end_device) { | 3386 void Internals::setIsLowEndDevice(bool is_low_end_device) { |
3344 MemoryCoordinator::SetIsLowEndDeviceForTesting(is_low_end_device); | 3387 MemoryCoordinator::SetIsLowEndDeviceForTesting(is_low_end_device); |
3345 } | 3388 } |
3346 | 3389 |
3347 } // namespace blink | 3390 } // namespace blink |
OLD | NEW |