OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 return result; | 285 return result; |
286 | 286 |
287 // We have to compute the expansion for annotations over the previous li
ne to see how much we should move. | 287 // We have to compute the expansion for annotations over the previous li
ne to see how much we should move. |
288 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(),
lineTop()) - result; | 288 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(),
lineTop()) - result; |
289 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos
ition); | 289 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos
ition); |
290 } | 290 } |
291 | 291 |
292 return result; | 292 return result; |
293 } | 293 } |
294 | 294 |
295 GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoi
nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 295 GapRects RootInlineBox::lineSelectionGap(const RenderBlock* rootBlock, const Lay
outPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
296 LayoutUnit selTop, LayoutUnit selHeight
, const PaintInfo* paintInfo) | 296 LayoutUnit selTop, LayoutUnit selHeight
, const PaintInfo* paintInfo) const |
297 { | 297 { |
298 RenderObject::SelectionState lineState = selectionState(); | 298 RenderObject::SelectionState lineState = selectionState(); |
299 | 299 |
300 bool leftGap, rightGap; | 300 bool leftGap, rightGap; |
301 block().getSelectionGapInfo(lineState, leftGap, rightGap); | 301 block().getSelectionGapInfo(lineState, leftGap, rightGap); |
302 | 302 |
303 GapRects result; | 303 GapRects result; |
304 | 304 |
305 InlineBox* firstBox = firstSelectedBox(); | 305 InlineBox* firstBox = firstSelectedBox(); |
306 InlineBox* lastBox = lastSelectedBox(); | 306 InlineBox* lastBox = lastSelectedBox(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 if (box == lastBox) | 340 if (box == lastBox) |
341 break; | 341 break; |
342 isPreviousBoxSelected = box->selectionState() != RenderObject::Selec
tionNone; | 342 isPreviousBoxSelected = box->selectionState() != RenderObject::Selec
tionNone; |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 return result; | 346 return result; |
347 } | 347 } |
348 | 348 |
349 RenderObject::SelectionState RootInlineBox::selectionState() | 349 RenderObject::SelectionState RootInlineBox::selectionState() const |
350 { | 350 { |
351 // Walk over all of the selected boxes. | 351 // Walk over all of the selected boxes. |
352 RenderObject::SelectionState state = RenderObject::SelectionNone; | 352 RenderObject::SelectionState state = RenderObject::SelectionNone; |
353 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { | 353 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { |
354 RenderObject::SelectionState boxState = box->selectionState(); | 354 RenderObject::SelectionState boxState = box->selectionState(); |
355 if ((boxState == RenderObject::SelectionStart && state == RenderObject::
SelectionEnd) || | 355 if ((boxState == RenderObject::SelectionStart && state == RenderObject::
SelectionEnd) || |
356 (boxState == RenderObject::SelectionEnd && state == RenderObject::Se
lectionStart)) | 356 (boxState == RenderObject::SelectionEnd && state == RenderObject::Se
lectionStart)) |
357 state = RenderObject::SelectionBoth; | 357 state = RenderObject::SelectionBoth; |
358 else if (state == RenderObject::SelectionNone || | 358 else if (state == RenderObject::SelectionNone || |
359 ((boxState == RenderObject::SelectionStart || boxState == Rende
rObject::SelectionEnd) && | 359 ((boxState == RenderObject::SelectionStart || boxState == Rende
rObject::SelectionEnd) && |
360 (state == RenderObject::SelectionNone || state == RenderObject
::SelectionInside))) | 360 (state == RenderObject::SelectionNone || state == RenderObject
::SelectionInside))) |
361 state = boxState; | 361 state = boxState; |
362 else if (boxState == RenderObject::SelectionNone && state == RenderObjec
t::SelectionStart) { | 362 else if (boxState == RenderObject::SelectionNone && state == RenderObjec
t::SelectionStart) { |
363 // We are past the end of the selection. | 363 // We are past the end of the selection. |
364 state = RenderObject::SelectionBoth; | 364 state = RenderObject::SelectionBoth; |
365 } | 365 } |
366 if (state == RenderObject::SelectionBoth) | 366 if (state == RenderObject::SelectionBoth) |
367 break; | 367 break; |
368 } | 368 } |
369 | 369 |
370 return state; | 370 return state; |
371 } | 371 } |
372 | 372 |
373 InlineBox* RootInlineBox::firstSelectedBox() | 373 InlineBox* RootInlineBox::firstSelectedBox() const |
374 { | 374 { |
375 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { | 375 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { |
376 if (box->selectionState() != RenderObject::SelectionNone) | 376 if (box->selectionState() != RenderObject::SelectionNone) |
377 return box; | 377 return box; |
378 } | 378 } |
379 | 379 |
380 return 0; | 380 return 0; |
381 } | 381 } |
382 | 382 |
383 InlineBox* RootInlineBox::lastSelectedBox() | 383 InlineBox* RootInlineBox::lastSelectedBox() const |
384 { | 384 { |
385 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { | 385 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { |
386 if (box->selectionState() != RenderObject::SelectionNone) | 386 if (box->selectionState() != RenderObject::SelectionNone) |
387 return box; | 387 return box; |
388 } | 388 } |
389 | 389 |
390 return 0; | 390 return 0; |
391 } | 391 } |
392 | 392 |
393 LayoutUnit RootInlineBox::selectionTop() const | 393 LayoutUnit RootInlineBox::selectionTop() const |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 } | 865 } |
866 | 866 |
867 #ifndef NDEBUG | 867 #ifndef NDEBUG |
868 const char* RootInlineBox::boxName() const | 868 const char* RootInlineBox::boxName() const |
869 { | 869 { |
870 return "RootInlineBox"; | 870 return "RootInlineBox"; |
871 } | 871 } |
872 #endif | 872 #endif |
873 | 873 |
874 } // namespace blink | 874 } // namespace blink |
OLD | NEW |