| OLD | NEW | 
|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/LayoutSelection.h" | 5 #include "core/editing/LayoutSelection.h" | 
| 6 | 6 | 
| 7 #include "bindings/core/v8/V8BindingForCore.h" | 7 #include "bindings/core/v8/V8BindingForCore.h" | 
| 8 #include "core/dom/ShadowRootInit.h" | 8 #include "core/dom/ShadowRootInit.h" | 
| 9 #include "core/editing/EditingTestBase.h" | 9 #include "core/editing/EditingTestBase.h" | 
| 10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55     return false; | 55     return false; | 
| 56   if (object->GetSelectionState() != state) | 56   if (object->GetSelectionState() != state) | 
| 57     return false; | 57     return false; | 
| 58   if (object->ShouldInvalidateSelection() != | 58   if (object->ShouldInvalidateSelection() != | 
| 59       (invalidate == InvalidateOption::ShouldInvalidate)) | 59       (invalidate == InvalidateOption::ShouldInvalidate)) | 
| 60     return false; | 60     return false; | 
| 61   return true; | 61   return true; | 
| 62 } | 62 } | 
| 63 | 63 | 
| 64 using IsTypeOf = Function<bool(const LayoutObject& layout_object)>; | 64 using IsTypeOf = Function<bool(const LayoutObject& layout_object)>; | 
|  | 65 #if 0 | 
| 65 #define USING_LAYOUTOBJECT_FUNC(member_func)                               \ | 66 #define USING_LAYOUTOBJECT_FUNC(member_func)                               \ | 
| 66   IsTypeOf member_func = WTF::Bind([](const LayoutObject& layout_object) { \ | 67   IsTypeOf member_func = WTF::Bind([](const LayoutObject& layout_object) { \ | 
| 67     return layout_object.member_func();                                    \ | 68     return layout_object.member_func();                                    \ | 
| 68   }) | 69   }) | 
|  | 70 #else | 
|  | 71 using IsTypeOfSimple = bool(const LayoutObject& layout_object); | 
|  | 72 #define USING_LAYOUTOBJECT_FUNC(member_func)                               \ | 
|  | 73   bool member_func(const LayoutObject& layout_object) { \ | 
|  | 74     return layout_object.member_func();                                    \ | 
|  | 75   } | 
|  | 76 #endif // 0 | 
| 69 | 77 | 
| 70 USING_LAYOUTOBJECT_FUNC(IsLayoutBlock); | 78 USING_LAYOUTOBJECT_FUNC(IsLayoutBlock); | 
| 71 USING_LAYOUTOBJECT_FUNC(IsLayoutBlockFlow); | 79 USING_LAYOUTOBJECT_FUNC(IsLayoutBlockFlow); | 
| 72 USING_LAYOUTOBJECT_FUNC(IsLayoutInline); | 80 USING_LAYOUTOBJECT_FUNC(IsLayoutInline); | 
| 73 USING_LAYOUTOBJECT_FUNC(IsBR); | 81 USING_LAYOUTOBJECT_FUNC(IsBR); | 
| 74 USING_LAYOUTOBJECT_FUNC(IsListItem); | 82 USING_LAYOUTOBJECT_FUNC(IsListItem); | 
| 75 USING_LAYOUTOBJECT_FUNC(IsListMarker); | 83 USING_LAYOUTOBJECT_FUNC(IsListMarker); | 
| 76 | 84 | 
| 77 static IsTypeOf IsLayoutTextFragmentOf(const String& text) { | 85 static IsTypeOf IsLayoutTextFragmentOf(const String& text) { | 
| 78   return WTF::Bind( | 86   return WTF::Bind( | 
| 79       [](const String& text, const LayoutObject& object) { | 87       [](const String& text, const LayoutObject& object) { | 
| 80         if (!object.IsText()) | 88         if (!object.IsText()) | 
| 81           return false; | 89           return false; | 
| 82         if (text != ToLayoutText(object).GetText()) | 90         if (text != ToLayoutText(object).GetText()) | 
| 83           return false; | 91           return false; | 
| 84         return ToLayoutText(object).IsTextFragment(); | 92         return ToLayoutText(object).IsTextFragment(); | 
| 85       }, | 93       }, | 
| 86       text); | 94       text); | 
| 87 } | 95 } | 
| 88 | 96 | 
| 89 static bool TestLayoutObject(LayoutObject* object, | 97 static bool TestLayoutObject(LayoutObject* object, | 
|  | 98                              IsTypeOfSimple& predicate, | 
|  | 99                              SelectionState state, | 
|  | 100                              InvalidateOption invalidate) { | 
|  | 101   if (!TestLayoutObjectState(object, state, invalidate)) | 
|  | 102     return false; | 
|  | 103 | 
|  | 104   if (!predicate(*object)) | 
|  | 105     return false; | 
|  | 106   return true; | 
|  | 107 } | 
|  | 108 static bool TestLayoutObject(LayoutObject* object, | 
| 90                              const IsTypeOf& predicate, | 109                              const IsTypeOf& predicate, | 
| 91                              SelectionState state, | 110                              SelectionState state, | 
| 92                              InvalidateOption invalidate) { | 111                              InvalidateOption invalidate) { | 
| 93   if (!TestLayoutObjectState(object, state, invalidate)) | 112   if (!TestLayoutObjectState(object, state, invalidate)) | 
| 94     return false; | 113     return false; | 
| 95 | 114 | 
| 96   if (!predicate(*object)) | 115   if (!predicate(*object)) | 
| 97     return false; | 116     return false; | 
| 98   return true; | 117   return true; | 
| 99 } | 118 } | 
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 387       ToElement(GetDocument().QuerySelector("#host")->firstChild()); | 406       ToElement(GetDocument().QuerySelector("#host")->firstChild()); | 
| 388   DCHECK(span); | 407   DCHECK(span); | 
| 389   Node* const baz = GetDocument().body()->firstChild()->nextSibling(); | 408   Node* const baz = GetDocument().body()->firstChild()->nextSibling(); | 
| 390   DCHECK(baz); | 409   DCHECK(baz); | 
| 391   Selection().SetSelection(SelectionInDOMTree::Builder() | 410   Selection().SetSelection(SelectionInDOMTree::Builder() | 
| 392                                .SetBaseAndExtent({baz, 1}, {span, 0}) | 411                                .SetBaseAndExtent({baz, 1}, {span, 0}) | 
| 393                                .Build()); | 412                                .Build()); | 
| 394   Selection().CommitAppearanceIfNeeded(); | 413   Selection().CommitAppearanceIfNeeded(); | 
| 395 } | 414 } | 
| 396 }  // namespace blink | 415 }  // namespace blink | 
| OLD | NEW | 
|---|