Bug 1761839 - Allow user-select: none to override modal dialog selectability. r=sefeng

Instead of enforcing it in C++ use a UA rule instead, so that authors
can override it if needed.

Depends on D142582

Differential Revision: https://phabricator.services.mozilla.com/D142583
This commit is contained in:
Emilio Cobos Álvarez 2022-03-31 19:49:53 +00:00
Родитель 84f5a800f6
Коммит bf2d51b0a5
3 изменённых файлов: 4 добавлений и 14 удалений

Просмотреть файл

@ -4651,12 +4651,6 @@ static bool IsEditingHost(const nsIFrame* aFrame) {
return element && element->IsEditableRoot();
}
static bool IsTopmostModalDialog(const nsIFrame* aFrame) {
auto* element = Element::FromNodeOrNull(aFrame->GetContent());
return element &&
element->State().HasState(NS_EVENT_STATE_TOPMOST_MODAL_DIALOG);
}
static StyleUserSelect UsedUserSelect(const nsIFrame* aFrame) {
if (aFrame->IsGeneratedContentFrame()) {
return StyleUserSelect::None;
@ -4681,14 +4675,10 @@ static StyleUserSelect UsedUserSelect(const nsIFrame* aFrame) {
return style;
}
if (aFrame->IsTextInputFrame() || IsEditingHost(aFrame) ||
IsTopmostModalDialog(aFrame)) {
if (aFrame->IsTextInputFrame() || IsEditingHost(aFrame)) {
// We don't implement 'contain' itself, but we make 'text' behave as
// 'contain' for contenteditable and <input> / <textarea> elements anyway so
// this is ok.
//
// Topmost modal dialogs need to behave like `text` too, because they're
// supposed to be selectable even if their ancestors are inert.
return StyleUserSelect::Text;
}

Просмотреть файл

@ -829,6 +829,9 @@ dialog:not([open]) {
* Avoid doing this if the dialog is explicitly inert though. */
dialog:not([inert]):-moz-topmost-modal-dialog {
-moz-inert: none;
/* Topmost modal dialog needs to be selectable even though ancestors are
* inert, but allow users to override this if they want to. */
user-select: text;
}
dialog:-moz-modal-dialog {

Просмотреть файл

@ -1,3 +0,0 @@
[modal-dialog-selection.html]
['user-select: none' prevents text from being selected]
expected: FAIL