Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove editing code from the C++ side of Sky. #96

Merged
merged 1 commit into from
Jul 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 2 additions & 83 deletions sky/engine/core/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -324,103 +324,29 @@ sky_core_files = [
"dom/shadow/SelectRuleFeatureSet.h",
"dom/shadow/ShadowRoot.cpp",
"dom/shadow/ShadowRoot.h",
"editing/AppendNodeCommand.cpp",
"editing/AppendNodeCommand.h",
"editing/ApplyBlockElementCommand.cpp",
"editing/ApplyBlockElementCommand.h",
"editing/Caret.cpp",
"editing/Caret.h",
"editing/CompositeEditCommand.cpp",
"editing/CompositeEditCommand.h",
"editing/CompositionUnderline.h",
"editing/CompositionUnderlineRangeFilter.cpp",
"editing/CompositionUnderlineRangeFilter.h",
"editing/DOMSelection.cpp",
"editing/DOMSelection.h",
"editing/DeleteFromTextNodeCommand.cpp",
"editing/DeleteFromTextNodeCommand.h",
"editing/DeleteSelectionCommand.cpp",
"editing/DeleteSelectionCommand.h",
"editing/EditAction.h",
"editing/EditCommand.cpp",
"editing/EditCommand.h",
"editing/EditingBehavior.cpp",
"editing/EditingBehavior.h",
"editing/EditingBoundary.h",
"editing/EditingStyle.cpp",
"editing/EditingStyle.h",
"editing/Editor.cpp",
"editing/Editor.h",
"editing/EditorCommand.cpp",
"editing/EditorKeyBindings.cpp",
"editing/FindOptions.h",
"editing/FrameSelection.cpp",
"editing/FrameSelection.h",
"editing/HTMLInterchange.cpp",
"editing/HTMLInterchange.h",
"editing/InputMethodController.cpp",
"editing/InputMethodController.h",
"editing/InsertIntoTextNodeCommand.cpp",
"editing/InsertIntoTextNodeCommand.h",
"editing/InsertLineBreakCommand.cpp",
"editing/InsertLineBreakCommand.h",
"editing/InsertNodeBeforeCommand.cpp",
"editing/InsertNodeBeforeCommand.h",
"editing/InsertParagraphSeparatorCommand.cpp",
"editing/InsertParagraphSeparatorCommand.h",
"editing/InsertTextCommand.cpp",
"editing/InsertTextCommand.h",
"editing/MoveSelectionCommand.cpp",
"editing/MoveSelectionCommand.h",
"editing/htmlediting.cpp",
"editing/htmlediting.h",
"editing/PlainTextRange.cpp",
"editing/PlainTextRange.h",
"editing/PositionWithAffinity.cpp",
"editing/PositionWithAffinity.h",
"editing/RemoveNodeCommand.cpp",
"editing/RemoveNodeCommand.h",
"editing/RemoveNodePreservingChildrenCommand.cpp",
"editing/RemoveNodePreservingChildrenCommand.h",
"editing/RenderedPosition.cpp",
"editing/RenderedPosition.h",
"editing/ReplaceSelectionCommand.cpp",
"editing/ReplaceSelectionCommand.h",
"editing/SelectionType.h",
"editing/SmartReplace.h",
"editing/SmartReplaceICU.cpp",
"editing/SpellCheckRequester.cpp",
"editing/SpellCheckRequester.h",
"editing/SpellChecker.cpp",
"editing/SpellChecker.h",
"editing/SplitElementCommand.cpp",
"editing/SplitElementCommand.h",
"editing/SplitTextNodeCommand.cpp",
"editing/SplitTextNodeCommand.h",
"editing/TextAffinity.h",
"editing/TextCheckingHelper.cpp",
"editing/TextCheckingHelper.h",
"editing/TextGranularity.h",
"editing/TextInsertionBaseCommand.cpp",
"editing/TextInsertionBaseCommand.h",
"editing/TextIterator.cpp",
"editing/TextIterator.h",
"editing/TypingCommand.cpp",
"editing/TypingCommand.h",
"editing/UndoStack.cpp",
"editing/UndoStack.h",
"editing/UndoStep.h",
"editing/VisiblePosition.cpp",
"editing/VisiblePosition.h",
"editing/VisibleSelection.cpp",
"editing/VisibleSelection.h",
"editing/VisibleUnits.cpp",
"editing/VisibleUnits.h",
"editing/WritingDirection.h",
"editing/htmlediting.cpp",
"editing/htmlediting.h",
"events/BeforeTextInsertedEvent.cpp",
"events/BeforeTextInsertedEvent.h",
"events/CompositionEvent.cpp",
"events/CompositionEvent.h",
"events/ErrorEvent.cpp",
"events/ErrorEvent.h",
"events/Event.cpp",
Expand Down Expand Up @@ -500,8 +426,6 @@ sky_core_files = [
"loader/CanvasImageDecoder.h",
"loader/DocumentLoadTiming.cpp",
"loader/DocumentLoadTiming.h",
"loader/EmptyClients.cpp",
"loader/EmptyClients.h",
"loader/FrameLoader.cpp",
"loader/FrameLoader.h",
"loader/FrameLoaderClient.h",
Expand All @@ -511,13 +435,11 @@ sky_core_files = [
"loader/UniqueIdentifier.cpp",
"loader/UniqueIdentifier.h",
"page/ChromeClient.h",
"page/EditorClient.h",
"page/FocusController.cpp",
"page/FocusController.h",
"page/FocusType.h",
"page/Page.cpp",
"page/Page.h",
"page/SpellCheckerClient.h",
"painting/Canvas.cpp",
"painting/Canvas.h",
"painting/CanvasColor.cpp",
Expand Down Expand Up @@ -761,8 +683,6 @@ core_idl_files = get_path_info([
"dom/Text.idl",
"dom/URL.idl",
"dom/shadow/ShadowRoot.idl",
"editing/Selection.idl",
"events/CompositionEvent.idl",
"events/ErrorEvent.idl",
"events/Event.idl",
"events/GestureEvent.idl",
Expand Down Expand Up @@ -836,7 +756,6 @@ core_dependency_idl_files = get_path_info([
# interfaces that inherit from Event, including Event itself
core_event_idl_files = get_path_info([
"css/MediaQueryListEvent.idl",
"events/CompositionEvent.idl",
"events/ErrorEvent.idl",
"events/Event.idl",
"events/GestureEvent.idl",
Expand Down
3 changes: 0 additions & 3 deletions sky/engine/core/css/SelectorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "sky/engine/core/css/CSSSelectorList.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
#include "sky/engine/core/editing/FrameSelection.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
#include "sky/engine/core/page/FocusController.h"
Expand All @@ -46,8 +45,6 @@ static bool matchesFocusPseudoClass(const Element& element)
LocalFrame* frame = element.document().frame();
if (!frame)
return false;
if (!frame->selection().isFocusedAndActive())
return false;
return true;
}

Expand Down
4 changes: 0 additions & 4 deletions sky/engine/core/dom/CharacterData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "sky/engine/core/dom/MutationObserverInterestGroup.h"
#include "sky/engine/core/dom/MutationRecord.h"
#include "sky/engine/core/dom/Text.h"
#include "sky/engine/core/editing/FrameSelection.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/wtf/CheckedArithmetic.h"

Expand Down Expand Up @@ -164,9 +163,6 @@ void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
if (isTextNode())
toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalcStyleBehavior);

if (document().frame())
document().frame()->selection().didUpdateCharacterData(this, offsetOfReplacedData, oldLength, newLength);

didModifyData(oldData);
}

Expand Down
22 changes: 2 additions & 20 deletions sky/engine/core/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "sky/engine/core/dom/NodeRenderingTraversal.h"
#include "sky/engine/core/dom/NodeTraversal.h"
#include "sky/engine/core/dom/NodeWithIndex.h"
#include "sky/engine/core/dom/Range.h"
#include "sky/engine/core/dom/RequestAnimationFrameCallback.h"
#include "sky/engine/core/dom/ScriptedAnimationController.h"
#include "sky/engine/core/dom/SelectorQuery.h"
Expand All @@ -65,8 +66,7 @@
#include "sky/engine/core/dom/custom/custom_element_registry.h"
#include "sky/engine/core/dom/shadow/ElementShadow.h"
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
#include "sky/engine/core/editing/FrameSelection.h"
#include "sky/engine/core/editing/SpellChecker.h"
#include "sky/engine/core/editing/PositionWithAffinity.h"
#include "sky/engine/core/events/Event.h"
#include "sky/engine/core/events/PageTransitionEvent.h"
#include "sky/engine/core/frame/FrameHost.h"
Expand Down Expand Up @@ -1193,13 +1193,6 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
(*it)->nodeChildrenWillBeRemoved(container);
}

if (LocalFrame* frame = this->frame()) {
for (Node* n = container.firstChild(); n; n = n->nextSibling()) {
frame->selection().nodeWillBeRemoved(*n);
frame->page()->dragCaretController().nodeWillBeRemoved(*n);
}
}
}

void Document::nodeWillBeRemoved(Node& n)
Expand All @@ -1209,11 +1202,6 @@ void Document::nodeWillBeRemoved(Node& n)
for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != rangesEnd; ++it)
(*it)->nodeWillBeRemoved(n);
}

if (LocalFrame* frame = this->frame()) {
frame->selection().nodeWillBeRemoved(n);
frame->page()->dragCaretController().nodeWillBeRemoved(n);
}
}

void Document::didInsertText(Node* text, unsigned offset, unsigned length)
Expand Down Expand Up @@ -1250,9 +1238,6 @@ void Document::didMergeTextNodes(Text& oldNode, unsigned offset)
(*it)->didMergeTextNodes(oldNodeWithIndex, offset);
}

