Bug 841192. Part 16: Take plugin's own clipping into account when computing the region for its window. Make SortByContentOrder handle cases where display items in the same list come from different documents. r=mattwoodrow

--HG--
extra : rebase_source : f39deb6250c7aef71d6cd3a62df43785a3bfc7b1
This commit is contained in:
Robert O'Callahan 2013-04-05 21:30:34 +13:00
Родитель a949bd58de
Коммит 3c4a6b56c6
3 изменённых файлов: 45 добавлений и 11 удалений

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

@ -1395,18 +1395,47 @@ static void Sort(nsDisplayList* aList, int32_t aCount, nsDisplayList::SortLEQ aC
}
}
static nsIContent* FindContentInDocument(nsIContent* aContent, nsIDocument* aDoc) {
nsIContent* c = aContent;
for (;;) {
nsIDocument* d = c->OwnerDoc();
if (d == aDoc) {
return c;
}
nsIDocument* parentDoc = d->GetParentDocument();
if (!parentDoc) {
return nullptr;
}
c = parentDoc->FindContentForSubDocument(d);
if (!c) {
NS_ERROR("No content for subdocument?");
return nullptr;
}
}
}
static bool IsContentLEQ(nsDisplayItem* aItem1, nsDisplayItem* aItem2,
void* aClosure) {
// These GetUnderlyingFrame calls return non-null because we're only used
// in sorting
return nsLayoutUtils::CompareTreePosition(
aItem1->GetUnderlyingFrame()->GetContent(),
aItem2->GetUnderlyingFrame()->GetContent(),
static_cast<nsIContent*>(aClosure)) <= 0;
void* aClosure) {
nsIContent* commonAncestor = static_cast<nsIContent*>(aClosure);
// It's possible that the nsIContent for aItem1 or aItem2 is in a subdocument
// of commonAncestor, because display items for subdocuments have been
// mixed into the same list. Ensure that we're looking at content
// in commonAncestor's document.
nsIDocument* commonAncestorDoc = commonAncestor->OwnerDoc();
nsIContent* content1 = FindContentInDocument(aItem1->GetUnderlyingFrame()->GetContent(),
commonAncestorDoc);
nsIContent* content2 = FindContentInDocument(aItem2->GetUnderlyingFrame()->GetContent(),
commonAncestorDoc);
if (!content1 || !content2) {
NS_ERROR("Document trees are mixed up!");
// Something weird going on
return true;
}
return nsLayoutUtils::CompareTreePosition(content1, content2, commonAncestor) <= 0;
}
static bool IsZOrderLEQ(nsDisplayItem* aItem1, nsDisplayItem* aItem2,
void* aClosure) {
void* aClosure) {
// These GetUnderlyingFrame calls return non-null because we're only used
// in sorting. Note that we can't just take the difference of the two
// z-indices here, because that might overflow a 32-bit int.

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

@ -1887,7 +1887,13 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
// might have placed child outline items between its own outline items.
// The element's outline items need to all come before any child outline
// items.
set.Outlines()->SortByContentOrder(aBuilder, GetContent());
nsIContent* content = GetContent();
if (!content) {
content = PresContext()->Document()->GetRootElement();
}
if (content) {
set.Outlines()->SortByContentOrder(aBuilder, content);
}
#ifdef DEBUG
DisplayDebugBorders(aBuilder, this, set);
#endif

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

@ -1058,9 +1058,8 @@ nsDisplayPlugin::ComputeVisibility(nsDisplayListBuilder* aBuilder,
ReferenceFrame()->PresContext()->AppUnitsPerDevPixel();
f->mNextConfigurationBounds = rAncestor.ToNearestPixels(appUnitsPerDevPixel);
bool snap;
nsRegion visibleRegion;
visibleRegion.And(*aVisibleRegion, GetBounds(aBuilder, &snap));
visibleRegion.And(*aVisibleRegion, GetClippedBounds(aBuilder));
// Make visibleRegion relative to f
visibleRegion.MoveBy(-ToReferenceFrame());