chore: modernize Value usage in converters (#34794)

* chore: modernize Value usage in converters

* Date is parsed as an empty object now
This commit is contained in:
Jeremy Rose 2022-07-05 08:25:18 -07:00 committed by GitHub
parent d28ed0da20
commit 0ee7f14190
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 203 additions and 829 deletions

View file

@ -241,8 +241,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
- (void)buttonAction:(id)sender {
NSString* item_id =
[NSString stringWithFormat:@"%ld", ((NSButton*)sender).tag];
window_->NotifyTouchBarItemInteraction([item_id UTF8String],
base::DictionaryValue());
window_->NotifyTouchBarItemInteraction([item_id UTF8String], {});
}
- (void)colorPickerAction:(id)sender {
@ -252,19 +251,20 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
NSColor* color = ((NSColorPickerTouchBarItem*)sender).color;
std::string hex_color =
electron::ToRGBHex(skia::NSDeviceColorToSkColor(color));
base::DictionaryValue details;
details.SetString("color", hex_color);
window_->NotifyTouchBarItemInteraction([item_id UTF8String], details);
base::Value::Dict details;
details.Set("color", hex_color);
window_->NotifyTouchBarItemInteraction([item_id UTF8String],
std::move(details));
}
- (void)sliderAction:(id)sender {
NSString* identifier = ((NSSliderTouchBarItem*)sender).identifier;
NSString* item_id = [self idFromIdentifier:identifier
withPrefix:SliderIdentifier];
base::DictionaryValue details;
details.SetInteger("value",
[((NSSliderTouchBarItem*)sender).slider intValue]);
window_->NotifyTouchBarItemInteraction([item_id UTF8String], details);
base::Value::Dict details;
details.Set("value", [((NSSliderTouchBarItem*)sender).slider intValue]);
window_->NotifyTouchBarItemInteraction([item_id UTF8String],
std::move(details));
}
- (NSString*)idFromIdentifier:(NSString*)identifier
@ -275,32 +275,33 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
- (void)segmentedControlAction:(id)sender {
NSString* item_id =
[NSString stringWithFormat:@"%ld", ((NSSegmentedControl*)sender).tag];
base::DictionaryValue details;
details.SetInteger("selectedIndex",
((NSSegmentedControl*)sender).selectedSegment);
details.SetBoolean(
base::Value::Dict details;
details.Set("selectedIndex",
static_cast<int>(((NSSegmentedControl*)sender).selectedSegment));
details.Set(
"isSelected",
[((NSSegmentedControl*)sender)
isSelectedForSegment:((NSSegmentedControl*)sender).selectedSegment]);
window_->NotifyTouchBarItemInteraction([item_id UTF8String], details);
window_->NotifyTouchBarItemInteraction([item_id UTF8String],
std::move(details));
}
- (void)scrubber:(NSScrubber*)scrubber
didSelectItemAtIndex:(NSInteger)selectedIndex {
base::DictionaryValue details;
details.SetInteger("selectedIndex", selectedIndex);
details.SetString("type", "select");
base::Value::Dict details;
details.Set("selectedIndex", static_cast<int>(selectedIndex));
details.Set("type", "select");
window_->NotifyTouchBarItemInteraction([scrubber.identifier UTF8String],
details);
std::move(details));
}
- (void)scrubber:(NSScrubber*)scrubber
didHighlightItemAtIndex:(NSInteger)highlightedIndex {
base::DictionaryValue details;
details.SetInteger("highlightedIndex", highlightedIndex);
details.SetString("type", "highlight");
base::Value::Dict details;
details.Set("highlightedIndex", static_cast<int>(highlightedIndex));
details.Set("type", "highlight");
window_->NotifyTouchBarItemInteraction([scrubber.identifier UTF8String],
details);
std::move(details));
}
- (NSTouchBarItemIdentifier)identifierFromID:(const std::string&)item_id