Bug 1363361 - Add ability to dirty root frame from nsIDOMWindowUtils. r?dholbert
MozReview-Commit-ID: Jy6PICTkq4l
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -4437,16 +4437,36 @@ nsDOMWindowUtils::GetDirectionFromText(c
case eDir_Auto:
MOZ_ASSERT_UNREACHABLE("GetDirectionFromText should never return this value");
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
+nsDOMWindowUtils::EnsureDirtyRootFrame()
+{
+ nsIDocument* doc = GetDocument();
+ nsIPresShell* presShell = doc ? doc->GetShell() : nullptr;
+
+ if (!presShell) {
+ return NS_ERROR_FAILURE;
+ }
+
+ nsIFrame* frame = presShell->GetRootFrame();
+ if (!frame) {
+ return NS_ERROR_FAILURE;
+ }
+
+ presShell->FrameNeedsReflow(frame, nsIPresShell::eStyleChange,
+ NS_FRAME_IS_DIRTY);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
nsDOMWindowUtils::GetIsStyledByServo(bool* aStyledByServo)
{
nsIDocument* doc = GetDocument();
*aStyledByServo = doc && doc->IsStyledByServo();
return NS_OK;
}
NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -2019,16 +2019,24 @@ interface nsIDOMWindowUtils : nsISupport
*
* @param aString the string to retrieve the direction for.
* @return one of DIRECTION_LTR, DIRECTION_RTL or DIRECTION_NOT_SET depending
* on the first-strong character found in the string.
*/
long getDirectionFromText(in AString aString);
/**
+ * Calls FrameNeedsReflow on that root frame so that a layout flush
+ * will be necessary.
+ *
+ * This should only be used for testing.
+ */
+ void ensureDirtyRootFrame();
+
+ /**
* Whether the current document is styled by Servo's style engine.
*
* This calls nsIDocument::IsStyledByServo().
*/
readonly attribute boolean isStyledByServo;
// These consts are only for testing purposes.
const long DEFAULT_MOUSE_POINTER_ID = 0;