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 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 frame().document()->updateLayoutIgnorePendingStylesheets(); | 1739 frame().document()->updateLayoutIgnorePendingStylesheets(); |
1740 blink::Platform::current()->histogramSparse("WebCore.Editing.Commands", m_co
mmand->idForUserMetrics); | 1740 blink::Platform::current()->histogramSparse("WebCore.Editing.Commands", m_co
mmand->idForUserMetrics); |
1741 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter); | 1741 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter); |
1742 } | 1742 } |
1743 | 1743 |
1744 bool Editor::Command::execute(Event* triggeringEvent) const | 1744 bool Editor::Command::execute(Event* triggeringEvent) const |
1745 { | 1745 { |
1746 return execute(String(), triggeringEvent); | 1746 return execute(String(), triggeringEvent); |
1747 } | 1747 } |
1748 | 1748 |
1749 bool Editor::Command::isSupported() const | 1749 bool Editor::Command::isSupported(bool enabled) const |
1750 { | 1750 { |
1751 if (!m_command) | 1751 if (!m_command) |
1752 return false; | 1752 return false; |
1753 switch (m_source) { | 1753 switch (m_source) { |
1754 case CommandFromMenuOrKeyBinding: | 1754 case CommandFromMenuOrKeyBinding: |
1755 return true; | 1755 return true; |
1756 case CommandFromDOM: | 1756 case CommandFromDOM: |
1757 return m_command->isSupportedFromDOM(m_frame.get()); | 1757 return enabled ? m_command->isSupportedFromDOM(m_frame.get()) : true; |
1758 } | 1758 } |
1759 ASSERT_NOT_REACHED(); | 1759 ASSERT_NOT_REACHED(); |
1760 return false; | 1760 return false; |
1761 } | 1761 } |
1762 | 1762 |
1763 bool Editor::Command::isEnabled(Event* triggeringEvent) const | 1763 bool Editor::Command::isEnabled(Event* triggeringEvent) const |
1764 { | 1764 { |
1765 if (!isSupported() || !m_frame) | 1765 if (!isSupported(true) || !m_frame) |
1766 return false; | 1766 return false; |
1767 return m_command->isEnabled(*m_frame, triggeringEvent, m_source); | 1767 return m_command->isEnabled(*m_frame, triggeringEvent, m_source); |
1768 } | 1768 } |
1769 | 1769 |
1770 TriState Editor::Command::state(Event* triggeringEvent) const | 1770 TriState Editor::Command::state(Event* triggeringEvent) const |
1771 { | 1771 { |
1772 if (!isSupported() || !m_frame) | 1772 if (!isSupported() || !m_frame) |
1773 return FalseTriState; | 1773 return FalseTriState; |
1774 return m_command->state(*m_frame, triggeringEvent); | 1774 return m_command->state(*m_frame, triggeringEvent); |
1775 } | 1775 } |
(...skipping 11 matching lines...) Expand all Loading... |
1787 { | 1787 { |
1788 return m_command && m_command->isTextInsertion; | 1788 return m_command && m_command->isTextInsertion; |
1789 } | 1789 } |
1790 | 1790 |
1791 int Editor::Command::idForHistogram() const | 1791 int Editor::Command::idForHistogram() const |
1792 { | 1792 { |
1793 return isSupported() ? m_command->idForUserMetrics : 0; | 1793 return isSupported() ? m_command->idForUserMetrics : 0; |
1794 } | 1794 } |
1795 | 1795 |
1796 } // namespace blink | 1796 } // namespace blink |
OLD | NEW |