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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 bool SVGTextQuery::subStringLengthCallback(Data* queryData, const SVGTextFragmen
t& fragment) const | 250 bool SVGTextQuery::subStringLengthCallback(Data* queryData, const SVGTextFragmen
t& fragment) const |
251 { | 251 { |
252 SubStringLengthData* data = static_cast<SubStringLengthData*>(queryData); | 252 SubStringLengthData* data = static_cast<SubStringLengthData*>(queryData); |
253 | 253 |
254 int startPosition = data->startPosition; | 254 int startPosition = data->startPosition; |
255 int endPosition = startPosition + data->length; | 255 int endPosition = startPosition + data->length; |
256 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 256 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
257 return false; | 257 return false; |
258 | 258 |
259 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData->te
xtLayoutObject, fragment.characterOffset + startPosition, endPosition - startPos
ition); | 259 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData->te
xtLayoutObject, fragment.characterOffset + startPosition, endPosition - startPos
ition, queryData->textLayoutObject->styleRef().direction()); |
260 data->subStringLength += queryData->isVerticalText ? metrics.height() : metr
ics.width(); | 260 data->subStringLength += queryData->isVerticalText ? metrics.height() : metr
ics.width(); |
261 return false; | 261 return false; |
262 } | 262 } |
263 | 263 |
264 float SVGTextQuery::subStringLength(unsigned startPosition, unsigned length) con
st | 264 float SVGTextQuery::subStringLength(unsigned startPosition, unsigned length) con
st |
265 { | 265 { |
266 SubStringLengthData data(startPosition, length); | 266 SubStringLengthData data(startPosition, length); |
267 executeQuery(&data, &SVGTextQuery::subStringLengthCallback); | 267 executeQuery(&data, &SVGTextQuery::subStringLengthCallback); |
268 return data.subStringLength; | 268 return data.subStringLength; |
269 } | 269 } |
(...skipping 14 matching lines...) Expand all Loading... |
284 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterDat
a*>(queryData); | 284 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterDat
a*>(queryData); |
285 | 285 |
286 int startPosition = data->position; | 286 int startPosition = data->position; |
287 int endPosition = startPosition + 1; | 287 int endPosition = startPosition + 1; |
288 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 288 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
289 return false; | 289 return false; |
290 | 290 |
291 data->startPosition = FloatPoint(fragment.x, fragment.y); | 291 data->startPosition = FloatPoint(fragment.x, fragment.y); |
292 | 292 |
293 if (startPosition) { | 293 if (startPosition) { |
294 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData
->textLayoutObject, fragment.characterOffset, startPosition); | 294 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData
->textLayoutObject, fragment.characterOffset, startPosition, queryData->textLayo
utObject->styleRef().direction()); |
295 if (queryData->isVerticalText) | 295 if (queryData->isVerticalText) |
296 data->startPosition.move(0, metrics.height()); | 296 data->startPosition.move(0, metrics.height()); |
297 else | 297 else |
298 data->startPosition.move(metrics.width(), 0); | 298 data->startPosition.move(metrics.width(), 0); |
299 } | 299 } |
300 | 300 |
301 AffineTransform fragmentTransform; | 301 AffineTransform fragmentTransform; |
302 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); | 302 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); |
303 if (fragmentTransform.isIdentity()) | 303 if (fragmentTransform.isIdentity()) |
304 return true; | 304 return true; |
(...skipping 24 matching lines...) Expand all Loading... |
329 { | 329 { |
330 EndPositionOfCharacterData* data = static_cast<EndPositionOfCharacterData*>(
queryData); | 330 EndPositionOfCharacterData* data = static_cast<EndPositionOfCharacterData*>(
queryData); |
331 | 331 |
332 int startPosition = data->position; | 332 int startPosition = data->position; |
333 int endPosition = startPosition + 1; | 333 int endPosition = startPosition + 1; |
334 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) | 334 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startP
osition, endPosition)) |
335 return false; | 335 return false; |
336 | 336 |
337 data->endPosition = FloatPoint(fragment.x, fragment.y); | 337 data->endPosition = FloatPoint(fragment.x, fragment.y); |
338 | 338 |
339 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData->te
xtLayoutObject, fragment.characterOffset, startPosition + 1); | 339 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData->te
xtLayoutObject, fragment.characterOffset, startPosition + 1, queryData->textLayo
utObject->styleRef().direction()); |
340 if (queryData->isVerticalText) | 340 if (queryData->isVerticalText) |
341 data->endPosition.move(0, metrics.height()); | 341 data->endPosition.move(0, metrics.height()); |
342 else | 342 else |
343 data->endPosition.move(metrics.width(), 0); | 343 data->endPosition.move(metrics.width(), 0); |
344 | 344 |
345 AffineTransform fragmentTransform; | 345 AffineTransform fragmentTransform; |
346 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); | 346 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); |
347 if (fragmentTransform.isIdentity()) | 347 if (fragmentTransform.isIdentity()) |
348 return true; | 348 return true; |
349 | 349 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 }; | 410 }; |
411 | 411 |
412 static inline void calculateGlyphBoundaries(SVGTextQuery::Data* queryData, const
SVGTextFragment& fragment, int startPosition, FloatRect& extent) | 412 static inline void calculateGlyphBoundaries(SVGTextQuery::Data* queryData, const
SVGTextFragment& fragment, int startPosition, FloatRect& extent) |
413 { | 413 { |
414 float scalingFactor = queryData->textLayoutObject->scalingFactor(); | 414 float scalingFactor = queryData->textLayoutObject->scalingFactor(); |
415 ASSERT(scalingFactor); | 415 ASSERT(scalingFactor); |
416 | 416 |
417 extent.setLocation(FloatPoint(fragment.x, fragment.y - queryData->textLayout
Object->scaledFont().fontMetrics().floatAscent() / scalingFactor)); | 417 extent.setLocation(FloatPoint(fragment.x, fragment.y - queryData->textLayout
Object->scaledFont().fontMetrics().floatAscent() / scalingFactor)); |
418 | 418 |
419 if (startPosition) { | 419 if (startPosition) { |
420 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData
->textLayoutObject, fragment.characterOffset, startPosition); | 420 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData
->textLayoutObject, fragment.characterOffset, startPosition, queryData->textLayo
utObject->styleRef().direction()); |
421 if (queryData->isVerticalText) | 421 if (queryData->isVerticalText) |
422 extent.move(0, metrics.height()); | 422 extent.move(0, metrics.height()); |
423 else | 423 else |
424 extent.move(metrics.width(), 0); | 424 extent.move(metrics.width(), 0); |
425 } | 425 } |
426 | 426 |
427 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData->te
xtLayoutObject, fragment.characterOffset + startPosition, 1); | 427 SVGTextMetrics metrics = SVGTextMetrics::measureCharacterRange(queryData->te
xtLayoutObject, fragment.characterOffset + startPosition, 1, queryData->textLayo
utObject->styleRef().direction()); |
428 extent.setSize(FloatSize(metrics.width(), metrics.height())); | 428 extent.setSize(FloatSize(metrics.width(), metrics.height())); |
429 | 429 |
430 AffineTransform fragmentTransform; | 430 AffineTransform fragmentTransform; |
431 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); | 431 fragment.buildFragmentTransform(fragmentTransform, SVGTextFragment::Transfor
mIgnoringTextLength); |
432 | 432 |
433 extent = fragmentTransform.mapRect(extent); | 433 extent = fragmentTransform.mapRect(extent); |
434 } | 434 } |
435 | 435 |
436 static inline FloatRect calculateFragmentBoundaries(const LayoutSVGInlineText& t
extLayoutObject, const SVGTextFragment& fragment) | 436 static inline FloatRect calculateFragmentBoundaries(const LayoutSVGInlineText& t
extLayoutObject, const SVGTextFragment& fragment) |
437 { | 437 { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const | 508 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const |
509 { | 509 { |
510 CharacterNumberAtPositionData data(position); | 510 CharacterNumberAtPositionData data(position); |
511 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) | 511 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) |
512 return -1; | 512 return -1; |
513 | 513 |
514 return data.processedCharacters; | 514 return data.processedCharacters; |
515 } | 515 } |
516 | 516 |
517 } | 517 } |
OLD | NEW |