Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp

Issue 2805043002: Revert "Neuter the "screen scale factor" computation for SVG <text>" (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp b/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp
index 1811efaa92538549f59d1b44e7d9e8497b5bc6d9..25b768fa770307f9c5c3c5c72f2353e3ddbb3212 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp
@@ -37,6 +37,7 @@
#include "core/layout/svg/LayoutSVGViewportContainer.h"
#include "core/layout/svg/SVGResources.h"
#include "core/layout/svg/SVGResourcesCache.h"
+#include "core/page/Page.h"
#include "core/paint/PaintLayer.h"
#include "core/svg/SVGElement.h"
#include "platform/geometry/TransformState.h"
@@ -519,7 +520,7 @@ SubtreeContentTransformScope::~SubtreeContentTransformScope() {
m_savedContentTransformation.copyTransformTo(s_currentContentTransformation);
}
-float SVGLayoutSupport::calculateScreenFontSizeScalingFactor(
+AffineTransform SVGLayoutSupport::deprecatedCalculateTransformToLayer(
const LayoutObject* layoutObject) {
AffineTransform transform;
while (layoutObject) {
@@ -528,10 +529,43 @@ float SVGLayoutSupport::calculateScreenFontSizeScalingFactor(
break;
layoutObject = layoutObject->parent();
}
- transform.multiply(
- SubtreeContentTransformScope::currentContentTransformation());
- return clampTo<float>(
- sqrt((transform.xScaleSquared() + transform.yScaleSquared()) / 2));
+
+ // Continue walking up the layer tree, accumulating CSS transforms.
+ // FIXME: this queries layer compositing state - which is not
+ // supported during layout. Hence, the result may not include all CSS
+ // transforms.
+ PaintLayer* layer = layoutObject ? layoutObject->enclosingLayer() : 0;
+ while (layer && layer->isAllowedToQueryCompositingState()) {
+ // We can stop at compositing layers, to match the backing resolution.
+ // FIXME: should we be computing the transform to the nearest composited
+ // layer, or the nearest composited layer that does not paint into its
+ // ancestor? I think this is the nearest composited ancestor since we will
+ // inherit its transforms in the composited layer tree.
+ if (layer->compositingState() != NotComposited)
+ break;
+
+ if (TransformationMatrix* layerTransform = layer->transform())
+ transform = layerTransform->toAffineTransform() * transform;
+
+ layer = layer->parent();
+ }
+
+ return transform;
+}
+
+float SVGLayoutSupport::calculateScreenFontSizeScalingFactor(
+ const LayoutObject* layoutObject) {
+ DCHECK(layoutObject);
+
+ // FIXME: trying to compute a device space transform at record time is wrong.
+ // All clients should be updated to avoid relying on this information, and the
+ // method should be removed.
+ AffineTransform ctm =
+ deprecatedCalculateTransformToLayer(layoutObject) *
+ SubtreeContentTransformScope::currentContentTransformation();
+ ctm.scale(layoutObject->document().page()->deviceScaleFactorDeprecated());
+
+ return clampTo<float>(sqrt((ctm.xScaleSquared() + ctm.yScaleSquared()) / 2));
}
static inline bool compareCandidateDistance(const SearchCandidate& r1,
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698