Skip to content

Commit

Permalink
Bug 1834133 part 1: Remove about:config prefs layout.css.notify-of-un…
Browse files Browse the repository at this point in the history
…visited and layout.css.always-repaint-on-unvisited. r=emilio

Update all of their usages to assume that they're true (which they have been, by-default, for several years).

Differential Revision: https://phabricator.services.mozilla.com/D178569
  • Loading branch information
dholbert committed May 20, 2023
1 parent 0d97343 commit 06aa3fb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 50 deletions.
8 changes: 0 additions & 8 deletions docshell/base/BaseHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ void BaseHistory::RegisterVisitedCallback(nsIURI* aURI, Link* aLink) {
case VisitedStatus::Unknown:
break;
case VisitedStatus::Unvisited:
if (!StaticPrefs::layout_css_notify_of_unvisited()) {
break;
}
[[fallthrough]];
case VisitedStatus::Visited:
aLink->VisitedQueryFinished(links->mStatus == VisitedStatus::Visited);
Expand Down Expand Up @@ -159,11 +156,6 @@ void BaseHistory::NotifyVisited(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aStatus != VisitedStatus::Unknown);

if (aStatus == VisitedStatus::Unvisited &&
!StaticPrefs::layout_css_notify_of_unvisited()) {
return;
}

NotifyVisitedInThisProcess(aURI, aStatus);
if (XRE_IsParentProcess()) {
NotifyVisitedFromParent(aURI, aStatus, aListOfProcessesToNotify);
Expand Down
10 changes: 4 additions & 6 deletions dom/base/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ void Link::VisitedQueryFinished(bool aVisited) {
// Tell the element to update its visited state.
mElement->UpdateState(true);

if (StaticPrefs::layout_css_always_repaint_on_unvisited()) {
// Even if the state didn't actually change, we need to repaint in order for
// the visited state not to be observable.
nsLayoutUtils::PostRestyleEvent(GetElement(), RestyleHint::RestyleSubtree(),
nsChangeHint_RepaintFrame);
}
// Even if the state didn't actually change, we need to repaint in order for
// the visited state not to be observable.
nsLayoutUtils::PostRestyleEvent(GetElement(), RestyleHint::RestyleSubtree(),
nsChangeHint_RepaintFrame);
}

ElementState Link::LinkState() const {
Expand Down
19 changes: 6 additions & 13 deletions layout/base/RestyleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3300,24 +3300,17 @@ void RestyleManager::ElementStateChanged(Element* aElement,
const ElementState kVisitedAndUnvisited =
ElementState::VISITED | ElementState::UNVISITED;

// When visited links are disabled, they cannot influence style for obvious
// reasons.
//
// When layout.css.always-repaint-on-unvisited is true, we'll restyle when the
// relevant visited query finishes, regardless of the style (see
// Link::VisitedQueryFinished). So there's no need to do anything as a result
// of this state change just yet.
// We'll restyle when the relevant visited query finishes, regardless of the
// style (see Link::VisitedQueryFinished). So there's no need to do anything
// as a result of this state change just yet.
//
// Note that this check checks for _both_ bits: This is only true when visited
// changes to unvisited or vice-versa, but not when we start or stop being a
// link itself.
if (aChangedBits.HasAllStates(kVisitedAndUnvisited)) {
if (!Gecko_VisitedStylesEnabled(aElement->OwnerDoc()) ||
StaticPrefs::layout_css_always_repaint_on_unvisited()) {
aChangedBits &= ~kVisitedAndUnvisited;
if (aChangedBits.IsEmpty()) {
return;
}
aChangedBits &= ~kVisitedAndUnvisited;
if (aChangedBits.IsEmpty()) {
return;
}
}

Expand Down
12 changes: 0 additions & 12 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8287,18 +8287,6 @@
value: true
mirror: always

# Whether we get notified of history queries for visited even if unvisited.
- name: layout.css.notify-of-unvisited
type: RelaxedAtomicBool
value: true
mirror: always

# Whether we always restyle / repaint as a result of a visited query
- name: layout.css.always-repaint-on-unvisited
type: RelaxedAtomicBool
value: true
mirror: always

# Make `zoom` a `transform` + `transform-origin` alias.
- name: layout.css.zoom-transform-hack.enabled
type: RelaxedAtomicBool
Expand Down
4 changes: 1 addition & 3 deletions toolkit/components/places/tests/gtest/mock_Link.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ class mock_Link : public mozilla::dom::Link {
bool GotNotified() const { return !mDeathGrip; }

void AwaitNewNotification(Handler aNewHandler) {
MOZ_ASSERT(
!mDeathGrip || !mozilla::StaticPrefs::layout_css_notify_of_unvisited(),
"Still waiting for a notification");
MOZ_ASSERT(!mDeathGrip, "Still waiting for a notification");
// Create a cyclic ownership, so that the link will be released only
// after its status has been updated. This will ensure that, when it should
// run the next test, it will happen at the end of the test function, if
Expand Down
12 changes: 4 additions & 8 deletions toolkit/components/places/tests/gtest/test_IHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ void test_visited_notifies() {
void test_unvisited_does_not_notify_part2() {
using namespace test_unvisited_does_not_notify;

if (StaticPrefs::layout_css_notify_of_unvisited()) {
SpinEventLoopUntil("places:test_unvisited_does_not_notify_part2"_ns,
[&]() { return testLink->GotNotified(); });
}
SpinEventLoopUntil("places:test_unvisited_does_not_notify_part2"_ns,
[&]() { return testLink->GotNotified(); });

// We would have had a failure at this point had the content node been told it
// was visited. Therefore, now we change it so that it expects a visited
Expand Down Expand Up @@ -238,10 +236,8 @@ void test_new_visit_notifies_waiting_Link() {
nsCOMPtr<IHistory> history = do_get_IHistory();
history->RegisterVisitedCallback(testURI, link);

if (StaticPrefs::layout_css_notify_of_unvisited()) {
SpinEventLoopUntil("places:test_new_visit_notifies_waiting_Link"_ns,
[&]() { return link->GotNotified(); });
}
SpinEventLoopUntil("places:test_new_visit_notifies_waiting_Link"_ns,
[&]() { return link->GotNotified(); });

link->AwaitNewNotification(expect_visit);

Expand Down

0 comments on commit 06aa3fb

Please sign in to comment.