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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp

Issue 2900553005: Treat selection as focused if it contains focused element (Closed)
Patch Set: Mon May 22 18:52:27 PDT 2017 Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/FrameSelection.h" 5 #include "core/editing/FrameSelection.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 SelectionInDOMTree::Builder() 876 SelectionInDOMTree::Builder()
877 .SetBaseAndExtent(Position(start, 0), Position(end, 3)) 877 .SetBaseAndExtent(Position(start, 0), Position(end, 3))
878 .Build()); 878 .Build());
879 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange()); 879 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange());
880 EXPECT_TRUE(Selection().SelectionHasFocus()); 880 EXPECT_TRUE(Selection().SelectionHasFocus());
881 EXPECT_FALSE(Selection().IsHidden()); 881 EXPECT_FALSE(Selection().IsHidden());
882 882
883 Element* const alink = GetDocument().getElementById("alink"); 883 Element* const alink = GetDocument().getElementById("alink");
884 alink->focus(); 884 alink->focus();
885 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange()); 885 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange());
886 EXPECT_FALSE(Selection().SelectionHasFocus()); 886 EXPECT_TRUE(Selection().SelectionHasFocus());
887 EXPECT_FALSE(Selection().IsHidden()); // Range still visible. 887 EXPECT_FALSE(Selection().IsHidden()); // Range still visible.
888 } 888 }
889 889
890 // crbug.com/707143 890 // crbug.com/707143
891 TEST_F(FrameSelectionTest, RangeOutsideFocus) { 891 TEST_F(FrameSelectionTest, RangeOutsideFocus) {
892 // Here the selection sits on a sub tree that hasn't the focused element. 892 // Here the selection sits on a sub tree that hasn't the focused element.
893 // This test case is the reason why we separate FrameSelection::HasFocus() and 893 // This test case is the reason why we separate FrameSelection::HasFocus() and
894 // FrameSelection::IsHidden(). Even when the selection's DOM nodes are 894 // FrameSelection::IsHidden(). Even when the selection's DOM nodes are
895 // completely disconnected from the focused node, we still want the selection 895 // completely disconnected from the focused node, we still want the selection
896 // to be visible (not hidden). 896 // to be visible (not hidden).
(...skipping 25 matching lines...) Expand all
922 EXPECT_FALSE(Selection().IsHidden()); 922 EXPECT_FALSE(Selection().IsHidden());
923 923
924 Element* const alink = GetDocument().getElementById("alink"); 924 Element* const alink = GetDocument().getElementById("alink");
925 alink->focus(); 925 alink->focus();
926 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange()); 926 EXPECT_TRUE(Selection().GetSelectionInDOMTree().IsRange());
927 EXPECT_FALSE(Selection().SelectionHasFocus()); 927 EXPECT_FALSE(Selection().SelectionHasFocus());
928 EXPECT_FALSE(Selection().IsHidden()); // Range still visible. 928 EXPECT_FALSE(Selection().IsHidden()); // Range still visible.
929 } 929 }
930 930
931 } // namespace blink 931 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | third_party/WebKit/Source/core/editing/Position.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698