Bug 1639893 Part 1 - Partial Imlementation of GetOverflowingChildrenOfElement. r=bradwerth,emilio
authormanas <manas.khurana20@gmail.com>
Tue, 23 Jun 2020 18:51:32 +0000
changeset 536956 d48aa0f0aa0bbe69f8eae663be2f5671c41af27c
parent 536955 0254a64157c3677ec30a650589b92e4a1dc66e0a
child 536957 53f01e0036e1bf65486cb0b0158f69de2ee46bd7
push id37533
push userdluca@mozilla.com
push dateTue, 23 Jun 2020 21:38:40 +0000
treeherdermozilla-central@d48aa0f0aa0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbradwerth, emilio
bugs1639893
milestone79.0a1
first release with
nightly linux32
d48aa0f0aa0b / 79.0a1 / 20200623213840 / files
nightly linux64
d48aa0f0aa0b / 79.0a1 / 20200623213840 / files
nightly mac
d48aa0f0aa0b / 79.0a1 / 20200623213840 / files
nightly win32
d48aa0f0aa0b / 79.0a1 / 20200623213840 / files
nightly win64
d48aa0f0aa0b / 79.0a1 / 20200623213840 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1639893 Part 1 - Partial Imlementation of GetOverflowingChildrenOfElement. r=bradwerth,emilio Differential Revision: https://phabricator.services.mozilla.com/D80216
dom/chrome-webidl/InspectorUtils.webidl
layout/inspector/InspectorUtils.cpp
layout/inspector/InspectorUtils.h
--- a/dom/chrome-webidl/InspectorUtils.webidl
+++ b/dom/chrome-webidl/InspectorUtils.webidl
@@ -75,16 +75,18 @@ namespace InspectorUtils {
   void clearPseudoClassLocks(Element element);
   [Throws] void parseStyleSheet(CSSStyleSheet sheet, UTF8String input);
   boolean isCustomElementName([TreatNullAs=EmptyString] DOMString name,
                               DOMString? namespaceURI);
 
   boolean isElementThemed(Element element);
 
   Element? containingBlockOf(Element element);
+
+  [NewObject] NodeList getOverflowingChildrenOfElement(Element element);
 };
 
 dictionary PropertyNamesOptions {
   boolean includeAliases = false;
   boolean includeShorthands = true;
   boolean includeExperimentals = false;
 };
 
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -698,10 +698,37 @@ Element* InspectorUtils::ContainingBlock
   }
   nsIFrame* cb = frame->GetContainingBlock();
   if (!cb) {
     return nullptr;
   }
   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
--- a/layout/inspector/InspectorUtils.h
+++ b/layout/inspector/InspectorUtils.h
@@ -233,16 +233,19 @@ class InspectorUtils {
   static bool HasPseudoClassLock(GlobalObject& aGlobal, Element& aElement,
                                  const nsAString& aPseudoClass);
   static void ClearPseudoClassLocks(GlobalObject& aGlobal, Element& aElement);
 
   static bool IsElementThemed(GlobalObject& aGlobal, Element& aElement);
 
   static Element* ContainingBlockOf(GlobalObject&, Element&);
 
+  static already_AddRefed<nsINodeList> GetOverflowingChildrenOfElement(
+      GlobalObject& aGlobal, Element& element);
+
   /**
    * Parse CSS and update the style sheet in place.
    *
    * @param DOMCSSStyleSheet aSheet
    * @param UTF8String aInput
    *        The new source string for the style sheet.
    */
   static void ParseStyleSheet(GlobalObject& aGlobal, StyleSheet& aSheet,