| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/editing/FrameCaret.h" | 26 #include "core/editing/FrameCaret.h" |
| 27 | 27 |
| 28 #include "core/dom/TaskRunnerHelper.h" | 28 #include "core/dom/TaskRunnerHelper.h" |
| 29 #include "core/editing/CaretDisplayItemClient.h" | 29 #include "core/editing/CaretDisplayItemClient.h" |
| 30 #include "core/editing/EditingUtilities.h" | 30 #include "core/editing/EditingUtilities.h" |
| 31 #include "core/editing/FrameSelection.h" |
| 31 #include "core/editing/SelectionEditor.h" | 32 #include "core/editing/SelectionEditor.h" |
| 32 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 33 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 34 #include "core/frame/Settings.h" | 35 #include "core/frame/Settings.h" |
| 35 #include "core/html/TextControlElement.h" | 36 #include "core/html/TextControlElement.h" |
| 36 #include "core/layout/LayoutBlock.h" | 37 #include "core/layout/LayoutBlock.h" |
| 37 #include "core/layout/LayoutTheme.h" | 38 #include "core/layout/LayoutTheme.h" |
| 38 #include "core/layout/api/LayoutPartItem.h" | 39 #include "core/layout/api/LayoutPartItem.h" |
| 39 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
| 40 #include "public/platform/WebTraceLocation.h" | 41 #include "public/platform/WebTraceLocation.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 return false; | 206 return false; |
| 206 | 207 |
| 207 Element* root = RootEditableElementOf(CaretPosition().GetPosition()); | 208 Element* root = RootEditableElementOf(CaretPosition().GetPosition()); |
| 208 if (!root) | 209 if (!root) |
| 209 return false; | 210 return false; |
| 210 | 211 |
| 211 Element* focused_element = root->GetDocument().FocusedElement(); | 212 Element* focused_element = root->GetDocument().FocusedElement(); |
| 212 if (!focused_element) | 213 if (!focused_element) |
| 213 return false; | 214 return false; |
| 214 | 215 |
| 215 return focused_element->IsShadowIncludingInclusiveAncestorOf( | 216 return frame_->Selection().SelectionHasFocus(); |
| 216 CaretPosition().AnchorNode()); | |
| 217 } | 217 } |
| 218 | 218 |
| 219 void FrameCaret::CaretBlinkTimerFired(TimerBase*) { | 219 void FrameCaret::CaretBlinkTimerFired(TimerBase*) { |
| 220 DCHECK_EQ(caret_visibility_, CaretVisibility::kVisible); | 220 DCHECK_EQ(caret_visibility_, CaretVisibility::kVisible); |
| 221 if (IsCaretBlinkingSuspended() && should_paint_caret_) | 221 if (IsCaretBlinkingSuspended() && should_paint_caret_) |
| 222 return; | 222 return; |
| 223 should_paint_caret_ = !should_paint_caret_; | 223 should_paint_caret_ = !should_paint_caret_; |
| 224 ScheduleVisualUpdateForPaintInvalidationIfNeeded(); | 224 ScheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void FrameCaret::ScheduleVisualUpdateForPaintInvalidationIfNeeded() { | 227 void FrameCaret::ScheduleVisualUpdateForPaintInvalidationIfNeeded() { |
| 228 if (FrameView* frame_view = frame_->View()) | 228 if (FrameView* frame_view = frame_->View()) |
| 229 frame_view->ScheduleVisualUpdateForPaintInvalidationIfNeeded(); | 229 frame_view->ScheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void FrameCaret::RecreateCaretBlinkTimerForTesting( | 232 void FrameCaret::RecreateCaretBlinkTimerForTesting( |
| 233 RefPtr<WebTaskRunner> task_runner) { | 233 RefPtr<WebTaskRunner> task_runner) { |
| 234 caret_blink_timer_.reset(new TaskRunnerTimer<FrameCaret>( | 234 caret_blink_timer_.reset(new TaskRunnerTimer<FrameCaret>( |
| 235 std::move(task_runner), this, &FrameCaret::CaretBlinkTimerFired)); | 235 std::move(task_runner), this, &FrameCaret::CaretBlinkTimerFired)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |