Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelection.h

Issue 1958093002: CONTINUED Make FrameSelection to hold non-canonicalized positions Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2017-01-16T20:04:35 Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/FrameSelection.h
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.h b/third_party/WebKit/Source/core/editing/FrameSelection.h
index d5caa1700b979a143af325a3edf338ab2c080ff1..f78632b4c29f32f61ad6867ecfeb5ea71125adea 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.h
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.h
@@ -29,8 +29,10 @@
#include "core/CoreExport.h"
#include "core/dom/Range.h"
+#include "core/dom/SynchronousMutationObserver.h"
#include "core/editing/EditingStyle.h"
#include "core/editing/EphemeralRange.h"
+#include "core/editing/SelectionTemplate.h"
#include "core/editing/VisiblePosition.h"
#include "core/editing/VisibleSelection.h"
#include "core/editing/iterators/TextIteratorFlags.h"
@@ -44,7 +46,6 @@
namespace blink {
-class CharacterData;
class DisplayItemClient;
class LayoutBlock;
class LocalFrame;
@@ -54,7 +55,6 @@ class GraphicsContext;
class HTMLFormElement;
class SelectionEditor;
class PendingSelection;
-class Text;
enum class CursorAlignOnScroll { IfNeeded, Always };
@@ -67,13 +67,13 @@ enum class SelectionDirectionalMode { NonDirectional, Directional };
enum class CaretVisibility;
class CORE_EXPORT FrameSelection final
- : public GarbageCollectedFinalized<FrameSelection> {
+ : public GarbageCollectedFinalized<FrameSelection>,
+ public SynchronousMutationObserver {
WTF_MAKE_NONCOPYABLE(FrameSelection);
+ USING_GARBAGE_COLLECTED_MIXIN(FrameSelection);
public:
- static FrameSelection* create(LocalFrame& frame) {
- return new FrameSelection(frame);
- }
+ static FrameSelection* create(LocalFrame&);
~FrameSelection();
enum EAlteration { AlterationMove, AlterationExtend };
@@ -84,6 +84,7 @@ class CORE_EXPORT FrameSelection final
DoNotSetFocus = 1 << 3,
DoNotUpdateAppearance = 1 << 4,
DoNotClearStrategy = 1 << 5,
+ // TODO(yosin): We should get rid of |DoNotAdjustInFlatTree|.
DoNotAdjustInFlatTree = 1 << 6,
};
// Union of values in SetSelectionOption and EUserTriggered
@@ -93,10 +94,8 @@ class CORE_EXPORT FrameSelection final
return static_cast<EUserTriggered>(options & UserTriggered);
}
- bool isAvailable() const { return m_document; }
- // You should not call |document()| when |!isAvailable()|.
- const Document& document() const;
- Document& document();
+ bool isAvailable() const { return lifecycleContext(); }
+ Document& document() const;
LocalFrame* frame() const { return m_frame; }
Element* rootEditableElement() const {
return selection().rootEditableElement();
@@ -113,8 +112,8 @@ class CORE_EXPORT FrameSelection final
// An implementation of |WebFrame::moveCaretSelection()|
void moveCaretSelection(const IntPoint&);
- template <typename Strategy>
- const VisibleSelectionTemplate<Strategy>& visibleSelection() const;
+ const VisibleSelection& computeVisibleSelectionInDOMTree() const;
+ const VisibleSelectionInFlatTree& computeVisibleSelectionInFlatTree() const;
const VisibleSelection& selection() const;
@@ -128,18 +127,22 @@ class CORE_EXPORT FrameSelection final
CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded,
TextGranularity = CharacterGranularity);
- // TODO(yosin): We should use |SelectionInDOMTree| version instead of
- // |VisibleSelection| version.
+ // TODO(yosin): Get rid of |granularity| parameter from |setSelection()|.
void setSelection(const VisibleSelection&,
SetSelectionOptions = CloseTyping | ClearTypingStyle,
CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded,
TextGranularity = CharacterGranularity);
- // TODO(yosin): We should use |SelectionInFlatTree| version instead of
- // |VisibleSelectionInFlatTree| version.
void setSelection(const VisibleSelectionInFlatTree&,
SetSelectionOptions = CloseTyping | ClearTypingStyle,
CursorAlignOnScroll = CursorAlignOnScroll::IfNeeded,
TextGranularity = CharacterGranularity);
+ // TODO(yosin) We should get rid of |Range| version of |setSelectedRagne()|
+ // for Oilpan.
+ bool setSelectedRange(
+ Range*,
+ TextAffinity,
+ SelectionDirectionalMode = SelectionDirectionalMode::NonDirectional,
+ SetSelectionOptions = CloseTyping | ClearTypingStyle);
bool setSelectedRange(
const EphemeralRange&,
TextAffinity,
@@ -176,6 +179,7 @@ class CORE_EXPORT FrameSelection final
const VisiblePosition& extent,
TextGranularity);
+ // TODO(yosin): We should use |selection().granularity()|.
TextGranularity granularity() const { return m_granularity; }
Position base() const { return selection().base(); }
@@ -192,28 +196,23 @@ class CORE_EXPORT FrameSelection final
void didChangeFocus();
+ const SelectionInDOMTree& selectionInDOMTree() const;
+ // TODO(yosin): We should rename |isNone()| to |isVisibleNone()|.
bool isNone() const { return selection().isNone(); }
bool isCaret() const { return selection().isCaret(); }
bool isRange() const { return selection().isRange(); }
bool isInPasswordField() const;
- bool isDirectional() const { return selection().isDirectional(); }
+ bool isDirectional() const { return selectionInDOMTree().isDirectional(); }
// If this FrameSelection has a logical range which is still valid, this
// function return its clone. Otherwise, the return value from underlying
// VisibleSelection's firstRange() is returned.
Range* firstRange() const;
+ // Called after layout finished.
+ void didLayout();
+
void documentAttached(Document*);
- void documentDetached(const Document&);
- void nodeChildrenWillBeRemoved(ContainerNode&);
- void nodeWillBeRemoved(Node&);
- void dataWillChange(const CharacterData& node);
- void didUpdateCharacterData(CharacterData*,
- unsigned offset,
- unsigned oldLength,
- unsigned newLength);
- void didMergeTextNodes(const Text& oldNode, unsigned offset);
- void didSplitTextNode(const Text& oldNode);
bool isAppearanceDirty() const;
void commitAppearanceIfNeeded(LayoutView&);
@@ -283,7 +282,6 @@ class CORE_EXPORT FrameSelection final
private:
friend class FrameSelectionTest;
friend class PaintControllerPaintTestForSlimmingPaintV1AndV2;
- friend class SelectionControllerTest;
FRIEND_TEST_ALL_PREFIXES(PaintControllerPaintTestForSlimmingPaintV1AndV2,
FullDocumentPaintingWithCaret);
@@ -292,16 +290,6 @@ class CORE_EXPORT FrameSelection final
// For |PaintControllerPaintTestForSlimmingPaintV1AndV2|.
const DisplayItemClient& caretDisplayItemClientForTesting() const;
- // Note: We have |selectionInFlatTree()| for unit tests, we should
- // use |visibleSelection<EditingInFlatTreeStrategy>()|.
- const VisibleSelectionInFlatTree& selectionInFlatTree() const;
-
- template <typename Strategy>
- void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&,
- SetSelectionOptions,
- CursorAlignOnScroll,
- TextGranularity);
-
void respondToNodeModification(Node&,
bool baseRemoved,
bool extentRemoved,
@@ -321,13 +309,21 @@ class CORE_EXPORT FrameSelection final
const Position& start,
const Position& end);
+ template <typename Strategy>
+ VisibleSelectionTemplate<Strategy> validateSelection(
+ const VisibleSelectionTemplate<Strategy>&);
+
GranularityStrategy* granularityStrategy();
+ // Implementation of |SynchronousMutationObserver| member functions.
+ void contextDestroyed(Document*) final;
+ void nodeChildrenWillBeRemoved(ContainerNode&) final;
+ void nodeWillBeRemoved(Node&) final;
+
// For unittests
bool shouldPaintCaretForTesting() const;
bool isPreviousCaretDirtyForTesting() const;
- Member<Document> m_document;
Member<LocalFrame> m_frame;
const Member<PendingSelection> m_pendingSelection;
const Member<SelectionEditor> m_selectionEditor;
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameCaret.cpp ('k') | third_party/WebKit/Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698