Bug 1397434 - Remove the ActiveElementUsesStyle optimization in ActiveElementManager. r=kats

The optimization avoided a 10ms delay in generating synthesized mouse events
after a touch tap, if the tapped element wasn't styled differently when in
the |:active| state.

This dates back to the B2G days when the delay was in the critical path of
app startup times. It's less important today, and determining whether the
element is styled differently is an expensive operation in the style engine,
so we are removing it.

MozReview-Commit-ID: FYO1GlCR3gS

--HG--
extra : rebase_source : 1b7ce6eec77d0260b153bfcd93e81bccb3558107
This commit is contained in:
Botond Ballo 2017-09-11 16:44:52 -04:00
Родитель d01cafd325
Коммит ab2b6fc21f
3 изменённых файлов: 2 добавлений и 52 удалений

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

@ -205,16 +205,8 @@ APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
}
LayoutDevicePoint ldPoint = aPoint * aScale;
if (!mActiveElementManager->ActiveElementUsesStyle()) {
// If the active element isn't visually affected by the :active style, we
// have no need to wait the extra sActiveDurationMs to make the activation
// visually obvious to the user.
widget::nsAutoRollup rollup(touchRollup.get());
APZCCallbackHelper::FireSingleTapEvent(ldPoint, aModifiers, aClickCount, widget);
return;
}
APZES_LOG("Active element uses style, scheduling timer for click event\n");
APZES_LOG("Scheduling timer for click event\n");
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
dom::TabChild* tabChild = widget->GetOwningTabChild();

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

@ -27,8 +27,7 @@ static bool sActivationDelayMsSet = false;
ActiveElementManager::ActiveElementManager()
: mCanBePan(false),
mCanBePanSet(false),
mSetActiveTask(nullptr),
mActiveElementUsesStyle(false)
mSetActiveTask(nullptr)
{
if (!sActivationDelayMsSet) {
Preferences::AddIntVarCache(&sActivationDelayMs,
@ -142,12 +141,6 @@ ActiveElementManager::HandleTouchEnd()
mCanBePanSet = false;
}
bool
ActiveElementManager::ActiveElementUsesStyle() const
{
return mActiveElementUsesStyle;
}
static nsPresContext*
GetPresContextFor(nsIContent* aContent)
{
@ -161,30 +154,6 @@ GetPresContextFor(nsIContent* aContent)
return shell->GetPresContext();
}
static bool
ElementHasActiveStyle(dom::Element* aElement)
{
nsPresContext* pc = GetPresContextFor(aElement);
if (!pc) {
return false;
}
nsStyleSet* styleSet = pc->StyleSet()->GetAsGecko();
if (!styleSet) {
// Bug 1397434 tracks making this optimization work for stylo.
AEM_LOG("Element %p uses Servo style backend, assuming dependence on active state\n", aElement);
return true;
}
for (dom::Element* e = aElement; e; e = e->GetParentElement()) {
if (styleSet->HasStateDependentStyle(e, NS_EVENT_STATE_ACTIVE)) {
AEM_LOG("Element %p's style is dependent on the active state\n", e);
return true;
}
}
AEM_LOG("Element %p doesn't use active styles\n", aElement);
return false;
}
void
ActiveElementManager::SetActive(dom::Element* aTarget)
{
@ -192,7 +161,6 @@ ActiveElementManager::SetActive(dom::Element* aTarget)
if (nsPresContext* pc = GetPresContextFor(aTarget)) {
pc->EventStateManager()->SetContentState(aTarget, NS_EVENT_STATE_ACTIVE);
mActiveElementUsesStyle = ElementHasActiveStyle(aTarget);
}
}

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

@ -59,12 +59,6 @@ public:
* delayed until after touch listeners have responded to the APZ.
*/
void HandleTouchEnd();
/**
* @return true iff the currently active element (or one of its ancestors)
* actually had a style for the :active pseudo-class. The currently active
* element is the root element if no other elements are active.
*/
bool ActiveElementUsesStyle() const;
private:
/**
* The target of the first touch point in the current touch block.
@ -84,10 +78,6 @@ private:
* A task for calling SetActive() after a timeout.
*/
RefPtr<CancelableRunnable> mSetActiveTask;
/**
* See ActiveElementUsesStyle() documentation.
*/
bool mActiveElementUsesStyle;
// Helpers
void TriggerElementActivation();