Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/devtools.js

Issue 1666573002: [DevTools] Polyfill Object.observe for old frontends. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comment Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/Settings.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(window) { 5 (function(window) {
6 6
7 // DevToolsAPI ---------------------------------------------------------------- 7 // DevToolsAPI ----------------------------------------------------------------
8 8
9 /** 9 /**
10 * @constructor 10 * @constructor
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 recordPanelShown: function(panelCode) 860 recordPanelShown: function(panelCode)
861 { 861 {
862 this.recordEnumeratedHistogram("DevTools.PanelShown", panelCode, 20); 862 this.recordEnumeratedHistogram("DevTools.PanelShown", panelCode, 20);
863 } 863 }
864 } 864 }
865 865
866 window.InspectorFrontendHost = new InspectorFrontendHostImpl(); 866 window.InspectorFrontendHost = new InspectorFrontendHostImpl();
867 867
868 // DevToolsApp --------------------------------------------------------------- 868 // DevToolsApp ---------------------------------------------------------------
869 869
870 function installObjectObserve()
871 {
872 var properties = [
873 "advancedSearchConfig", "auditsPanelSplitViewState", "auditsSidebarWidth ", "blockedURLs", "breakpoints", "cacheDisabled", "colorFormat", "consoleHistory ",
874 "consoleTimestampsEnabled", "cpuProfilerView", "cssSourceMapsEnabled", " currentDockState", "customColorPalette", "customDevicePresets", "customEmulatedD eviceList",
875 "customFormatters", "customUserAgent", "databaseTableViewVisibleColumns" , "dataGrid-cookiesTable", "dataGrid-DOMStorageItemsView", "debuggerSidebarHidde n", "disableDataSaverInfobar",
876 "disablePausedStateOverlay", "domBreakpoints", "domWordWrap", "elementsP anelSplitViewState", "elementsSidebarWidth", "emulation.deviceHeight", "emulatio n.deviceModeValue",
877 "emulation.deviceOrientationOverride", "emulation.deviceScale", "emulati on.deviceScaleFactor", "emulation.deviceUA", "emulation.deviceWidth", "emulation .geolocationOverride",
878 "emulation.showDeviceMode", "emulation.showRulers", "enableAsyncStackTra ces", "eventListenerBreakpoints", "fileMappingEntries", "fileSystemMapping", "Fi leSystemViewSidebarWidth",
879 "fileSystemViewSplitViewState", "filterBar-consoleView", "filterBar-netw orkPanel", "filterBar-promisePane", "filterBar-timelinePanel", "frameViewerHideC hromeWindow",
880 "heapSnapshotRetainersViewSize", "heapSnapshotSplitViewState", "hideColl ectedPromises", "hideNetworkMessages", "highlightNodeOnHoverInOverlay", "highRes olutionCpuProfiling",
881 "inlineVariableValues", "Inspector.drawerSplitView", "Inspector.drawerSp litViewState", "InspectorView.panelOrder", "InspectorView.screencastSplitView",
882 "InspectorView.screencastSplitViewState", "InspectorView.splitView", "In spectorView.splitViewState", "javaScriptDisabled", "jsSourceMapsEnabled", "lastA ctivePanel", "lastDockState",
883 "lastSelectedSourcesSidebarPaneTab", "lastSnippetEvaluationIndex", "laye rDetailsSplitView", "layerDetailsSplitViewState", "layersPanelSplitViewState", " layersShowInternalLayers",
884 "layersSidebarWidth", "messageLevelFilters", "messageURLFilters", "monit oringXHREnabled", "navigatorGroupByFolder", "navigatorHidden", "networkColorCode ResourceTypes",
885 "networkConditions", "networkConditionsCustomProfiles", "networkHideData URL", "networkLogColumnsVisibility", "networkLogLargeRows", "networkLogShowOverv iew",
886 "networkPanelSplitViewState", "networkRecordFilmStripSetting", "networkR esourceTypeFilters", "networkShowPrimaryLoadWaterfall", "networkSidebarWidth", " openLinkHandler",
887 "pauseOnCaughtException", "pauseOnExceptionEnabled", "preserveConsoleLog ", "prettyPrintInfobarDisabled", "previouslyViewedFiles", "profilesPanelSplitVie wState",
888 "profilesSidebarWidth", "promiseStatusFilters", "recordAllocationStacks" , "requestHeaderFilterSetting", "request-info-formData-category-expanded",
889 "request-info-general-category-expanded", "request-info-queryString-cate gory-expanded", "request-info-requestHeaders-category-expanded",
890 "request-info-requestPayload-category-expanded", "request-info-responseH eaders-category-expanded", "resources", "resourcesLastSelectedItem", "resourcesP anelSplitViewState",
891 "resourcesSidebarWidth", "resourceViewTab", "savedURLs", "screencastEnab led", "scriptsPanelNavigatorSidebarWidth", "searchInContentScripts", "selectedAu ditCategories",
892 "selectedColorPalette", "selectedProfileType", "shortcutPanelSwitch", "s howAdvancedHeapSnapshotProperties", "showEventListenersForAncestors", "showFrame owkrListeners",
893 "showHeaSnapshotObjectsHiddenProperties", "showInheritedComputedStylePro perties", "showMediaQueryInspector", "showNativeFunctionsInJSProfile", "showUASh adowDOM",
894 "showWhitespacesInEditor", "sidebarPosition", "skipContentScripts", "ski pStackFramesPattern", "sourceMapInfobarDisabled", "sourcesPanelDebuggerSidebarSp litViewState",
895 "sourcesPanelNavigatorSplitViewState", "sourcesPanelSplitSidebarRatio", "sourcesPanelSplitViewState", "sourcesSidebarWidth", "standardEmulatedDeviceList ",
896 "StylesPaneSplitRatio", "stylesPaneSplitViewState", "textEditorAutocompl etion", "textEditorAutoDetectIndent", "textEditorBracketMatching", "textEditorIn dent",
897 "timelineCaptureFilmStrip", "timelineCaptureLayersAndPictures", "timelin eCaptureMemory", "timelineCaptureNetwork", "timeline-details", "timelineEnableJS Sampling",
898 "timelineOverviewMode", "timelinePanelDetailsSplitViewState", "timelineP anelRecorsSplitViewState", "timelinePanelTimelineStackSplitViewState", "timeline Perspective",
899 "timeline-split", "timelineTreeGroupBy", "timeline-view", "timelineViewM ode", "uiTheme", "watchExpressions", "WebInspector.Drawer.lastSelectedView", "We bInspector.Drawer.showOnLoad",
900 "workspaceExcludedFolders", "workspaceFolderExcludePattern", "workspaceI nfobarDisabled", "workspaceMappingInfobarDisabled", "xhrBreakpoints"];
901
902 /**
903 * @this {!{_storage: Object, _name: string}}
904 */
905 function settingRemove()
906 {
907 this._storage[this._name] = undefined;
908 }
909
910 function objectObserve(object, observer)
911 {
912 if (window["WebInspector"]) {
913 var settingPrototype = window["WebInspector"]["Setting"]["prototype" ];
914 if (typeof settingPrototype["remove"] === "function")
915 settingPrototype["remove"] = settingRemove;
916 }
917
918 var changedProperties = new Set();
919 var scheduled = false;
920
921 function scheduleObserver()
922 {
923 if (!scheduled) {
924 scheduled = true;
925 setImmediate(callObserver);
926 }
927 }
928
929 function callObserver()
930 {
931 scheduled = false;
932 var changes = [];
933 changedProperties.forEach(function(name) { changes.push({name: name} ); });
934 changedProperties.clear();
935 observer.call(null, changes);
936 }
937
938 var storage = new Map();
939
940 function defineProperty(property)
941 {
942 if (property in object) {
943 storage.set(property, object[property]);
944 delete object[property];
945 }
946
947 Object.defineProperty(object, property, {
948 get: function()
949 {
950 return storage.get(property);
951 },
952
953 set: function(value)
954 {
955 storage.set(property, value);
956 changedProperties.add(property);
957 scheduleObserver();
958 }
959 });
960 }
961
962 for (var i = 0; i < properties.length; ++i)
963 defineProperty(properties[i]);
964 }
965
966 window.Object.observe = objectObserve;
967 }
968
870 /** 969 /**
871 * @suppressGlobalPropertiesCheck 970 * @suppressGlobalPropertiesCheck
872 */ 971 */
873 function installBackwardsCompatibility() 972 function installBackwardsCompatibility()
874 { 973 {
875 if (window.location.search.indexOf("remoteFrontend") === -1) 974 if (window.location.search.indexOf("remoteFrontend") === -1)
876 return; 975 return;
877 976
977 // Support for legacy (<M50) frontends.
978 installObjectObserve();
979
878 /** 980 /**
879 * @this {CSSStyleDeclaration} 981 * @this {CSSStyleDeclaration}
880 */ 982 */
881 function getValue(property) 983 function getValue(property)
882 { 984 {
883 // Note that |property| comes from another context, so we can't use === here. 985 // Note that |property| comes from another context, so we can't use === here.
884 if (property == "padding-left") { 986 if (property == "padding-left") {
885 return { 987 return {
886 /** 988 /**
887 * @suppressReceiverCheck 989 * @suppressReceiverCheck
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 1056
955 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { 1057 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) {
956 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype .toggle; 1058 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype .toggle;
957 DOMTokenList.prototype.toggle = function(token, force) 1059 DOMTokenList.prototype.toggle = function(token, force)
958 { 1060 {
959 if (arguments.length === 1) 1061 if (arguments.length === 1)
960 force = !this.contains(token); 1062 force = !this.contains(token);
961 return this.__originalDOMTokenListToggle(token, !!force); 1063 return this.__originalDOMTokenListToggle(token, !!force);
962 } 1064 }
963 } 1065 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/Settings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698