Bug 1479760 - Use the ::selection colors to paint inactive as well as active selections. r=emilio

This will enable the devtools font highlighting issue in bug 1479760 to be fixed
using ::selection, and matches webkit/blink behavior.

When we implement ::inactive-selection (bug 1475773) it will supersede this.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2019-04-04 09:17:25 +00:00
Родитель ac318ef92e
Коммит 224d07137d
5 изменённых файлов: 31 добавлений и 24 удалений

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

@ -2219,10 +2219,11 @@ Color nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(
Color nsDisplaySelectionOverlay::ComputeColor() const {
LookAndFeel::ColorID colorID;
if (RefPtr<ComputedStyle> style =
mFrame->ComputeSelectionStyle(mSelectionValue)) {
return ComputeColorFromSelectionStyle(*style);
}
if (mSelectionValue == nsISelectionController::SELECTION_ON) {
if (RefPtr<ComputedStyle> style = mFrame->ComputeSelectionStyle()) {
return ComputeColorFromSelectionStyle(*style);
}
colorID = LookAndFeel::eColorID_TextSelectBackground;
} else if (mSelectionValue == nsISelectionController::SELECTION_ATTENTION) {
colorID = LookAndFeel::eColorID_TextSelectBackgroundAttention;
@ -2274,7 +2275,13 @@ static Element* FindElementAncestorForMozSelection(nsIContent* aContent) {
return aContent ? aContent->AsElement() : nullptr;
}
already_AddRefed<ComputedStyle> nsIFrame::ComputeSelectionStyle() const {
already_AddRefed<ComputedStyle> nsIFrame::ComputeSelectionStyle(
int16_t aSelectionStatus) const {
// Just bail out if not a selection-status that ::selection applies to.
if (aSelectionStatus != nsISelectionController::SELECTION_ON &&
aSelectionStatus != nsISelectionController::SELECTION_DISABLED) {
return nullptr;
}
Element* element = FindElementAncestorForMozSelection(GetContent());
if (!element) {
return nullptr;

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

@ -850,7 +850,8 @@ class nsIFrame : public nsQueryFrame {
virtual void SetAdditionalComputedStyle(int32_t aIndex,
ComputedStyle* aComputedStyle) = 0;
already_AddRefed<ComputedStyle> ComputeSelectionStyle() const;
already_AddRefed<ComputedStyle> ComputeSelectionStyle(
int16_t aSelectionStatus) const;
/**
* Accessor functions for geometric parent.

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

@ -4064,17 +4064,16 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() {
mInitSelectionColorsAndShadow = true;
if (selectionStatus == nsISelectionController::SELECTION_ON) {
// Use ::selection pseudo class.
if (RefPtr<ComputedStyle> style = mFrame->ComputeSelectionStyle()) {
mSelectionBGColor =
style->GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor);
mSelectionTextColor =
style->GetVisitedDependentColor(&nsStyleText::mWebkitTextFillColor);
mHasSelectionShadow = true;
mSelectionShadow = style->StyleText()->mTextShadow;
return true;
}
// Use ::selection pseudo class if applicable.
if (RefPtr<ComputedStyle> style =
mFrame->ComputeSelectionStyle(selectionStatus)) {
mSelectionBGColor =
style->GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor);
mSelectionTextColor =
style->GetVisitedDependentColor(&nsStyleText::mWebkitTextFillColor);
mHasSelectionShadow = true;
mSelectionShadow = style->StyleText()->mTextShadow;
return true;
}
nscolor selectionBGColor =

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

@ -48,7 +48,7 @@ fuzzy-if(OSX==1010,0-9,0-1) fuzzy-if(OSX&&skiaContent&&!webrender,0-6,0-1) fuzzy
== invalidation-2d.html invalidation-2-ref.html
== invalidation-2e.html invalidation-2-ref.html
== invalidation-2f.html invalidation-2-ref.html
fuzzy(0-7,0-2) fuzzy-if(OSX,0-1,0-1) fails-if(isDebugBuild&&!browserIsRemote) fails-if(Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) needs-focus == rtl-selection-with-decoration.html rtl-selection-with-decoration-ref.html # Bug 1392106
fails-if(isDebugBuild&&!browserIsRemote) fails-if(Android) needs-focus == semitransparent-decoration-line.html semitransparent-decoration-line-ref.html
fuzzy-if(OSX,0-1,0-6) fails-if(isDebugBuild&&!browserIsRemote) fails-if(Android) needs-focus == writing-mode.html writing-mode-ref.html
fuzzy(0-7,0-2) needs-focus == rtl-selection-with-decoration.html rtl-selection-with-decoration-ref.html
needs-focus == semitransparent-decoration-line.html semitransparent-decoration-line-ref.html
fuzzy-if(OSX,0-1,0-6) fuzzy-if(Android,0-188,0-39) needs-focus == writing-mode.html writing-mode-ref.html
needs-focus == 1478604.html 1478604-ref.html

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

@ -196,10 +196,10 @@ needs-focus == deselectAll.svg deselectAll-ref.svg
fuzzy-if(skiaContent,0-1,0-250) needs-focus == selectSubString.svg selectSubString-ref.svg
fuzzy-if(skiaContent,0-1,0-600) needs-focus == selectSubString-2.svg selectSubString-2-ref.svg
fuzzy-if(skiaContent,0-1,0-250) needs-focus == selectSubString-3.svg selectSubString-3-ref.svg
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy-if(webrender,1-1,237-237) needs-focus fuzzy-if(webrender&&!gtkWidget,127-148,221-254) == simple-selection.svg simple-selection-ref.html # Bug 1392106
fuzzy-if(skiaContent,0-1,0-100) fuzzy-if(webrender,1-1,575-575) needs-focus fuzzy-if(webrender&&!gtkWidget,134-148,261-318) == simple-bidi-selection.svg simple-bidi-selection-ref.html
fuzzy-if(skiaContent,0-1,0-50) fuzzy-if(webrender,1-1,237-237) needs-focus fuzzy-if(webrender&&!gtkWidget,127-148,221-254) == simple-fill-color-selection.svg simple-fill-color-selection-ref.html
fuzzy-if(skiaContent,0-1,0-150) fuzzy-if(webrender,1-1,222-222) needs-focus fuzzy-if(webrender&&!gtkWidget,127-148,221-254) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == simple-underline-selection.svg simple-underline-selection-ref.html # Bug 1392106
fuzzy-if(skiaContent,0-1,0-300) fuzzy-if(webrender,1-1,934-934) needs-focus fuzzy-if(webrender&&!gtkWidget,134-152,432-501) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == multiple-text-selection.svg multiple-text-selection-ref.html # Bug 1392106
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fuzzy-if(webrender,1-1,237-237) needs-focus fuzzy-if(webrender&&!gtkWidget,127-148,221-254) fails-if(Android) == simple-selection.svg simple-selection-ref.html # Bug 1392106 # Bug 1541500
fuzzy-if(skiaContent,0-1,0-100) fuzzy-if(webrender,1-1,575-575) needs-focus fuzzy-if(webrender&&!gtkWidget,134-148,261-318) fails-if(Android) == simple-bidi-selection.svg simple-bidi-selection-ref.html # Bug 1541500
fuzzy-if(skiaContent,0-1,0-50) fuzzy-if(webrender,1-1,237-237) needs-focus fuzzy-if(webrender&&!gtkWidget,127-148,221-254) fails-if(Android) == simple-fill-color-selection.svg simple-fill-color-selection-ref.html # Bug 1541500
fuzzy-if(skiaContent,0-1,0-150) fuzzy-if(webrender,1-1,222-222) needs-focus fuzzy-if(webrender&&!gtkWidget,127-148,221-254) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(Android) == simple-underline-selection.svg simple-underline-selection-ref.html # Bug 1392106 # Bug 1541500
fuzzy-if(skiaContent,0-1,0-300) fuzzy-if(webrender,1-1,934-934) needs-focus fuzzy-if(webrender&&!gtkWidget,134-152,432-501) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(Android) == multiple-text-selection.svg multiple-text-selection-ref.html # Bug 1392106 # Bug 1541500
needs-focus == multiple-chunks-selection.svg multiple-chunks-selection-ref.svg
fuzzy-if(skiaContent,0-1,0-200) needs-focus == textpath-selection.svg textpath-selection-ref.svg