| 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) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
| 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 14 matching lines...) Expand all Loading... |
| 25 #include "core/editing/Position.h" | 25 #include "core/editing/Position.h" |
| 26 #include "core/editing/VisibleSelection.h" | 26 #include "core/editing/VisibleSelection.h" |
| 27 #include "platform/heap/Handle.h" | 27 #include "platform/heap/Handle.h" |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 | 30 |
| 31 class FrameSelection; | 31 class FrameSelection; |
| 32 | 32 |
| 33 class LayoutSelection final : public GarbageCollected<LayoutSelection> { | 33 class LayoutSelection final : public GarbageCollected<LayoutSelection> { |
| 34 public: | 34 public: |
| 35 enum class PaintHint { kHide, kKeep, kPaint }; | |
| 36 | |
| 37 static LayoutSelection* Create(FrameSelection& frame_selection) { | 35 static LayoutSelection* Create(FrameSelection& frame_selection) { |
| 38 return new LayoutSelection(frame_selection); | 36 return new LayoutSelection(frame_selection); |
| 39 } | 37 } |
| 40 | 38 |
| 41 bool HasPendingSelection() const { return has_pending_selection_; } | 39 bool HasPendingSelection() const { return has_pending_selection_; } |
| 42 void SetHasPendingSelection(PaintHint); | 40 void SetHasPendingSelection() { has_pending_selection_ = true; } |
| 43 void Commit(); | 41 void Commit(); |
| 44 | 42 |
| 45 IntRect SelectionBounds(); | 43 IntRect SelectionBounds(); |
| 46 void InvalidatePaintForSelection(); | 44 void InvalidatePaintForSelection(); |
| 47 enum SelectionPaintInvalidationMode { | 45 enum SelectionPaintInvalidationMode { |
| 48 kPaintInvalidationNewXOROld, | 46 kPaintInvalidationNewXOROld, |
| 49 kPaintInvalidationNewMinusOld | 47 kPaintInvalidationNewMinusOld |
| 50 }; | 48 }; |
| 51 void SetSelection( | 49 void SetSelection( |
| 52 LayoutObject* start, | 50 LayoutObject* start, |
| 53 int start_pos, | 51 int start_pos, |
| 54 LayoutObject*, | 52 LayoutObject*, |
| 55 int end_pos, | 53 int end_pos, |
| 56 SelectionPaintInvalidationMode = kPaintInvalidationNewXOROld); | 54 SelectionPaintInvalidationMode = kPaintInvalidationNewXOROld); |
| 57 void ClearSelection(); | 55 void ClearSelection(); |
| 58 std::pair<int, int> SelectionStartEnd(); | 56 std::pair<int, int> SelectionStartEnd(); |
| 59 void OnDocumentShutdown(); | 57 void OnDocumentShutdown(); |
| 60 | 58 |
| 61 DECLARE_TRACE(); | 59 DECLARE_TRACE(); |
| 62 | 60 |
| 63 private: | 61 private: |
| 64 LayoutSelection(FrameSelection&); | 62 LayoutSelection(FrameSelection&); |
| 65 | 63 |
| 66 SelectionInFlatTree CalcVisibleSelection( | 64 SelectionInFlatTree CalcVisibleSelection( |
| 67 const VisibleSelectionInFlatTree&) const; | 65 const VisibleSelectionInFlatTree&) const; |
| 68 | 66 |
| 69 Member<FrameSelection> frame_selection_; | 67 Member<FrameSelection> frame_selection_; |
| 70 bool has_pending_selection_ : 1; | 68 bool has_pending_selection_ : 1; |
| 71 bool force_hide_ : 1; | |
| 72 | 69 |
| 73 // The current selection represented as 2 boundaries. | 70 // The current selection represented as 2 boundaries. |
| 74 // Selection boundaries are represented in LayoutView by a tuple | 71 // Selection boundaries are represented in LayoutView by a tuple |
| 75 // (LayoutObject, DOM node offset). | 72 // (LayoutObject, DOM node offset). |
| 76 // See http://www.w3.org/TR/dom/#range for more information. | 73 // See http://www.w3.org/TR/dom/#range for more information. |
| 77 // | 74 // |
| 78 // |m_selectionStartPos| and |m_selectionEndPos| are only valid for | 75 // |m_selectionStartPos| and |m_selectionEndPos| are only valid for |
| 79 // |Text| node without 'transform' or 'first-letter'. | 76 // |Text| node without 'transform' or 'first-letter'. |
| 80 // | 77 // |
| 81 // Those are used for selection painting and paint invalidation upon | 78 // Those are used for selection painting and paint invalidation upon |
| 82 // selection change. | 79 // selection change. |
| 83 LayoutObject* selection_start_; | 80 LayoutObject* selection_start_; |
| 84 LayoutObject* selection_end_; | 81 LayoutObject* selection_end_; |
| 85 | 82 |
| 86 // TODO(yosin): Clarify the meaning of these variables. editing/ passes | 83 // TODO(yosin): Clarify the meaning of these variables. editing/ passes |
| 87 // them as offsets in the DOM tree but layout uses them as offset in the | 84 // them as offsets in the DOM tree but layout uses them as offset in the |
| 88 // layout tree. | 85 // layout tree. |
| 89 int selection_start_pos_; | 86 int selection_start_pos_; |
| 90 int selection_end_pos_; | 87 int selection_end_pos_; |
| 91 }; | 88 }; |
| 92 | 89 |
| 93 } // namespace blink | 90 } // namespace blink |
| 94 | 91 |
| 95 #endif | 92 #endif |
| OLD | NEW |