Chromium Code Reviews| 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; |
| 445 | 455 |
| 456 HashSet<const RenderBlock*> visitedContainingBlocks; | |
|
kouhei (in TOK)
2014/11/13 01:33:37
WillBeHeapHashSet<RawPtrWillbeMember<const RenderB
Julien - ping for review
2014/11/13 17:03:42
Changed, thanks!
| |
| 446 RenderObject* os = m_selectionStart; | 457 RenderObject* os = m_selectionStart; |
| 447 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos ); | 458 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos ); |
| 448 while (os && os != stop) { | 459 while (os && os != stop) { |
| 449 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) { | 460 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. | 461 // 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))); | 462 selRect.unite(selectionRectForRenderer(os)); |
| 452 RenderBlock* cb = os->containingBlock(); | 463 const RenderBlock* cb = os->containingBlock(); |
| 453 while (cb && !cb->isRenderView()) { | 464 while (cb && !cb->isRenderView()) { |
| 454 OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObj ects.add(cb, nullptr).storedValue->value; | 465 selRect.unite(selectionRectForRenderer(cb)); |
| 455 if (blockInfo) | 466 HashSet<const RenderBlock*>::AddResult addResult = visitedContai ningBlocks.add(cb); |
| 467 if (!addResult.isNewEntry) | |
| 456 break; | 468 break; |
| 457 blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb)); | |
| 458 cb = cb->containingBlock(); | 469 cb = cb->containingBlock(); |
| 459 } | 470 } |
| 460 } | 471 } |
| 461 | 472 |
| 462 os = os->nextInPreOrder(); | 473 os = os->nextInPreOrder(); |
| 463 } | 474 } |
| 464 | 475 |
| 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); | 476 return pixelSnappedIntRect(selRect); |
| 472 } | 477 } |
| 473 | 478 |
| 474 void RenderView::invalidatePaintForSelection() const | 479 void RenderView::invalidatePaintForSelection() const |
| 475 { | 480 { |
| 476 HashSet<RenderBlock*> processedBlocks; | 481 HashSet<RenderBlock*> processedBlocks; |
| 477 | 482 |
| 478 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ; | 483 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ; |
| 479 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) { | 484 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) { |
| 480 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd) | 485 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; | 873 return viewWidth(IncludeScrollbars) / scale; |
| 869 } | 874 } |
| 870 | 875 |
| 871 double RenderView::layoutViewportHeight() const | 876 double RenderView::layoutViewportHeight() const |
| 872 { | 877 { |
| 873 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 878 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
| 874 return viewHeight(IncludeScrollbars) / scale; | 879 return viewHeight(IncludeScrollbars) / scale; |
| 875 } | 880 } |
| 876 | 881 |
| 877 } // namespace blink | 882 } // namespace blink |
| OLD | NEW |