From e14391e94c850b8bd03680c23b38978db68687a8 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 4 Nov 2010 12:00:17 -0700 Subject: Merge Webkit at r70949: Initial merge by git. Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e --- WebCore/dom/Element.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 12 deletions(-) (limited to 'WebCore/dom/Element.cpp') 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 #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 quads; +#if ENABLE(SVG) + if (isSVGElement() && renderer()) { + // Get the bounding rectangle from the SVG model. + const SVGElement* svgElement = static_cast(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 Element::getClientRects() const { document()->updateLayoutIgnorePendingStylesheets(); @@ -488,15 +524,12 @@ PassRefPtr Element::getBoundingClientRect() const Vector quads; #if ENABLE(SVG) - if (isSVGElement()) { + if (isSVGElement() && renderer()) { // Get the bounding rectangle from the SVG model. const SVGElement* svgElement = static_cast(this); - if (svgElement->isStyledLocatable()) { - if (renderer()) { - const FloatRect& localRect = static_cast(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 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 -- cgit v1.1