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

Side by Side Diff: sky/engine/core/editing/EditorCommand.cpp

Issue 879993004: Remove ScrollableArea and Scrollbar (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/core/dom/Element.cpp ('k') | sky/engine/core/frame/FrameView.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2009 Igalia S.L. 4 * Copyright (C) 2009 Igalia S.L.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "sky/engine/core/editing/htmlediting.h" 42 #include "sky/engine/core/editing/htmlediting.h"
43 #include "sky/engine/core/events/Event.h" 43 #include "sky/engine/core/events/Event.h"
44 #include "sky/engine/core/frame/FrameHost.h" 44 #include "sky/engine/core/frame/FrameHost.h"
45 #include "sky/engine/core/frame/FrameView.h" 45 #include "sky/engine/core/frame/FrameView.h"
46 #include "sky/engine/core/frame/LocalFrame.h" 46 #include "sky/engine/core/frame/LocalFrame.h"
47 #include "sky/engine/core/frame/Settings.h" 47 #include "sky/engine/core/frame/Settings.h"
48 #include "sky/engine/core/html/HTMLImageElement.h" 48 #include "sky/engine/core/html/HTMLImageElement.h"
49 #include "sky/engine/core/page/EditorClient.h" 49 #include "sky/engine/core/page/EditorClient.h"
50 #include "sky/engine/core/page/EventHandler.h" 50 #include "sky/engine/core/page/EventHandler.h"
51 #include "sky/engine/core/rendering/RenderBox.h" 51 #include "sky/engine/core/rendering/RenderBox.h"
52 #include "sky/engine/platform/scroll/Scrollbar.h"
53 #include "sky/engine/public/platform/Platform.h" 52 #include "sky/engine/public/platform/Platform.h"
54 #include "sky/engine/wtf/text/AtomicString.h" 53 #include "sky/engine/wtf/text/AtomicString.h"
55 54
56 namespace blink { 55 namespace blink {
57 56
58 class EditorInternalCommand { 57 class EditorInternalCommand {
59 public: 58 public:
60 int idForUserMetrics; 59 int idForUserMetrics;
61 bool (*execute)(LocalFrame&, Event*, EditorCommandSource, const String&); 60 bool (*execute)(LocalFrame&, Event*, EditorCommandSource, const String&);
62 bool (*isSupportedFromDOM)(LocalFrame*); 61 bool (*isSupportedFromDOM)(LocalFrame*);
63 bool (*isEnabled)(LocalFrame&, Event*, EditorCommandSource); 62 bool (*isEnabled)(LocalFrame&, Event*, EditorCommandSource);
64 TriState (*state)(LocalFrame&, Event*); 63 TriState (*state)(LocalFrame&, Event*);
65 String (*value)(LocalFrame&, Event*); 64 String (*value)(LocalFrame&, Event*);
66 bool isTextInsertion; 65 bool isTextInsertion;
67 bool allowExecutionWhenDisabled; 66 bool allowExecutionWhenDisabled;
68 }; 67 };
69 68
70 typedef HashMap<String, const EditorInternalCommand*, CaseFoldingHash> CommandMa p; 69 typedef HashMap<String, const EditorInternalCommand*, CaseFoldingHash> CommandMa p;
71 70
72 static const bool notTextInsertion = false; 71 static const bool notTextInsertion = false;
73 static const bool isTextInsertion = true; 72 static const bool isTextInsertion = true;
74 73
75 static const bool allowExecutionWhenDisabled = true; 74 static const bool allowExecutionWhenDisabled = true;
76 static const bool doNotAllowExecutionWhenDisabled = false; 75 static const bool doNotAllowExecutionWhenDisabled = false;
77 76
77 static const float kMinFractionToStepWhenPaging = 0.875f;
78
78 // Related to Editor::selectionForCommand. 79 // Related to Editor::selectionForCommand.
79 // Certain operations continue to use the target control's selection even if the event handler 80 // Certain operations continue to use the target control's selection even if the event handler
80 // already moved the selection outside of the text control. 81 // already moved the selection outside of the text control.
81 static LocalFrame* targetFrame(LocalFrame& frame, Event* event) 82 static LocalFrame* targetFrame(LocalFrame& frame, Event* event)
82 { 83 {
83 if (!event) 84 if (!event)
84 return &frame; 85 return &frame;
85 Node* node = event->target()->toNode(); 86 Node* node = event->target()->toNode();
86 if (!node) 87 if (!node)
87 return &frame; 88 return &frame;
88 return node->document().frame(); 89 return node->document().frame();
89 } 90 }
90 91
91 static unsigned verticalScrollDistance(LocalFrame& frame) 92 static unsigned verticalScrollDistance(LocalFrame& frame)
92 { 93 {
93 Element* focusedElement = frame.document()->focusedElement(); 94 Element* focusedElement = frame.document()->focusedElement();
94 if (!focusedElement) 95 if (!focusedElement)
95 return 0; 96 return 0;
96 RenderObject* renderer = focusedElement->renderer(); 97 RenderObject* renderer = focusedElement->renderer();
97 if (!renderer || !renderer->isBox()) 98 if (!renderer || !renderer->isBox())
98 return 0; 99 return 0;
99 RenderBox& renderBox = toRenderBox(*renderer); 100 RenderBox& renderBox = toRenderBox(*renderer);
100 RenderStyle* style = renderBox.style(); 101 RenderStyle* style = renderBox.style();
101 if (!style) 102 if (!style)
102 return 0; 103 return 0;
103 if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focuse dElement->hasEditableStyle())) 104 if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focuse dElement->hasEditableStyle()))
104 return 0; 105 return 0;
105 int height = std::min<int>(renderBox.clientHeight(), 106 int height = std::min<int>(renderBox.clientHeight(),
106 frame.view()->height()); 107 frame.view()->height());
107 return static_cast<unsigned>(max(max<int>(height * ScrollableArea::minFracti onToStepWhenPaging(), height - ScrollableArea::maxOverlapBetweenPages()), 1)); 108 return static_cast<unsigned>(max<int>(height * kMinFractionToStepWhenPaging, 1));
108 } 109 }
109 110
110 static bool executeCopy(LocalFrame& frame, Event*, EditorCommandSource, const St ring&) 111 static bool executeCopy(LocalFrame& frame, Event*, EditorCommandSource, const St ring&)
111 { 112 {
112 frame.editor().copy(); 113 frame.editor().copy();
113 return true; 114 return true;
114 } 115 }
115 116
116 static bool executeCut(LocalFrame& frame, Event*, EditorCommandSource, const Str ing&) 117 static bool executeCut(LocalFrame& frame, Event*, EditorCommandSource, const Str ing&)
117 { 118 {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 { 647 {
647 return m_command && m_command->isTextInsertion; 648 return m_command && m_command->isTextInsertion;
648 } 649 }
649 650
650 int Editor::Command::idForHistogram() const 651 int Editor::Command::idForHistogram() const
651 { 652 {
652 return isSupported() ? m_command->idForUserMetrics : 0; 653 return isSupported() ? m_command->idForUserMetrics : 0;
653 } 654 }
654 655
655 } // namespace blink 656 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Element.cpp ('k') | sky/engine/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698