if (m_frame)
m_frame->selection().didMergeTextNodes(oldNode, offset);

// FIXME: This should update markers for spelling and grammar checking.
}

Expand All @@ -1264,9 +1249,6 @@ void Document::didSplitTextNode(Text& oldNode)
(*it)->didSplitTextNode(oldNode);
}

if (m_frame)
m_frame->selection().didSplitTextNode(oldNode);

// FIXME: This should update markers for spelling and grammar checking.
}

Expand Down
3 changes: 0 additions & 3 deletions sky/engine/core/dom/Document.idl
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ callback CustomElementConstructor = Element ();
Range caretRangeFromPoint([Default=Undefined] optional long x,
[Default=Undefined] optional long y);

// Mozilla extensions
Selection getSelection();

// HTML 5
readonly attribute Element activeElement;
boolean hasFocus();
Expand Down
1 change: 1 addition & 0 deletions sky/engine/core/dom/DocumentMarkerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define SKY_ENGINE_CORE_DOM_DOCUMENTMARKERCONTROLLER_H_

#include "sky/engine/core/dom/DocumentMarker.h"
#include "sky/engine/core/dom/Range.h"
#include "sky/engine/platform/geometry/IntRect.h"
#include "sky/engine/platform/heap/Handle.h"
#include "sky/engine/wtf/HashMap.h"
Expand Down
12 changes: 0 additions & 12 deletions sky/engine/core/dom/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "sky/engine/core/dom/custom/custom_element.h"
#include "sky/engine/core/dom/shadow/InsertionPoint.h"
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
#include "sky/engine/core/editing/FrameSelection.h"
#include "sky/engine/core/editing/TextIterator.h"
#include "sky/engine/core/editing/htmlediting.h"
#include "sky/engine/core/frame/FrameView.h"
Expand Down Expand Up @@ -1094,17 +1093,6 @@ void Element::updateFocusAppearance(bool /*restorePreviousSelection*/)
RefPtr<LocalFrame> frame(document().frame());
if (!frame)
return;

