gecko-dev/devtools/shared
Michael Ratcliffe 639bed7bb2 Bug 1509620 - Computed style inspector CSS cascade calculation is wrong r=ladybenko
### Try

https://treeherder.mozilla.org/#/jobs?repo=try&revision=f1bad5e5282812225da95c0ea9e2ef173640b5da

### Summary

!!Comparing numerous complex websites such as github, facebook, cnn etc. the cascade now matchers that of Chrome so we are in a much better place.!!

According to https://www.w3.org/TR/css-cascade-3/#cascading (which platform follows now) and https://www.w3.org/TR/css-cascade-4/#cascading we should now be doing this (descending order):

  - Transition declarations
  - User-Agent & !important
  - User & !important
  - Author & !important
  - CSS Animations, @keyframes
  - Author, normal weight
  - User, normal weight
  - User-Agent, normal weight
  - specificity
  - Sheet Index
  - Rule Line
  - Rule Column

We are only dealing with CSS selectors here so we can safely drop Transition declarations and CSS Animations because their presence here is irrelevant when it comes to the CSS cascade information we display in the computed view.

This leaves us with:

  - User-Agent & !important
  - User & !important
  - Author & !important
  - Author, normal weight
  - User, normal weight
  - User-Agent, normal weight
  - specificity
  - Sheet Index
  - Rule Line
  - Rule Column

### Changes

- References to content stylesheets have been changed to author stylesheet to closely match the technical terms author, user and agent stylesheets.
- Simplified and modernized a bunch of for loops to make the code easier to understand.
- Previous to these changes all matching parent rules were classed as equal e.g. color on the body tag was equal to color on a node's immediate container. We now use the `distance` variable to tell how close a rule is to the current node. This is the highest qualifier in our cascade calculation.
- The `_agentSheet`, `_authorSheet` and `_userSheet` properties are now used to obtain a sheets origin.
- `elementStyle` was renamed to `inlineStyle` in order to correctly identify the rule's origin.
- We used to sort the matchedSelectors to move rules with `STATUS.MATCHED` above `STATUS.PARENT_MATCH` but this is unnecessary now that we have the `distance` property so we no longer do this.
- The `compareTo()` method has been updated to match https://www.w3.org/TR/css-cascade-3/#cascading (which platform follows now) and https://www.w3.org/TR/css-cascade-4/#cascading. It has also been simplified and made far less prone to error.

Differential Revision: https://phabricator.services.mozilla.com/D23711

