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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 501 |
502 static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset
) | 502 static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset
) |
503 { | 503 { |
504 if (!object) | 504 if (!object) |
505 return 0; | 505 return 0; |
506 | 506 |
507 RenderObject* child = object->childAt(offset); | 507 RenderObject* child = object->childAt(offset); |
508 return child ? child : object->nextInPreOrderAfterChildren(); | 508 return child ? child : object->nextInPreOrderAfterChildren(); |
509 } | 509 } |
510 | 510 |
511 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const | 511 IntRect RenderView::selectionBounds() const |
512 { | 512 { |
513 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMemb
er<RenderSelectionInfo> > SelectionMap; | 513 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMemb
er<RenderSelectionInfo> > SelectionMap; |
514 SelectionMap selectedObjects; | 514 SelectionMap selectedObjects; |
515 | 515 |
516 RenderObject* os = m_selectionStart; | 516 RenderObject* os = m_selectionStart; |
517 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 517 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
518 while (os && os != stop) { | 518 while (os && os != stop) { |
519 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 519 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
520 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. | 520 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. |
521 selectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(o
s, clipToVisibleContent))); | 521 selectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(o
s))); |
522 RenderBlock* cb = os->containingBlock(); | 522 RenderBlock* cb = os->containingBlock(); |
523 while (cb && !cb->isRenderView()) { | 523 while (cb && !cb->isRenderView()) { |
524 OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObj
ects.add(cb, nullptr).storedValue->value; | 524 OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObj
ects.add(cb, nullptr).storedValue->value; |
525 if (blockInfo) | 525 if (blockInfo) |
526 break; | 526 break; |
527 blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb, clipT
oVisibleContent)); | 527 blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb)); |
528 cb = cb->containingBlock(); | 528 cb = cb->containingBlock(); |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 os = os->nextInPreOrder(); | 532 os = os->nextInPreOrder(); |
533 } | 533 } |
534 | 534 |
535 // Now create a single bounding box rect that encloses the whole selection. | 535 // Now create a single bounding box rect that encloses the whole selection. |
536 LayoutRect selRect; | 536 LayoutRect selRect; |
537 SelectionMap::iterator end = selectedObjects.end(); | 537 SelectionMap::iterator end = selectedObjects.end(); |
(...skipping 18 matching lines...) Expand all Loading... |
556 // FIXME: this may be wrong. crbug.com/407416 | 556 // FIXME: this may be wrong. crbug.com/407416 |
557 DisableCompositingQueryAsserts disabler; | 557 DisableCompositingQueryAsserts disabler; |
558 | 558 |
559 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos)
; | 559 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos)
; |
560 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde
r()) { | 560 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde
r()) { |
561 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio
nEnd) | 561 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio
nEnd) |
562 continue; | 562 continue; |
563 if (o->selectionState() == SelectionNone) | 563 if (o->selectionState() == SelectionNone) |
564 continue; | 564 continue; |
565 | 565 |
566 RenderSelectionInfo(o, true).invalidatePaint(); | 566 RenderSelectionInfo(o).invalidatePaint(); |
567 | 567 |
568 // Blocks are responsible for painting line gaps and margin gaps. They m
ust be examined as well. | 568 // Blocks are responsible for painting line gaps and margin gaps. They m
ust be examined as well. |
569 for (RenderBlock* block = o->containingBlock(); block && !block->isRende
rView(); block = block->containingBlock()) { | 569 for (RenderBlock* block = o->containingBlock(); block && !block->isRende
rView(); block = block->containingBlock()) { |
570 if (!processedBlocks.add(block).isNewEntry) | 570 if (!processedBlocks.add(block).isNewEntry) |
571 break; | 571 break; |
572 RenderSelectionInfo(block, true).invalidatePaint(); | 572 RenderSelectionInfo(block).invalidatePaint(); |
573 } | 573 } |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 // When exploring the RenderTree looking for the nodes involved in the Selection
, sometimes it's | 577 // When exploring the RenderTree looking for the nodes involved in the Selection
, sometimes it's |
578 // required to change the traversing direction because the "start" position is b
elow the "end" one. | 578 // required to change the traversing direction because the "start" position is b
elow the "end" one. |
579 static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const Rend
erObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringB
ackwards) | 579 static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const Rend
erObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringB
ackwards) |
580 { | 580 { |
581 RenderObject* next; | 581 RenderObject* next; |
582 if (exploringBackwards) { | 582 if (exploringBackwards) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 SelectedBlockMap oldSelectedBlocks; | 629 SelectedBlockMap oldSelectedBlocks; |
630 SelectedBlockMap newSelectedBlocks; | 630 SelectedBlockMap newSelectedBlocks; |
631 | 631 |
632 RenderObject* os = m_selectionStart; | 632 RenderObject* os = m_selectionStart; |
633 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 633 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
634 bool exploringBackwards = false; | 634 bool exploringBackwards = false; |
635 bool continueExploring = os && (os != stop); | 635 bool continueExploring = os && (os != stop); |
636 while (continueExploring) { | 636 while (continueExploring) { |
637 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 637 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
638 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. | 638 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. |
639 oldSelectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInf
o(os, true))); | 639 oldSelectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInf
o(os))); |
640 if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { | 640 if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { |
641 RenderBlock* cb = os->containingBlock(); | 641 RenderBlock* cb = os->containingBlock(); |
642 while (cb && !cb->isRenderView()) { | 642 while (cb && !cb->isRenderView()) { |
643 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = ol
dSelectedBlocks.add(cb, nullptr).storedValue->value; | 643 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = ol
dSelectedBlocks.add(cb, nullptr).storedValue->value; |
644 if (blockInfo) | 644 if (blockInfo) |
645 break; | 645 break; |
646 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(
cb)); | 646 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(
cb)); |
647 cb = cb->containingBlock(); | 647 cb = cb->containingBlock(); |
648 } | 648 } |
649 } | 649 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 if (blockPaintInvalidationMode != PaintInvalidationNothing) | 685 if (blockPaintInvalidationMode != PaintInvalidationNothing) |
686 layer()->clearBlockSelectionGapsBounds(); | 686 layer()->clearBlockSelectionGapsBounds(); |
687 | 687 |
688 // Now that the selection state has been updated for the new objects, walk t
hem again and | 688 // Now that the selection state has been updated for the new objects, walk t
hem again and |
689 // put them in the new objects list. | 689 // put them in the new objects list. |
690 o = start; | 690 o = start; |
691 exploringBackwards = false; | 691 exploringBackwards = false; |
692 continueExploring = o && (o != stop); | 692 continueExploring = o && (o != stop); |
693 while (continueExploring) { | 693 while (continueExploring) { |
694 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { | 694 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { |
695 newSelectedObjects.set(o, adoptPtrWillBeNoop(new RenderSelectionInfo
(o, true))); | 695 newSelectedObjects.set(o, adoptPtrWillBeNoop(new RenderSelectionInfo
(o))); |
696 RenderBlock* cb = o->containingBlock(); | 696 RenderBlock* cb = o->containingBlock(); |
697 while (cb && !cb->isRenderView()) { | 697 while (cb && !cb->isRenderView()) { |
698 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = newSel
ectedBlocks.add(cb, nullptr).storedValue->value; | 698 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = newSel
ectedBlocks.add(cb, nullptr).storedValue->value; |
699 if (blockInfo) | 699 if (blockInfo) |
700 break; | 700 break; |
701 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(cb))
; | 701 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(cb))
; |
702 cb = cb->containingBlock(); | 702 cb = cb->containingBlock(); |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 return viewWidth(IncludeScrollbars) / scale; | 966 return viewWidth(IncludeScrollbars) / scale; |
967 } | 967 } |
968 | 968 |
969 double RenderView::layoutViewportHeight() const | 969 double RenderView::layoutViewportHeight() const |
970 { | 970 { |
971 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 971 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
972 return viewHeight(IncludeScrollbars) / scale; | 972 return viewHeight(IncludeScrollbars) / scale; |
973 } | 973 } |
974 | 974 |
975 } // namespace blink | 975 } // namespace blink |
OLD | NEW |