Changeset 237574 in webkit


Ignore:
Timestamp:
Oct 29, 2018 5:10:53 PM (6 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Canvas: show warning when path moves offscreen
https://bugs.webkit.org/show_bug.cgi?id=191016

Reviewed by Joseph Pecoraro.

  • UserInterface/Models/RecordingAction.js:

(WI.RecordingAction):
(WI.RecordingAction.deriveCurrentState):
(WI.RecordingAction.prototype.get isVisual):
(WI.RecordingAction.prototype.get warning): Added.
(WI.RecordingAction.prototype.process.checkInvalidCurrentAxisPoint): Added.
(WI.RecordingAction.prototype.process):
(WI.RecordingAction.prototype.get hasVisibleEffect): Deleted.
Replace hasVisibleEffect with a more general warning value, so that it can be used for
more types of warnings.

  • UserInterface/Views/RecordingActionTreeElement.js:

(WI.RecordingActionTreeElement.prototype.onattach):

  • UserInterface/Views/RecordingActionTreeElement.css:

(.item.action.visual.warning:not(.invalid) > .status > .warning): Added.
(.item.action.visual.no-visible-effect:not(.invalid) > .status > .warning): Deleted.

  • Localizations/en.lproj/localizedStrings.js:
Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r237571 r237574  
     12018-10-29  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: show warning when path moves offscreen
     4        https://bugs.webkit.org/show_bug.cgi?id=191016
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Models/RecordingAction.js:
     9        (WI.RecordingAction):
     10        (WI.RecordingAction.deriveCurrentState):
     11        (WI.RecordingAction.prototype.get isVisual):
     12        (WI.RecordingAction.prototype.get warning): Added.
     13        (WI.RecordingAction.prototype.process.checkInvalidCurrentAxisPoint): Added.
     14        (WI.RecordingAction.prototype.process):
     15        (WI.RecordingAction.prototype.get hasVisibleEffect): Deleted.
     16        Replace `hasVisibleEffect` with a more general `warning` value, so that it can be used for
     17        more types of warnings.
     18
     19        * UserInterface/Views/RecordingActionTreeElement.js:
     20        (WI.RecordingActionTreeElement.prototype.onattach):
     21        * UserInterface/Views/RecordingActionTreeElement.css:
     22        (.item.action.visual.warning:not(.invalid) > .status > .warning): Added.
     23        (.item.action.visual.no-visible-effect:not(.invalid) > .status > .warning): Deleted.
     24
     25        * Localizations/en.lproj/localizedStrings.js:
     26
    1272018-10-29  Devin Rousso  <drousso@apple.com>
    228
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r237431 r237574  
    852852localizedStrings["The “%s”\ntable is empty."] = "The “%s”\ntable is empty.";
    853853localizedStrings["This action causes no visual change"] = "This action causes no visual change";
     854localizedStrings["This action moves the path outside the visible area"] = "This action moves the path outside the visible area";
    854855localizedStrings["This object is a root"] = "This object is a root";
    855856localizedStrings["This object is referenced by internal objects"] = "This object is referenced by internal objects";
  • trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js

    r237198 r237574  
    4545        this._isGetter = false;
    4646        this._isVisual = false;
    47         this._hasVisibleEffect = undefined;
    4847
    4948        this._states = [];
    5049        this._stateModifiers = new Set;
    5150
     51        this._warning = null;
    5252        this._swizzled = false;
    5353        this._processed = false;
     
    136136            let matrix = context.getTransform();
    137137
    138             let state = {
    139                 currentX: context.currentX,
    140                 currentY: context.currentY,
    141                 direction: context.direction,
    142                 fillStyle: context.fillStyle,
    143                 font: context.font,
    144                 globalAlpha: context.globalAlpha,
    145                 globalCompositeOperation: context.globalCompositeOperation,
    146                 imageSmoothingEnabled: context.imageSmoothingEnabled,
    147                 imageSmoothingQuality: context.imageSmoothingQuality,
    148                 lineCap: context.lineCap,
    149                 lineDash: context.getLineDash(),
    150                 lineDashOffset: context.lineDashOffset,
    151                 lineJoin: context.lineJoin,
    152                 lineWidth: context.lineWidth,
    153                 miterLimit: context.miterLimit,
    154                 shadowBlur: context.shadowBlur,
    155                 shadowColor: context.shadowColor,
    156                 shadowOffsetX: context.shadowOffsetX,
    157                 shadowOffsetY: context.shadowOffsetY,
    158                 strokeStyle: context.strokeStyle,
    159                 textAlign: context.textAlign,
    160                 textBaseline: context.textBaseline,
    161                 transform: [matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f],
    162                 webkitImageSmoothingEnabled: context.webkitImageSmoothingEnabled,
    163                 webkitLineDash: context.webkitLineDash,
    164                 webkitLineDashOffset: context.webkitLineDashOffset,
    165             };
     138            let state = {};
     139
     140            if (WI.ImageUtilities.supportsCanvasPathDebugging()) {
     141                state.currentX = context.currentX;
     142                state.currentY = context.currentY;
     143            }
     144
     145            state.direction = context.direction;
     146            state.fillStyle = context.fillStyle;
     147            state.font = context.font;
     148            state.globalAlpha = context.globalAlpha;
     149            state.globalCompositeOperation = context.globalCompositeOperation;
     150            state.imageSmoothingEnabled = context.imageSmoothingEnabled;
     151            state.imageSmoothingQuality = context.imageSmoothingQuality;
     152            state.lineCap = context.lineCap;
     153            state.lineDash = context.getLineDash();
     154            state.lineDashOffset = context.lineDashOffset;
     155            state.lineJoin = context.lineJoin;
     156            state.lineWidth = context.lineWidth;
     157            state.miterLimit = context.miterLimit;
     158            state.shadowBlur = context.shadowBlur;
     159            state.shadowColor = context.shadowColor;
     160            state.shadowOffsetX = context.shadowOffsetX;
     161            state.shadowOffsetY = context.shadowOffsetY;
     162            state.strokeStyle = context.strokeStyle;
     163            state.textAlign = context.textAlign;
     164            state.textBaseline = context.textBaseline;
     165            state.transform = [matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f];
     166            state.webkitImageSmoothingEnabled = context.webkitImageSmoothingEnabled;
     167            state.webkitLineDash = context.webkitLineDash;
     168            state.webkitLineDashOffset = context.webkitLineDashOffset;
    166169
    167170            if (WI.ImageUtilities.supportsCanvasPathDebugging())
     
    196199    get isGetter() { return this._isGetter; }
    197200    get isVisual() { return this._isVisual; }
    198     get hasVisibleEffect() { return this._hasVisibleEffect; }
    199201    get states() { return this._states; }
    200202    get stateModifiers() { return this._stateModifiers; }
     203    get warning() { return this._warning; }
    201204
    202205    get ready()
     
    216219            if (this._valid && this._isVisual) {
    217220                let contentBefore = recording.visualActionIndexes.length ? recording.actions[recording.visualActionIndexes.lastValue].snapshot : recording.initialState.content;
    218                 this._hasVisibleEffect = this._snapshot !== contentBefore;
     221                if (this._snapshot === contentBefore)
     222                    this._warning = WI.UIString("This action causes no visual change");
    219223            }
    220224            return;
     
    245249        this.apply(context);
    246250
    247         if (shouldCheckHasVisualEffect)
    248             this._hasVisibleEffect = !Array.shallowEqual(contentBefore, getContent());
     251        if (shouldCheckHasVisualEffect) {
     252            let contentAfter = getContent();
     253            if (Array.shallowEqual(contentBefore, contentAfter))
     254                this._warning = WI.UIString("This action causes no visual change");
     255        }
    249256
    250257        if (recording.type === WI.Recording.Type.Canvas2D) {
     
    260267            this._states.push(currentState);
    261268
     269            let lastState = null;
    262270            if (lastAction) {
    263                 let lastState = lastAction.states.lastValue;
     271                lastState = lastAction.states.lastValue;
    264272                for (let key in currentState) {
    265273                    if (!(key in lastState) || (currentState[key] !== lastState[key] && !Object.shallowEqual(currentState[key], lastState[key])))
    266274                        this._stateModifiers.add(key);
    267275                }
     276            }
     277
     278            if (WI.ImageUtilities.supportsCanvasPathDebugging()) {
     279                let currentX = currentState.currentX;
     280                let invalidX = (currentX < 0 || currentX >= context.canvas.width) && (!lastState || currentX !== lastState.currentX);
     281
     282                let currentY = currentState.currentY;
     283                let invalidY = (currentY < 0 || currentY >= context.canvas.height) && (!lastState || currentY !== lastState.currentY);
     284
     285                if (invalidX || invalidY)
     286                    this._warning = WI.UIString("This action moves the path outside the visible area");
    268287            }
    269288        }
  • trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.css

    r237050 r237574  
    221221}
    222222
    223 .item.action.visual.no-visible-effect:not(.invalid) > .status > .warning {
     223.item.action.warning:not(.invalid) > .status > .warning {
    224224    width: 12px;
    225225    height: 12px;
  • trunk/Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js

    r236715 r237574  
    408408        this.element.dataset.index = this._index.toLocaleString();
    409409
    410         if (this.representedObject.valid && this.representedObject.isVisual && !this.representedObject.hasVisibleEffect) {
    411             this.addClassName("no-visible-effect");
    412 
    413             const title = WI.UIString("This action causes no visual change");
    414             this.status = WI.ImageUtilities.useSVGSymbol("Images/Warning.svg", "warning", title);
     410        if (this.representedObject.valid && this.representedObject.warning) {
     411            this.addClassName("warning");
     412            this.status = WI.ImageUtilities.useSVGSymbol("Images/Warning.svg", "warning", this.representedObject.warning);
    415413        }
    416414    }
Note: See TracChangeset for help on using the changeset viewer.