Bug 1419221 - Introduce a new argument for getUnanimatedComputedStyle to be able to flush pending styles. r=birtles

Even with this patch, in Gecko getUnanimatedComputedStyle flushes pendings
styles somehow.  Also in Stylo the function flushes pending styles if the
target element hasn't yet styled or Servo style data has cleared for some
reasons (e.g. the element is in display:none subtree).

MozReview-Commit-ID: HCizzM0JnFz
This commit is contained in:
Hiroyuki Ikezoe
2017-11-21 18:03:17 +09:00
parent 72a4e1a44e
commit 4ee9c6ff0c
4 changed files with 54 additions and 7 deletions

View File

@@ -2970,6 +2970,7 @@ NS_IMETHODIMP
nsDOMWindowUtils::GetUnanimatedComputedStyle(nsIDOMElement* aElement,
const nsAString& aPseudoElement,
const nsAString& aProperty,
int32_t aFlushType,
nsAString& aResult)
{
nsCOMPtr<Element> element = do_QueryInterface(aElement);
@@ -2984,6 +2985,20 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(nsIDOMElement* aElement,
return NS_ERROR_INVALID_ARG;
}
switch (aFlushType) {
case FLUSH_NONE:
break;
case FLUSH_STYLE: {
nsIDocument* doc = element->GetComposedDoc();
if (doc) {
doc->FlushPendingNotifications(FlushType::Style);
}
break;
}
default:
return NS_ERROR_INVALID_ARG;
}
nsIPresShell* shell = GetPresShell();
if (!shell) {
return NS_ERROR_FAILURE;