mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 10:15:41 +00:00
Backed out changeset b387c724bda4
This commit is contained in:
parent
fb4a464bd0
commit
094ef7e2c8
@ -106,8 +106,8 @@ class nsIBoxObject;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x7d1ff787, 0x8c35, 0x45f3, \
|
||||
{ 0xa6, 0x7c, 0x8d, 0x7f, 0x36, 0xbd, 0x4e, 0x68 } }
|
||||
{ 0x6b2f1996, 0x95d4, 0x48db, \
|
||||
{0xaf, 0xd1, 0xfd, 0xaa, 0x75, 0x4c, 0x79, 0x92 } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
@ -918,6 +918,11 @@ public:
|
||||
* (eventually) called on it again.
|
||||
*/
|
||||
virtual void ForgetLink(nsIContent* aContent) = 0;
|
||||
/**
|
||||
* Notification that the visitedness state of a URI has been changed
|
||||
* and style related to elements linking to that URI should be updated.
|
||||
*/
|
||||
virtual void NotifyURIVisitednessChanged(nsIURI* aURI) = 0;
|
||||
|
||||
/**
|
||||
* Resets and removes a box object from the document's box object cache
|
||||
|
@ -1809,6 +1809,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDocument)
|
||||
// Traverse all our nsCOMArrays.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mStyleSheets)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mCatalogSheets)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mVisitednessChangedURIs)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mPreloadingImages)
|
||||
|
||||
#ifdef MOZ_SMIL
|
||||
@ -7319,6 +7320,8 @@ nsDocument::OnPageShow(PRBool aPersisted,
|
||||
EnumerateFreezableElements(NotifyActivityChanged, nsnull);
|
||||
EnumerateExternalResources(NotifyPageShow, &aPersisted);
|
||||
|
||||
UpdateLinkMap();
|
||||
|
||||
nsIContent* root = GetRootContent();
|
||||
if (aPersisted && root) {
|
||||
// Send out notifications that our <link> elements are attached.
|
||||
@ -7521,12 +7524,80 @@ nsDocument::ForgetLink(nsIContent* aContent)
|
||||
}
|
||||
}
|
||||
|
||||
class URIVisitNotifier : public nsUint32ToContentHashEntry::Visitor
|
||||
{
|
||||
public:
|
||||
nsCAutoString matchURISpec;
|
||||
nsCOMArray<nsIContent> contentVisited;
|
||||
|
||||
virtual void Visit(nsIContent* aContent) {
|
||||
// Ensure that the URIs really match before we try to do anything
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (!aContent->IsLink(getter_AddRefs(uri))) {
|
||||
NS_ERROR("Should have found a URI for content in the link map");
|
||||
return;
|
||||
}
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
// We use nsCString::Equals here instead of nsIURI::Equals because
|
||||
// history matching is all based on spec equality
|
||||
if (!spec.Equals(matchURISpec))
|
||||
return;
|
||||
|
||||
// Throw away the cached link state so it gets refetched by the style
|
||||
// system. We can't call ContentStatesChanged here, because that might
|
||||
// modify the hashtable. Instead, we'll just insert into this array and
|
||||
// leave it to our caller to call ContentStatesChanged.
|
||||
aContent->SetLinkState(eLinkState_Unknown);
|
||||
contentVisited.AppendObject(aContent);
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
nsDocument::NotifyURIVisitednessChanged(nsIURI* aURI)
|
||||
{
|
||||
if (!mVisible) {
|
||||
mVisitednessChangedURIs.AppendObject(aURI);
|
||||
return;
|
||||
}
|
||||
|
||||
nsUint32ToContentHashEntry* entry = mLinkMap.GetEntry(GetURIHash(aURI));
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
URIVisitNotifier visitor;
|
||||
aURI->GetSpec(visitor.matchURISpec);
|
||||
entry->VisitContent(&visitor);
|
||||
|
||||
MOZ_AUTO_DOC_UPDATE(this, UPDATE_CONTENT_STATE, PR_TRUE);
|
||||
for (PRUint32 count = visitor.contentVisited.Count(), i = 0; i < count; ++i) {
|
||||
ContentStatesChanged(visitor.contentVisited[i],
|
||||
nsnull, NS_EVENT_STATE_VISITED);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::DestroyLinkMap()
|
||||
{
|
||||
mVisitednessChangedURIs.Clear();
|
||||
mLinkMap.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::UpdateLinkMap()
|
||||
{
|
||||
NS_ASSERTION(mVisible,
|
||||
"Should only be updating the link map in visible documents");
|
||||
if (!mVisible)
|
||||
return;
|
||||
|
||||
PRInt32 count = mVisitednessChangedURIs.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
NotifyURIVisitednessChanged(mVisitednessChangedURIs[i]);
|
||||
}
|
||||
mVisitednessChangedURIs.Clear();
|
||||
}
|
||||
|
||||
class RefreshLinkStateVisitor : public nsUint32ToContentHashEntry::Visitor
|
||||
{
|
||||
public:
|
||||
|
@ -945,6 +945,7 @@ public:
|
||||
|
||||
virtual NS_HIDDEN_(void) AddStyleRelevantLink(nsIContent* aContent, nsIURI* aURI);
|
||||
virtual NS_HIDDEN_(void) ForgetLink(nsIContent* aContent);
|
||||
virtual NS_HIDDEN_(void) NotifyURIVisitednessChanged(nsIURI* aURI);
|
||||
|
||||
NS_HIDDEN_(void) ClearBoxObjectFor(nsIContent* aContent);
|
||||
NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult);
|
||||
@ -1037,6 +1038,7 @@ protected:
|
||||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
|
||||
void UpdateLinkMap();
|
||||
// Call this before the document does something that will unbind all content.
|
||||
// That will stop us from resolving URIs for all links as they are removed.
|
||||
void DestroyLinkMap();
|
||||
@ -1241,9 +1243,11 @@ private:
|
||||
PRUint32 mOnloadBlockCount;
|
||||
nsCOMPtr<nsIRequest> mOnloadBlocker;
|
||||
ReadyState mReadyState;
|
||||
|
||||
|
||||
// A map from unvisited URI hashes to content elements
|
||||
nsTHashtable<nsUint32ToContentHashEntry> mLinkMap;
|
||||
// URIs whose visitedness has changed while we were hidden
|
||||
nsCOMArray<nsIURI> mVisitednessChangedURIs;
|
||||
|
||||
// Member to store out last-selected stylesheet set.
|
||||
nsString mLastStyleSheetSet;
|
||||
|
Loading…
Reference in New Issue
Block a user