mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-30 01:43:36 +08:00
A warning will be shown for inline elements that are known to never be non-replaced elements and that have width/height property set. Fixed: 1373597 Change-Id: Ie2c0d58b2a23758fd9255f1c5615060e4551ccc2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3952675 Auto-Submit: Alex Rudenko <alexrudenko@chromium.org> Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org> Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org>
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
// Copyright 2022 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
export const buildPropertyDefinitionText = (property: string, value?: string): string => {
|
|
if (value === undefined) {
|
|
return buildPropertyName(property);
|
|
}
|
|
return '<code class="unbreakable-text"><span class="property">' + property + '</span>: ' + value + '</code>';
|
|
};
|
|
|
|
export const buildPropertyName = (property: string): string => {
|
|
return '<code class="unbreakable-text"><span class="property">' + property + '</span></code>';
|
|
};
|
|
|
|
export const buildPropertyValue = (property: string): string => {
|
|
return '<code class="unbreakable-text">' + property + '</code>';
|
|
};
|
|
|
|
export const isFlexContainer = (computedStyles?: Map<string, string>): boolean => {
|
|
if (!computedStyles) {
|
|
return false;
|
|
}
|
|
const display = computedStyles.get('display');
|
|
return display === 'flex' || display === 'inline-flex';
|
|
};
|
|
|
|
export const isInlineElement = (computedStyles?: Map<string, string>): boolean => {
|
|
if (!computedStyles) {
|
|
return false;
|
|
}
|
|
return computedStyles.get('display') === 'inline';
|
|
};
|
|
|
|
// See https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements
|
|
const possiblyReplacedElements = new Set([
|
|
'audio',
|
|
'canvas',
|
|
'embed',
|
|
'iframe',
|
|
'img',
|
|
'input',
|
|
'object',
|
|
'video',
|
|
]);
|
|
|
|
export const isPossiblyReplacedElement = (nodeName?: string): boolean => {
|
|
if (!nodeName) {
|
|
return false;
|
|
}
|
|
return possiblyReplacedElements.has(nodeName);
|
|
};
|
|
|
|
export const isGridContainer = (computedStyles?: Map<string, string>): boolean => {
|
|
if (!computedStyles) {
|
|
return false;
|
|
}
|
|
const display = computedStyles.get('display');
|
|
return display === 'grid' || display === 'inline-grid';
|
|
};
|
|
|
|
export const isMulticolContainer = (computedStyles?: Map<string, string>): boolean => {
|
|
if (!computedStyles) {
|
|
return false;
|
|
}
|
|
const columnWidth = computedStyles.get('column-width');
|
|
const columnCount = computedStyles.get('column-count');
|
|
|
|
return columnWidth !== 'auto' || columnCount !== 'auto';
|
|
};
|