// When focusing an editable element in an iframe, don't reset the selection if it already contains a selection.
if (this == frame->selection().rootEditableElement())
return;

// FIXME: We should restore the previous selection if there is one.
VisibleSelection newSelection = VisibleSelection(firstPositionInOrBeforeNode(this), DOWNSTREAM);
// Passing DoNotSetFocus as this function is called after FocusController::setFocusedElement()
// and we don't want to change the focus to a new Element.
frame->selection().setSelection(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus);
frame->selection().revealSelection();
}
}

Expand Down
21 changes: 0 additions & 21 deletions sky/engine/core/dom/TreeScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "sky/engine/core/dom/TreeScopeAdopter.h"
#include "sky/engine/core/dom/shadow/ElementShadow.h"
#include "sky/engine/core/dom/shadow/ShadowRoot.h"
#include "sky/engine/core/editing/DOMSelection.h"
#include "sky/engine/core/frame/FrameView.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/page/FocusController.h"
Expand Down Expand Up @@ -74,11 +73,6 @@ TreeScope::~TreeScope()
ASSERT(!m_guardRefCount);
m_rootNode->setTreeScope(0);

if (m_selection) {
m_selection->clearTreeScope();
m_selection = nullptr;
}

if (m_parentTreeScope)
m_parentTreeScope->guardDeref();
}
Expand Down Expand Up @@ -192,21 +186,6 @@ Element* TreeScope::elementFromPoint(int x, int y) const
return toElement(node);
}

DOMSelection* TreeScope::getSelection() const
{
if (!rootNode().document().frame())
return 0;

if (m_selection)
return m_selection.get();

// FIXME: The correct selection in Shadow DOM requires that Position can have a ShadowRoot
// as a container.
// See https://bugs.webkit.org/show_bug.cgi?id=82697
m_selection = DOMSelection::create(this);
return m_selection.get();
}

void TreeScope::adoptIfNeeded(Node& node)
{
ASSERT(this);
Expand Down
5 changes: 0 additions & 5 deletions sky/engine/core/dom/TreeScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
namespace blink {

class ContainerNode;
class DOMSelection;
class Document;
class Element;
class HitTestResult;
Expand Down Expand Up @@ -68,8 +67,6 @@ class TreeScope {
// For accessibility.
bool shouldCacheLabelsByForAttribute() const { return m_labelsByForAttribute; }

DOMSelection* getSelection() const;

// Used by the basic DOM mutation methods (e.g., appendChild()).
void adoptIfNeeded(Node&);

Expand Down Expand Up @@ -156,8 +153,6 @@ class TreeScope {
OwnPtr<DocumentOrderedMap> m_imageMapsByName;
OwnPtr<DocumentOrderedMap> m_labelsByForAttribute;

mutable RefPtr<DOMSelection> m_selection;

int m_guardRefCount;
};

Expand Down
1 change: 0 additions & 1 deletion sky/engine/core/dom/shadow/ShadowRoot.idl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface ShadowRoot : DocumentFragment {
readonly attribute Element activeElement;

[RaisesException] Node cloneNode([Named] optional boolean deep = true);
Selection getSelection();
Element getElementById([Default=Undefined] optional DOMString elementId);

Element elementFromPoint([Default=Undefined] optional long x,
Expand Down
Loading