зеркало из https://github.com/mozilla/gecko-dev.git
Bug 782387 - Blank SVG rendering, after clicking a link to a view fragment and then navigating back. r=dholbert
This commit is contained in:
Родитель
8f9211b383
Коммит
e6dbebb0f5
|
@ -32,8 +32,7 @@ GetViewElement(nsIDocument *aDocument, const nsAString &aId)
|
|||
void
|
||||
SVGFragmentIdentifier::SaveOldPreserveAspectRatio(nsSVGSVGElement *root)
|
||||
{
|
||||
const SVGPreserveAspectRatio *oldPARPtr = root->GetPreserveAspectRatioProperty();
|
||||
if (!oldPARPtr) {
|
||||
if (root->mPreserveAspectRatio.IsExplicitlySet()) {
|
||||
root->SetPreserveAspectRatioProperty(root->mPreserveAspectRatio.GetBaseValue());
|
||||
}
|
||||
}
|
||||
|
@ -44,15 +43,15 @@ SVGFragmentIdentifier::RestoreOldPreserveAspectRatio(nsSVGSVGElement *root)
|
|||
const SVGPreserveAspectRatio *oldPARPtr = root->GetPreserveAspectRatioProperty();
|
||||
if (oldPARPtr) {
|
||||
root->mPreserveAspectRatio.SetBaseValue(*oldPARPtr, root);
|
||||
root->ClearPreserveAspectRatioProperty();
|
||||
} else if (root->mPreserveAspectRatio.IsExplicitlySet()) {
|
||||
root->RemoveAttribute(NS_LITERAL_STRING("preserveAspectRatio"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SVGFragmentIdentifier::SaveOldViewBox(nsSVGSVGElement *root)
|
||||
{
|
||||
const nsSVGViewBoxRect *oldViewBoxPtr = root->GetViewBoxProperty();
|
||||
if (!oldViewBoxPtr) {
|
||||
if (root->mViewBox.IsExplicitlySet()) {
|
||||
root->SetViewBoxProperty(root->mViewBox.GetBaseValue());
|
||||
}
|
||||
}
|
||||
|
@ -63,15 +62,15 @@ SVGFragmentIdentifier::RestoreOldViewBox(nsSVGSVGElement *root)
|
|||
const nsSVGViewBoxRect *oldViewBoxPtr = root->GetViewBoxProperty();
|
||||
if (oldViewBoxPtr) {
|
||||
root->mViewBox.SetBaseValue(*oldViewBoxPtr, root);
|
||||
root->ClearViewBoxProperty();
|
||||
} else if (root->mViewBox.IsExplicitlySet()) {
|
||||
root->RemoveAttribute(NS_LITERAL_STRING("viewBox"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SVGFragmentIdentifier::SaveOldZoomAndPan(nsSVGSVGElement *root)
|
||||
{
|
||||
PRUint16 oldZoomAndPan = root->GetZoomAndPanProperty();
|
||||
if (oldZoomAndPan == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_UNKNOWN) {
|
||||
if (root->mEnumAttributes[nsSVGSVGElement::ZOOMANDPAN].IsExplicitlySet()) {
|
||||
root->SetZoomAndPanProperty(root->mEnumAttributes[nsSVGSVGElement::ZOOMANDPAN].GetBaseValue());
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +81,8 @@ SVGFragmentIdentifier::RestoreOldZoomAndPan(nsSVGSVGElement *root)
|
|||
PRUint16 oldZoomAndPan = root->GetZoomAndPanProperty();
|
||||
if (oldZoomAndPan != nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_UNKNOWN) {
|
||||
root->mEnumAttributes[nsSVGSVGElement::ZOOMANDPAN].SetBaseValue(oldZoomAndPan, root);
|
||||
root->ClearZoomAndPanProperty();
|
||||
} else if (root->mEnumAttributes[nsSVGSVGElement::ZOOMANDPAN].IsExplicitlySet()) {
|
||||
root->RemoveAttribute(NS_LITERAL_STRING("zoomAndPan"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,21 +146,18 @@ SVGFragmentIdentifier::ProcessSVGViewSpec(const nsAString &aViewSpec,
|
|||
} while (tokenizer.hasMoreTokens());
|
||||
|
||||
if (viewBoxParams) {
|
||||
SaveOldViewBox(root);
|
||||
root->mViewBox.SetBaseValueString(*viewBoxParams, root);
|
||||
} else {
|
||||
RestoreOldViewBox(root);
|
||||
}
|
||||
|
||||
if (preserveAspectRatioParams) {
|
||||
SaveOldPreserveAspectRatio(root);
|
||||
root->mPreserveAspectRatio.SetBaseValueString(*preserveAspectRatioParams, root);
|
||||
} else {
|
||||
RestoreOldPreserveAspectRatio(root);
|
||||
}
|
||||
|
||||
if (zoomAndPanParams) {
|
||||
SaveOldZoomAndPan(root);
|
||||
nsCOMPtr<nsIAtom> valAtom = do_GetAtom(*zoomAndPanParams);
|
||||
const nsSVGEnumMapping *mapping = root->sZoomAndPanMap;
|
||||
while (mapping->mKey) {
|
||||
|
@ -187,25 +184,28 @@ SVGFragmentIdentifier::ProcessFragmentIdentifier(nsIDocument *aDocument,
|
|||
nsSVGSVGElement *rootElement =
|
||||
static_cast<nsSVGSVGElement*>(aDocument->GetRootElement());
|
||||
|
||||
if (!rootElement->mUseCurrentView) {
|
||||
SaveOldViewBox(rootElement);
|
||||
SaveOldPreserveAspectRatio(rootElement);
|
||||
SaveOldZoomAndPan(rootElement);
|
||||
}
|
||||
|
||||
const nsSVGViewElement *viewElement = GetViewElement(aDocument, aAnchorName);
|
||||
|
||||
if (viewElement) {
|
||||
if (viewElement->mViewBox.IsExplicitlySet()) {
|
||||
SaveOldViewBox(rootElement);
|
||||
rootElement->mViewBox.SetBaseValue(
|
||||
viewElement->mViewBox.GetBaseValue(), rootElement);
|
||||
} else {
|
||||
RestoreOldViewBox(rootElement);
|
||||
}
|
||||
if (viewElement->mPreserveAspectRatio.IsExplicitlySet()) {
|
||||
SaveOldPreserveAspectRatio(rootElement);
|
||||
rootElement->mPreserveAspectRatio.SetBaseValue(
|
||||
viewElement->mPreserveAspectRatio.GetBaseValue(), rootElement);
|
||||
} else {
|
||||
RestoreOldPreserveAspectRatio(rootElement);
|
||||
}
|
||||
if (viewElement->mEnumAttributes[nsSVGViewElement::ZOOMANDPAN].IsExplicitlySet()) {
|
||||
SaveOldZoomAndPan(rootElement);
|
||||
rootElement->mEnumAttributes[nsSVGSVGElement::ZOOMANDPAN].SetBaseValue(
|
||||
viewElement->mEnumAttributes[nsSVGViewElement::ZOOMANDPAN].GetBaseValue(), rootElement);
|
||||
} else {
|
||||
|
@ -220,7 +220,10 @@ SVGFragmentIdentifier::ProcessFragmentIdentifier(nsIDocument *aDocument,
|
|||
return true;
|
||||
}
|
||||
RestoreOldViewBox(rootElement);
|
||||
rootElement->ClearViewBoxProperty();
|
||||
RestoreOldPreserveAspectRatio(rootElement);
|
||||
rootElement->ClearPreserveAspectRatioProperty();
|
||||
RestoreOldZoomAndPan(rootElement);
|
||||
rootElement->ClearZoomAndPanProperty();
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче