| 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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 Color& color, | 1054 Color& color, |
| 1055 ExceptionState& exception_state, | 1055 ExceptionState& exception_state, |
| 1056 String error_message) { | 1056 String error_message) { |
| 1057 if (!color.SetFromString(value)) { | 1057 if (!color.SetFromString(value)) { |
| 1058 exception_state.ThrowDOMException(kInvalidAccessError, error_message); | 1058 exception_state.ThrowDOMException(kInvalidAccessError, error_message); |
| 1059 return false; | 1059 return false; |
| 1060 } | 1060 } |
| 1061 return true; | 1061 return true; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 static WTF::Optional<CompositionMarker::Thickness> ThicknessFrom( |
| 1065 const String& thickness) { |
| 1066 if (EqualIgnoringASCIICase(thickness, "thin")) |
| 1067 return CompositionMarker::Thickness::kThin; |
| 1068 if (EqualIgnoringASCIICase(thickness, "thick")) |
| 1069 return CompositionMarker::Thickness::kThick; |
| 1070 return WTF::nullopt; |
| 1071 } |
| 1072 |
| 1064 void Internals::addCompositionMarker(const Range* range, | 1073 void Internals::addCompositionMarker(const Range* range, |
| 1065 const String& underline_color_value, | 1074 const String& underline_color_value, |
| 1066 bool thick, | 1075 const String& thickness_value, |
| 1067 const String& background_color_value, | 1076 const String& background_color_value, |
| 1068 ExceptionState& exception_state) { | 1077 ExceptionState& exception_state) { |
| 1069 DCHECK(range); | 1078 DCHECK(range); |
| 1070 range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | 1079 range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 1071 | 1080 |
| 1081 WTF::Optional<CompositionMarker::Thickness> thickness = |
| 1082 ThicknessFrom(thickness_value); |
| 1083 if (!thickness) { |
| 1084 exception_state.ThrowDOMException( |
| 1085 kSyntaxError, |
| 1086 "The thickness provided ('" + thickness_value + "') is invalid."); |
| 1087 return; |
| 1088 } |
| 1089 |
| 1072 Color underline_color; | 1090 Color underline_color; |
| 1073 Color background_color; | 1091 Color background_color; |
| 1074 if (ParseColor(underline_color_value, underline_color, exception_state, | 1092 if (ParseColor(underline_color_value, underline_color, exception_state, |
| 1075 "Invalid underline color.") && | 1093 "Invalid underline color.") && |
| 1076 ParseColor(background_color_value, background_color, exception_state, | 1094 ParseColor(background_color_value, background_color, exception_state, |
| 1077 "Invalid background color.")) { | 1095 "Invalid background color.")) { |
| 1078 range->OwnerDocument().Markers().AddCompositionMarker( | 1096 range->OwnerDocument().Markers().AddCompositionMarker( |
| 1079 EphemeralRange(range), underline_color, thick, background_color); | 1097 EphemeralRange(range), underline_color, thickness.value(), |
| 1098 background_color); |
| 1080 } | 1099 } |
| 1081 } | 1100 } |
| 1082 | 1101 |
| 1083 void Internals::setTextMatchMarkersActive(Node* node, | 1102 void Internals::setTextMatchMarkersActive(Node* node, |
| 1084 unsigned start_offset, | 1103 unsigned start_offset, |
| 1085 unsigned end_offset, | 1104 unsigned end_offset, |
| 1086 bool active) { | 1105 bool active) { |
| 1087 DCHECK(node); | 1106 DCHECK(node); |
| 1088 node->GetDocument().Markers().SetTextMatchMarkersActive(node, start_offset, | 1107 node->GetDocument().Markers().SetTextMatchMarkersActive(node, start_offset, |
| 1089 end_offset, active); | 1108 end_offset, active); |
| (...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3291 | 3310 |
| 3292 void Internals::crash() { | 3311 void Internals::crash() { |
| 3293 CHECK(false) << "Intentional crash"; | 3312 CHECK(false) << "Intentional crash"; |
| 3294 } | 3313 } |
| 3295 | 3314 |
| 3296 void Internals::setIsLowEndDevice(bool is_low_end_device) { | 3315 void Internals::setIsLowEndDevice(bool is_low_end_device) { |
| 3297 MemoryCoordinator::SetIsLowEndDeviceForTesting(is_low_end_device); | 3316 MemoryCoordinator::SetIsLowEndDeviceForTesting(is_low_end_device); |
| 3298 } | 3317 } |
| 3299 | 3318 |
| 3300 } // namespace blink | 3319 } // namespace blink |
| OLD | NEW |