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

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

Issue 772133003: Mostly merge HTMLElement into Element. (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.h ('k') | sky/engine/core/dom/Element.idl » ('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 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 26 matching lines...) Expand all
37 #include "sky/engine/core/css/CSSImageValue.h" 37 #include "sky/engine/core/css/CSSImageValue.h"
38 #include "sky/engine/core/css/CSSStyleSheet.h" 38 #include "sky/engine/core/css/CSSStyleSheet.h"
39 #include "sky/engine/core/css/CSSValuePool.h" 39 #include "sky/engine/core/css/CSSValuePool.h"
40 #include "sky/engine/core/css/PropertySetCSSStyleDeclaration.h" 40 #include "sky/engine/core/css/PropertySetCSSStyleDeclaration.h"
41 #include "sky/engine/core/css/StylePropertySet.h" 41 #include "sky/engine/core/css/StylePropertySet.h"
42 #include "sky/engine/core/css/parser/BisonCSSParser.h" 42 #include "sky/engine/core/css/parser/BisonCSSParser.h"
43 #include "sky/engine/core/css/resolver/StyleResolver.h" 43 #include "sky/engine/core/css/resolver/StyleResolver.h"
44 #include "sky/engine/core/dom/Attr.h" 44 #include "sky/engine/core/dom/Attr.h"
45 #include "sky/engine/core/dom/ClientRect.h" 45 #include "sky/engine/core/dom/ClientRect.h"
46 #include "sky/engine/core/dom/ClientRectList.h" 46 #include "sky/engine/core/dom/ClientRectList.h"
47 #include "sky/engine/core/dom/Document.h"
47 #include "sky/engine/core/dom/ElementDataCache.h" 48 #include "sky/engine/core/dom/ElementDataCache.h"
48 #include "sky/engine/core/dom/ElementRareData.h" 49 #include "sky/engine/core/dom/ElementRareData.h"
49 #include "sky/engine/core/dom/ElementTraversal.h" 50 #include "sky/engine/core/dom/ElementTraversal.h"
50 #include "sky/engine/core/dom/ExceptionCode.h" 51 #include "sky/engine/core/dom/ExceptionCode.h"
51 #include "sky/engine/core/dom/MutationObserverInterestGroup.h" 52 #include "sky/engine/core/dom/MutationObserverInterestGroup.h"
52 #include "sky/engine/core/dom/MutationRecord.h" 53 #include "sky/engine/core/dom/MutationRecord.h"
53 #include "sky/engine/core/dom/NodeRenderStyle.h" 54 #include "sky/engine/core/dom/NodeRenderStyle.h"
54 #include "sky/engine/core/dom/RenderTreeBuilder.h" 55 #include "sky/engine/core/dom/RenderTreeBuilder.h"
55 #include "sky/engine/core/dom/SelectorQuery.h" 56 #include "sky/engine/core/dom/SelectorQuery.h"
56 #include "sky/engine/core/dom/StyleEngine.h" 57 #include "sky/engine/core/dom/StyleEngine.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ensureElementRareData().setTabIndexExplicitly(tabIndex); 158 ensureElementRareData().setTabIndexExplicitly(tabIndex);
158 } 159 }
159 160
160 void Element::setTabIndex(int value) 161 void Element::setTabIndex(int value)
161 { 162 {
162 setIntegralAttribute(HTMLNames::tabindexAttr, value); 163 setIntegralAttribute(HTMLNames::tabindexAttr, value);
163 } 164 }
164 165
165 short Element::tabIndex() const 166 short Element::tabIndex() const
166 { 167 {
167 return hasRareData() ? elementRareData()->tabIndex() : 0; 168 if (supportsFocus())
169 return hasRareData() ? elementRareData()->tabIndex() : 0;
170 return -1;
168 } 171 }
169 172
170 bool Element::rendererIsFocusable() const 173 bool Element::rendererIsFocusable() const
171 { 174 {
172 // FIXME: These asserts should be in Node::isFocusable, but there are some 175 // FIXME: These asserts should be in Node::isFocusable, but there are some
173 // callsites like Document::setFocusedElement that would currently fail on 176 // callsites like Document::setFocusedElement that would currently fail on
174 // them. See crbug.com/251163 177 // them. See crbug.com/251163
175 if (!renderer()) { 178 if (!renderer()) {
176 // Elements in canvas fallback content are not rendered, but they are al lowed to be 179 // Elements in canvas fallback content are not rendered, but they are al lowed to be
177 // focusable as long as their canvas is displayed and visible. 180 // focusable as long as their canvas is displayed and visible.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 Node::NodeType Element::nodeType() const 269 Node::NodeType Element::nodeType() const
267 { 270 {
268 return ELEMENT_NODE; 271 return ELEMENT_NODE;
269 } 272 }
270 273
271 void Element::synchronizeAllAttributes() const 274 void Element::synchronizeAllAttributes() const
272 { 275 {
273 synchronizeAttribute(HTMLNames::styleAttr.localName()); 276 synchronizeAttribute(HTMLNames::styleAttr.localName());
274 } 277 }
275 278
279 String Element::title() const
280 {
281 return getAttribute(HTMLNames::titleAttr);
282 }
283
284 String Element::contentEditable() const
285 {
286 const AtomicString& value = getAttribute(HTMLNames::contenteditableAttr);
287
288 if (value.isNull())
289 return "inherit";
290 if (value.isEmpty() || equalIgnoringCase(value, "true"))
291 return "true";
292 if (equalIgnoringCase(value, "false"))
293 return "false";
294 if (equalIgnoringCase(value, "plaintext-only"))
295 return "plaintext-only";
296
297 return "inherit";
298 }
299
300 void Element::setContentEditable(const String& enabled, ExceptionState& exceptio nState)
301 {
302 if (equalIgnoringCase(enabled, "true"))
303 setAttribute(HTMLNames::contenteditableAttr, "true");
304 else if (equalIgnoringCase(enabled, "false"))
305 setAttribute(HTMLNames::contenteditableAttr, "false");
306 else if (equalIgnoringCase(enabled, "plaintext-only"))
307 setAttribute(HTMLNames::contenteditableAttr, "plaintext-only");
308 else if (equalIgnoringCase(enabled, "inherit"))
309 removeAttribute(HTMLNames::contenteditableAttr);
310 else
311 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + enabled + "') is not one of 'true', 'false', 'plaintext-only', or 'inherit'.");
312 }
313
314 bool Element::spellcheck() const
315 {
316 return isSpellCheckingEnabled();
317 }
318
319 void Element::setSpellcheck(bool enable)
320 {
321 setAttribute(HTMLNames::spellcheckAttr, enable ? "true" : "false");
322 }
323
324
325 void Element::click()
326 {
327 dispatchSimulatedClick(0, SendNoEvents);
328 }
329
330 // Returns the conforming 'dir' value associated with the state the attribute is in (in its canonical case), if any,
331 // or the empty string if the attribute is in a state that has no associated key word value or if the attribute is
332 // not in a defined state (e.g. the attribute is missing and there is no missing value default).
333 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interf aces.html#limited-to-only-known-values
334 static inline const AtomicString& toValidDirValue(const AtomicString& value)
335 {
336 DEFINE_STATIC_LOCAL(const AtomicString, ltrValue, ("ltr", AtomicString::Cons tructFromLiteral));
337 DEFINE_STATIC_LOCAL(const AtomicString, rtlValue, ("rtl", AtomicString::Cons tructFromLiteral));
338 DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto", AtomicString::Co nstructFromLiteral));
339
340 if (equalIgnoringCase(value, ltrValue))
341 return ltrValue;
342 if (equalIgnoringCase(value, rtlValue))
343 return rtlValue;
344 if (equalIgnoringCase(value, autoValue))
345 return autoValue;
346 return nullAtom;
347 }
348
349 const AtomicString& Element::dir()
350 {
351 return toValidDirValue(getAttribute(HTMLNames::dirAttr));
352 }
353
354 void Element::setDir(const AtomicString& value)
355 {
356 setAttribute(HTMLNames::dirAttr, value);
357 }
358
276 int Element::offsetLeft() 359 int Element::offsetLeft()
277 { 360 {
278 document().updateLayoutIgnorePendingStylesheets(); 361 document().updateLayoutIgnorePendingStylesheets();
279 if (RenderBoxModelObject* renderer = renderBoxModelObject()) 362 if (RenderBoxModelObject* renderer = renderBoxModelObject())
280 return renderer->offsetLeft(); 363 return renderer->offsetLeft();
281 return 0; 364 return 0;
282 } 365 }
283 366
284 int Element::offsetTop() 367 int Element::offsetTop()
285 { 368 {
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 return false; 1834 return false;
1752 // Turn off style sharing for elements that can gain layers for reasons outs ide of the style system. 1835 // Turn off style sharing for elements that can gain layers for reasons outs ide of the style system.
1753 // See comments in RenderObject::setStyle(). 1836 // See comments in RenderObject::setStyle().
1754 // FIXME: Why does gaining a layer from outside the style system require dis abling sharing? 1837 // FIXME: Why does gaining a layer from outside the style system require dis abling sharing?
1755 if (isHTMLCanvasElement(*this)) 1838 if (isHTMLCanvasElement(*this))
1756 return false; 1839 return false;
1757 return true; 1840 return true;
1758 } 1841 }
1759 1842
1760 } // namespace blink 1843 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Element.h ('k') | sky/engine/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698