Auto merge of #27491 - paulrouget:devPreviewTab, r=jdm

UWP: only show promoted preferences

This depends on changes made in #27438
Fix #27419
This commit is contained in:
bors-servo 2020-08-05 08:51:13 -04:00 committed by GitHub
commit 611c57bfdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 182 additions and 13 deletions

View file

@ -16,6 +16,7 @@ using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::ViewManagement;
using namespace winrt::Windows::ApplicationModel::Core;
using namespace winrt::Windows::ApplicationModel::Resources;
using namespace winrt::Windows::ApplicationModel::Resources::Core;
using namespace winrt::Windows::UI::Notifications;
using namespace winrt::Windows::Data::Json;
using namespace winrt::Windows::Data::Xml::Dom;
@ -28,6 +29,17 @@ BrowserPage::BrowserPage() {
InitializeComponent();
BindServoEvents();
mLogs = winrt::single_threaded_observable_vector<IInspectable>();
auto ctx = ResourceContext::GetForCurrentView();
auto current = ResourceManager::Current();
auto tree = current.MainResourceMap().GetSubtree(L"PromotedPrefs");
for (auto s : tree) {
hstring k = s.Key();
std::wstring wk = k.c_str();
std::replace(wk.begin(), wk.end(), '/', '.');
hstring v = s.Value().Resolve(ctx).ValueAsString();
mPromotedPrefs.insert(std::pair(wk, v));
}
}
void BrowserPage::BindServoEvents() {
@ -182,17 +194,34 @@ void BrowserPage::UpdatePref(ServoApp::Pref pref, Controls::Control ctrl) {
stack.Children().GetAt(2).as<Controls::Button>().IsEnabled(!pref.IsDefault());
}
void BrowserPage::OnSeeAllPrefClicked(IInspectable const &,
RoutedEventArgs const &) {
BuildPrefList();
}
// Retrieve the preference list from Servo and build the preference table.
void BrowserPage::BuildPrefList() {
prefList().Children().Clear();
bool promoted = !seeAllPrefCheckBox().IsChecked().GetBoolean();
preferenceSearchbox().Visibility(promoted ? Visibility::Collapsed
: Visibility::Visible);
preferenceSearchbox().Text(L"");
// It would be better to use a template and bindings, but the
// <ListView> takes too long to generate all the items, and
// it's pretty difficiult to have different controls depending
// on the pref type.
prefList().Children().Clear();
auto resourceLoader = ResourceLoader::GetForCurrentView();
auto resetStr =
resourceLoader.GetString(L"devtoolsPreferenceResetButton/Content");
for (auto pref : servoView().Preferences()) {
std::optional<hstring> description = {};
if (promoted) {
auto search = mPromotedPrefs.find(pref.Key());
if (search == mPromotedPrefs.end()) {
continue;
}
description = {search->second};
}
auto value = pref.Value();
auto type = value.as<IPropertyValue>().Type();
std::optional<Controls::Control> ctrl;
@ -243,7 +272,7 @@ void BrowserPage::BuildPrefList() {
stack.Padding({4, 4, 4, 4});
stack.Orientation(Controls::Orientation::Horizontal);
auto key = Controls::TextBlock();
key.Text(pref.Key());
key.Text(promoted ? *description : pref.Key());
key.Width(350);
if (!pref.IsDefault()) {
auto font = winrt::Windows::UI::Text::FontWeights::Bold();

View file

@ -34,6 +34,7 @@ public:
void OnDevtoolsButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnJSInputEdited(IInspectable const &, Input::KeyRoutedEventArgs const &);
void OnURLEdited(IInspectable const &, Input::KeyRoutedEventArgs const &);
void OnSeeAllPrefClicked(IInspectable const &, RoutedEventArgs const &);
void OnURLFocused(IInspectable const &);
void
OnURLKeyboardAccelerator(IInspectable const &,
@ -53,13 +54,13 @@ public:
void ClearConsole();
void OnDevtoolsDetached();
Collections::IObservableVector<IInspectable> ConsoleLogs() { return mLogs; };
void BuildPrefList();
private:
void SetTransientMode(bool);
void UpdatePref(ServoApp::Pref, Controls::Control);
void CheckCrashReport();
void BindServoEvents();
void BuildPrefList();
void ShowToolbox();
void HideToolbox();
DevtoolsStatus mDevtoolsStatus = DevtoolsStatus::Stopped;
@ -68,6 +69,7 @@ private:
bool mPanicking = false;
std::unique_ptr<servo::DevtoolsClient> mDevtoolsClient;
Collections::IObservableVector<IInspectable> mLogs;
std::map<hstring, hstring> mPromotedPrefs;
};
struct ConsoleLog : ConsoleLogT<ConsoleLog> {

View file

@ -192,11 +192,13 @@
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" IsTabStop="true" x:Uid="preferenceSearchbox" x:Name="preferenceSearchbox" VerticalAlignment="Center" KeyUp="OnPrefererenceSearchboxEdited" IsSpellCheckEnabled="False" Margin="3"/>
<CheckBox Margin="3" x:Name="seeAllPrefCheckBox" x:Uid="seeAllPrefCheckBox" Click="OnSeeAllPrefClicked" IsChecked="False" Grid.Row="0"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="prefList"/>
</ScrollViewer>
<TextBox Grid.Row="2" IsTabStop="true" x:Uid="preferenceSearchbox" x:Name="preferenceSearchbox" VerticalAlignment="Center" KeyUp="OnPrefererenceSearchboxEdited" IsSpellCheckEnabled="False" Margin="3"/>
</Grid>
</muxc:TabViewItem>
<muxc:TabViewItem x:Uid="crashTab" x:Name="crashTab" IsClosable="False" Visibility="Collapsed">

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="dom.webxr.hands.enabled"><value>WebXR: Enable XRJointPose (hands joints positions)</value></data>
<data name="dom.webxr.layers.enabled"><value>WebXR: Enable composition layers</value></data>
<data name="dom.webxr.sessionavailable"><value>WebXR: Enable "sessionavailable" event</value></data>
<data name="dom.webxr.first_person_observer_view"><value>WebXR: Enable first person observer view</value></data>
<data name="dom.webgl2.enabled"><value>Enable WebGL2</value></data>
</root>

View file

@ -171,4 +171,7 @@
<data name="ContextMenu.title" xml:space="preserve">
<value>Menu</value>
</data>
<data name="seeAllPrefCheckBox.Content" xml:space="preserve">
<value>See all preferences</value>
</data>
</root>

View file

@ -988,8 +988,9 @@
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-US\Resources.resw" />
<PRIResource Include="Strings\fr-FR\Resources.resw" />
<PRIResource Include="Resources\PromotedPrefs.resw" />
<PRIResource Include="Resources\Strings\en-US\Resources.resw" />
<PRIResource Include="Resources\Strings\fr-FR\Resources.resw" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -924,13 +924,16 @@
<Filter Include="ServoControl">
<UniqueIdentifier>{d21a959c-19d1-4a54-b942-692c27e5b3a6}</UniqueIdentifier>
</Filter>
<Filter Include="Strings">
<Filter Include="Resources">
<UniqueIdentifier>{c05cce0c-d62c-11ea-87d0-0242ac130003}</UniqueIdentifier>
</Filter>
<Filter Include="Resources\Strings">
<UniqueIdentifier>{49e23631-d899-4caf-bf7b-30776fee4d09}</UniqueIdentifier>
</Filter>
<Filter Include="Strings\en-US">
<Filter Include="Resources\Strings\en-US">
<UniqueIdentifier>{c12ff5d4-3730-4a0e-8b16-56ded3138875}</UniqueIdentifier>
</Filter>
<Filter Include="Strings\fr-FR">
<Filter Include="Resources\Strings\fr-FR">
<UniqueIdentifier>{b7d3273d-a27c-4176-87a1-3d5222b796b3}</UniqueIdentifier>
</Filter>
<Filter Include="Devtools">
@ -950,11 +953,14 @@
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-US\Resources.resw">
<Filter>Strings\en-US</Filter>
<PRIResource Include="Resources\PromotedPrefs.resw">
<Filter>Resources</Filter>
</PRIResource>
<PRIResource Include="Strings\fr-FR\Resources.resw">
<Filter>Strings\fr-FR</Filter>
<PRIResource Include="Resources\Strings\en-US\Resources.resw">
<Filter>Resources\Strings\en-US</Filter>
</PRIResource>
<PRIResource Include="Resources\Strings\fr-FR\Resources.resw">
<Filter>Resources\Strings\fr-FR</Filter>
</PRIResource>
</ItemGroup>
</Project>

View file

@ -31,6 +31,7 @@
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.ApplicationModel.Core.h>
#include <winrt/Windows.ApplicationModel.Resources.h>
#include <winrt/Windows.ApplicationModel.Resources.Core.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Metadata.h>