diff options
author | John Reck <jreck@google.com> | 2010-11-04 12:00:17 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-11-09 11:35:04 -0800 |
commit | e14391e94c850b8bd03680c23b38978db68687a8 (patch) | |
tree | 3fed87e6620fecaf3edc7259ae58a11662bedcb2 /WebCore/dom/Element.cpp | |
parent | 1bd705833a68f07850cf7e204b26f8d328d16951 (diff) | |
download | external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.zip external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.gz external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.bz2 |
Merge Webkit at r70949: Initial merge by git.
Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e
Diffstat (limited to 'WebCore/dom/Element.cpp')
-rw-r--r-- | WebCore/dom/Element.cpp | 88 |
1 files changed, 76 insertions, 12 deletions
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index 10ba71b..a86f30a 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -31,6 +31,7 @@ #include "CSSParser.h" #include "CSSSelectorList.h" #include "CSSStyleSelector.h" +#include "ClassList.h" #include "ClientRect.h" #include "ClientRectList.h" #include "DOMTokenList.h" @@ -52,13 +53,13 @@ #include "RenderLayer.h" #include "RenderView.h" #include "RenderWidget.h" -#include "SVGStyledLocatableElement.h" #include "Settings.h" #include "TextIterator.h" #include "XMLNames.h" #include <wtf/text/CString.h> #if ENABLE(SVG) +#include "SVGElement.h" #include "SVGNames.h" #endif @@ -457,6 +458,41 @@ int Element::scrollHeight() const return 0; } +IntRect Element::boundsInWindowSpace() const +{ + document()->updateLayoutIgnorePendingStylesheets(); + + FrameView* view = document()->view(); + if (!view) + return IntRect(); + + Vector<FloatQuad> quads; +#if ENABLE(SVG) + if (isSVGElement() && renderer()) { + // Get the bounding rectangle from the SVG model. + const SVGElement* svgElement = static_cast<const SVGElement*>(this); + FloatRect localRect; + if (svgElement->boundingBox(localRect)) + quads.append(renderer()->localToAbsoluteQuad(localRect)); + } else +#endif + { + // Get the bounding rectangle from the box model. + if (renderBoxModelObject()) + renderBoxModelObject()->absoluteQuads(quads); + } + + if (quads.isEmpty()) + return IntRect(); + + IntRect result = quads[0].enclosingBoundingBox(); + for (size_t i = 1; i < quads.size(); ++i) + result.unite(quads[i].enclosingBoundingBox()); + + result = view->contentsToWindow(result); + return result; +} + PassRefPtr<ClientRectList> Element::getClientRects() const { document()->updateLayoutIgnorePendingStylesheets(); @@ -488,15 +524,12 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect() const Vector<FloatQuad> quads; #if ENABLE(SVG) - if (isSVGElement()) { + if (isSVGElement() && renderer()) { // Get the bounding rectangle from the SVG model. const SVGElement* svgElement = static_cast<const SVGElement*>(this); - if (svgElement->isStyledLocatable()) { - if (renderer()) { - const FloatRect& localRect = static_cast<const SVGStyledLocatableElement*>(svgElement)->getBBox(); - quads.append(renderer()->localToAbsoluteQuad(localRect)); - } - } + FloatRect localRect; + if (svgElement->boundingBox(localRect)) + quads.append(renderer()->localToAbsoluteQuad(localRect)); } else #endif { @@ -517,9 +550,7 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect() const result.move(-visibleContentRect.x(), -visibleContentRect.y()); } - if (renderBoxModelObject()) - adjustIntRectForAbsoluteZoom(result, renderBoxModelObject()); - + adjustIntRectForAbsoluteZoom(result, renderer()); return ClientRect::create(result); } @@ -1588,7 +1619,7 @@ DOMTokenList* Element::classList() { ElementRareData* data = ensureRareData(); if (!data->m_classList) - data->m_classList = DOMTokenList::create(this); + data->m_classList = ClassList::create(this); return data->m_classList.get(); } @@ -1681,4 +1712,37 @@ void Element::webkitRequestFullScreen(unsigned short flags) } #endif +SpellcheckAttributeState Element::spellcheckAttributeState() const +{ + if (!hasAttribute(HTMLNames::spellcheckAttr)) + return SpellcheckAttributeDefault; + + const AtomicString& value = getAttribute(HTMLNames::spellcheckAttr); + if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, "")) + return SpellcheckAttributeTrue; + if (equalIgnoringCase(value, "false")) + return SpellcheckAttributeFalse; + + return SpellcheckAttributeDefault; +} + +bool Element::isSpellCheckingEnabled() const +{ + const Element* element = this; + while (element) { + switch (element->spellcheckAttributeState()) { + case SpellcheckAttributeTrue: + return true; + case SpellcheckAttributeFalse: + return false; + case SpellcheckAttributeDefault: + break; + } + + element = element->parentElement(); + } + + return true; +} + } // namespace WebCore |