Bug 1321284 - Part 1: Make StyleChildrenIterator skip NAC generated by root element primary frame ancestors. r=bholley

MozReview-Commit-ID: HICYWQgkE77

--HG--
extra : rebase_source : 7c5a533ada4eaa9839ca0497426f2c9c2a2d6c0b
This commit is contained in:
Cameron McCormack 2016-12-01 11:34:57 +08:00
Родитель 2edc2d42db
Коммит c7423798c3
4 изменённых файлов: 25 добавлений и 15 удалений

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

@ -383,7 +383,10 @@ AllChildrenIterator::AppendNativeAnonymousChildren()
// The root scroll frame is not the primary frame of the root element.
// Detect and handle this case.
if (mOriginalContent == mOriginalContent->OwnerDoc()->GetRootElement()) {
//
// XXXheycam This probably needs to find the nsCanvasFrame's NAC too.
if (!(mFlags & nsIContent::eSkipDocumentLevelNativeAnonymousContent) &&
mOriginalContent == mOriginalContent->OwnerDoc()->GetRootElement()) {
nsIPresShell* presShell = mOriginalContent->OwnerDoc()->GetShell();
nsIFrame* scrollFrame = presShell ? presShell->GetRootScrollFrame() : nullptr;
if (scrollFrame) {
@ -585,12 +588,6 @@ StyleChildrenIterator::IsNeeded(const Element* aElement)
return true;
}
// The root element has a scroll frame that is not the primary frame, so we
// need to do special checking for that case.
if (aElement == aElement->OwnerDoc()->GetRootElement()) {
return true;
}
return false;
}

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

@ -256,18 +256,22 @@ private:
/**
* StyleChildrenIterator traverses the children of the element from the
* perspective of the style system, particularly the children we need to traverse
* during restyle. This is identical to AllChildrenIterator with eAllChildren,
* _except_ that we detect and skip any native anonymous children that are used
* to implement pseudo-elements (since the style system needs to cascade those
* using different algorithms).
* during restyle. This is identical to AllChildrenIterator with
* (eAllChildren | eSkipDocumentLevelNativeAnonymousContent), _except_ that we
* detect and skip any native anonymous children that are used to implement
* pseudo-elements (since the style system needs to cascade those using
* different algorithms).
*
* Note: it assumes that no mutation of the DOM or frame tree takes place during
* iteration, and will break horribly if that is not true.
*/
class StyleChildrenIterator : private AllChildrenIterator {
class StyleChildrenIterator : private AllChildrenIterator
{
public:
explicit StyleChildrenIterator(const nsIContent* aContent)
: AllChildrenIterator(aContent, nsIContent::eAllChildren)
: AllChildrenIterator(aContent,
nsIContent::eAllChildren |
nsIContent::eSkipDocumentLevelNativeAnonymousContent)
{
MOZ_COUNT_CTOR(StyleChildrenIterator);
}

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

@ -145,7 +145,14 @@ public:
* Skip native anonymous content created for placeholder of HTML input,
* used in conjunction with eAllChildren or eAllButXBL.
*/
eSkipPlaceholderContent = 2
eSkipPlaceholderContent = 2,
/**
* Skip native anonymous content created by ancestor frames of the root
* element's primary frame, such as scrollbar elements created by the root
* scroll frame.
*/
eSkipDocumentLevelNativeAnonymousContent = 4,
};
/**

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

@ -66,7 +66,9 @@ public:
* Appends "native" anonymous children created by CreateAnonymousContent()
* to the given content list depending on the filter.
*
* @see nsIContent::GetChildren for set of values used for filter.
* @see nsIContent::GetChildren for set of values used for filter. Currently,
* eSkipPlaceholderContent is the only flag that any implementation of
* this method heeds.
*/
virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
uint32_t aFilter) = 0;