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

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

Issue 696903002: Remove a lot of API surface from Element. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | sky/engine/core/dom/Element.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 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2003-2011, 2013, 2014 Apple Inc. All rights reserved. 6 * Copyright (C) 2003-2011, 2013, 2014 Apple Inc. All rights reserved.
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class Image; 52 class Image;
53 class InputMethodContext; 53 class InputMethodContext;
54 class IntSize; 54 class IntSize;
55 class Locale; 55 class Locale;
56 class MutableStylePropertySet; 56 class MutableStylePropertySet;
57 class PropertySetCSSStyleDeclaration; 57 class PropertySetCSSStyleDeclaration;
58 class PseudoElement; 58 class PseudoElement;
59 class ShadowRoot; 59 class ShadowRoot;
60 class StylePropertySet; 60 class StylePropertySet;
61 61
62 enum AffectedSelectorType {
63 AffectedSelectorChecked = 1,
64 AffectedSelectorEnabled = 1 << 1,
65 AffectedSelectorDisabled = 1 << 2,
66 AffectedSelectorIndeterminate = 1 << 3,
67 AffectedSelectorLink = 1 << 4,
68 AffectedSelectorVisited = 1 << 5
69 };
70 typedef int AffectedSelectorMask;
71
72 enum SpellcheckAttributeState { 62 enum SpellcheckAttributeState {
73 SpellcheckAttributeTrue, 63 SpellcheckAttributeTrue,
74 SpellcheckAttributeFalse, 64 SpellcheckAttributeFalse,
75 SpellcheckAttributeDefault 65 SpellcheckAttributeDefault
76 }; 66 };
77 67
78 enum ElementFlags { 68 enum ElementFlags {
79 TabIndexWasSetExplicitly = 1 << 0, 69 TabIndexWasSetExplicitly = 1 << 0,
80 70
81 NumberOfElementFlags = 2, // Required size of bitfield used to store the fla gs. 71 NumberOfElementFlags = 2, // Required size of bitfield used to store the fla gs.
82 }; 72 };
83 73
84 class Element : public ContainerNode { 74 class Element : public ContainerNode {
85 DEFINE_WRAPPERTYPEINFO(); 75 DEFINE_WRAPPERTYPEINFO();
86 public: 76 public:
87 static PassRefPtr<Element> create(const QualifiedName&, Document*); 77 static PassRefPtr<Element> create(const QualifiedName&, Document*);
88 virtual ~Element(); 78 virtual ~Element();
89 79
90 bool hasAttribute(const QualifiedName&) const; 80 bool hasAttribute(const QualifiedName&) const;
91 const AtomicString& getAttribute(const QualifiedName&) const; 81 const AtomicString& getAttribute(const QualifiedName&) const;
92
93 Vector<RefPtr<Attr>> getAttributes(); 82 Vector<RefPtr<Attr>> getAttributes();
83 bool hasAttributes() const;
84 bool hasAttribute(const AtomicString& name) const;
85 const AtomicString& getAttribute(const AtomicString& name) const;
86 void setAttribute(const AtomicString& name, const AtomicString& value, Excep tionState&);
87 void removeAttribute(const AtomicString& name);
88 void removeAttribute(const QualifiedName&);
94 89
95 // Passing nullAtom as the second parameter removes the attribute when calli ng either of these set methods. 90 // Passing nullAtom as the second parameter removes the attribute when calli ng either of these set methods.
96 void setAttribute(const QualifiedName&, const AtomicString& value); 91 void setAttribute(const QualifiedName&, const AtomicString& value);
97 void setSynchronizedLazyAttribute(const QualifiedName&, const AtomicString& value); 92 void setSynchronizedLazyAttribute(const QualifiedName&, const AtomicString& value);
98 93
99 void removeAttribute(const QualifiedName&);
100
101 // Typed getters and setters for language bindings. 94 // Typed getters and setters for language bindings.
102 int getIntegralAttribute(const QualifiedName& attributeName) const; 95 int getIntegralAttribute(const QualifiedName& attributeName) const;
103 void setIntegralAttribute(const QualifiedName& attributeName, int value); 96 void setIntegralAttribute(const QualifiedName& attributeName, int value);
104 unsigned getUnsignedIntegralAttribute(const QualifiedName& attributeName) co nst; 97 unsigned getUnsignedIntegralAttribute(const QualifiedName& attributeName) co nst;
105 void setUnsignedIntegralAttribute(const QualifiedName& attributeName, unsign ed value); 98 void setUnsignedIntegralAttribute(const QualifiedName& attributeName, unsign ed value);
106 double getFloatingPointAttribute(const QualifiedName& attributeName, double fallbackValue = std::numeric_limits<double>::quiet_NaN()) const; 99 double getFloatingPointAttribute(const QualifiedName& attributeName, double fallbackValue = std::numeric_limits<double>::quiet_NaN()) const;
107 void setFloatingPointAttribute(const QualifiedName& attributeName, double va lue); 100 void setFloatingPointAttribute(const QualifiedName& attributeName, double va lue);
108 101
109 bool hasAttributes() const;
110
111 bool hasAttribute(const AtomicString& name) const;
112
113 const AtomicString& getAttribute(const AtomicString& name) const;
114
115 void setAttribute(const AtomicString& name, const AtomicString& value, Excep tionState&);
116 static bool parseAttributeName(QualifiedName&, const AtomicString& namespace URI, const AtomicString& qualifiedName, ExceptionState&);
117
118 const AtomicString& getIdAttribute() const; 102 const AtomicString& getIdAttribute() const;
119 void setIdAttribute(const AtomicString&); 103 void setIdAttribute(const AtomicString&);
120 104
121 const AtomicString& getClassAttribute() const; 105 const AtomicString& getClassAttribute() const;
122 106
123 // Call this to get the value of the id attribute for style resolution purpo ses. 107 // Call this to get the value of the id attribute for style resolution purpo ses.
124 // The value will already be lowercased if the document is in compatibility mode, 108 // The value will already be lowercased if the document is in compatibility mode,
125 // so this function is not suitable for non-style uses. 109 // so this function is not suitable for non-style uses.
126 const AtomicString& idForStyleResolution() const; 110 const AtomicString& idForStyleResolution() const;
127 111
(...skipping 26 matching lines...) Expand all
154 void setScrollTop(int); 138 void setScrollTop(int);
155 void setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionState&); 139 void setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionState&);
156 int scrollWidth(); 140 int scrollWidth();
157 int scrollHeight(); 141 int scrollHeight();
158 142
159 PassRefPtr<ClientRectList> getClientRects(); 143 PassRefPtr<ClientRectList> getClientRects();
160 PassRefPtr<ClientRect> getBoundingClientRect(); 144 PassRefPtr<ClientRect> getBoundingClientRect();
161 145
162 virtual void didMoveToNewDocument(Document&) override; 146 virtual void didMoveToNewDocument(Document&) override;
163 147
164 void removeAttribute(const AtomicString& name);
165
166 CSSStyleDeclaration* style(); 148 CSSStyleDeclaration* style();
167 149
168 const QualifiedName& tagQName() const { return m_tagName; } 150 const QualifiedName& tagQName() const { return m_tagName; }
169 String tagName() const { return nodeName(); } 151 String tagName() const { return nodeName(); }
170 152
171 bool hasTagName(const QualifiedName& tagName) const { return m_tagName == ta gName; } 153 bool hasTagName(const QualifiedName& tagName) const { return m_tagName == ta gName; }
172 bool hasTagName(const HTMLQualifiedName& tagName) const { return ContainerNo de::hasTagName(tagName); } 154 bool hasTagName(const HTMLQualifiedName& tagName) const { return ContainerNo de::hasTagName(tagName); }
173 155
174 // A fast function for checking the local name against another atomic string . 156 // A fast function for checking the local name against another atomic string .
175 bool hasLocalName(const AtomicString& other) const { return m_tagName.localN ame() == other; } 157 bool hasLocalName(const AtomicString& other) const { return m_tagName.localN ame() == other; }
(...skipping 17 matching lines...) Expand all
193 bool removeInlineStyleProperty(CSSPropertyID); 175 bool removeInlineStyleProperty(CSSPropertyID);
194 void removeAllInlineStyleProperties(); 176 void removeAllInlineStyleProperties();
195 177
196 void synchronizeStyleAttributeInternal() const; 178 void synchronizeStyleAttributeInternal() const;
197 179
198 enum AttributeModificationReason { 180 enum AttributeModificationReason {
199 ModifiedDirectly, 181 ModifiedDirectly,
200 ModifiedByCloning 182 ModifiedByCloning
201 }; 183 };
202 184
203 virtual void attributeChanged(const QualifiedName&, const AtomicString&, Att ributeModificationReason = ModifiedDirectly);
204 virtual void parseAttribute(const QualifiedName&, const AtomicString&); 185 virtual void parseAttribute(const QualifiedName&, const AtomicString&);
205 186
206 virtual bool hasLegalLinkAttribute(const QualifiedName&) const; 187 virtual bool hasLegalLinkAttribute(const QualifiedName&) const;
207 virtual const QualifiedName& subResourceAttributeName() const; 188 virtual const QualifiedName& subResourceAttributeName() const;
208 189
209 // Only called by the parser immediately after element construction. 190 // Only called by the parser immediately after element construction.
210 void parserSetAttributes(const Vector<Attribute>&); 191 void parserSetAttributes(const Vector<Attribute>&);
211 192
212 // Remove attributes that might introduce scripting from the vector leaving the element unchanged.
213 void stripScriptingAttributes(Vector<Attribute>&) const;
214
215 bool sharesSameElementData(const Element& other) const { return elementData( ) == other.elementData(); } 193 bool sharesSameElementData(const Element& other) const { return elementData( ) == other.elementData(); }
216 194
217 // Clones attributes only. 195 // Clones attributes only.
218 void cloneAttributesFromElement(const Element&); 196 void cloneAttributesFromElement(const Element&);
219 197
220 // Clones all attribute-derived data, including subclass specifics (through copyNonAttributeProperties.) 198 // Clones all attribute-derived data, including subclass specifics (through copyNonAttributeProperties.)
221 void cloneDataFromElement(const Element&); 199 void cloneDataFromElement(const Element&);
222 200
223 bool hasEquivalentAttributes(const Element* other) const; 201 bool hasEquivalentAttributes(const Element* other) const;
224 202
225 virtual void attach(const AttachContext& = AttachContext()) override; 203 virtual void attach(const AttachContext& = AttachContext()) override;
226 virtual void detach(const AttachContext& = AttachContext()) override; 204 virtual void detach(const AttachContext& = AttachContext()) override;
227 virtual RenderObject* createRenderer(RenderStyle*); 205 virtual RenderObject* createRenderer(RenderStyle*);
228 virtual bool rendererIsNeeded(const RenderStyle&); 206 virtual bool rendererIsNeeded(const RenderStyle&);
229 void recalcStyle(StyleRecalcChange, Text* nextTextSibling = 0); 207 void recalcStyle(StyleRecalcChange, Text* nextTextSibling = 0);
230 void didAffectSelector(AffectedSelectorMask);
231 void setAnimationStyleChange(bool); 208 void setAnimationStyleChange(bool);
232 void setNeedsAnimationStyleRecalc(); 209 void setNeedsAnimationStyleRecalc();
233 210
234 void setNeedsCompositingUpdate(); 211 void setNeedsCompositingUpdate();
235 212
236 bool supportsStyleSharing() const; 213 bool supportsStyleSharing() const;
237 214
238 ElementShadow* shadow() const; 215 ElementShadow* shadow() const;
239 ElementShadow& ensureShadow(); 216 ElementShadow& ensureShadow();
240 PassRefPtr<ShadowRoot> createShadowRoot(ExceptionState&); 217 PassRefPtr<ShadowRoot> createShadowRoot(ExceptionState&);
241 ShadowRoot* shadowRoot() const; 218 ShadowRoot* shadowRoot() const;
242 ShadowRoot* youngestShadowRoot() const; 219 ShadowRoot* youngestShadowRoot() const;
243 220
244 bool hasAuthorShadowRoot() const { return shadowRoot(); } 221 bool hasAuthorShadowRoot() const { return shadowRoot(); }
245 222
246 bool isInDescendantTreeOf(const Element* shadowHost) const;
247
248 RenderStyle* computedStyle(PseudoId = NOPSEUDO); 223 RenderStyle* computedStyle(PseudoId = NOPSEUDO);
249 224
250 bool isUpgradedCustomElement() { return customElementState() == Upgraded; } 225 bool isUpgradedCustomElement() { return customElementState() == Upgraded; }
251 bool isUnresolvedCustomElement() { return customElementState() == WaitingFor Upgrade; } 226 bool isUnresolvedCustomElement() { return customElementState() == WaitingFor Upgrade; }
252 227
253 AtomicString computeInheritedLanguage() const; 228 AtomicString computeInheritedLanguage() const;
254 Locale& locale() const; 229 Locale& locale() const;
255 230
256 virtual void accessKeyAction(bool /*sendToAnyEvent*/) { } 231 virtual void accessKeyAction(bool /*sendToAnyEvent*/) { }
257 232
258 virtual bool isURLAttribute(const Attribute&) const { return false; } 233 virtual bool isURLAttribute(const Attribute&) const { return false; }
259 virtual bool isHTMLContentAttribute(const Attribute&) const { return false; }
260 234
261 virtual bool isLiveLink() const { return false; } 235 virtual bool isLiveLink() const { return false; }
262 KURL hrefURL() const; 236 KURL hrefURL() const;
263 237
264 KURL getURLAttribute(const QualifiedName&) const; 238 KURL getURLAttribute(const QualifiedName&) const;
265 KURL getNonEmptyURLAttribute(const QualifiedName&) const; 239 KURL getNonEmptyURLAttribute(const QualifiedName&) const;
266 240
267 virtual const AtomicString imageSourceURL() const; 241 virtual const AtomicString imageSourceURL() const;
268 virtual Image* imageContents() { return 0; } 242 virtual Image* imageContents() { return 0; }
269 243
270 void focus(bool restorePreviousSelection = true, FocusType = FocusTypeNone); 244 void focus(bool restorePreviousSelection = true, FocusType = FocusTypeNone);
271 void updateFocusAppearance(bool restorePreviousSelection); 245 void updateFocusAppearance(bool restorePreviousSelection);
272 void blur(); 246 void blur();
273 // Whether this element can receive focus at all. Most elements are not 247 // Whether this element can receive focus at all. Most elements are not
274 // focusable but some elements, such as form controls and links, are. Unlike 248 // focusable but some elements, such as form controls and links, are. Unlike
275 // rendererIsFocusable(), this method may be called when layout is not up to 249 // rendererIsFocusable(), this method may be called when layout is not up to
276 // date, so it must not use the renderer to determine focusability. 250 // date, so it must not use the renderer to determine focusability.
277 virtual bool supportsFocus() const; 251 virtual bool supportsFocus() const;
278 // Whether the node can actually be focused. 252 // Whether the node can actually be focused.
279 bool isFocusable() const; 253 bool isFocusable() const;
280 virtual bool isKeyboardFocusable() const; 254 bool isKeyboardFocusable() const;
281 virtual bool isMouseFocusable() const; 255 virtual bool isMouseFocusable() const;
282 virtual void willCallDefaultEventHandler(const Event&) override final; 256 virtual void willCallDefaultEventHandler(const Event&) override final;
283 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType); 257 void dispatchFocusEvent(Element* oldFocusedElement, FocusType);
284 virtual void dispatchBlurEvent(Element* newFocusedElement); 258 void dispatchBlurEvent(Element* newFocusedElement);
285 void dispatchFocusInEvent(const AtomicString& eventType, Element* oldFocused Element); 259 void dispatchFocusInEvent(const AtomicString& eventType, Element* oldFocused Element);
286 void dispatchFocusOutEvent(const AtomicString& eventType, Element* newFocuse dElement); 260 void dispatchFocusOutEvent(const AtomicString& eventType, Element* newFocuse dElement);
287 261
288 String innerText();
289 String outerText();
290
291 String textFromChildren();
292
293 virtual String title() const { return String(); } 262 virtual String title() const { return String(); }
294 263
295 LayoutSize minimumSizeForResizing() const; 264 LayoutSize minimumSizeForResizing() const;
296 void setMinimumSizeForResizing(const LayoutSize&); 265 void setMinimumSizeForResizing(const LayoutSize&);
297 266
298 // Called by the parser when this element's close tag is reached, 267 // Called by the parser when this element's close tag is reached,
299 // signaling that all child tags have been parsed and added. 268 // signaling that all child tags have been parsed and added.
300 // This is needed for <applet> and <object> elements, which can't lay themse lves out 269 // This is needed for <applet> and <object> elements, which can't lay themse lves out
301 // until they know all of their nested <param>s. [Radar 3603191, 4040848]. 270 // until they know all of their nested <param>s. [Radar 3603191, 4040848].
302 // Also used for script elements and some SVG elements for similar purposes, 271 // Also used for script elements and some SVG elements for similar purposes,
303 // but making parsing a special case in this respect should be avoided if po ssible. 272 // but making parsing a special case in this respect should be avoided if po ssible.
304 virtual void finishParsingChildren(); 273 virtual void finishParsingChildren() { }
305 274
306 void beginParsingChildren() { setIsFinishedParsingChildren(false); }
307
308 virtual bool matchesReadOnlyPseudoClass() const { return false; }
309 virtual bool matchesReadWritePseudoClass() const { return false; }
310 bool matches(const String& selectors, ExceptionState&); 275 bool matches(const String& selectors, ExceptionState&);
311 virtual bool shouldAppearIndeterminate() const { return false; }
312 276
313 DOMTokenList& classList(); 277 DOMTokenList& classList();
314 278
315 virtual bool canContainRangeEndPoint() const override { return true; } 279 virtual bool canContainRangeEndPoint() const override { return true; }
316 280
317 void setCustomElementDefinition(PassRefPtr<CustomElementDefinition>); 281 void setCustomElementDefinition(PassRefPtr<CustomElementDefinition>);
318 CustomElementDefinition* customElementDefinition() const; 282 CustomElementDefinition* customElementDefinition() const;
319 283
320 bool isSpellCheckingEnabled() const; 284 bool isSpellCheckingEnabled() const;
321 285
(...skipping 15 matching lines...) Expand all
337 bool hasInputMethodContext() const; 301 bool hasInputMethodContext() const;
338 302
339 void synchronizeAttribute(const AtomicString& localName) const; 303 void synchronizeAttribute(const AtomicString& localName) const;
340 304
341 MutableStylePropertySet& ensureMutableInlineStyle(); 305 MutableStylePropertySet& ensureMutableInlineStyle();
342 void clearMutableInlineStyleIfEmpty(); 306 void clearMutableInlineStyleIfEmpty();
343 307
344 void setTabIndex(int); 308 void setTabIndex(int);
345 virtual short tabIndex() const override; 309 virtual short tabIndex() const override;
346 310
347 virtual void trace(Visitor*) override; 311 String textFromChildren();
348 312
349 protected: 313 protected:
350 Element(const QualifiedName& tagName, Document*, ConstructionType); 314 Element(const QualifiedName& tagName, Document*, ConstructionType);
351 315
352 const ElementData* elementData() const { return m_elementData.get(); } 316 const ElementData* elementData() const { return m_elementData.get(); }
353 UniqueElementData& ensureUniqueElementData(); 317 UniqueElementData& ensureUniqueElementData();
354 318
355 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; 319 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
356 virtual void removedFrom(ContainerNode*) override; 320 virtual void removedFrom(ContainerNode*) override;
357 virtual void childrenChanged(const ChildrenChange&) override; 321 virtual void childrenChanged(const ChildrenChange&) override;
(...skipping 16 matching lines...) Expand all
374 virtual void setWasFocusedByMouse(bool) { } 338 virtual void setWasFocusedByMouse(bool) { }
375 339
376 // classAttributeChanged() exists to share code between 340 // classAttributeChanged() exists to share code between
377 // parseAttribute (called via setAttribute()) and 341 // parseAttribute (called via setAttribute()) and
378 // svgAttributeChanged (called when element.className.baseValue is set) 342 // svgAttributeChanged (called when element.className.baseValue is set)
379 void classAttributeChanged(const AtomicString& newClassString); 343 void classAttributeChanged(const AtomicString& newClassString);
380 344
381 PassRefPtr<RenderStyle> originalStyleForRenderer(); 345 PassRefPtr<RenderStyle> originalStyleForRenderer();
382 346
383 private: 347 private:
348 void attributeChanged(const QualifiedName&, const AtomicString&, AttributeMo dificationReason = ModifiedDirectly);
349
384 bool hasElementFlag(ElementFlags mask) const { return hasRareData() && hasEl ementFlagInternal(mask); } 350 bool hasElementFlag(ElementFlags mask) const { return hasRareData() && hasEl ementFlagInternal(mask); }
385 void setElementFlag(ElementFlags, bool value = true); 351 void setElementFlag(ElementFlags, bool value = true);
386 void clearElementFlag(ElementFlags); 352 void clearElementFlag(ElementFlags);
387 bool hasElementFlagInternal(ElementFlags) const; 353 bool hasElementFlagInternal(ElementFlags) const;
388 354
389 bool isElementNode() const = delete; // This will catch anyone doing an unne cessary check. 355 bool isElementNode() const = delete; // This will catch anyone doing an unne cessary check.
390 bool isDocumentFragment() const = delete; // This will catch anyone doing an unnecessary check. 356 bool isDocumentFragment() const = delete; // This will catch anyone doing an unnecessary check.
391 bool isDocumentNode() const = delete; // This will catch anyone doing an unn ecessary check. 357 bool isDocumentNode() const = delete; // This will catch anyone doing an unn ecessary check.
392 358
393 void styleAttributeChanged(const AtomicString& newStyleString); 359 void styleAttributeChanged(const AtomicString& newStyleString);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 static PassRefPtr<T> create(const QualifiedName&, Document&) 606 static PassRefPtr<T> create(const QualifiedName&, Document&)
641 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ 607 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \
642 PassRefPtr<T> T::create(const QualifiedName& tagName, Document& document) \ 608 PassRefPtr<T> T::create(const QualifiedName& tagName, Document& document) \
643 { \ 609 { \
644 return adoptRef(new T(tagName, document)); \ 610 return adoptRef(new T(tagName, document)); \
645 } 611 }
646 612
647 } // namespace 613 } // namespace
648 614
649 #endif // Element_h 615 #endif // Element_h
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698