Skip to content

Instantly share code, notes, and snippets.

View captainbrosset's full-sized avatar
👋

Patrick Brosset captainbrosset

👋
View GitHub Profile
@captainbrosset
captainbrosset / order-segments.ts
Created March 5, 2021 09:13
Code snippets for the "How we built the DevTools Tooltips" article
// Our list of all segments. Each one being an object like
// {start: {x, y}, end: {x, y}}
const allSegments = [...];
// Start at the first segment.
const orderedSegments = [allSegments[0]];
while (true) {
// The previous segment.
const previous = orderedSegments[orderedSegments.length - 1];
@captainbrosset
captainbrosset / get-coordinates.ts
Created March 5, 2021 09:10
Code snippets for the "How we built the DevTools Tooltips" article
// Get the coordinates of the element.
const rect = element.getBoundingClientRect();
// Apply any offset that might be configured for it.
for (const {direction, size} of offsets) {
if (direction === Direction.Top) {
rect.y -= size;
rect.height += size;
}
if (direction === Direction.Right) {
rect.width += size;
@captainbrosset
captainbrosset / queryselector-shadow.ts
Created March 5, 2021 09:08
Code snippets for the "How we built the DevTools Tooltips" article
function querySelectorShadow(selector: string): Element|null {
let found: Element|null = null;
const search = (root: Element|ShadowRoot) => {
const iter = document.createTreeWalker(
root,
NodeFilter.SHOW_ELEMENT,
);
do {
const currentNode = iter.currentNode as HTMLElement;
@captainbrosset
captainbrosset / intersections.ts
Last active March 5, 2021 09:08
Code snippets for the "How we built the DevTools Tooltips" article
{
// The ID of the area we're highlighting
"elements-panel": {
// Some information for the displayed content
"tooltip": {
"title": "...",
"description": "...",
},
// The list of DOM elements to wrap
"selectors": [
const {writeFile} = require('fs');
const CDP = require('chrome-remote-interface');
const WIDTH = 892;
const HEIGHT = 689;
const URL = 'https://google.com';
let client;
async function getClient() {
if (!client) {
@captainbrosset
captainbrosset / data.txt
Created July 9, 2020 15:24
css grid website scraping
column-gap: 0.375rem
column-gap: 1rem
column-gap: 2rem
column-gap: 2vw
column-gap: 35px
column-gap: 5rem
column-gap:.625rem
column-gap:1.875rem
column-gap:10px
column-gap:10px
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Verify the content page can be zoomed in within RDM.
// We do not verify here that the fullZoom level applied to the page before RDM starts is
// carried over to the content page after RDM is open. This bug hasn't been fixed.
// See bug 1529166.
function findRulesMatching(el) {
const rules = [];
for (const { cssRules } of document.styleSheets) {
for (const rule of cssRules) {
if (el.matches(rule.selectorText)) {
rules.push(rule);
}
}
}
exporting patch:
# HG changeset patch
# User Patrick Brosset <pbrosset@mozilla.com>
# Date 1540390759 -7200
# Wed Oct 24 16:19:19 2018 +0200
# Node ID 28252579eb8db33d857061e4db42a15e04a87e45
# Parent 079c7a062b23950449e9ce1ef809ff43026cc259
WIP pref to disable anoncontent highlighters
diff --git a/devtools/client/preferences/devtools-client.js b/devtools/client/preferences/devtools-client.js
exporting patch:
# HG changeset patch
# User Patrick Brosset <pbrosset@mozilla.com>
# Date 1540391188 -7200
# Wed Oct 24 16:26:28 2018 +0200
# Node ID f65095a765a557f6f3c039bb7209dbce37657f68
# Parent 079c7a062b23950449e9ce1ef809ff43026cc259
WIP investigating why inspector 'fixes' layout
diff --git a/devtools/server/actors/inspector/walker.js b/devtools/server/actors/inspector/walker.js