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 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 Color& color, | 1059 Color& color, |
1060 ExceptionState& exception_state, | 1060 ExceptionState& exception_state, |
1061 String error_message) { | 1061 String error_message) { |
1062 if (!color.SetFromString(value)) { | 1062 if (!color.SetFromString(value)) { |
1063 exception_state.ThrowDOMException(kInvalidAccessError, error_message); | 1063 exception_state.ThrowDOMException(kInvalidAccessError, error_message); |
1064 return false; | 1064 return false; |
1065 } | 1065 } |
1066 return true; | 1066 return true; |
1067 } | 1067 } |
1068 | 1068 |
1069 static WTF::Optional<CompositionMarker::Thickness> ThicknessFrom( | |
1070 const String& thickness) { | |
1071 if (EqualIgnoringASCIICase(thickness, "kThin")) | |
yosin_UTC9
2017/05/29 05:22:08
Let's use "thin" and "thick" as MarkerTypeForm().
| |
1072 return CompositionMarker::Thickness::kThin; | |
1073 if (EqualIgnoringASCIICase(thickness, "kThick")) | |
1074 return CompositionMarker::Thickness::kThick; | |
1075 return WTF::nullopt; | |
1076 } | |
1077 | |
1069 void Internals::addCompositionMarker(const Range* range, | 1078 void Internals::addCompositionMarker(const Range* range, |
1070 const String& underline_color_value, | 1079 const String& underline_color_value, |
1071 bool thick, | 1080 const String& thickness_value, |
yosin_UTC9
2017/05/29 05:22:08
Good catch! (^_^)b
| |
1072 const String& background_color_value, | 1081 const String& background_color_value, |
1073 ExceptionState& exception_state) { | 1082 ExceptionState& exception_state) { |
1074 DCHECK(range); | 1083 DCHECK(range); |
1075 range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | 1084 range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
1076 | 1085 |
1086 WTF::Optional<CompositionMarker::Thickness> thickness = | |
1087 ThicknessFrom(thickness_value); | |
1088 if (!thickness) { | |
1089 exception_state.ThrowDOMException( | |
1090 kSyntaxError, | |
1091 "The thickness provided ('" + thickness_value + "') is invalid."); | |
1092 return; | |
1093 } | |
1094 | |
1077 Color underline_color; | 1095 Color underline_color; |
1078 Color background_color; | 1096 Color background_color; |
1079 if (ParseColor(underline_color_value, underline_color, exception_state, | 1097 if (ParseColor(underline_color_value, underline_color, exception_state, |
1080 "Invalid underline color.") && | 1098 "Invalid underline color.") && |
1081 ParseColor(background_color_value, background_color, exception_state, | 1099 ParseColor(background_color_value, background_color, exception_state, |
1082 "Invalid background color.")) { | 1100 "Invalid background color.")) { |
1083 range->OwnerDocument().Markers().AddCompositionMarker( | 1101 range->OwnerDocument().Markers().AddCompositionMarker( |
1084 EphemeralRange(range), underline_color, thick, background_color); | 1102 EphemeralRange(range), underline_color, thickness.value(), |
1103 background_color); | |
1085 } | 1104 } |
1086 } | 1105 } |
1087 | 1106 |
1088 void Internals::setTextMatchMarkersActive(Node* node, | 1107 void Internals::setTextMatchMarkersActive(Node* node, |
1089 unsigned start_offset, | 1108 unsigned start_offset, |
1090 unsigned end_offset, | 1109 unsigned end_offset, |
1091 bool active) { | 1110 bool active) { |
1092 DCHECK(node); | 1111 DCHECK(node); |
1093 node->GetDocument().Markers().SetTextMatchMarkersActive(node, start_offset, | 1112 node->GetDocument().Markers().SetTextMatchMarkersActive(node, start_offset, |
1094 end_offset, active); | 1113 end_offset, active); |
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3296 | 3315 |
3297 void Internals::crash() { | 3316 void Internals::crash() { |
3298 CHECK(false) << "Intentional crash"; | 3317 CHECK(false) << "Intentional crash"; |
3299 } | 3318 } |
3300 | 3319 |
3301 void Internals::setIsLowEndDevice(bool is_low_end_device) { | 3320 void Internals::setIsLowEndDevice(bool is_low_end_device) { |
3302 MemoryCoordinator::SetIsLowEndDeviceForTesting(is_low_end_device); | 3321 MemoryCoordinator::SetIsLowEndDeviceForTesting(is_low_end_device); |
3303 } | 3322 } |
3304 | 3323 |
3305 } // namespace blink | 3324 } // namespace blink |
OLD | NEW |