OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 { | 290 { |
291 previousBoxInDifferentBlock = false; | 291 previousBoxInDifferentBlock = false; |
292 | 292 |
293 // FIXME: Handle the case when we don't have an inline text box. | 293 // FIXME: Handle the case when we don't have an inline text box. |
294 const InlineTextBox* previousBox = logicallyPreviousBox(visiblePosition, tex
tBox, previousBoxInDifferentBlock, leafBoxes); | 294 const InlineTextBox* previousBox = logicallyPreviousBox(visiblePosition, tex
tBox, previousBoxInDifferentBlock, leafBoxes); |
295 | 295 |
296 int len = 0; | 296 int len = 0; |
297 string.clear(); | 297 string.clear(); |
298 if (previousBox) { | 298 if (previousBox) { |
299 previousBoxLength = previousBox->len(); | 299 previousBoxLength = previousBox->len(); |
300 previousBox->textRenderer().text().appendTo(string, previousBox->start()
, previousBoxLength); | 300 previousBox->renderer().text().appendTo(string, previousBox->start(), pr
eviousBoxLength); |
301 len += previousBoxLength; | 301 len += previousBoxLength; |
302 } | 302 } |
303 textBox->textRenderer().text().appendTo(string, textBox->start(), textBox->l
en()); | 303 textBox->renderer().text().appendTo(string, textBox->start(), textBox->len()
); |
304 len += textBox->len(); | 304 len += textBox->len(); |
305 | 305 |
306 return wordBreakIterator(string.data(), len); | 306 return wordBreakIterator(string.data(), len); |
307 } | 307 } |
308 | 308 |
309 static TextBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePos
ition& visiblePosition, const InlineTextBox* textBox, | 309 static TextBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePos
ition& visiblePosition, const InlineTextBox* textBox, |
310 bool& nextBoxInDifferentBlock, Vector<UChar, 1024>& string, CachedLogicallyO
rderedLeafBoxes& leafBoxes) | 310 bool& nextBoxInDifferentBlock, Vector<UChar, 1024>& string, CachedLogicallyO
rderedLeafBoxes& leafBoxes) |
311 { | 311 { |
312 nextBoxInDifferentBlock = false; | 312 nextBoxInDifferentBlock = false; |
313 | 313 |
314 // FIXME: Handle the case when we don't have an inline text box. | 314 // FIXME: Handle the case when we don't have an inline text box. |
315 const InlineTextBox* nextBox = logicallyNextBox(visiblePosition, textBox, ne
xtBoxInDifferentBlock, leafBoxes); | 315 const InlineTextBox* nextBox = logicallyNextBox(visiblePosition, textBox, ne
xtBoxInDifferentBlock, leafBoxes); |
316 | 316 |
317 int len = 0; | 317 int len = 0; |
318 string.clear(); | 318 string.clear(); |
319 textBox->textRenderer().text().appendTo(string, textBox->start(), textBox->l
en()); | 319 textBox->renderer().text().appendTo(string, textBox->start(), textBox->len()
); |
320 len += textBox->len(); | 320 len += textBox->len(); |
321 if (nextBox) { | 321 if (nextBox) { |
322 nextBox->textRenderer().text().appendTo(string, nextBox->start(), nextBo
x->len()); | 322 nextBox->renderer().text().appendTo(string, nextBox->start(), nextBox->l
en()); |
323 len += nextBox->len(); | 323 len += nextBox->len(); |
324 } | 324 } |
325 | 325 |
326 return wordBreakIterator(string.data(), len); | 326 return wordBreakIterator(string.data(), len); |
327 } | 327 } |
328 | 328 |
329 static bool isLogicalStartOfWord(TextBreakIterator* iter, int position, bool har
dLineBreak) | 329 static bool isLogicalStartOfWord(TextBreakIterator* iter, int position, bool har
dLineBreak) |
330 { | 330 { |
331 bool boundary = hardLineBreak ? true : iter->isBoundary(position); | 331 bool boundary = hardLineBreak ? true : iter->isBoundary(position); |
332 if (!boundary) | 332 if (!boundary) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 int previousBoxLength = 0; | 379 int previousBoxLength = 0; |
380 bool previousBoxInDifferentBlock = false; | 380 bool previousBoxInDifferentBlock = false; |
381 bool nextBoxInDifferentBlock = false; | 381 bool nextBoxInDifferentBlock = false; |
382 bool movingIntoNewBox = previouslyVisitedBox != box; | 382 bool movingIntoNewBox = previouslyVisitedBox != box; |
383 | 383 |
384 if (offsetInBox == box->caretMinOffset()) | 384 if (offsetInBox == box->caretMinOffset()) |
385 iter = wordBreakIteratorForMinOffsetBoundary(visiblePosition, textBo
x, previousBoxLength, previousBoxInDifferentBlock, string, leafBoxes); | 385 iter = wordBreakIteratorForMinOffsetBoundary(visiblePosition, textBo
x, previousBoxLength, previousBoxInDifferentBlock, string, leafBoxes); |
386 else if (offsetInBox == box->caretMaxOffset()) | 386 else if (offsetInBox == box->caretMaxOffset()) |
387 iter = wordBreakIteratorForMaxOffsetBoundary(visiblePosition, textBo
x, nextBoxInDifferentBlock, string, leafBoxes); | 387 iter = wordBreakIteratorForMaxOffsetBoundary(visiblePosition, textBo
x, nextBoxInDifferentBlock, string, leafBoxes); |
388 else if (movingIntoNewBox) { | 388 else if (movingIntoNewBox) { |
389 iter = wordBreakIterator(textBox->textRenderer().text(), textBox->st
art(), textBox->len()); | 389 iter = wordBreakIterator(textBox->renderer().text(), textBox->start(
), textBox->len()); |
390 previouslyVisitedBox = box; | 390 previouslyVisitedBox = box; |
391 } | 391 } |
392 | 392 |
393 if (!iter) | 393 if (!iter) |
394 break; | 394 break; |
395 | 395 |
396 iter->first(); | 396 iter->first(); |
397 int offsetInIterator = offsetInBox - textBox->start() + previousBoxLengt
h; | 397 int offsetInIterator = offsetInBox - textBox->start() + previousBoxLengt
h; |
398 | 398 |
399 bool isWordBreak; | 399 bool isWordBreak; |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 { | 1380 { |
1381 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); | 1381 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); |
1382 } | 1382 } |
1383 | 1383 |
1384 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) | 1384 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) |
1385 { | 1385 { |
1386 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); | 1386 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); |
1387 } | 1387 } |
1388 | 1388 |
1389 } | 1389 } |
OLD | NEW |