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

Side by Side Diff: sky/engine/core/dom/Node.h

Issue 772743004: Remove more Node API. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « sky/engine/core/dom/Element.cpp ('k') | sky/engine/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved. 5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved.
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // which will already know and hold a ref on the right node to return. 157 // which will already know and hold a ref on the right node to return.
158 PassRefPtr<Node> insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exc eptionState& = ASSERT_NO_EXCEPTION); 158 PassRefPtr<Node> insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exc eptionState& = ASSERT_NO_EXCEPTION);
159 PassRefPtr<Node> replaceChild(PassRefPtr<Node> newChild, PassRefPtr<Node> ol dChild, ExceptionState& = ASSERT_NO_EXCEPTION); 159 PassRefPtr<Node> replaceChild(PassRefPtr<Node> newChild, PassRefPtr<Node> ol dChild, ExceptionState& = ASSERT_NO_EXCEPTION);
160 PassRefPtr<Node> removeChild(PassRefPtr<Node> child, ExceptionState& = ASSER T_NO_EXCEPTION); 160 PassRefPtr<Node> removeChild(PassRefPtr<Node> child, ExceptionState& = ASSER T_NO_EXCEPTION);
161 PassRefPtr<Node> appendChild(PassRefPtr<Node> newChild, ExceptionState& = AS SERT_NO_EXCEPTION); 161 PassRefPtr<Node> appendChild(PassRefPtr<Node> newChild, ExceptionState& = AS SERT_NO_EXCEPTION);
162 162
163 bool hasChildren() const { return firstChild(); } 163 bool hasChildren() const { return firstChild(); }
164 virtual PassRefPtr<Node> cloneNode(bool deep = false) = 0; 164 virtual PassRefPtr<Node> cloneNode(bool deep = false) = 0;
165 virtual const AtomicString& localName() const; 165 virtual const AtomicString& localName() const;
166 166
167 bool isSameNode(Node* other) const { return this == other; }
168 bool isEqualNode(Node*) const;
169
170 String textContent(bool convertBRsToNewlines = false) const; 167 String textContent(bool convertBRsToNewlines = false) const;
171 void setTextContent(const String&); 168 void setTextContent(const String&);
172 169
173 // Other methods (not part of DOM) 170 // Other methods (not part of DOM)
174 171
175 bool isElementNode() const { return getFlag(IsElementFlag); } 172 bool isElementNode() const { return getFlag(IsElementFlag); }
176 bool isContainerNode() const { return getFlag(IsContainerFlag); } 173 bool isContainerNode() const { return getFlag(IsContainerFlag); }
177 bool isTextNode() const { return getFlag(IsTextFlag); } 174 bool isTextNode() const { return getFlag(IsTextFlag); }
178 bool isHTMLElement() const { return getFlag(IsHTMLFlag); } 175 bool isHTMLElement() const { return getFlag(IsHTMLFlag); }
179 176
180 bool isCustomElement() const { return getFlag(CustomElementFlag); } 177 bool isCustomElement() const { return getFlag(CustomElementFlag); }
181 enum CustomElementState { 178 enum CustomElementState {
182 NotCustomElement = 0, 179 NotCustomElement = 0,
183 WaitingForUpgrade = 1 << 0, 180 WaitingForUpgrade = 1 << 0,
184 Upgraded = 1 << 1 181 Upgraded = 1 << 1
185 }; 182 };
186 CustomElementState customElementState() const 183 CustomElementState customElementState() const
187 { 184 {
188 return isCustomElement() 185 return isCustomElement()
189 ? (getFlag(CustomElementUpgradedFlag) ? Upgraded : WaitingForUpgrade ) 186 ? (getFlag(CustomElementUpgradedFlag) ? Upgraded : WaitingForUpgrade )
190 : NotCustomElement; 187 : NotCustomElement;
191 } 188 }
192 void setCustomElementState(CustomElementState newState); 189 void setCustomElementState(CustomElementState newState);
193 190
194 virtual bool isCharacterDataNode() const { return false; }
195
196 // StyledElements allow inline style (style="border: 1px"), presentational a ttributes (ex. color), 191 // StyledElements allow inline style (style="border: 1px"), presentational a ttributes (ex. color),
197 // class names (ex. class="foo bar") and other non-basic styling features. T hey and also control 192 // class names (ex. class="foo bar") and other non-basic styling features. T hey and also control
198 // if this element can participate in style sharing. 193 // if this element can participate in style sharing.
199 // 194 //
200 // FIXME: The only things that ever go through StyleResolver that aren't Sty ledElements are 195 // FIXME: The only things that ever go through StyleResolver that aren't Sty ledElements are
201 // PseudoElements and VTTElements. It's possible we can just eliminate all t he checks 196 // PseudoElements and VTTElements. It's possible we can just eliminate all t he checks
202 // since those elements will never have class names, inline style, or other things that 197 // since those elements will never have class names, inline style, or other things that
203 // this apparently guards against. 198 // this apparently guards against.
204 bool isStyledElement() const { return isHTMLElement(); } 199 bool isStyledElement() const { return isHTMLElement(); }
205 200
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool isV8CollectableDuringMinorGC() const { return getFlag(V8CollectableDuri ngMinorGCFlag); } 288 bool isV8CollectableDuringMinorGC() const { return getFlag(V8CollectableDuri ngMinorGCFlag); }
294 void markV8CollectableDuringMinorGC() { setFlag(true, V8CollectableDuringMin orGCFlag); } 289 void markV8CollectableDuringMinorGC() { setFlag(true, V8CollectableDuringMin orGCFlag); }
295 void clearV8CollectableDuringMinorGC() { setFlag(false, V8CollectableDuringM inorGCFlag); } 290 void clearV8CollectableDuringMinorGC() { setFlag(false, V8CollectableDuringM inorGCFlag); }
296 291
297 virtual void setFocus(bool flag); 292 virtual void setFocus(bool flag);
298 virtual void setActive(bool flag = true); 293 virtual void setActive(bool flag = true);
299 virtual void setHovered(bool flag = true); 294 virtual void setHovered(bool flag = true);
300 295
301 virtual short tabIndex() const; 296 virtual short tabIndex() const;
302 297
303 virtual Node* focusDelegate();
304 // This is called only when the node is focused.
305 virtual bool shouldHaveFocusAppearance() const;
306
307 // Whether the node is inert. This can't be in Element because text nodes
308 // must be recognized as inert to prevent text selection.
309 bool isInert() const;
310
311 enum UserSelectAllTreatment { 298 enum UserSelectAllTreatment {
312 UserSelectAllDoesNotAffectEditability, 299 UserSelectAllDoesNotAffectEditability,
313 UserSelectAllIsAlwaysNonEditable 300 UserSelectAllIsAlwaysNonEditable
314 }; 301 };
315 bool isContentEditable(UserSelectAllTreatment = UserSelectAllDoesNotAffectEd itability); 302 bool isContentEditable(UserSelectAllTreatment = UserSelectAllDoesNotAffectEd itability);
316 bool isContentRichlyEditable(); 303 bool isContentRichlyEditable();
317 304
318 bool hasEditableStyle(EditableType editableType = ContentIsEditable, UserSel ectAllTreatment treatment = UserSelectAllIsAlwaysNonEditable) const 305 bool hasEditableStyle(EditableType editableType = ContentIsEditable, UserSel ectAllTreatment treatment = UserSelectAllIsAlwaysNonEditable) const
319 { 306 {
320 switch (editableType) { 307 switch (editableType) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 436
450 #ifndef NDEBUG 437 #ifndef NDEBUG
451 virtual void formatForDebugger(char* buffer, unsigned length) const; 438 virtual void formatForDebugger(char* buffer, unsigned length) const;
452 439
453 void showNode(const char* prefix = "") const; 440 void showNode(const char* prefix = "") const;
454 void showTreeForThis() const; 441 void showTreeForThis() const;
455 void showNodePathForThis() const; 442 void showNodePathForThis() const;
456 void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, cons t Node* markedNode2 = 0, const char* markedLabel2 = 0) const; 443 void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, cons t Node* markedNode2 = 0, const char* markedLabel2 = 0) const;
457 #endif 444 #endif
458 445
459 virtual bool willRespondToMouseMoveEvents(); 446 bool willRespondToMouseMoveEvents();
447 bool willRespondToTouchEvents();
448
460 virtual bool willRespondToMouseClickEvents(); 449 virtual bool willRespondToMouseClickEvents();
461 virtual bool willRespondToTouchEvents();
462 450
463 enum ShadowTreesTreatment { 451 enum ShadowTreesTreatment {
464 TreatShadowTreesAsDisconnected, 452 TreatShadowTreesAsDisconnected,
465 TreatShadowTreesAsComposed 453 TreatShadowTreesAsComposed
466 }; 454 };
467 455
468 unsigned short compareDocumentPosition(const Node*, ShadowTreesTreatment = T reatShadowTreesAsDisconnected) const; 456 unsigned short compareDocumentPosition(const Node*, ShadowTreesTreatment = T reatShadowTreesAsDisconnected) const;
469 457
470 virtual Node* toNode() override final; 458 virtual Node* toNode() override final;
471 459
472 virtual const AtomicString& interfaceName() const override; 460 virtual const AtomicString& interfaceName() const override;
473 virtual ExecutionContext* executionContext() const override final; 461 virtual ExecutionContext* executionContext() const override final;
474 462
475 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) override; 463 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) override;
476 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture = false) override;
477 virtual void removeAllEventListeners() override;
478 void removeAllEventListenersRecursively(); 464 void removeAllEventListenersRecursively();
479 465
480 // Handlers to do/undo actions on the target node before an event is dispatc hed to it and after the event
481 // has been dispatched. The data pointer is handed back by the preDispatch and passed to postDispatch.
482 virtual void* preDispatchEventHandler(Event*) { return 0; }
483 virtual void postDispatchEventHandler(Event*, void* /*dataFromPreDispatch*/) { }
484
485 using EventTarget::dispatchEvent; 466 using EventTarget::dispatchEvent;
486 virtual bool dispatchEvent(PassRefPtr<Event>) override; 467 virtual bool dispatchEvent(PassRefPtr<Event>) override;
487 468
488 void dispatchScopedEvent(PassRefPtr<Event>); 469 void dispatchScopedEvent(PassRefPtr<Event>);
489 void dispatchScopedEventDispatchMediator(PassRefPtr<EventDispatchMediator>); 470 void dispatchScopedEventDispatchMediator(PassRefPtr<EventDispatchMediator>);
490 471
491 virtual void handleLocalEvents(Event*); 472 virtual void handleLocalEvents(Event*);
492 473
493 bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent) ; 474 bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent) ;
494 475
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 void setStyleChange(StyleChangeType); 626 void setStyleChange(StyleChangeType);
646 627
647 virtual RenderStyle* virtualComputedStyle(PseudoId = NOPSEUDO); 628 virtual RenderStyle* virtualComputedStyle(PseudoId = NOPSEUDO);
648 629
649 void trackForDebugging(); 630 void trackForDebugging();
650 631
651 Vector<OwnPtr<MutationObserverRegistration> >* mutationObserverRegistry(); 632 Vector<OwnPtr<MutationObserverRegistration> >* mutationObserverRegistry();
652 HashSet<RawPtr<MutationObserverRegistration> >* transientMutationObserverReg istry(); 633 HashSet<RawPtr<MutationObserverRegistration> >* transientMutationObserverReg istry();
653 634
654 uint32_t m_nodeFlags; 635 uint32_t m_nodeFlags;
655 RawPtr<ContainerNode> m_parentOrShadowHostNode; 636 ContainerNode* m_parentOrShadowHostNode;
656 RawPtr<TreeScope> m_treeScope; 637 TreeScope* m_treeScope;
657 RawPtr<Node> m_previous; 638 Node* m_previous;
658 RawPtr<Node> m_next; 639 Node* m_next;
659 // When a node has rare data we move the renderer into the rare data. 640 // When a node has rare data we move the renderer into the rare data.
660 union DataUnion { 641 union DataUnion {
661 DataUnion() : m_renderer(0) { } 642 DataUnion() : m_renderer(0) { }
662 RenderObject* m_renderer; 643 RenderObject* m_renderer;
663 NodeRareDataBase* m_rareData; 644 NodeRareDataBase* m_rareData;
664 } m_data; 645 } m_data;
665 }; 646 };
666 647
667 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) 648 inline void Node::setParentOrShadowHostNode(ContainerNode* parent)
668 { 649 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } // namespace blink 705 } // namespace blink
725 706
726 #ifndef NDEBUG 707 #ifndef NDEBUG
727 // Outside the WebCore namespace for ease of invocation from gdb. 708 // Outside the WebCore namespace for ease of invocation from gdb.
728 void showNode(const blink::Node*); 709 void showNode(const blink::Node*);
729 void showTree(const blink::Node*); 710 void showTree(const blink::Node*);
730 void showNodePath(const blink::Node*); 711 void showNodePath(const blink::Node*);
731 #endif 712 #endif
732 713
733 #endif // SKY_ENGINE_CORE_DOM_NODE_H_ 714 #endif // SKY_ENGINE_CORE_DOM_NODE_H_
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Element.cpp ('k') | sky/engine/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698