--HG--
extra : moz-landing-system : lando
2019-03-25 16:32:19 +00:00
..
acorn Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
adb Bug 1528912 - Do not stop ADB when closing aboutdebugging or webide;r=daisuke 2019-03-25 08:05:18 +00:00
client Bug 1532567 - remove unused eval method from threadClient and threadActor; r=bhackett 2019-03-12 15:03:47 +00:00
css Bug 205202 part 1 - [css-lists][css-pseudo] Add support for the ::marker pseudo element on list items. Alias :-moz-list-bullet/number to that in the parser. r=emilio 2019-03-24 23:13:53 +01:00
discovery Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
fronts Bug 1531704 - Remove isClosed flag from WorkerTargetFront r=ochameau 2019-03-21 07:54:03 +00:00
heapsnapshot Bug 1523969 part 4 - Move method definition inline comments to new line in 'devtools/'. r=fitzgen 2019-02-25 16:04:29 -06:00
inspector Bug 1509620 - Computed style inspector CSS cascade calculation is wrong r=ladybenko 2019-03-25 16:32:19 +00:00
jsbeautify Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
layout Bug 1523335 - Make use of parentFlexElement in Flexbox inspector r=pbro 2019-02-06 17:35:20 +00:00
locales Bug 1536834 - Remove leftover csscoverage code; r=jdescottes 2019-03-20 16:06:59 +00:00
node-properties
performance Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
platform Bug 1493292 - Remove aDataLen parameters from nsITransferable.getTransferData. r=smaug 2018-11-20 16:59:56 +00:00
preferences Bug 1505172 - Remove references to devtools.debugger.forbid-certified-apps preference. r=jdescottes,jryans 2018-11-08 16:46:58 +00:00
protocol Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
qrcode Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
screenshot Bug 1498143 - Pass nodeActorID to screenshot actor to enable feature in iframes and shadowroots;r=pbro,yulia 2018-11-19 13:27:51 +00:00
security Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
specs Bug 1536834 - Remove leftover csscoverage code; r=jdescottes 2019-03-20 16:06:59 +00:00
sprintfjs
test-helpers Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
tests Bug 1114929: Add a test for multiline comment. r=pbro 2019-03-21 09:18:31 +00:00
transport Bug 1521052 - Add DebuggerServer.hasConnection to track if it still has active connections. r=jdescottes 2019-01-23 14:46:10 +00:00
webconsole Bug 1525319 - Removing context from OnDataAvailable r=valentin 2019-02-27 23:42:27 +00:00
worker Bug 1523262 Part 2 - Provide atob/btoa in worker debugger scope, r=lsmyth,baku. 2019-02-21 17:25:39 -10:00
.eslintrc.js
DevToolsUtils.js Bug 1517483 - Get rid of nsIScriptSecurityManager::IsSystemPrincipal r=bzbarsky 2019-03-24 20:36:25 +00:00
Loader.jsm Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
Parser.jsm Bug 1514594: Part 3 - Change ChromeUtils.import API. 2019-01-17 10:18:31 -08:00
ThreadSafeDevToolsUtils.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
async-storage.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
async-utils.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
base-loader.js Bug 1517210 - Stop always loading DevTools modules in fresh compartments. r=jandem,nchevobbe 2019-02-28 16:03:26 +00:00
builtin-modules.js Bug 1532237 - Use a Debugger loaded in a distinct compartment when debugging chrome in the event collector codebase. r=miker 2019-03-05 14:58:05 +00:00
content-observer.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
debounce.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
defer.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
deprecated-sync-thenables.js
dom-node-constants.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
dom-node-filter-constants.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
event-emitter.js Bug 1514197 - finish emitting events before clearing; r=jdescottes 2018-12-14 17:36:45 +00:00
extend.js
flags.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
generate-uuid.js
indentation.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
indexed-db.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
jar.mn
l10n.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
loader-plugin-raw.jsm Bug 1520868 - Replacing AsyncOpen2 with AsyncOpen always r=valentin 2019-02-12 16:08:25 +00:00
moz.build Bug 1495382 - Check isMultiE10s from runtime info;r=daisuke,ladybenko 2019-01-09 09:44:15 +00:00
multi-e10s-helper.js Bug 1522511 - [remote-dbg-next] Do not prevent service-worker debugging if new sw implementation is enabled r=ladybenko 2019-03-07 09:35:52 +00:00
path.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
plural-form.js Bug 1533688 - Sync DevTools plural-form.js with intl/PluralForm.jsm (add rule #19) r=jdescottes 2019-03-19 08:41:43 +00:00
protocol.js Bug 1465635 - Merge all target fronts with Target class. r=yulia,jdescottes 2019-02-02 11:24:32 +00:00
system.js Backed out 7 changesets (bug 1518632, bug 1463198, bug 1455707, bug 1522934, bug 1322797, bug 1474285) for build bustages at /builds/worker/workspace/build/src/toolkit/xre/nsAppRunner.cpp on a CLOSED TREE 2019-01-31 03:34:49 +02:00
task.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00
throttle.js Bug 1454696 - Run eslint --fix for prefer-const;r=yulia 2018-06-01 12:36:09 +02:00
wasm-source-map.js Bug 1486741 - Enable ESLint rule comma-dangle for all of mozilla-central (automatic fixes). r=mossop 2018-10-19 12:55:39 +00:00