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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return !element.getElementsByTagName(tagName.localName())->isEmpty(); | 413 return !element.getElementsByTagName(tagName.localName())->isEmpty(); |
414 } | 414 } |
415 | 415 |
416 static TriState selectionListState(const FrameSelection& selection, | 416 static TriState selectionListState(const FrameSelection& selection, |
417 const QualifiedName& tagName) { | 417 const QualifiedName& tagName) { |
418 if (selection.computeVisibleSelectionInDOMTreeDeprecated().isCaret()) { | 418 if (selection.computeVisibleSelectionInDOMTreeDeprecated().isCaret()) { |
419 if (enclosingElementWithTag( | 419 if (enclosingElementWithTag( |
420 selection.computeVisibleSelectionInDOMTreeDeprecated().start(), | 420 selection.computeVisibleSelectionInDOMTreeDeprecated().start(), |
421 tagName)) | 421 tagName)) |
422 return TrueTriState; | 422 return TrueTriState; |
423 } else if (selection.isRange()) { | 423 } else if (selection.computeVisibleSelectionInDOMTreeDeprecated().isRange()) { |
424 Element* startElement = enclosingElementWithTag( | 424 Element* startElement = enclosingElementWithTag( |
425 selection.computeVisibleSelectionInDOMTreeDeprecated().start(), | 425 selection.computeVisibleSelectionInDOMTreeDeprecated().start(), |
426 tagName); | 426 tagName); |
427 Element* endElement = enclosingElementWithTag( | 427 Element* endElement = enclosingElementWithTag( |
428 selection.computeVisibleSelectionInDOMTreeDeprecated().end(), tagName); | 428 selection.computeVisibleSelectionInDOMTreeDeprecated().end(), tagName); |
429 | 429 |
430 if (startElement && endElement && startElement == endElement) { | 430 if (startElement && endElement && startElement == endElement) { |
431 // If the selected list has the different type of list as child, return | 431 // If the selected list has the different type of list as child, return |
432 // |FalseTriState|. | 432 // |FalseTriState|. |
433 // See http://crbug.com/385374 | 433 // See http://crbug.com/385374 |
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 } | 1932 } |
1933 | 1933 |
1934 static bool enabledRangeInEditableText(LocalFrame& frame, | 1934 static bool enabledRangeInEditableText(LocalFrame& frame, |
1935 Event*, | 1935 Event*, |
1936 EditorCommandSource) { | 1936 EditorCommandSource) { |
1937 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 1937 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1938 | 1938 |
1939 // We should update selection to canonicalize with current layout and style, | 1939 // We should update selection to canonicalize with current layout and style, |
1940 // before accessing |FrameSelection::selection()|. | 1940 // before accessing |FrameSelection::selection()|. |
1941 frame.selection().updateIfNeeded(); | 1941 frame.selection().updateIfNeeded(); |
1942 return frame.selection().isRange() && frame.selection().isContentEditable(); | 1942 return frame.selection() |
| 1943 .computeVisibleSelectionInDOMTreeDeprecated() |
| 1944 .isRange() && |
| 1945 frame.selection().isContentEditable(); |
1943 } | 1946 } |
1944 | 1947 |
1945 static bool enabledRangeInRichlyEditableText(LocalFrame& frame, | 1948 static bool enabledRangeInRichlyEditableText(LocalFrame& frame, |
1946 Event*, | 1949 Event*, |
1947 EditorCommandSource) { | 1950 EditorCommandSource) { |
1948 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 1951 frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1949 | 1952 |
1950 // We should update selection to canonicalize with current layout and style, | 1953 // We should update selection to canonicalize with current layout and style, |
1951 // before accessing |FrameSelection::selection()|. | 1954 // before accessing |FrameSelection::selection()|. |
1952 frame.selection().updateIfNeeded(); | 1955 frame.selection().updateIfNeeded(); |
1953 return frame.selection().isRange() && | 1956 return frame.selection() |
| 1957 .computeVisibleSelectionInDOMTreeDeprecated() |
| 1958 .isRange() && |
1954 frame.selection() | 1959 frame.selection() |
1955 .computeVisibleSelectionInDOMTreeDeprecated() | 1960 .computeVisibleSelectionInDOMTreeDeprecated() |
1956 .isContentRichlyEditable(); | 1961 .isContentRichlyEditable(); |
1957 } | 1962 } |
1958 | 1963 |
1959 static bool enabledRedo(LocalFrame& frame, Event*, EditorCommandSource) { | 1964 static bool enabledRedo(LocalFrame& frame, Event*, EditorCommandSource) { |
1960 return frame.editor().canRedo(); | 1965 return frame.editor().canRedo(); |
1961 } | 1966 } |
1962 | 1967 |
1963 static bool enabledUndo(LocalFrame& frame, Event*, EditorCommandSource) { | 1968 static bool enabledUndo(LocalFrame& frame, Event*, EditorCommandSource) { |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2757 *m_frame, DirectionBackward, WordGranularity); | 2762 *m_frame, DirectionBackward, WordGranularity); |
2758 case WebEditingCommandType::DeleteWordForward: | 2763 case WebEditingCommandType::DeleteWordForward: |
2759 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, | 2764 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, |
2760 WordGranularity); | 2765 WordGranularity); |
2761 default: | 2766 default: |
2762 return targetRangesForInputEvent(*target); | 2767 return targetRangesForInputEvent(*target); |
2763 } | 2768 } |
2764 } | 2769 } |
2765 | 2770 |
2766 } // namespace blink | 2771 } // namespace blink |
OLD | NEW |