Bug 1444580: Devirtualize autofocus and navigation timing stuff. r=smaug

MozReview-Commit-ID: K5Y9lxSJgOG
This commit is contained in:
Emilio Cobos Álvarez 2018-03-10 05:24:24 +01:00
Родитель 92ca1ace1b
Коммит 07907b44d5
3 изменённых файлов: 33 добавлений и 45 удалений

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

@ -1490,6 +1490,10 @@ nsIDocument::nsIDocument()
mStyleSetFilled(false), mStyleSetFilled(false),
mSSApplicableStateNotificationPending(false), mSSApplicableStateNotificationPending(false),
mMayHaveTitleElement(false), mMayHaveTitleElement(false),
mDOMLoadingSet(false),
mDOMInteractiveSet(false),
mDOMCompleteSet(false),
mAutoFocusFired(false),
mIsScopedStyleEnabled(eScopedStyle_Unknown), mIsScopedStyleEnabled(eScopedStyle_Unknown),
mCompatMode(eCompatibility_FullStandards), mCompatMode(eCompatibility_FullStandards),
mReadyState(ReadyState::READYSTATE_UNINITIALIZED), mReadyState(ReadyState::READYSTATE_UNINITIALIZED),
@ -1568,10 +1572,6 @@ nsDocument::nsDocument(const char* aContentType)
#ifdef DEBUG #ifdef DEBUG
, mWillReparent(false) , mWillReparent(false)
#endif #endif
, mDOMLoadingSet(false)
, mDOMInteractiveSet(false)
, mDOMCompleteSet(false)
, mAutoFocusFired(false)
{ {
SetContentTypeInternal(nsDependentCString(aContentType)); SetContentTypeInternal(nsDependentCString(aContentType));
@ -8891,7 +8891,7 @@ nsDocument::CloneDocHelper(nsDocument* clone, bool aPreallocateChildren) const
} }
void void
nsDocument::SetReadyStateInternal(ReadyState rs) nsIDocument::SetReadyStateInternal(ReadyState rs)
{ {
mReadyState = rs; mReadyState = rs;
if (rs == READYSTATE_UNINITIALIZED) { if (rs == READYSTATE_UNINITIALIZED) {
@ -9413,7 +9413,7 @@ private:
}; };
void void
nsDocument::SetAutoFocusElement(Element* aAutoFocusElement) nsIDocument::SetAutoFocusElement(Element* aAutoFocusElement)
{ {
if (mAutoFocusFired) { if (mAutoFocusFired) {
// Too late. // Too late.
@ -9431,7 +9431,7 @@ nsDocument::SetAutoFocusElement(Element* aAutoFocusElement)
} }
void void
nsDocument::TriggerAutoFocus() nsIDocument::TriggerAutoFocus()
{ {
if (mAutoFocusFired) { if (mAutoFocusFired) {
return; return;
@ -9799,20 +9799,13 @@ nsDocument::GetStateObject(nsIVariant** aState)
return NS_OK; return NS_OK;
} }
nsDOMNavigationTiming* void
nsDocument::GetNavigationTiming() const nsIDocument::SetNavigationTiming(nsDOMNavigationTiming* aTiming)
{
return mTiming;
}
nsresult
nsDocument::SetNavigationTiming(nsDOMNavigationTiming* aTiming)
{ {
mTiming = aTiming; mTiming = aTiming;
if (!mLoadingTimeStamp.IsNull() && mTiming) { if (!mLoadingTimeStamp.IsNull() && mTiming) {
mTiming->SetDOMLoadingTimeStamp(nsIDocument::GetDocumentURI(), mLoadingTimeStamp); mTiming->SetDOMLoadingTimeStamp(GetDocumentURI(), mLoadingTimeStamp);
} }
return NS_OK;
} }
Element* Element*
@ -13408,7 +13401,7 @@ nsIDocument::GetSelection(ErrorResult& aRv)
} }
void void
nsDocument::RecordNavigationTiming(ReadyState aReadyState) nsIDocument::RecordNavigationTiming(ReadyState aReadyState)
{ {
if (!XRE_IsContentProcess()) { if (!XRE_IsContentProcess()) {
return; return;

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

@ -406,8 +406,6 @@ public:
virtual void BeginLoad() override; virtual void BeginLoad() override;
virtual void EndLoad() override; virtual void EndLoad() override;
virtual void SetReadyStateInternal(ReadyState rs) override;
virtual void FlushExternalResources(mozilla::FlushType aType) override; virtual void FlushExternalResources(mozilla::FlushType aType) override;
virtual void SetXMLDeclaration(const char16_t *aVersion, virtual void SetXMLDeclaration(const char16_t *aVersion,
const char16_t *aEncoding, const char16_t *aEncoding,
@ -659,9 +657,6 @@ public:
// Only BlockOnload should call this! // Only BlockOnload should call this!
void AsyncBlockOnload(); void AsyncBlockOnload();
virtual void SetAutoFocusElement(Element* aAutoFocusElement) override;
virtual void TriggerAutoFocus() override;
virtual void SetScrollToRef(nsIURI *aDocumentURI) override; virtual void SetScrollToRef(nsIURI *aDocumentURI) override;
virtual void ScrollToRef() override; virtual void ScrollToRef() override;
virtual void ResetScrolledToRefAlready() override; virtual void ResetScrolledToRefAlready() override;
@ -689,9 +684,6 @@ public:
virtual nsresult GetStateObject(nsIVariant** aResult) override; virtual nsresult GetStateObject(nsIVariant** aResult) override;
virtual nsDOMNavigationTiming* GetNavigationTiming() const override;
virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) override;
virtual Element* FindImageMap(const nsAString& aNormalizedMapName) override; virtual Element* FindImageMap(const nsAString& aNormalizedMapName) override;
virtual nsTArray<Element*> GetFullscreenStack() const override; virtual nsTArray<Element*> GetFullscreenStack() const override;
@ -897,9 +889,6 @@ public:
nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups; nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
// Recorded time of change to 'loading' state.
mozilla::TimeStamp mLoadingTimeStamp;
bool mHasWarnedAboutBoxObjects:1; bool mHasWarnedAboutBoxObjects:1;
bool mDelayFrameLoaderInitialization:1; bool mDelayFrameLoaderInitialization:1;
@ -942,8 +931,6 @@ public:
nsCOMPtr<nsIApplicationCache> mApplicationCache; nsCOMPtr<nsIApplicationCache> mApplicationCache;
nsCOMPtr<nsIContent> mFirstBaseNodeWithHref; nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
RefPtr<nsDOMNavigationTiming> mTiming;
private: private:
friend class nsUnblockOnloadEvent; friend class nsUnblockOnloadEvent;
// Recomputes the visibility state but doesn't set the new value. // Recomputes the visibility state but doesn't set the new value.
@ -1007,8 +994,6 @@ private:
RefPtr<nsContentList> mImageMaps; RefPtr<nsContentList> mImageMaps;
nsWeakPtr mAutoFocusElement;
nsCString mScrollToRef; nsCString mScrollToRef;
uint8_t mScrolledToRefAlready : 1; uint8_t mScrolledToRefAlready : 1;
uint8_t mChangeScrollPosWhenScrollingToRef : 1; uint8_t mChangeScrollPosWhenScrollingToRef : 1;
@ -1037,13 +1022,6 @@ private:
public: public:
bool mWillReparent; bool mWillReparent;
#endif #endif
private:
void RecordNavigationTiming(ReadyState aReadyState);
bool mDOMLoadingSet : 1;
bool mDOMInteractiveSet : 1;
bool mDOMCompleteSet : 1;
bool mAutoFocusFired : 1;
}; };
class nsDocumentOnStack class nsDocumentOnStack

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

@ -1754,7 +1754,7 @@ public:
virtual void EndLoad() = 0; virtual void EndLoad() = 0;
enum ReadyState { READYSTATE_UNINITIALIZED = 0, READYSTATE_LOADING = 1, READYSTATE_INTERACTIVE = 3, READYSTATE_COMPLETE = 4}; enum ReadyState { READYSTATE_UNINITIALIZED = 0, READYSTATE_LOADING = 1, READYSTATE_INTERACTIVE = 3, READYSTATE_COMPLETE = 4};
virtual void SetReadyStateInternal(ReadyState rs) = 0; void SetReadyStateInternal(ReadyState rs);
ReadyState GetReadyStateEnum() ReadyState GetReadyStateEnum()
{ {
return mReadyState; return mReadyState;
@ -2707,8 +2707,8 @@ public:
virtual nsISupports* GetCurrentContentSink() = 0; virtual nsISupports* GetCurrentContentSink() = 0;
virtual void SetAutoFocusElement(Element* aAutoFocusElement) = 0; void SetAutoFocusElement(Element* aAutoFocusElement);
virtual void TriggerAutoFocus() = 0; void TriggerAutoFocus();
virtual void SetScrollToRef(nsIURI *aDocumentURI) = 0; virtual void SetScrollToRef(nsIURI *aDocumentURI) = 0;
virtual void ScrollToRef() = 0; virtual void ScrollToRef() = 0;
@ -2770,9 +2770,12 @@ public:
virtual nsresult GetStateObject(nsIVariant** aResult) = 0; virtual nsresult GetStateObject(nsIVariant** aResult) = 0;
virtual nsDOMNavigationTiming* GetNavigationTiming() const = 0; nsDOMNavigationTiming* GetNavigationTiming() const
{
return mTiming;
}
virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) = 0; void SetNavigationTiming(nsDOMNavigationTiming* aTiming);
virtual Element* FindImageMap(const nsAString& aNormalizedMapName) = 0; virtual Element* FindImageMap(const nsAString& aNormalizedMapName) = 0;
@ -3309,6 +3312,8 @@ protected:
// the classification lists and the classification of parent documents. // the classification lists and the classification of parent documents.
mozilla::dom::FlashClassification ComputeFlashClassification(); mozilla::dom::FlashClassification ComputeFlashClassification();
void RecordNavigationTiming(ReadyState aReadyState);
bool GetUseCounter(mozilla::UseCounter aUseCounter) bool GetUseCounter(mozilla::UseCounter aUseCounter)
{ {
return mUseCounters[aUseCounter]; return mUseCounters[aUseCounter];
@ -3737,6 +3742,11 @@ protected:
// bound to it // bound to it
bool mMayHaveTitleElement: 1; bool mMayHaveTitleElement: 1;
bool mDOMLoadingSet: 1;
bool mDOMInteractiveSet: 1;
bool mDOMCompleteSet: 1;
bool mAutoFocusFired: 1;
// Whether <style scoped> support is enabled in this document. // Whether <style scoped> support is enabled in this document.
enum { eScopedStyle_Unknown, eScopedStyle_Disabled, eScopedStyle_Enabled }; enum { eScopedStyle_Unknown, eScopedStyle_Disabled, eScopedStyle_Enabled };
unsigned int mIsScopedStyleEnabled : 2; unsigned int mIsScopedStyleEnabled : 2;
@ -3960,6 +3970,13 @@ protected:
nsRevocableEventPtr<nsRunnableMethod<nsIDocument, void, false>> nsRevocableEventPtr<nsRunnableMethod<nsIDocument, void, false>>
mPendingTitleChangeEvent; mPendingTitleChangeEvent;
RefPtr<nsDOMNavigationTiming> mTiming;
// Recorded time of change to 'loading' state.
mozilla::TimeStamp mLoadingTimeStamp;
nsWeakPtr mAutoFocusElement;
nsTArray<RefPtr<mozilla::StyleSheet>> mOnDemandBuiltInUASheets; nsTArray<RefPtr<mozilla::StyleSheet>> mOnDemandBuiltInUASheets;
nsTArray<RefPtr<mozilla::StyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount]; nsTArray<RefPtr<mozilla::StyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];