| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (fragment.isTransformed()) { | 334 if (fragment.isTransformed()) { |
| 335 AffineTransform fragmentTransform; | 335 AffineTransform fragmentTransform = fragment.buildFragmentTransform(SVGT
extFragment::TransformIgnoringTextLength); |
| 336 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Tran
sformIgnoringTextLength); | |
| 337 glyphPosition = fragmentTransform.mapPoint(glyphPosition); | 336 glyphPosition = fragmentTransform.mapPoint(glyphPosition); |
| 338 } | 337 } |
| 339 return glyphPosition; | 338 return glyphPosition; |
| 340 } | 339 } |
| 341 | 340 |
| 342 static bool startPositionOfCharacterCallback(QueryData* queryData, const SVGText
Fragment& fragment) | 341 static bool startPositionOfCharacterCallback(QueryData* queryData, const SVGText
Fragment& fragment) |
| 343 { | 342 { |
| 344 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterDat
a*>(queryData); | 343 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterDat
a*>(queryData); |
| 345 | 344 |
| 346 int startPosition = data->position; | 345 int startPosition = data->position; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 RotationOfCharacterData* data = static_cast<RotationOfCharacterData*>(queryD
ata); | 409 RotationOfCharacterData* data = static_cast<RotationOfCharacterData*>(queryD
ata); |
| 411 | 410 |
| 412 int startPosition = data->position; | 411 int startPosition = data->position; |
| 413 int endPosition = startPosition + 1; | 412 int endPosition = startPosition + 1; |
| 414 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 413 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
| 415 return false; | 414 return false; |
| 416 | 415 |
| 417 if (!fragment.isTransformed()) { | 416 if (!fragment.isTransformed()) { |
| 418 data->rotation = 0; | 417 data->rotation = 0; |
| 419 } else { | 418 } else { |
| 420 AffineTransform fragmentTransform; | 419 AffineTransform fragmentTransform = fragment.buildFragmentTransform(SVGT
extFragment::TransformIgnoringTextLength); |
| 421 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Tran
sformIgnoringTextLength); | |
| 422 fragmentTransform.scale(1 / fragmentTransform.xScale(), 1 / fragmentTran
sform.yScale()); | 420 fragmentTransform.scale(1 / fragmentTransform.xScale(), 1 / fragmentTran
sform.yScale()); |
| 423 data->rotation = narrowPrecisionToFloat(rad2deg(atan2(fragmentTransform.
b(), fragmentTransform.a()))); | 421 data->rotation = narrowPrecisionToFloat(rad2deg(atan2(fragmentTransform.
b(), fragmentTransform.a()))); |
| 424 } | 422 } |
| 425 | |
| 426 return true; | 423 return true; |
| 427 } | 424 } |
| 428 | 425 |
| 429 float SVGTextQuery::rotationOfCharacter(unsigned position) const | 426 float SVGTextQuery::rotationOfCharacter(unsigned position) const |
| 430 { | 427 { |
| 431 RotationOfCharacterData data(position); | 428 RotationOfCharacterData data(position); |
| 432 logicalQuery(m_queryRootLayoutObject, &data, rotationOfCharacterCallback); | 429 logicalQuery(m_queryRootLayoutObject, &data, rotationOfCharacterCallback); |
| 433 return data.rotation; | 430 return data.rotation; |
| 434 } | 431 } |
| 435 | 432 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 478 |
| 482 // If RTL, adjust the starting point to align with the LHS of the glyph boun
ding box. | 479 // If RTL, adjust the starting point to align with the LHS of the glyph boun
ding box. |
| 483 if (!queryData->textBox->isLeftToRightDirection()) { | 480 if (!queryData->textBox->isLeftToRightDirection()) { |
| 484 if (queryData->isVerticalText) | 481 if (queryData->isVerticalText) |
| 485 extent.move(0, -glyphSize.height()); | 482 extent.move(0, -glyphSize.height()); |
| 486 else | 483 else |
| 487 extent.move(-glyphSize.width(), 0); | 484 extent.move(-glyphSize.width(), 0); |
| 488 } | 485 } |
| 489 | 486 |
| 490 if (fragment.isTransformed()) { | 487 if (fragment.isTransformed()) { |
| 491 AffineTransform fragmentTransform; | 488 AffineTransform fragmentTransform = fragment.buildFragmentTransform(SVGT
extFragment::TransformIgnoringTextLength); |
| 492 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Tran
sformIgnoringTextLength); | |
| 493 extent = fragmentTransform.mapRect(extent); | 489 extent = fragmentTransform.mapRect(extent); |
| 494 } | 490 } |
| 495 } | 491 } |
| 496 | 492 |
| 497 static inline FloatRect calculateFragmentBoundaries(LineLayoutSVGInlineText text
LineLayout, const SVGTextFragment& fragment) | 493 static inline FloatRect calculateFragmentBoundaries(LineLayoutSVGInlineText text
LineLayout, const SVGTextFragment& fragment) |
| 498 { | 494 { |
| 499 float scalingFactor = textLineLayout.scalingFactor(); | 495 float scalingFactor = textLineLayout.scalingFactor(); |
| 500 ASSERT(scalingFactor); | 496 ASSERT(scalingFactor); |
| 501 float baseline = textLineLayout.scaledFont().fontMetrics().floatAscent() / s
calingFactor; | 497 float baseline = textLineLayout.scaledFont().fontMetrics().floatAscent() / s
calingFactor; |
| 502 | 498 return fragment.boundingBox(baseline); |
| 503 AffineTransform fragmentTransform; | |
| 504 FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.width, fr
agment.height); | |
| 505 fragment.buildFragmentTransform(fragmentTransform); | |
| 506 return fragmentTransform.mapRect(fragmentRect); | |
| 507 } | 499 } |
| 508 | 500 |
| 509 static bool extentOfCharacterCallback(QueryData* queryData, const SVGTextFragmen
t& fragment) | 501 static bool extentOfCharacterCallback(QueryData* queryData, const SVGTextFragmen
t& fragment) |
| 510 { | 502 { |
| 511 ExtentOfCharacterData* data = static_cast<ExtentOfCharacterData*>(queryData)
; | 503 ExtentOfCharacterData* data = static_cast<ExtentOfCharacterData*>(queryData)
; |
| 512 | 504 |
| 513 int startPosition = data->position; | 505 int startPosition = data->position; |
| 514 int endPosition = startPosition + 1; | 506 int endPosition = startPosition + 1; |
| 515 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 507 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
| 516 return false; | 508 return false; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 } | 602 } |
| 611 | 603 |
| 612 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const | 604 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const |
| 613 { | 605 { |
| 614 CharacterNumberAtPositionData data(position); | 606 CharacterNumberAtPositionData data(position); |
| 615 spatialQuery(m_queryRootLayoutObject, &data, characterNumberAtPositionCallba
ck); | 607 spatialQuery(m_queryRootLayoutObject, &data, characterNumberAtPositionCallba
ck); |
| 616 return data.characterNumberWithin(m_queryRootLayoutObject); | 608 return data.characterNumberWithin(m_queryRootLayoutObject); |
| 617 } | 609 } |
| 618 | 610 |
| 619 } | 611 } |
| OLD | NEW |