Skip to content

Commit

Permalink
Bug 1639893 Part 1 - Partial Imlementation of GetOverflowingChildrenO…
Browse files Browse the repository at this point in the history
…fElement. r=bradwerth,emilio

Differential Revision: https://phabricator.services.mozilla.com/D80216
  • Loading branch information
20manas committed Jun 23, 2020
1 parent 8553991 commit 4093444
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dom/chrome-webidl/InspectorUtils.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ namespace InspectorUtils {
boolean isElementThemed(Element element);

Element? containingBlockOf(Element element);

[NewObject] NodeList getOverflowingChildrenOfElement(Element element);
};

dictionary PropertyNamesOptions {
Expand Down
27 changes: 27 additions & 0 deletions layout/inspector/InspectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,5 +703,32 @@ Element* InspectorUtils::ContainingBlockOf(GlobalObject&, Element& aElement) {
return Element::FromNodeOrNull(cb->GetContent());
}

already_AddRefed<nsINodeList> InspectorUtils::GetOverflowingChildrenOfElement(
GlobalObject& aGlobal, Element& aElement) {
RefPtr<nsSimpleContentList> list = new nsSimpleContentList(&aElement);
nsIFrame* scrollableFrame = aElement.GetPrimaryFrame();

std::function<void(const nsIFrame*)> GetOverflowingElement =
[&](const nsIFrame* aFrame) {
MOZ_ASSERT(aFrame, "we assume the passed-in frame is non-null");
for (const auto& childList : aFrame->ChildLists()) {
for (const nsIFrame* child : childList.mList) {
bool isBlameElem = true; // change this so that it becomes true iff
// child is causing overflow.
if (!isBlameElem) {
GetOverflowingElement(child);
} else {
list->AppendElement(child->GetContent());
}
}
}
};

if (scrollableFrame) {
GetOverflowingElement(scrollableFrame);
}
return list.forget();
}

} // namespace dom
} // namespace mozilla
3 changes: 3 additions & 0 deletions layout/inspector/InspectorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ class InspectorUtils {

static Element* ContainingBlockOf(GlobalObject&, Element&);

static already_AddRefed<nsINodeList> GetOverflowingChildrenOfElement(
GlobalObject& aGlobal, Element& element);

/**
* Parse CSS and update the style sheet in place.
*
Expand Down

0 comments on commit 4093444

Please sign in to comment.