Bug 1440961: Make canvas style-related code interact a bit better with Shadow DOM. r=smaug

The only relevant spec reference unfortunately is for color parsing[1], which
mentions:

> Otherwise, set color to the computed value of the 'color' property of element.

Using IsInComposedDoc there should be fine, since the computed style of an
element is well defined there.

The rest look like implementation limitations, for which should not be an issue
to extend the check for the composed doc.

[1]: https://html.spec.whatwg.org/#parsed-as-a-css-color-value

MozReview-Commit-ID: ADnVPNqf3X1

--HG--
extra : rebase_source : ea72f695afe86820d2d04c2b8eca1d17bc356a71
This commit is contained in:
Emilio Cobos Álvarez 2018-02-25 02:37:44 +01:00
Родитель 4415223066
Коммит 21a36fad95
1 изменённых файлов: 5 добавлений и 5 удалений

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

@ -1226,7 +1226,7 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
// otherwise resolve it
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
RefPtr<nsStyleContext> parentContext;
if (mCanvasElement && mCanvasElement->IsInUncomposedDoc()) {
if (mCanvasElement && mCanvasElement->IsInComposedDoc()) {
// Inherit from the canvas element.
parentContext =
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr);
@ -2002,7 +2002,7 @@ CanvasRenderingContext2D::ClearTarget()
SetInitialState();
if (!mCanvasElement || !mCanvasElement->IsInUncomposedDoc()) {
if (!mCanvasElement || !mCanvasElement->IsInComposedDoc()) {
return;
}
@ -2739,7 +2739,7 @@ GetFontParentStyleContext(Element* aElement,
nsIPresShell* aPresShell,
ErrorResult& aError)
{
if (aElement && aElement->IsInUncomposedDoc()) {
if (aElement && aElement->IsInComposedDoc()) {
// Inherit from the canvas element.
RefPtr<nsStyleContext> result =
nsComputedDOMStyle::GetStyleContext(aElement, nullptr);
@ -2919,7 +2919,7 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont,
RefPtr<nsStyleContext> parentStyle;
// have to get a parent style context for inherit-like relative
// values (2em, bolder, etc.)
if (aElement && aElement->IsInUncomposedDoc()) {
if (aElement && aElement->IsInComposedDoc()) {
parentStyle = nsComputedDOMStyle::GetStyleContext(aElement, nullptr);
} else {
RefPtr<RawServoDeclarationBlock> declarations =
@ -4576,7 +4576,7 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
bool isRTL = false;
RefPtr<nsStyleContext> canvasStyle;
if (mCanvasElement && mCanvasElement->IsInUncomposedDoc()) {
if (mCanvasElement && mCanvasElement->IsInComposedDoc()) {
// try to find the closest context
canvasStyle =
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr);