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

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

Issue 1933183002: Move isEmptyValue and emptyValue to SVGCharacterData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp ('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) Research In Motion Limited 2010-2012. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 , m_textPathSpacing(0) 47 , m_textPathSpacing(0)
48 , m_textPathScaling(1) 48 , m_textPathScaling(1)
49 { 49 {
50 ASSERT(!m_layoutAttributes.isEmpty()); 50 ASSERT(!m_layoutAttributes.isEmpty());
51 } 51 }
52 52
53 SVGTextLayoutEngine::~SVGTextLayoutEngine() = default; 53 SVGTextLayoutEngine::~SVGTextLayoutEngine() = default;
54 54
55 bool SVGTextLayoutEngine::setCurrentTextPosition(const SVGCharacterData& data) 55 bool SVGTextLayoutEngine::setCurrentTextPosition(const SVGCharacterData& data)
56 { 56 {
57 bool hasX = !SVGTextLayoutAttributes::isEmptyValue(data.x); 57 bool hasX = data.hasX();
58 if (hasX) 58 if (hasX)
59 m_textPosition.setX(data.x); 59 m_textPosition.setX(data.x);
60 60
61 bool hasY = !SVGTextLayoutAttributes::isEmptyValue(data.y); 61 bool hasY = data.hasY();
62 if (hasY) 62 if (hasY)
63 m_textPosition.setY(data.y); 63 m_textPosition.setY(data.y);
64 64
65 // If there's an absolute x/y position available, it marks the beginning of 65 // If there's an absolute x/y position available, it marks the beginning of
66 // a new position along the path. 66 // a new position along the path.
67 if (m_inPathLayout) { 67 if (m_inPathLayout) {
68 // TODO(fs): If a new chunk (== absolute position) is defined while in 68 // TODO(fs): If a new chunk (== absolute position) is defined while in
69 // path layout mode, alignment should be based on that chunk and not 69 // path layout mode, alignment should be based on that chunk and not
70 // the path as a whole. (Re: the addition of m_textPathStartOffset 70 // the path as a whole. (Re: the addition of m_textPathStartOffset
71 // below.) 71 // below.)
(...skipping 14 matching lines...) Expand all
86 // here, but that requires a bit more untangling yet. 86 // here, but that requires a bit more untangling yet.
87 if (m_isVerticalText) 87 if (m_isVerticalText)
88 m_textPosition.setY(m_textPosition.y() + glyphAdvance); 88 m_textPosition.setY(m_textPosition.y() + glyphAdvance);
89 else 89 else
90 m_textPosition.setX(m_textPosition.x() + glyphAdvance); 90 m_textPosition.setX(m_textPosition.x() + glyphAdvance);
91 } 91 }
92 92
93 bool SVGTextLayoutEngine::applyRelativePositionAdjustmentsIfNeeded(const SVGChar acterData& data) 93 bool SVGTextLayoutEngine::applyRelativePositionAdjustmentsIfNeeded(const SVGChar acterData& data)
94 { 94 {
95 FloatPoint delta; 95 FloatPoint delta;
96 bool hasDx = !SVGTextLayoutAttributes::isEmptyValue(data.dx); 96 bool hasDx = data.hasDx();
97 if (hasDx) 97 if (hasDx)
98 delta.setX(data.dx); 98 delta.setX(data.dx);
99 99
100 bool hasDy = !SVGTextLayoutAttributes::isEmptyValue(data.dy); 100 bool hasDy = data.hasDy();
101 if (hasDy) 101 if (hasDy)
102 delta.setY(data.dy); 102 delta.setY(data.dy);
103 103
104 // Apply dx/dy value adjustments to current text position, if needed. 104 // Apply dx/dy value adjustments to current text position, if needed.
105 m_textPosition.moveBy(delta); 105 m_textPosition.moveBy(delta);
106 106
107 if (m_inPathLayout) { 107 if (m_inPathLayout) {
108 if (m_isVerticalText) 108 if (m_isVerticalText)
109 delta = delta.transposedPoint(); 109 delta = delta.transposedPoint();
110 110
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 m_textPosition = position; 442 m_textPosition = position;
443 443
444 // For vertical text on path, the actual angle has to be rotated 90 degrees anti-clockwise, not the orientation angle! 444 // For vertical text on path, the actual angle has to be rotated 90 degrees anti-clockwise, not the orientation angle!
445 if (m_isVerticalText) 445 if (m_isVerticalText)
446 angle -= 90; 446 angle -= 90;
447 } else { 447 } else {
448 position = m_textPosition; 448 position = m_textPosition;
449 position += baselineShift; 449 position += baselineShift;
450 } 450 }
451 451
452 if (!SVGTextLayoutAttributes::isEmptyValue(data.rotate)) 452 if (data.hasRotate())
453 angle += data.rotate; 453 angle += data.rotate;
454 454
455 // Determine whether we have to start a new fragment. 455 // Determine whether we have to start a new fragment.
456 bool shouldStartNewFragment = needsFragmentPerGlyph || hasRelativePositi on 456 bool shouldStartNewFragment = needsFragmentPerGlyph || hasRelativePositi on
457 || angle || angle != lastAngle || applySpacingToNextCharacter; 457 || angle || angle != lastAngle || applySpacingToNextCharacter;
458 458
459 // If we already started a fragment, close it now. 459 // If we already started a fragment, close it now.
460 if (didStartTextFragment && shouldStartNewFragment) { 460 if (didStartTextFragment && shouldStartNewFragment) {
461 applySpacingToNextCharacter = false; 461 applySpacingToNextCharacter = false;
462 recordTextFragment(textBox); 462 recordTextFragment(textBox);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 504 }
505 505
506 if (!didStartTextFragment) 506 if (!didStartTextFragment)
507 return; 507 return;
508 508
509 // Close last open fragment, if needed. 509 // Close last open fragment, if needed.
510 recordTextFragment(textBox); 510 recordTextFragment(textBox);
511 } 511 }
512 512
513 } // namespace blink 513 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698