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

Side by Side Diff: Source/core/editing/EditorCommand.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Back out non-Oilpan experiment + tidy up by adding frame() ref accessors Created 6 years, 3 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
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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 } 1661 }
1662 1662
1663 static const EditorInternalCommand* internalCommand(const String& commandName) 1663 static const EditorInternalCommand* internalCommand(const String& commandName)
1664 { 1664 {
1665 static const CommandMap& commandMap = createCommandMap(); 1665 static const CommandMap& commandMap = createCommandMap();
1666 return commandName.isEmpty() ? 0 : commandMap.get(commandName); 1666 return commandName.isEmpty() ? 0 : commandMap.get(commandName);
1667 } 1667 }
1668 1668
1669 Editor::Command Editor::command(const String& commandName) 1669 Editor::Command Editor::command(const String& commandName)
1670 { 1670 {
1671 return Command(internalCommand(commandName), CommandFromMenuOrKeyBinding, &m _frame); 1671 return Command(internalCommand(commandName), CommandFromMenuOrKeyBinding, m_ frame);
1672 } 1672 }
1673 1673
1674 Editor::Command Editor::command(const String& commandName, EditorCommandSource s ource) 1674 Editor::Command Editor::command(const String& commandName, EditorCommandSource s ource)
1675 { 1675 {
1676 return Command(internalCommand(commandName), source, &m_frame); 1676 return Command(internalCommand(commandName), source, m_frame);
1677 } 1677 }
1678 1678
1679 bool Editor::executeCommand(const String& commandName) 1679 bool Editor::executeCommand(const String& commandName)
1680 { 1680 {
1681 // Specially handling commands that Editor::execCommand does not directly 1681 // Specially handling commands that Editor::execCommand does not directly
1682 // support. 1682 // support.
1683 if (commandName == "DeleteToEndOfParagraph") { 1683 if (commandName == "DeleteToEndOfParagraph") {
1684 if (!deleteWithDirection(DirectionForward, ParagraphBoundary, true, fals e)) 1684 if (!deleteWithDirection(DirectionForward, ParagraphBoundary, true, fals e))
1685 deleteWithDirection(DirectionForward, CharacterGranularity, true, fa lse); 1685 deleteWithDirection(DirectionForward, CharacterGranularity, true, fa lse);
1686 return true; 1686 return true;
(...skipping 11 matching lines...) Expand all
1698 spellChecker().showSpellingGuessPanel(); 1698 spellChecker().showSpellingGuessPanel();
1699 return true; 1699 return true;
1700 } 1700 }
1701 return command(commandName).execute(); 1701 return command(commandName).execute();
1702 } 1702 }
1703 1703
1704 bool Editor::executeCommand(const String& commandName, const String& value) 1704 bool Editor::executeCommand(const String& commandName, const String& value)
1705 { 1705 {
1706 // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebK it for editable nodes. 1706 // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebK it for editable nodes.
1707 if (!canEdit() && commandName == "moveToBeginningOfDocument") 1707 if (!canEdit() && commandName == "moveToBeginningOfDocument")
1708 return m_frame.eventHandler().bubblingScroll(ScrollUp, ScrollByDocument) ; 1708 return frame().eventHandler().bubblingScroll(ScrollUp, ScrollByDocument) ;
1709 1709
1710 if (!canEdit() && commandName == "moveToEndOfDocument") 1710 if (!canEdit() && commandName == "moveToEndOfDocument")
1711 return m_frame.eventHandler().bubblingScroll(ScrollDown, ScrollByDocumen t); 1711 return frame().eventHandler().bubblingScroll(ScrollDown, ScrollByDocumen t);
1712 1712
1713 if (commandName == "showGuessPanel") { 1713 if (commandName == "showGuessPanel") {
1714 spellChecker().showSpellingGuessPanel(); 1714 spellChecker().showSpellingGuessPanel();
1715 return true; 1715 return true;
1716 } 1716 }
1717 1717
1718 return command(commandName).execute(value); 1718 return command(commandName).execute(value);
1719 } 1719 }
1720 1720
1721 Editor::Command::Command() 1721 Editor::Command::Command()
1722 : m_command(0) 1722 : m_command(0)
1723 { 1723 {
1724 } 1724 }
1725 1725
1726 Editor::Command::Command(const EditorInternalCommand* command, EditorCommandSour ce source, PassRefPtr<LocalFrame> frame) 1726 Editor::Command::Command(const EditorInternalCommand* command, EditorCommandSour ce source, PassRefPtrWillBeRawPtr<LocalFrame> frame)
1727 : m_command(command) 1727 : m_command(command)
1728 , m_source(source) 1728 , m_source(source)
1729 , m_frame(command ? frame : nullptr) 1729 , m_frame(command ? frame : nullptr)
1730 { 1730 {
1731 // Use separate assertions so we can tell which bad thing happened. 1731 // Use separate assertions so we can tell which bad thing happened.
1732 if (!command) 1732 if (!command)
1733 ASSERT(!m_frame); 1733 ASSERT(!m_frame);
1734 else 1734 else
1735 ASSERT(m_frame); 1735 ASSERT(m_frame);
1736 } 1736 }
1737 1737
1738 bool Editor::Command::execute(const String& parameter, Event* triggeringEvent) c onst 1738 bool Editor::Command::execute(const String& parameter, Event* triggeringEvent) c onst
1739 { 1739 {
1740 if (!isEnabled(triggeringEvent)) { 1740 if (!isEnabled(triggeringEvent)) {
1741 // Let certain commands be executed when performed explicitly even if th ey are disabled. 1741 // Let certain commands be executed when performed explicitly even if th ey are disabled.
1742 if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled ) 1742 if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled )
1743 return false; 1743 return false;
1744 } 1744 }
1745 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 1745 frame().document()->updateLayoutIgnorePendingStylesheets();
1746 blink::Platform::current()->histogramSparse("WebCore.Editing.Commands", m_co mmand->idForUserMetrics); 1746 blink::Platform::current()->histogramSparse("WebCore.Editing.Commands", m_co mmand->idForUserMetrics);
1747 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter); 1747 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter);
1748 } 1748 }
1749 1749
1750 bool Editor::Command::execute(Event* triggeringEvent) const 1750 bool Editor::Command::execute(Event* triggeringEvent) const
1751 { 1751 {
1752 return execute(String(), triggeringEvent); 1752 return execute(String(), triggeringEvent);
1753 } 1753 }
1754 1754
1755 bool Editor::Command::isSupported() const 1755 bool Editor::Command::isSupported() const
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 { 1794 {
1795 return m_command && m_command->isTextInsertion; 1795 return m_command && m_command->isTextInsertion;
1796 } 1796 }
1797 1797
1798 int Editor::Command::idForHistogram() const 1798 int Editor::Command::idForHistogram() const
1799 { 1799 {
1800 return isSupported() ? m_command->idForUserMetrics : 0; 1800 return isSupported() ? m_command->idForUserMetrics : 0;
1801 } 1801 }
1802 1802
1803 } // namespace blink 1803 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698