Skip to content

Commit

Permalink
Merge branch 'main' into chore/add-address-ui-js-file
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 2, 2024
2 parents b688632 + eda4a1f commit 17c5365
Show file tree
Hide file tree
Showing 29 changed files with 164 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ open class LinkButton: UIButton, ThemeApplicable {
updatedConfiguration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
var outgoing = incoming
outgoing.font = viewModel.font
outgoing.underlineStyle = .single
return outgoing
}
updatedConfiguration.contentInsets = viewModel.contentInsets
Expand Down
2 changes: 1 addition & 1 deletion firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21593,7 +21593,7 @@
repositoryURL = "https://github.com/mozilla/rust-components-swift.git";
requirement = {
kind = exactVersion;
version = 127.0.20240427050414;
version = 127.0.20240430050317;
};
};
435C85EE2788F4D00072B526 /* XCRemoteSwiftPackageReference "glean-swift" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mozilla/rust-components-swift.git",
"state" : {
"revision" : "67ea48dede8487276ccd6531f9da29ca793c11cc",
"version" : "127.0.20240427050414"
"revision" : "fb6671d24023c79a1dc2afd3aac7c850167c5c63",
"version" : "127.0.20240430050317"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ export class FormAutofillSection {
profile[`${fieldDetail.fieldName}-formatted`] ||
profile[fieldDetail.fieldName] ||
"";

if (HTMLSelectElement.isInstance(element)) {
// Unlike text input, select element is always previewed even if
// the option is already selected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,11 @@ extension BrowserViewController: ToolBarActionMenuDelegate {
textAlignment: .left)
let toast = ButtonToast(viewModel: viewModel,
theme: currentTheme()) { [weak self] isButtonTapped in
guard let self, let closedTab = tabManager.backupCloseTab else { return }
isButtonTapped ? self.tabManager.undoCloseTab(tab: closedTab.tab, position: closedTab.restorePosition) : nil
guard let self,
tabManager.backupCloseTab != nil,
isButtonTapped
else { return }
self.tabManager.undoCloseTab()
}
show(toast: toast)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,6 @@ extension BrowserViewController: WKNavigationDelegate {
tab.contentBlocker?.notifyContentBlockingChanged()
self.scrollController.resetZoomState()

scrollController.shouldScrollToTop = true

if tabManager.selectedTab === tab {
updateUIForReaderHomeStateForTab(tab, focusUrlBar: true)
updateFakespot(tab: tab, isReload: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct BrowserViewControllerState: ScreenState, Equatable {
return BrowserViewControllerState(
searchScreenState: state.searchScreenState,
showDataClearanceFlow: state.showDataClearanceFlow,
fakespotState: FakespotState.reducer(state.fakespotState, action),
fakespotState: state.fakespotState,
showOverlay: state.showOverlay,
windowUUID: state.windowUUID,
reloadWebView: false,
Expand Down Expand Up @@ -111,7 +111,7 @@ struct BrowserViewControllerState: ScreenState, Equatable {
return BrowserViewControllerState(
searchScreenState: SearchScreenState(inPrivateMode: privacyState),
showDataClearanceFlow: privacyState,
fakespotState: FakespotState.reducer(state.fakespotState, action),
fakespotState: state.fakespotState,
windowUUID: state.windowUUID,
reloadWebView: true,
browserViewType: browserViewType)
Expand All @@ -128,7 +128,7 @@ struct BrowserViewControllerState: ScreenState, Equatable {
return BrowserViewControllerState(
searchScreenState: state.searchScreenState,
showDataClearanceFlow: state.showDataClearanceFlow,
fakespotState: FakespotState.reducer(state.fakespotState, action),
fakespotState: state.fakespotState,
toast: toastType,
windowUUID: state.windowUUID,
browserViewType: state.browserViewType)
Expand All @@ -137,7 +137,7 @@ struct BrowserViewControllerState: ScreenState, Equatable {
return BrowserViewControllerState(
searchScreenState: state.searchScreenState,
showDataClearanceFlow: state.showDataClearanceFlow,
fakespotState: FakespotState.reducer(state.fakespotState, action),
fakespotState: state.fakespotState,
showOverlay: showOverlay,
windowUUID: state.windowUUID,
browserViewType: state.browserViewType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class BrowserViewController: UIViewController,

private func dismissModalsIfStartAtHome() {
guard tabManager.startAtHomeCheck() else { return }
let action = FakespotAction(isExpanded: false,
let action = FakespotAction(isOpen: false,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(action)
Expand Down Expand Up @@ -1807,6 +1807,11 @@ class BrowserViewController: UIViewController,

self.screenshotHelper.takeScreenshot(tab)

// when navigate in tab, if the tab mime type is pdf, we should scroll to top
if tab.mimeType == MIMEType.PDF {
tab.shouldScrollToTop = true
}

if let url = webView.url {
if (!InternalURL.isValid(url: url) || url.isReaderModeURL) && !url.isFileURL {
postLocationChangeNotificationForTab(tab, navigation: navigation)
Expand Down Expand Up @@ -1854,7 +1859,7 @@ class BrowserViewController: UIViewController,
let url = webView.url
else {
// We're on homepage or a blank tab
let action = FakespotAction(isExpanded: false,
let action = FakespotAction(isOpen: false,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(action)
Expand All @@ -1870,7 +1875,7 @@ class BrowserViewController: UIViewController,
let product = ShoppingProduct(url: url, client: FakespotClient(environment: environment))

guard product.product != nil, !tab.isPrivate else {
let action = FakespotAction(isExpanded: false,
let action = FakespotAction(isOpen: false,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(action)
Expand Down Expand Up @@ -1905,7 +1910,7 @@ class BrowserViewController: UIViewController,
fakespotState.sidebarOpenForiPadLandscape,
UIDevice.current.userInterfaceIdiom == .pad {
// Sidebar should be displayed, display Fakespot
let action = FakespotAction(isExpanded: true,
let action = FakespotAction(isOpen: true,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(action)
Expand Down
9 changes: 6 additions & 3 deletions firefox-ios/Client/Frontend/Browser/TabDisplayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class LegacyTabDisplayManager: NSObject, FeatureFlaggable {
}

func undoCloseTab(tab: Tab, index: Int?) {
tabManager.undoCloseTab(tab: tab, position: index)
tabManager.undoCloseTab()
_ = profile.recentlyClosedTabs.popFirstTab()

refreshStore { [weak self] in
Expand Down Expand Up @@ -549,7 +549,10 @@ extension LegacyTabDisplayManager: UICollectionViewDataSource {
// MARK: - InactiveTabsDelegate
extension LegacyTabDisplayManager: LegacyInactiveTabsDelegate {
func closeInactiveTab(_ tab: Tab, index: Int) {
tabManager.backupCloseTab = BackupCloseTab(tab: tab, restorePosition: index)
tabManager.backupCloseTab = BackupCloseTab(
tab: tab,
restorePosition: index,
isSelected: false)
removeSingleInactiveTab(tab)

cfrDelegate?.presentUndoSingleToast { [weak self] undoButtonPressed in
Expand Down Expand Up @@ -622,7 +625,7 @@ extension LegacyTabDisplayManager: LegacyInactiveTabsDelegate {
}

private func undoDeleteInactiveTab(_ tab: Tab, at index: Int) {
tabManager.undoCloseTab(tab: tab, position: index)
tabManager.undoCloseTab()
inactiveViewModel?.inactiveTabs.insert(tab, at: index)

if inactiveViewModel?.inactiveTabs.count == 1 {
Expand Down
12 changes: 4 additions & 8 deletions firefox-ios/Client/Frontend/Browser/TabScrollController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ class TabScrollingController: NSObject, FeatureFlaggable, SearchBarLocationProvi
return isBottomSearchBar ? bottomShowing : headerTopOffset == 0
}

private var shouldSetInitialScrollToTop: Bool {
return tab?.mimeType == MIMEType.PDF && shouldScrollToTop
}

var shouldScrollToTop = false

private var isZoomedOut = false
private var lastZoomedScale: CGFloat = 0
private var isUserZoom = false
Expand Down Expand Up @@ -160,6 +154,8 @@ class TabScrollingController: NSObject, FeatureFlaggable, SearchBarLocationProvi

guard !tabIsLoading() else { return }

tab?.shouldScrollToTop = false

if let containerView = scrollView?.superview {
let translation = gesture.translation(in: containerView)
let delta = lastContentOffset - translation.y
Expand Down Expand Up @@ -458,7 +454,7 @@ extension TabScrollingController: UIScrollViewDelegate {
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
guard !tabIsLoading(), !isBouncingAtBottom(), isAbleToScroll else { return }

shouldScrollToTop = false
tab?.shouldScrollToTop = false

if decelerate || (toolbarState == .animating && !decelerate) {
if scrollDirection == .up {
Expand All @@ -473,7 +469,7 @@ extension TabScrollingController: UIScrollViewDelegate {
// before the WKWebView's contentOffset is reset as a result of the contentView's frame becoming smaller
func scrollViewDidScroll(_ scrollView: UIScrollView) {
// for PDFs, we should set the initial offset to 0 (ZERO)
if shouldSetInitialScrollToTop {
if let tab, tab.shouldScrollToTop {
setOffset(y: 0, for: scrollView)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,10 @@ class LegacyGridTabViewController: UIViewController,

/// Handles close tab by clicking on close button or swipe gesture
func closeTabAction(tab: Tab, cell: LegacyTabCell) {
tabManager.backupCloseTab = BackupCloseTab(tab: tab,
restorePosition: tabManager.tabs.firstIndex(of: tab))
tabManager.backupCloseTab = BackupCloseTab(
tab: tab,
restorePosition: tabManager.tabs.firstIndex(of: tab),
isSelected: tabManager.selectedTab?.tabUUID == tab.tabUUID)
tabDisplayManager.tabDisplayCompletionDelegate = self
tabDisplayManager.performCloseAction(for: tab)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class TabManagerMiddleware {
let tabManagerTabs = isPrivateMode ? tabManager.privateTabs : tabManager.normalActiveTabs
tabManagerTabs.forEach { tab in
let tabModel = TabModel(tabUUID: tab.tabUUID,
isSelected: tab == selectedTab,
isSelected: tab.tabUUID == selectedTab?.tabUUID,
isPrivate: tab.isPrivate,
isFxHomeTab: tab.isFxHomeTab,
tabTitle: tab.displayTitle,
Expand Down Expand Up @@ -358,10 +358,10 @@ class TabManagerMiddleware {
private func undoCloseTab(state: AppState, uuid: WindowUUID) {
let tabManager = tabManager(for: uuid)
guard let tabsState = state.screenState(TabsPanelState.self, for: .tabsPanel, window: uuid),
let backupTab = tabManager.backupCloseTab
tabManager.backupCloseTab != nil
else { return }

tabManager.undoCloseTab(tab: backupTab.tab, position: backupTab.restorePosition)
tabManager.undoCloseTab()

let model = getTabsDisplayModel(for: tabsState.isPrivateMode, shouldScrollToTab: false, uuid: uuid)
let action = TabPanelMiddlewareAction(tabDisplayModel: model,
Expand Down Expand Up @@ -456,7 +456,10 @@ class TabManagerMiddleware {
Task {
if let tabToClose = tabManager.getTabForUUID(uuid: tabUUID) {
let index = tabsState.inactiveTabs.firstIndex { $0.tabUUID == tabUUID }
tabManager.backupCloseTab = BackupCloseTab(tab: tabToClose, restorePosition: index)
tabManager.backupCloseTab = BackupCloseTab(
tab: tabToClose,
restorePosition: index,
isSelected: false)
}
await tabManager.removeTab(tabUUID)

Expand All @@ -475,9 +478,9 @@ class TabManagerMiddleware {

private func undoCloseInactiveTab(uuid: WindowUUID) {
let windowTabManager = self.tabManager(for: uuid)
guard let backupTab = windowTabManager.backupCloseTab else { return }
guard windowTabManager.backupCloseTab != nil else { return }

windowTabManager.undoCloseTab(tab: backupTab.tab, position: backupTab.restorePosition)
windowTabManager.undoCloseTab()
let inactiveTabs = self.refreshInactiveTabs(uuid: uuid)
let refreshAction = TabPanelMiddlewareAction(inactiveTabModels: inactiveTabs,
windowUUID: uuid,
Expand Down
5 changes: 4 additions & 1 deletion firefox-ios/Client/Frontend/Fakespot/FakespotAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import Common
import Redux

class FakespotAction: Action {
let isOpen: Bool?
let isExpanded: Bool?
let tabUUID: TabUUID?
let productId: String?

init(isExpanded: Bool? = nil,
init(isOpen: Bool? = nil,
isExpanded: Bool? = nil,
tabUUID: TabUUID? = nil,
productId: String? = nil,
windowUUID: UUID,
actionType: ActionType) {
self.isOpen = isOpen
self.isExpanded = isExpanded
self.tabUUID = tabUUID
self.productId = productId
Expand Down
8 changes: 3 additions & 5 deletions firefox-ios/Client/Frontend/Fakespot/FakespotState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ struct FakespotState: ScreenState, Equatable {
return state

case FakespotActionType.reviewQualityDidChange:
let isExpanded = action.isExpanded ?? state.isSettingsExpanded
let isExpanded = action.isExpanded ?? state.isReviewQualityExpanded
var state = state
state.expandState[state.currentTabUUID, default: ExpandState()].isReviewQualityExpanded = isExpanded
return state

case FakespotActionType.highlightsDidChange:
let isExpanded = action.isExpanded ?? state.isSettingsExpanded
let isExpanded = action.isExpanded ?? state.isHighlightsSectionExpanded
var state = state
state.expandState[state.currentTabUUID, default: ExpandState()].isHighlightsSectionExpanded = isExpanded
return state
Expand Down Expand Up @@ -138,16 +138,14 @@ struct FakespotState: ScreenState, Equatable {
return state

case FakespotActionType.setAppearanceTo:
let isEnabled = action.isExpanded ?? state.isSettingsExpanded
let isEnabled = action.isOpen ?? state.isOpen
var state = state
state.isOpen = isEnabled
state.sendSurfaceDisplayedTelemetryEvent = !isEnabled
return state

case FakespotActionType.surfaceDisplayedEventSend:
let isEnabled = action.isExpanded ?? state.isSettingsExpanded
var state = state
state.isOpen = isEnabled
state.sendSurfaceDisplayedTelemetryEvent = false
return state

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class FakespotViewController: UIViewController,
if dismissPermanently {
self?.triggerDismiss()
} else {
let appearanceAction = FakespotAction(isExpanded: false,
let appearanceAction = FakespotAction(isOpen: false,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(appearanceAction)
Expand Down Expand Up @@ -468,7 +468,7 @@ class FakespotViewController: UIViewController,
let reviewQualityCardView: FakespotReviewQualityCardView = .build()
viewModel.reviewQualityCardViewModel.expandState = fakespotState.isReviewQualityExpanded ? .expanded : .collapsed
viewModel.reviewQualityCardViewModel.dismissViewController = {
let action = FakespotAction(isExpanded: false,
let action = FakespotAction(isOpen: false,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(action)
Expand Down Expand Up @@ -527,7 +527,7 @@ class FakespotViewController: UIViewController,
self?.viewModel.addTab(url: adData.url)
self?.viewModel.recordSurfaceAdsClickedTelemetry()
self?.viewModel.reportAdEvent(eventName: .trustedDealsLinkClicked, aidvs: [adData.aid])
let action = FakespotAction(isExpanded: false,
let action = FakespotAction(isOpen: false,
windowUUID: windowUUID,
actionType: FakespotActionType.setAppearanceTo)
store.dispatch(action)
Expand Down
Loading

0 comments on commit 17c5365

Please sign in to comment.