| OLD | NEW |
| 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 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 } | 2044 } |
| 2045 | 2045 |
| 2046 static bool EnabledCut(LocalFrame& frame, Event*, EditorCommandSource source) { | 2046 static bool EnabledCut(LocalFrame& frame, Event*, EditorCommandSource source) { |
| 2047 if (!CanWriteClipboard(frame, source)) | 2047 if (!CanWriteClipboard(frame, source)) |
| 2048 return false; | 2048 return false; |
| 2049 return frame.GetEditor().CanDHTMLCut() || frame.GetEditor().CanCut(); | 2049 return frame.GetEditor().CanDHTMLCut() || frame.GetEditor().CanCut(); |
| 2050 } | 2050 } |
| 2051 | 2051 |
| 2052 static bool EnabledInEditableText(LocalFrame& frame, | 2052 static bool EnabledInEditableText(LocalFrame& frame, |
| 2053 Event* event, | 2053 Event* event, |
| 2054 EditorCommandSource) { | 2054 EditorCommandSource source) { |
| 2055 frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 2055 frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 2056 return frame.GetEditor().SelectionForCommand(event).RootEditableElement(); | 2056 return frame.GetEditor().SelectionForCommand(event).RootEditableElement(); |
| 2057 } | 2057 } |
| 2058 | 2058 |
| 2059 static bool EnabledDelete(LocalFrame& frame, | 2059 static bool EnabledDelete(LocalFrame& frame, |
| 2060 Event* event, | 2060 Event* event, |
| 2061 EditorCommandSource source) { | 2061 EditorCommandSource source) { |
| 2062 switch (source) { | 2062 switch (source) { |
| 2063 case kCommandFromMenuOrKeyBinding: | 2063 case kCommandFromMenuOrKeyBinding: |
| 2064 return frame.GetEditor().CanDelete(); | 2064 return frame.GetEditor().CanDelete(); |
| 2065 case kCommandFromDOM: | 2065 case kCommandFromDOM: |
| 2066 // "Delete" from DOM is like delete/backspace keypress, affects selected | 2066 // "Delete" from DOM is like delete/backspace keypress, affects selected |
| 2067 // range if non-empty, otherwise removes a character | 2067 // range if non-empty, otherwise removes a character |
| 2068 return EnabledInEditableText(frame, event, source); | 2068 return EnabledInEditableText(frame, event, source); |
| 2069 } | 2069 } |
| 2070 NOTREACHED(); | 2070 NOTREACHED(); |
| 2071 return false; | 2071 return false; |
| 2072 } | 2072 } |
| 2073 | 2073 |
| 2074 static bool EnabledInRichlyEditableText(LocalFrame& frame, | 2074 static bool EnabledInRichlyEditableText(LocalFrame& frame, |
| 2075 Event*, | 2075 Event*, |
| 2076 EditorCommandSource) { | 2076 EditorCommandSource source) { |
| 2077 frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 2077 frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 2078 if (source == kCommandFromMenuOrKeyBinding && |
| 2079 !frame.Selection().SelectionHasFocus()) |
| 2080 return false; |
| 2078 return !frame.Selection() | 2081 return !frame.Selection() |
| 2079 .ComputeVisibleSelectionInDOMTreeDeprecated() | 2082 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 2080 .IsNone() && | 2083 .IsNone() && |
| 2081 frame.Selection() | 2084 frame.Selection() |
| 2082 .ComputeVisibleSelectionInDOMTreeDeprecated() | 2085 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 2083 .IsContentRichlyEditable() && | 2086 .IsContentRichlyEditable() && |
| 2084 frame.Selection() | 2087 frame.Selection() |
| 2085 .ComputeVisibleSelectionInDOMTreeDeprecated() | 2088 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 2086 .RootEditableElement(); | 2089 .RootEditableElement(); |
| 2087 } | 2090 } |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2977 *frame_, kDirectionBackward, kWordGranularity); | 2980 *frame_, kDirectionBackward, kWordGranularity); |
| 2978 case WebEditingCommandType::kDeleteWordForward: | 2981 case WebEditingCommandType::kDeleteWordForward: |
| 2979 return RangesFromCurrentSelectionOrExtendCaret(*frame_, kDirectionForward, | 2982 return RangesFromCurrentSelectionOrExtendCaret(*frame_, kDirectionForward, |
| 2980 kWordGranularity); | 2983 kWordGranularity); |
| 2981 default: | 2984 default: |
| 2982 return TargetRangesForInputEvent(*target); | 2985 return TargetRangesForInputEvent(*target); |
| 2983 } | 2986 } |
| 2984 } | 2987 } |
| 2985 | 2988 |
| 2986 } // namespace blink | 2989 } // namespace blink |
| OLD | NEW |