Skip to content

Commit

Permalink
124.0b5
Browse files Browse the repository at this point in the history
  • Loading branch information
bot committed Feb 29, 2024
1 parent c14fec6 commit 5a54715
Show file tree
Hide file tree
Showing 27 changed files with 293 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const SEARCH_DEBOUNCE_TIMEOUT_MS = 1000;
*
* @property {string} placeholder
* The placeholder text for the search box.
* @property {string} query
* The query that is currently in the search box.
* @property {number} size
* The width (number of characters) of the search box.
* @property {string} pageName
Expand All @@ -34,7 +32,6 @@ const SEARCH_DEBOUNCE_TIMEOUT_MS = 1000;
export default class FxviewSearchTextbox extends MozLitElement {
static properties = {
placeholder: { type: String },
query: { type: String },
size: { type: Number },
pageName: { type: String },
};
Expand All @@ -44,9 +41,10 @@ export default class FxviewSearchTextbox extends MozLitElement {
input: "input",
};

#query = "";

constructor() {
super();
this.query = "";
this.searchTask = new lazy.DeferredTask(
() => this.#dispatchQueryEvent(),
SEARCH_DEBOUNCE_RATE_MS,
Expand All @@ -70,14 +68,18 @@ export default class FxviewSearchTextbox extends MozLitElement {
}

onInput(event) {
this.query = event.target.value.trim();
this.#query = event.target.value.trim();
event.preventDefault();
this.onSearch();
}

/**
* Handler for query updates from keyboard input, and textbox clears from 'X'
* button.
*/
onSearch() {
// Make the search and then immediately finalize
this.searchTask?.arm();
this.requestUpdate();
}

clear(event) {
Expand All @@ -86,7 +88,7 @@ export default class FxviewSearchTextbox extends MozLitElement {
(event.type == "keydown" && event.code == "Enter") ||
(event.type == "keydown" && event.code == "Space")
) {
this.query = "";
this.#query = "";
event.preventDefault();
this.onSearch();
}
Expand All @@ -98,7 +100,7 @@ export default class FxviewSearchTextbox extends MozLitElement {
new CustomEvent("fxview-search-textbox-query", {
bubbles: true,
composed: true,
detail: { query: this.query },
detail: { query: this.#query },
})
);

Expand All @@ -122,14 +124,14 @@ export default class FxviewSearchTextbox extends MozLitElement {
type="search"
.placeholder=${ifDefined(this.placeholder)}
.size=${ifDefined(this.size)}
.value=${this.query}
.value=${this.#query}
@input=${this.onInput}
></input>
<div
class="clear-icon"
role="button"
tabindex="0"
?hidden=${!this.query}
?hidden=${!this.#query}
@click=${this.clear}
@keydown=${this.clear}
data-l10n-id="firefoxview-search-text-box-clear-button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ class HistoryInView extends ViewPage {
isSearchEnabled(),
() => html` <div class="history-sort-option">
<fxview-search-textbox
.query=${this.searchQuery}
data-l10n-id="firefoxview-search-text-box-history"
data-l10n-attrs="placeholder"
.size=${this.searchTextboxSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ class RecentlyClosedTabsInView extends ViewPage {
isSearchEnabled(),
() => html`<div>
<fxview-search-textbox
.query=${this.searchQuery}
data-l10n-id="firefoxview-search-text-box-recentlyclosed"
data-l10n-attrs="placeholder"
@fxview-search-textbox-query=${this.onSearchQuery}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ $ds-card-image-gradient-solid: rgba(0, 0, 0, 100%);
}

.story-sponsored-label {
margin: var(--space-small) 0;
margin: var(--space-small) 0 0;
}

.source {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3613,7 +3613,7 @@ main section {
padding-top: 52.4%;
}
.ds-card.ds-card-cta-button.variant-a .story-sponsored-label, .ds-card.ds-card-cta-button.variant-b .story-sponsored-label {
margin: var(--space-small) 0;
margin: var(--space-small) 0 0;
}
.ds-card.ds-card-cta-button.variant-a .source, .ds-card.ds-card-cta-button.variant-b .source {
text-decoration: underline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3617,7 +3617,7 @@ main section {
padding-top: 52.4%;
}
.ds-card.ds-card-cta-button.variant-a .story-sponsored-label, .ds-card.ds-card-cta-button.variant-b .story-sponsored-label {
margin: var(--space-small) 0;
margin: var(--space-small) 0 0;
}
.ds-card.ds-card-cta-button.variant-a .source, .ds-card.ds-card-cta-button.variant-b .source {
text-decoration: underline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3613,7 +3613,7 @@ main section {
padding-top: 52.4%;
}
.ds-card.ds-card-cta-button.variant-a .story-sponsored-label, .ds-card.ds-card-cta-button.variant-b .story-sponsored-label {
margin: var(--space-small) 0;
margin: var(--space-small) 0 0;
}
.ds-card.ds-card-cta-button.variant-a .source, .ds-card.ds-card-cta-button.variant-b .source {
text-decoration: underline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,9 @@ function makeResultGroups({ showSearchSuggestionsFirst }) {
group: lazy.UrlbarUtils.RESULT_GROUP.FORM_HISTORY,
},
{
flex: 2,
flex: 99,
group: lazy.UrlbarUtils.RESULT_GROUP.RECENT_SEARCH,
},

{
flex: 4,
group: lazy.UrlbarUtils.RESULT_GROUP.REMOTE_SUGGESTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const RESULT_MENU_COMMAND = {
INACCURATE_LOCATION: "inaccurate_location",
NOT_INTERESTED: "not_interested",
NOT_RELEVANT: "not_relevant",
SHOW_LESS_FREQUENTLY: "show_less_frequentry",
SHOW_LESS_FREQUENTLY: "show_less_frequently",
};

/**
Expand All @@ -42,6 +42,19 @@ export class YelpSuggestions extends BaseFeature {
return ["Yelp"];
}

get showLessFrequentlyCount() {
const count = lazy.UrlbarPrefs.get("yelp.showLessFrequentlyCount") || 0;
return Math.max(count, 0);
}

get canShowLessFrequently() {
const cap =
lazy.UrlbarPrefs.get("yelpShowLessFrequentlyCap") ||
lazy.QuickSuggest.backend.config?.showLessFrequentlyCap ||
0;
return !cap || this.showLessFrequentlyCount < cap;
}

getSuggestionTelemetryType(suggestion) {
return "yelp";
}
Expand All @@ -57,9 +70,9 @@ export class YelpSuggestions extends BaseFeature {
// subject wasn't typed in full, then apply the min length threshold and
// return null if the entire search string is too short.
if (
(this.#showLessFrequentlyCount || !suggestion.subjectExactMatch) &&
(this.showLessFrequentlyCount || !suggestion.subjectExactMatch) &&
searchString.length <
this.#showLessFrequentlyCount + this.#minKeywordLength
this.showLessFrequentlyCount + this.#minKeywordLength
) {
return null;
}
Expand Down Expand Up @@ -87,14 +100,15 @@ export class YelpSuggestions extends BaseFeature {
lazy.UrlbarUtils.RESULT_SOURCE.SEARCH,
...lazy.UrlbarResult.payloadAndSimpleHighlights(queryContext.tokens, {
url: url.toString(),
originalUrl: suggestion.url,
title: [title, lazy.UrlbarUtils.HIGHLIGHT.TYPED],
shouldShowUrl: true,
bottomTextL10n: { id: "firefox-suggest-yelp-bottom-text" },
})
),
{
isRichSuggestion: true,
richSuggestionIconSize: suggestion.is_top_pick ? 38 : 24,
richSuggestionIconSize: suggestion.is_top_pick ? 38 : 16,
showFeedbackMenu: true,
}
);
Expand All @@ -110,7 +124,7 @@ export class YelpSuggestions extends BaseFeature {
},
];

if (this.#canShowLessFrequently) {
if (this.canShowLessFrequently) {
commands.push({
name: RESULT_MENU_COMMAND.SHOW_LESS_FREQUENTLY,
l10n: {
Expand Down Expand Up @@ -166,7 +180,7 @@ export class YelpSuggestions extends BaseFeature {
// selType == "dismiss" when the user presses the dismiss key shortcut.
case "dismiss":
case RESULT_MENU_COMMAND.NOT_RELEVANT:
lazy.QuickSuggest.blockedSuggestions.add(result.payload.url);
lazy.QuickSuggest.blockedSuggestions.add(result.payload.originalUrl);
result.acknowledgeDismissalL10n = {
id: "firefox-suggest-dismissal-acknowledgment-one-yelp",
};
Expand All @@ -181,19 +195,19 @@ export class YelpSuggestions extends BaseFeature {
break;
case RESULT_MENU_COMMAND.SHOW_LESS_FREQUENTLY:
view.acknowledgeFeedback(result);
this.#incrementShowLessFrequentlyCount();
if (!this.#canShowLessFrequently) {
this.incrementShowLessFrequentlyCount();
if (!this.canShowLessFrequently) {
view.invalidateResultMenuCommands();
}
break;
}
}

#incrementShowLessFrequentlyCount() {
if (this.#canShowLessFrequently) {
incrementShowLessFrequentlyCount() {
if (this.canShowLessFrequently) {
lazy.UrlbarPrefs.set(
"yelp.showLessFrequentlyCount",
this.#showLessFrequentlyCount + 1
this.showLessFrequentlyCount + 1
);
}
}
Expand All @@ -203,16 +217,6 @@ export class YelpSuggestions extends BaseFeature {
return Math.max(len, 0);
}

get #showLessFrequentlyCount() {
const count = lazy.UrlbarPrefs.get("yelp.showLessFrequentlyCount") || 0;
return Math.max(count, 0);
}

get #canShowLessFrequently() {
const cap = lazy.UrlbarPrefs.get("yelpShowLessFrequentlyCap") || 0;
return !cap || this.#showLessFrequentlyCount < cap;
}

async #fetchCity() {
if (!this.#merino) {
this.#merino = new lazy.MerinoClient(this.constructor.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ import {
// This is only used by jest tests (and within this module)
export const setSelectedLocation = (
location,
shouldSelectOriginalLocation
shouldSelectOriginalLocation,
shouldHighlightSelectedLocation
) => ({
type: "SET_SELECTED_LOCATION",
location,
shouldSelectOriginalLocation,
shouldHighlightSelectedLocation,
});

// This is only used by jest tests (and within this module)
Expand Down Expand Up @@ -117,8 +119,14 @@ export function selectSource(source, sourceActor) {
* If false, this will ignore the currently selected source
* and select the generated or original location, even if we
* were currently selecting the other source type.
* @param {boolean} options.highlight
* True by default. To be set to false in order to preveng highlighting the selected location in the editor.
* We will only show the location, but do not put a special background on the line.
*/
export function selectLocation(location, { keepContext = true } = {}) {
export function selectLocation(
location,
{ keepContext = true, highlight = true } = {}
) {
return async thunkArgs => {
const { dispatch, getState, client } = thunkArgs;

Expand Down Expand Up @@ -189,7 +197,9 @@ export function selectLocation(location, { keepContext = true } = {}) {
dispatch(addTab(source, sourceActor));
}

dispatch(setSelectedLocation(location, shouldSelectOriginalLocation));
dispatch(
setSelectedLocation(location, shouldSelectOriginalLocation, highlight)
);

await dispatch(loadSourceText(source, sourceActor));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getSelectedSourceTextContent,
getPauseCommand,
getCurrentThread,
getShouldHighlightSelectedLocation,
} from "../../selectors/index";

function isDebugLine(selectedFrame, selectedLocation) {
Expand Down Expand Up @@ -95,6 +96,7 @@ export class HighlightLine extends Component {
selectedLocation,
selectedFrame,
selectedSourceTextContent,
shouldHighlightSelectedLocation,
} = this.props;
if (pauseCommand) {
this.isStepping = true;
Expand All @@ -107,11 +109,13 @@ export class HighlightLine extends Component {
prevProps.selectedSourceTextContent
);
}
this.setHighlightLine(
selectedLocation,
selectedFrame,
selectedSourceTextContent
);
if (shouldHighlightSelectedLocation) {
this.setHighlightLine(
selectedLocation,
selectedFrame,
selectedSourceTextContent
);
}
endOperation();
}

Expand Down Expand Up @@ -182,6 +186,7 @@ export default connect(state => {
}
return {
pauseCommand: getPauseCommand(state, getCurrentThread(state)),
shouldHighlightSelectedLocation: getShouldHighlightSelectedLocation(state),
selectedFrame: getVisibleSelectedFrame(state),
selectedLocation,
selectedSourceTextContent: getSelectedSourceTextContent(state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ class Editor extends PureComponent {
// Reset the context, so that we don't switch to original
// while moving the cursor within a bundle
keepContext: false,

// Avoid highlighting the selected line
highlight: false,
}
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ export function initialSourcesState(state) {
*/
selectedOriginalLocation: UNDEFINED_LOCATION,

/**
* By default, the `selectedLocation` should be highlighted in the editor with a special background.
* On demand, this flag can be set to false in order to prevent this.
* The location will be shown, but not highlighted.
*/
shouldHighlightSelectedLocation: true,

/**
* By default, if we have a source-mapped source, we would automatically try
* to select and show the content of the original source. But, if we explicitly
Expand Down Expand Up @@ -149,6 +156,7 @@ function update(state = initialSourcesState(), action) {
selectedOriginalLocation: UNDEFINED_LOCATION,
pendingSelectedLocation,
shouldSelectOriginalLocation: action.shouldSelectOriginalLocation,
shouldHighlightSelectedLocation: action.shouldHighlightSelectedLocation,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export function getShouldSelectOriginalLocation(state) {
return state.sources.shouldSelectOriginalLocation;
}

export function getShouldHighlightSelectedLocation(state) {
return state.sources.shouldHighlightSelectedLocation;
}

/**
* Gets the first source actor for the source and/or thread
* provided.
Expand Down
Loading

0 comments on commit 5a54715

Please sign in to comment.