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

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

Issue 2492013004: Neuter font size scaling (Closed)
Patch Set: Updated test expectations Created 4 years 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. All rights reserved. 5 * Copyright (C) 2009 Google, Inc. All rights reserved.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 AffineTransform contentTransformation = 513 AffineTransform contentTransformation =
514 subtreeContentTransformation * 514 subtreeContentTransformation *
515 AffineTransform(s_currentContentTransformation); 515 AffineTransform(s_currentContentTransformation);
516 contentTransformation.copyTransformTo(s_currentContentTransformation); 516 contentTransformation.copyTransformTo(s_currentContentTransformation);
517 } 517 }
518 518
519 SubtreeContentTransformScope::~SubtreeContentTransformScope() { 519 SubtreeContentTransformScope::~SubtreeContentTransformScope() {
520 m_savedContentTransformation.copyTransformTo(s_currentContentTransformation); 520 m_savedContentTransformation.copyTransformTo(s_currentContentTransformation);
521 } 521 }
522 522
523 AffineTransform SVGLayoutSupport::deprecatedCalculateTransformToLayer( 523 float SVGLayoutSupport::calculateScreenFontSizeScalingFactor(
524 const LayoutObject* layoutObject) { 524 const LayoutObject* layoutObject) {
525 AffineTransform transform; 525 AffineTransform transform;
526 while (layoutObject) { 526 while (layoutObject) {
527 transform = layoutObject->localToSVGParentTransform() * transform; 527 transform = layoutObject->localToSVGParentTransform() * transform;
528 if (layoutObject->isSVGRoot()) 528 if (layoutObject->isSVGRoot())
529 break; 529 break;
530 layoutObject = layoutObject->parent(); 530 layoutObject = layoutObject->parent();
531 } 531 }
532 532 transform.multiply(
533 // Continue walking up the layer tree, accumulating CSS transforms. 533 SubtreeContentTransformScope::currentContentTransformation());
534 // FIXME: this queries layer compositing state - which is not 534 return clampTo<float>(
535 // supported during layout. Hence, the result may not include all CSS 535 sqrt((transform.xScaleSquared() + transform.yScaleSquared()) / 2));
536 // transforms.
537 PaintLayer* layer = layoutObject ? layoutObject->enclosingLayer() : 0;
538 while (layer && layer->isAllowedToQueryCompositingState()) {
539 // We can stop at compositing layers, to match the backing resolution.
540 // FIXME: should we be computing the transform to the nearest composited
541 // layer, or the nearest composited layer that does not paint into its
542 // ancestor? I think this is the nearest composited ancestor since we will
543 // inherit its transforms in the composited layer tree.
544 if (layer->compositingState() != NotComposited)
545 break;
546
547 if (TransformationMatrix* layerTransform = layer->transform())
548 transform = layerTransform->toAffineTransform() * transform;
549
550 layer = layer->parent();
551 }
552
553 return transform;
554 }
555
556 float SVGLayoutSupport::calculateScreenFontSizeScalingFactor(
557 const LayoutObject* layoutObject) {
558 ASSERT(layoutObject);
559
560 // FIXME: trying to compute a device space transform at record time is wrong.
561 // All clients should be updated to avoid relying on this information, and the
562 // method should be removed.
563 AffineTransform ctm =
564 deprecatedCalculateTransformToLayer(layoutObject) *
565 SubtreeContentTransformScope::currentContentTransformation();
566 ctm.scale(
567 layoutObject->document().frameHost()->deviceScaleFactorDeprecated());
568
569 return clampTo<float>(sqrt((ctm.xScaleSquared() + ctm.yScaleSquared()) / 2));
570 } 536 }
571 537
572 static inline bool compareCandidateDistance(const SearchCandidate& r1, 538 static inline bool compareCandidateDistance(const SearchCandidate& r1,
573 const SearchCandidate& r2) { 539 const SearchCandidate& r2) {
574 return r1.candidateDistance < r2.candidateDistance; 540 return r1.candidateDistance < r2.candidateDistance;
575 } 541 }
576 542
577 static inline float distanceToChildLayoutObject(LayoutObject* child, 543 static inline float distanceToChildLayoutObject(LayoutObject* child,
578 const FloatPoint& point) { 544 const FloatPoint& point) {
579 const AffineTransform& localToParentTransform = 545 const AffineTransform& localToParentTransform =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 } 609 }
644 610
645 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText( 611 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText(
646 LayoutObject* layoutObject, 612 LayoutObject* layoutObject,
647 const FloatPoint& point) { 613 const FloatPoint& point) {
648 return searchTreeForFindClosestLayoutSVGText(layoutObject, point) 614 return searchTreeForFindClosestLayoutSVGText(layoutObject, point)
649 .candidateLayoutObject; 615 .candidateLayoutObject;
650 } 616 }
651 617
652 } // namespace blink 618 } // namespace blink
OLDNEW
« 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