OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "core/paint/ViewPainter.h" | 30 #include "core/paint/ViewPainter.h" |
31 #include "core/rendering/ColumnInfo.h" | 31 #include "core/rendering/ColumnInfo.h" |
32 #include "core/rendering/FlowThreadController.h" | 32 #include "core/rendering/FlowThreadController.h" |
33 #include "core/rendering/GraphicsContextAnnotator.h" | 33 #include "core/rendering/GraphicsContextAnnotator.h" |
34 #include "core/rendering/HitTestResult.h" | 34 #include "core/rendering/HitTestResult.h" |
35 #include "core/rendering/RenderFlowThread.h" | 35 #include "core/rendering/RenderFlowThread.h" |
36 #include "core/rendering/RenderGeometryMap.h" | 36 #include "core/rendering/RenderGeometryMap.h" |
37 #include "core/rendering/RenderLayer.h" | 37 #include "core/rendering/RenderLayer.h" |
38 #include "core/rendering/RenderPart.h" | 38 #include "core/rendering/RenderPart.h" |
39 #include "core/rendering/RenderQuote.h" | 39 #include "core/rendering/RenderQuote.h" |
40 #include "core/rendering/RenderSelectionInfo.h" | |
41 #include "core/rendering/compositing/CompositedLayerMapping.h" | 40 #include "core/rendering/compositing/CompositedLayerMapping.h" |
42 #include "core/rendering/compositing/RenderLayerCompositor.h" | 41 #include "core/rendering/compositing/RenderLayerCompositor.h" |
43 #include "core/svg/SVGDocumentExtensions.h" | 42 #include "core/svg/SVGDocumentExtensions.h" |
44 #include "platform/TraceEvent.h" | 43 #include "platform/TraceEvent.h" |
45 #include "platform/geometry/FloatQuad.h" | 44 #include "platform/geometry/FloatQuad.h" |
46 #include "platform/geometry/TransformState.h" | 45 #include "platform/geometry/TransformState.h" |
47 #include "platform/graphics/GraphicsContext.h" | 46 #include "platform/graphics/GraphicsContext.h" |
48 | 47 |
49 namespace blink { | 48 namespace blink { |
50 | 49 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 430 |
432 static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset
) | 431 static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset
) |
433 { | 432 { |
434 if (!object) | 433 if (!object) |
435 return 0; | 434 return 0; |
436 | 435 |
437 RenderObject* child = object->childAt(offset); | 436 RenderObject* child = object->childAt(offset); |
438 return child ? child : object->nextInPreOrderAfterChildren(); | 437 return child ? child : object->nextInPreOrderAfterChildren(); |
439 } | 438 } |
440 | 439 |
| 440 static LayoutRect selectionRectForRenderer(const RenderObject* object) |
| 441 { |
| 442 if (!object->isRooted()) |
| 443 return LayoutRect(); |
| 444 |
| 445 if (!object->canUpdateSelectionOnRootLineBoxes()) |
| 446 return LayoutRect(); |
| 447 |
| 448 return object->selectionRectForPaintInvalidation(object->containerForPaintIn
validation()); |
| 449 } |
| 450 |
441 IntRect RenderView::selectionBounds() const | 451 IntRect RenderView::selectionBounds() const |
442 { | 452 { |
443 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMemb
er<RenderSelectionInfo> > SelectionMap; | 453 // Now create a single bounding box rect that encloses the whole selection. |
444 SelectionMap selectedObjects; | 454 LayoutRect selRect; |
| 455 |
| 456 typedef WillBeHeapHashSet<RawPtrWillBeMember<const RenderBlock> > VisitedCon
tainingBlockSet; |
| 457 VisitedContainingBlockSet visitedContainingBlocks; |
445 | 458 |
446 RenderObject* os = m_selectionStart; | 459 RenderObject* os = m_selectionStart; |
447 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 460 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
448 while (os && os != stop) { | 461 while (os && os != stop) { |
449 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 462 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
450 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. | 463 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. |
451 selectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(o
s))); | 464 selRect.unite(selectionRectForRenderer(os)); |
452 RenderBlock* cb = os->containingBlock(); | 465 const RenderBlock* cb = os->containingBlock(); |
453 while (cb && !cb->isRenderView()) { | 466 while (cb && !cb->isRenderView()) { |
454 OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObj
ects.add(cb, nullptr).storedValue->value; | 467 selRect.unite(selectionRectForRenderer(cb)); |
455 if (blockInfo) | 468 VisitedContainingBlockSet::AddResult addResult = visitedContaini
ngBlocks.add(cb); |
| 469 if (!addResult.isNewEntry) |
456 break; | 470 break; |
457 blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb)); | |
458 cb = cb->containingBlock(); | 471 cb = cb->containingBlock(); |
459 } | 472 } |
460 } | 473 } |
461 | 474 |
462 os = os->nextInPreOrder(); | 475 os = os->nextInPreOrder(); |
463 } | 476 } |
464 | 477 |
465 // Now create a single bounding box rect that encloses the whole selection. | |
466 LayoutRect selRect; | |
467 SelectionMap::iterator end = selectedObjects.end(); | |
468 for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i) | |
469 selRect.unite(i->value->absoluteSelectionRect()); | |
470 | |
471 return pixelSnappedIntRect(selRect); | 478 return pixelSnappedIntRect(selRect); |
472 } | 479 } |
473 | 480 |
474 void RenderView::invalidatePaintForSelection() const | 481 void RenderView::invalidatePaintForSelection() const |
475 { | 482 { |
476 HashSet<RenderBlock*> processedBlocks; | 483 HashSet<RenderBlock*> processedBlocks; |
477 | 484 |
478 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos)
; | 485 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos)
; |
479 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde
r()) { | 486 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde
r()) { |
480 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio
nEnd) | 487 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio
nEnd) |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 return viewWidth(IncludeScrollbars) / scale; | 875 return viewWidth(IncludeScrollbars) / scale; |
869 } | 876 } |
870 | 877 |
871 double RenderView::layoutViewportHeight() const | 878 double RenderView::layoutViewportHeight() const |
872 { | 879 { |
873 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 880 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
874 return viewHeight(IncludeScrollbars) / scale; | 881 return viewHeight(IncludeScrollbars) / scale; |
875 } | 882 } |
876 | 883 |
877 } // namespace blink | 884 } // namespace blink |
OLD | NEW |