| OLD | NEW |
| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 glyphPosition.move(0, glyphOffsetInDirection); | 324 glyphPosition.move(0, glyphOffsetInDirection); |
| 325 else | 325 else |
| 326 glyphPosition.move(glyphOffsetInDirection, 0); | 326 glyphPosition.move(glyphOffsetInDirection, 0); |
| 327 | 327 |
| 328 return glyphPosition; | 328 return glyphPosition; |
| 329 } | 329 } |
| 330 | 330 |
| 331 static FloatPoint calculateGlyphPosition(const QueryData* queryData, const SVGTe
xtFragment& fragment, int offsetInFragment) | 331 static FloatPoint calculateGlyphPosition(const QueryData* queryData, const SVGTe
xtFragment& fragment, int offsetInFragment) |
| 332 { | 332 { |
| 333 FloatPoint glyphPosition = calculateGlyphPositionWithoutTransform(queryData,
fragment, offsetInFragment); | 333 FloatPoint glyphPosition = calculateGlyphPositionWithoutTransform(queryData,
fragment, offsetInFragment); |
| 334 AffineTransform fragmentTransform; | 334 if (fragment.isTransformed()) { |
| 335 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); | 335 AffineTransform fragmentTransform; |
| 336 if (!fragmentTransform.isIdentity()) | 336 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Tran
sformIgnoringTextLength); |
| 337 glyphPosition = fragmentTransform.mapPoint(glyphPosition); | 337 glyphPosition = fragmentTransform.mapPoint(glyphPosition); |
| 338 | 338 } |
| 339 return glyphPosition; | 339 return glyphPosition; |
| 340 } | 340 } |
| 341 | 341 |
| 342 static bool startPositionOfCharacterCallback(QueryData* queryData, const SVGText
Fragment& fragment) | 342 static bool startPositionOfCharacterCallback(QueryData* queryData, const SVGText
Fragment& fragment) |
| 343 { | 343 { |
| 344 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterDat
a*>(queryData); | 344 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterDat
a*>(queryData); |
| 345 | 345 |
| 346 int startPosition = data->position; | 346 int startPosition = data->position; |
| 347 int endPosition = startPosition + 1; | 347 int endPosition = startPosition + 1; |
| 348 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 348 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 407 |
| 408 static bool rotationOfCharacterCallback(QueryData* queryData, const SVGTextFragm
ent& fragment) | 408 static bool rotationOfCharacterCallback(QueryData* queryData, const SVGTextFragm
ent& fragment) |
| 409 { | 409 { |
| 410 RotationOfCharacterData* data = static_cast<RotationOfCharacterData*>(queryD
ata); | 410 RotationOfCharacterData* data = static_cast<RotationOfCharacterData*>(queryD
ata); |
| 411 | 411 |
| 412 int startPosition = data->position; | 412 int startPosition = data->position; |
| 413 int endPosition = startPosition + 1; | 413 int endPosition = startPosition + 1; |
| 414 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 414 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
| 415 return false; | 415 return false; |
| 416 | 416 |
| 417 AffineTransform fragmentTransform; | 417 if (!fragment.isTransformed()) { |
| 418 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); | |
| 419 if (fragmentTransform.isIdentity()) { | |
| 420 data->rotation = 0; | 418 data->rotation = 0; |
| 421 } else { | 419 } else { |
| 420 AffineTransform fragmentTransform; |
| 421 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Tran
sformIgnoringTextLength); |
| 422 fragmentTransform.scale(1 / fragmentTransform.xScale(), 1 / fragmentTran
sform.yScale()); | 422 fragmentTransform.scale(1 / fragmentTransform.xScale(), 1 / fragmentTran
sform.yScale()); |
| 423 data->rotation = narrowPrecisionToFloat(rad2deg(atan2(fragmentTransform.
b(), fragmentTransform.a()))); | 423 data->rotation = narrowPrecisionToFloat(rad2deg(atan2(fragmentTransform.
b(), fragmentTransform.a()))); |
| 424 } | 424 } |
| 425 | 425 |
| 426 return true; | 426 return true; |
| 427 } | 427 } |
| 428 | 428 |
| 429 float SVGTextQuery::rotationOfCharacter(unsigned position) const | 429 float SVGTextQuery::rotationOfCharacter(unsigned position) const |
| 430 { | 430 { |
| 431 RotationOfCharacterData data(position); | 431 RotationOfCharacterData data(position); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 extent.setSize(glyphSize); | 480 extent.setSize(glyphSize); |
| 481 | 481 |
| 482 // If RTL, adjust the starting point to align with the LHS of the glyph boun
ding box. | 482 // If RTL, adjust the starting point to align with the LHS of the glyph boun
ding box. |
| 483 if (!queryData->textBox->isLeftToRightDirection()) { | 483 if (!queryData->textBox->isLeftToRightDirection()) { |
| 484 if (queryData->isVerticalText) | 484 if (queryData->isVerticalText) |
| 485 extent.move(0, -glyphSize.height()); | 485 extent.move(0, -glyphSize.height()); |
| 486 else | 486 else |
| 487 extent.move(-glyphSize.width(), 0); | 487 extent.move(-glyphSize.width(), 0); |
| 488 } | 488 } |
| 489 | 489 |
| 490 AffineTransform fragmentTransform; | 490 if (fragment.isTransformed()) { |
| 491 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); | 491 AffineTransform fragmentTransform; |
| 492 | 492 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Tran
sformIgnoringTextLength); |
| 493 extent = fragmentTransform.mapRect(extent); | 493 extent = fragmentTransform.mapRect(extent); |
| 494 } |
| 494 } | 495 } |
| 495 | 496 |
| 496 static inline FloatRect calculateFragmentBoundaries(LineLayoutSVGInlineText text
LineLayout, const SVGTextFragment& fragment) | 497 static inline FloatRect calculateFragmentBoundaries(LineLayoutSVGInlineText text
LineLayout, const SVGTextFragment& fragment) |
| 497 { | 498 { |
| 498 float scalingFactor = textLineLayout.scalingFactor(); | 499 float scalingFactor = textLineLayout.scalingFactor(); |
| 499 ASSERT(scalingFactor); | 500 ASSERT(scalingFactor); |
| 500 float baseline = textLineLayout.scaledFont().fontMetrics().floatAscent() / s
calingFactor; | 501 float baseline = textLineLayout.scaledFont().fontMetrics().floatAscent() / s
calingFactor; |
| 501 | 502 |
| 502 AffineTransform fragmentTransform; | 503 AffineTransform fragmentTransform; |
| 503 FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.width, fr
agment.height); | 504 FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.width, fr
agment.height); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } | 610 } |
| 610 | 611 |
| 611 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const | 612 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const |
| 612 { | 613 { |
| 613 CharacterNumberAtPositionData data(position); | 614 CharacterNumberAtPositionData data(position); |
| 614 spatialQuery(m_queryRootLayoutObject, &data, characterNumberAtPositionCallba
ck); | 615 spatialQuery(m_queryRootLayoutObject, &data, characterNumberAtPositionCallba
ck); |
| 615 return data.characterNumberWithin(m_queryRootLayoutObject); | 616 return data.characterNumberWithin(m_queryRootLayoutObject); |
| 616 } | 617 } |
| 617 | 618 |
| 618 } | 619 } |
| OLD | NEW |