summaryrefslogtreecommitdiff
path: root/src/3rdparty/webkit/WebCore/dom/Element.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/dom/Element.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/dom/Element.cpp281
1 files changed, 192 insertions, 89 deletions
diff --git a/src/3rdparty/webkit/WebCore/dom/Element.cpp b/src/3rdparty/webkit/WebCore/dom/Element.cpp
index 5faeea2f0c..4cf49bb4ac 100644
--- a/src/3rdparty/webkit/WebCore/dom/Element.cpp
+++ b/src/3rdparty/webkit/WebCore/dom/Element.cpp
@@ -4,7 +4,7 @@
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* (C) 2007 David Smith (catfish.man@gmail.com)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* (C) 2007 Eric Seidel (eric@webkit.org)
*
* This library is free software; you can redistribute it and/or
@@ -27,8 +27,11 @@
#include "Element.h"
#include "AXObjectCache.h"
+#include "Attr.h"
#include "CSSStyleSelector.h"
#include "CString.h"
+#include "ClientRect.h"
+#include "ClientRectList.h"
#include "Document.h"
#include "Editor.h"
#include "ElementRareData.h"
@@ -38,7 +41,7 @@
#include "FrameView.h"
#include "HTMLElement.h"
#include "HTMLNames.h"
-#include "NamedAttrMap.h"
+#include "NamedNodeMap.h"
#include "NodeList.h"
#include "NodeRenderStyle.h"
#include "Page.h"
@@ -48,6 +51,10 @@
#include "TextIterator.h"
#include "XMLNames.h"
+#if ENABLE(SVG)
+#include "SVGNames.h"
+#endif
+
namespace WebCore {
using namespace HTMLNames;
@@ -78,30 +85,35 @@ inline ElementRareData* Element::ensureRareData()
NodeRareData* Element::createRareData()
{
- return new ElementRareData(this);
+ return new ElementRareData;
}
PassRefPtr<Node> Element::cloneNode(bool deep)
{
- ExceptionCode ec = 0;
- RefPtr<Element> clone = document()->createElementNS(namespaceURI(), nodeName(), ec);
- ASSERT(!ec);
-
- // clone attributes
- if (namedAttrMap)
- clone->attributes()->setAttributes(*namedAttrMap);
-
- clone->copyNonAttributeProperties(this);
-
- if (deep)
- cloneChildNodes(clone.get());
+ return deep ? cloneElementWithChildren() : cloneElementWithoutChildren();
+}
+PassRefPtr<Element> Element::cloneElementWithChildren()
+{
+ RefPtr<Element> clone = cloneElementWithoutChildren();
+ cloneChildNodes(clone.get());
return clone.release();
}
-PassRefPtr<Element> Element::cloneElement()
+PassRefPtr<Element> Element::cloneElementWithoutChildren()
{
- return static_pointer_cast<Element>(cloneNode(false));
+ RefPtr<Element> clone = document()->createElement(tagQName(), false);
+ // This will catch HTML elements in the wrong namespace that are not correctly copied.
+ // This is a sanity check as HTML overloads some of the DOM methods.
+ ASSERT(isHTMLElement() == clone->isHTMLElement());
+
+ // Clone attributes.
+ if (namedAttrMap)
+ clone->attributes()->setAttributes(*attributes(true)); // Call attributes(true) to force attribute synchronization to occur (for svg and style) before cloning happens.
+
+ clone->copyNonAttributeProperties(this);
+
+ return clone.release();
}
void Element::removeAttribute(const QualifiedName& name, ExceptionCode& ec)
@@ -130,12 +142,12 @@ void Element::setBooleanAttribute(const QualifiedName& name, bool b)
}
// Virtual function, defined in base class.
-NamedAttrMap* Element::attributes() const
+NamedNodeMap* Element::attributes() const
{
return attributes(false);
}
-NamedAttrMap* Element::attributes(bool readonly) const
+NamedNodeMap* Element::attributes(bool readonly) const
{
if (!m_isStyleAttributeValid)
updateStyleAttribute();
@@ -189,9 +201,9 @@ void Element::scrollIntoView(bool alignToTop)
if (renderer()) {
// Align to the top / bottom and to the closest edge.
if (alignToTop)
- renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, RenderLayer::gAlignToEdgeIfNeeded, RenderLayer::gAlignTopAlways);
+ renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
else
- renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, RenderLayer::gAlignToEdgeIfNeeded, RenderLayer::gAlignBottomAlways);
+ renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
}
}
@@ -201,9 +213,9 @@ void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
IntRect bounds = getRect();
if (renderer()) {
if (centerIfNeeded)
- renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, RenderLayer::gAlignCenterIfNeeded, RenderLayer::gAlignCenterIfNeeded);
+ renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
else
- renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, RenderLayer::gAlignToEdgeIfNeeded, RenderLayer::gAlignToEdgeIfNeeded);
+ renderer()->enclosingLayer()->scrollRectToVisible(bounds, false, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
}
}
@@ -217,7 +229,7 @@ void Element::scrollByUnits(int units, ScrollGranularity granularity)
direction = ScrollUp;
units = -units;
}
- rend->layer()->scroll(direction, granularity, units);
+ toRenderBox(rend)->layer()->scroll(direction, granularity, units);
}
}
}
@@ -258,23 +270,54 @@ static float localZoomForRenderer(RenderObject* renderer)
static int adjustForLocalZoom(int value, RenderObject* renderer)
{
float zoomFactor = localZoomForRenderer(renderer);
- if (zoomFactor == 1.0f)
+ if (zoomFactor == 1)
return value;
+ // Needed because computeLengthInt truncates (rather than rounds) when scaling up.
+ if (zoomFactor > 1)
+ value++;
return static_cast<int>(value / zoomFactor);
}
static int adjustForAbsoluteZoom(int value, RenderObject* renderer)
{
float zoomFactor = renderer->style()->effectiveZoom();
- if (zoomFactor == 1.0f)
+ if (zoomFactor == 1)
return value;
+ // Needed because computeLengthInt truncates (rather than rounds) when scaling up.
+ if (zoomFactor > 1)
+ value++;
return static_cast<int>(value / zoomFactor);
}
+static FloatPoint adjustFloatPointForAbsoluteZoom(const FloatPoint& point, RenderObject* renderer)
+{
+ // The result here is in floats, so we don't need the truncation hack from the integer version above.
+ float zoomFactor = renderer->style()->effectiveZoom();
+ if (zoomFactor == 1)
+ return point;
+ return FloatPoint(point.x() / zoomFactor, point.y() / zoomFactor);
+}
+
+static void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
+{
+ quad.setP1(adjustFloatPointForAbsoluteZoom(quad.p1(), renderer));
+ quad.setP2(adjustFloatPointForAbsoluteZoom(quad.p2(), renderer));
+ quad.setP3(adjustFloatPointForAbsoluteZoom(quad.p3(), renderer));
+ quad.setP4(adjustFloatPointForAbsoluteZoom(quad.p4(), renderer));
+}
+
+static void adjustIntRectForAbsoluteZoom(IntRect& rect, RenderObject* renderer)
+{
+ rect.setX(adjustForAbsoluteZoom(rect.x(), renderer));
+ rect.setY(adjustForAbsoluteZoom(rect.y(), renderer));
+ rect.setWidth(adjustForAbsoluteZoom(rect.width(), renderer));
+ rect.setHeight(adjustForAbsoluteZoom(rect.height(), renderer));
+}
+
int Element::offsetLeft()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBoxModelObject* rend = renderBoxModelObject())
return adjustForLocalZoom(rend->offsetLeft(), rend);
return 0;
}
@@ -282,7 +325,7 @@ int Element::offsetLeft()
int Element::offsetTop()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBoxModelObject* rend = renderBoxModelObject())
return adjustForLocalZoom(rend->offsetTop(), rend);
return 0;
}
@@ -290,7 +333,7 @@ int Element::offsetTop()
int Element::offsetWidth()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBoxModelObject* rend = renderBoxModelObject())
return adjustForAbsoluteZoom(rend->offsetWidth(), rend);
return 0;
}
@@ -298,7 +341,7 @@ int Element::offsetWidth()
int Element::offsetHeight()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBoxModelObject* rend = renderBoxModelObject())
return adjustForAbsoluteZoom(rend->offsetHeight(), rend);
return 0;
}
@@ -308,7 +351,7 @@ Element* Element::offsetParent()
document()->updateLayoutIgnorePendingStylesheets();
if (RenderObject* rend = renderer())
if (RenderObject* offsetParent = rend->offsetParent())
- return static_cast<Element*>(offsetParent->element());
+ return static_cast<Element*>(offsetParent->node());
return 0;
}
@@ -316,7 +359,7 @@ int Element::clientLeft()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->clientLeft(), rend);
return 0;
}
@@ -325,7 +368,7 @@ int Element::clientTop()
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->clientTop(), rend);
return 0;
}
@@ -340,11 +383,10 @@ int Element::clientWidth()
if ((!inCompatMode && document()->documentElement() == this) ||
(inCompatMode && isHTMLElement() && document()->body() == this)) {
if (FrameView* view = document()->view())
- return view->layoutWidth();
+ return adjustForAbsoluteZoom(view->layoutWidth(), document()->renderer());
}
-
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->clientWidth(), rend);
return 0;
}
@@ -360,26 +402,26 @@ int Element::clientHeight()
if ((!inCompatMode && document()->documentElement() == this) ||
(inCompatMode && isHTMLElement() && document()->body() == this)) {
if (FrameView* view = document()->view())
- return view->layoutHeight();
+ return adjustForAbsoluteZoom(view->layoutHeight(), document()->renderer());
}
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->clientHeight(), rend);
return 0;
}
-int Element::scrollLeft()
+int Element::scrollLeft() const
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->scrollLeft(), rend);
return 0;
}
-int Element::scrollTop()
+int Element::scrollTop() const
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->scrollTop(), rend);
return 0;
}
@@ -387,33 +429,85 @@ int Element::scrollTop()
void Element::setScrollLeft(int newLeft)
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZoom()));
}
void Element::setScrollTop(int newTop)
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoom()));
}
-int Element::scrollWidth()
+int Element::scrollWidth() const
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->scrollWidth(), rend);
return 0;
}
-int Element::scrollHeight()
+int Element::scrollHeight() const
{
document()->updateLayoutIgnorePendingStylesheets();
- if (RenderObject* rend = renderer())
+ if (RenderBox* rend = renderBox())
return adjustForAbsoluteZoom(rend->scrollHeight(), rend);
return 0;
}
+PassRefPtr<ClientRectList> Element::getClientRects() const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+
+ RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject();
+ if (!renderBoxModelObject)
+ return ClientRectList::create();
+
+ // FIXME: Handle SVG elements.
+ // FIXME: Handle table/inline-table with a caption.
+
+ Vector<FloatQuad> quads;
+ renderBoxModelObject->absoluteQuads(quads);
+
+ if (FrameView* view = document()->view()) {
+ IntRect visibleContentRect = view->visibleContentRect();
+ for (size_t i = 0; i < quads.size(); ++i) {
+ quads[i].move(-visibleContentRect.x(), -visibleContentRect.y());
+ adjustFloatQuadForAbsoluteZoom(quads[i], renderBoxModelObject);
+ }
+ }
+
+ return ClientRectList::create(quads);
+}
+
+PassRefPtr<ClientRect> Element::getBoundingClientRect() const
+{
+ document()->updateLayoutIgnorePendingStylesheets();
+ RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject();
+ if (!renderBoxModelObject)
+ return ClientRect::create();
+
+ Vector<FloatQuad> quads;
+ renderBoxModelObject->absoluteQuads(quads);
+
+ if (quads.isEmpty())
+ return ClientRect::create();
+
+ IntRect result = quads[0].enclosingBoundingBox();
+ for (size_t i = 1; i < quads.size(); ++i)
+ result.unite(quads[i].enclosingBoundingBox());
+
+ if (FrameView* view = document()->view()) {
+ IntRect visibleContentRect = view->visibleContentRect();
+ result.move(-visibleContentRect.x(), -visibleContentRect.y());
+ }
+
+ adjustIntRectForAbsoluteZoom(result, renderBoxModelObject);
+
+ return ClientRect::create(result);
+}
+
static inline bool shouldIgnoreAttributeCase(const Element* e)
{
return e && e->document()->isHTMLDocument() && e->isHTMLElement();
@@ -496,20 +590,20 @@ PassRefPtr<Attribute> Element::createAttribute(const QualifiedName& name, const
void Element::attributeChanged(Attribute* attr, bool)
{
+ if (!document()->axObjectCache()->accessibilityEnabled())
+ return;
+
const QualifiedName& attrName = attr->name();
if (attrName == aria_activedescendantAttr) {
// any change to aria-activedescendant attribute triggers accessibility focus change, but document focus remains intact
- if (document()->axObjectCache()->accessibilityEnabled())
- document()->axObjectCache()->handleActiveDescendantChanged(renderer());
- }
- if (attrName == roleAttr) {
+ document()->axObjectCache()->handleActiveDescendantChanged(renderer());
+ } else if (attrName == roleAttr) {
// the role attribute can change at any time, and the AccessibilityObject must pick up these changes
- if (document()->axObjectCache()->accessibilityEnabled())
- document()->axObjectCache()->handleAriaRoleChanged(renderer());
+ document()->axObjectCache()->handleAriaRoleChanged(renderer());
}
}
-void Element::setAttributeMap(PassRefPtr<NamedAttrMap> list)
+void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list)
{
document()->incDOMTreeVersion();
@@ -587,7 +681,7 @@ KURL Element::baseURI() const
void Element::createAttributeMap() const
{
- namedAttrMap = NamedAttrMap::create(const_cast<Element*>(this));
+ namedAttrMap = NamedNodeMap::create(const_cast<Element*>(this));
}
bool Element::isURLAttribute(Attribute*) const
@@ -620,7 +714,7 @@ void Element::insertedIntoDocument()
ContainerNode::insertedIntoDocument();
if (hasID()) {
- if (NamedAttrMap* attrs = namedAttrMap.get()) {
+ if (NamedNodeMap* attrs = namedAttrMap.get()) {
Attribute* idItem = attrs->getAttributeItem(idAttr);
if (idItem && !idItem->isNull())
updateId(nullAtom, idItem->value());
@@ -631,7 +725,7 @@ void Element::insertedIntoDocument()
void Element::removedFromDocument()
{
if (hasID()) {
- if (NamedAttrMap* attrs = namedAttrMap.get()) {
+ if (NamedNodeMap* attrs = namedAttrMap.get()) {
Attribute* idItem = attrs->getAttributeItem(idAttr);
if (idItem && !idItem->isNull())
updateId(idItem->value(), nullAtom);
@@ -643,6 +737,8 @@ void Element::removedFromDocument()
void Element::attach()
{
+ suspendPostAttachCallbacks();
+
createRendererIfNeeded();
ContainerNode::attach();
if (hasRareData()) {
@@ -653,13 +749,15 @@ void Element::attach()
data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
}
}
+
+ resumePostAttachCallbacks();
}
void Element::detach()
{
cancelFocusAppearanceUpdate();
if (hasRareData())
- rareData()->resetComputedStyle(this);
+ rareData()->resetComputedStyle();
ContainerNode::detach();
}
@@ -667,7 +765,7 @@ void Element::recalcStyle(StyleChange change)
{
RenderStyle* currentStyle = renderStyle();
bool hasParentStyle = parentNode() ? parentNode()->renderStyle() : false;
- bool hasPositionalRules = changed() && currentStyle && currentStyle->childrenAffectedByPositionalRules();
+ bool hasPositionalRules = needsStyleRecalc() && currentStyle && currentStyle->childrenAffectedByPositionalRules();
bool hasDirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByDirectAdjacentRules();
#if ENABLE(SVG)
@@ -675,11 +773,11 @@ void Element::recalcStyle(StyleChange change)
hasParentStyle = true;
#endif
- if ((change > NoChange || changed())) {
+ if ((change > NoChange || needsStyleRecalc())) {
if (hasRareData())
- rareData()->resetComputedStyle(this);
+ rareData()->resetComputedStyle();
}
- if (hasParentStyle && (change >= Inherit || changed())) {
+ if (hasParentStyle && (change >= Inherit || needsStyleRecalc())) {
RefPtr<RenderStyle> newStyle = document()->styleSelector()->styleForElement(this);
StyleChange ch = diff(currentStyle, newStyle.get());
if (ch == Detach || !currentStyle) {
@@ -687,8 +785,8 @@ void Element::recalcStyle(StyleChange change)
detach();
attach(); // FIXME: The style gets computed twice by calling attach. We could do better if we passed the style along.
// attach recalulates the style for all children. No need to do it twice.
- setChanged(NoStyleChange);
- setHasChangedChild(false);
+ setNeedsStyleRecalc(NoStyleChange);
+ setChildNeedsStyleRecalc(false);
return;
}
@@ -715,7 +813,7 @@ void Element::recalcStyle(StyleChange change)
if (ch != NoChange) {
setRenderStyle(newStyle);
- } else if (changed() && (styleChangeType() != AnimationStyleChange) && (document()->usesSiblingRules() || document()->usesDescendantRules())) {
+ } else if (needsStyleRecalc() && (styleChangeType() != AnimationStyleChange) && (document()->usesSiblingRules() || document()->usesDescendantRules())) {
// Although no change occurred, we use the new style so that the cousin style sharing code won't get
// fooled into believing this style is the same. This is only necessary if the document actually uses
// sibling/descendant rules, since otherwise it isn't possible for ancestor styles to affect sharing of
@@ -740,17 +838,17 @@ void Element::recalcStyle(StyleChange change)
// without doing way too much re-resolution.
bool forceCheckOfNextElementSibling = false;
for (Node *n = firstChild(); n; n = n->nextSibling()) {
- bool childRulesChanged = n->changed() && n->styleChangeType() == FullStyleChange;
+ bool childRulesChanged = n->needsStyleRecalc() && n->styleChangeType() == FullStyleChange;
if (forceCheckOfNextElementSibling && n->isElementNode())
- n->setChanged();
- if (change >= Inherit || n->isTextNode() || n->hasChangedChild() || n->changed())
+ n->setNeedsStyleRecalc();
+ if (change >= Inherit || n->isTextNode() || n->childNeedsStyleRecalc() || n->needsStyleRecalc())
n->recalcStyle(change);
if (n->isElementNode())
forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
}
- setChanged(NoStyleChange);
- setHasChangedChild(false);
+ setNeedsStyleRecalc(NoStyleChange);
+ setChildNeedsStyleRecalc(false);
}
bool Element::childTypeAllowed(NodeType type)
@@ -772,7 +870,7 @@ bool Element::childTypeAllowed(NodeType type)
static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool finishedParsingCallback,
Node* beforeChange, Node* afterChange, int childCountDelta)
{
- if (!style || (e->changed() && style->childrenAffectedByPositionalRules()))
+ if (!style || (e->needsStyleRecalc() && style->childrenAffectedByPositionalRules()))
return;
// :first-child. In the parser callback case, we don't have to check anything, since we were right the first time.
@@ -792,11 +890,11 @@ static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin
// This is the insert/append case.
if (newFirstChild != firstElementAfterInsertion && firstElementAfterInsertion && firstElementAfterInsertion->attached() &&
firstElementAfterInsertion->renderStyle() && firstElementAfterInsertion->renderStyle()->firstChildState())
- firstElementAfterInsertion->setChanged();
+ firstElementAfterInsertion->setNeedsStyleRecalc();
// We also have to handle node removal.
if (childCountDelta < 0 && newFirstChild == firstElementAfterInsertion && newFirstChild && newFirstChild->renderStyle() && !newFirstChild->renderStyle()->firstChildState())
- newFirstChild->setChanged();
+ newFirstChild->setNeedsStyleRecalc();
}
// :last-child. In the parser callback case, we don't have to check anything, since we were right the first time.
@@ -814,12 +912,12 @@ static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin
if (newLastChild != lastElementBeforeInsertion && lastElementBeforeInsertion && lastElementBeforeInsertion->attached() &&
lastElementBeforeInsertion->renderStyle() && lastElementBeforeInsertion->renderStyle()->lastChildState())
- lastElementBeforeInsertion->setChanged();
+ lastElementBeforeInsertion->setNeedsStyleRecalc();
// We also have to handle node removal. The parser callback case is similar to node removal as well in that we need to change the last child
// to match now.
if ((childCountDelta < 0 || finishedParsingCallback) && newLastChild == lastElementBeforeInsertion && newLastChild && newLastChild->renderStyle() && !newLastChild->renderStyle()->lastChildState())
- newLastChild->setChanged();
+ newLastChild->setNeedsStyleRecalc();
}
// The + selector. We need to invalidate the first element following the insertion point. It is the only possible element
@@ -830,7 +928,7 @@ static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin
firstElementAfterInsertion && !firstElementAfterInsertion->isElementNode();
firstElementAfterInsertion = firstElementAfterInsertion->nextSibling()) {};
if (firstElementAfterInsertion && firstElementAfterInsertion->attached())
- firstElementAfterInsertion->setChanged();
+ firstElementAfterInsertion->setNeedsStyleRecalc();
}
// Forward positional selectors include the ~ selector, nth-child, nth-of-type, first-of-type and only-of-type.
@@ -842,11 +940,11 @@ static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin
// here. recalcStyle will then force a walk of the children when it sees that this has happened.
if ((style->childrenAffectedByForwardPositionalRules() && afterChange) ||
(style->childrenAffectedByBackwardPositionalRules() && beforeChange))
- e->setChanged();
+ e->setNeedsStyleRecalc();
// :empty selector.
if (style->affectedByEmpty() && (!style->emptyState() || e->hasChildNodes()))
- e->setChanged();
+ e->setNeedsStyleRecalc();
}
void Element::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
@@ -891,7 +989,7 @@ String Element::openTagStartToString() const
{
String result = "<" + nodeName();
- NamedAttrMap *attrMap = attributes(true);
+ NamedNodeMap* attrMap = attributes(true);
if (attrMap) {
unsigned numAttrs = attrMap->length();
@@ -991,7 +1089,7 @@ PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionCode& ec)
return 0;
}
- NamedAttrMap *attrs = attributes(true);
+ NamedNodeMap* attrs = attributes(true);
if (!attrs)
return 0;
@@ -1026,7 +1124,7 @@ void Element::removeAttributeNS(const String& namespaceURI, const String& localN
PassRefPtr<Attr> Element::getAttributeNode(const String& name)
{
- NamedAttrMap* attrs = attributes(true);
+ NamedNodeMap* attrs = attributes(true);
if (!attrs)
return 0;
String localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
@@ -1035,7 +1133,7 @@ PassRefPtr<Attr> Element::getAttributeNode(const String& name)
PassRefPtr<Attr> Element::getAttributeNodeNS(const String& namespaceURI, const String& localName)
{
- NamedAttrMap* attrs = attributes(true);
+ NamedNodeMap* attrs = attributes(true);
if (!attrs)
return 0;
return static_pointer_cast<Attr>(attrs->getNamedItem(QualifiedName(nullAtom, localName, namespaceURI)));
@@ -1043,7 +1141,7 @@ PassRefPtr<Attr> Element::getAttributeNodeNS(const String& namespaceURI, const S
bool Element::hasAttribute(const String& name) const
{
- NamedAttrMap* attrs = attributes(true);
+ NamedNodeMap* attrs = attributes(true);
if (!attrs)
return false;
@@ -1055,7 +1153,7 @@ bool Element::hasAttribute(const String& name) const
bool Element::hasAttributeNS(const String& namespaceURI, const String& localName) const
{
- NamedAttrMap* attrs = attributes(true);
+ NamedNodeMap* attrs = attributes(true);
if (!attrs)
return false;
return attrs->getAttributeItem(QualifiedName(nullAtom, localName, namespaceURI));
@@ -1097,14 +1195,19 @@ void Element::updateFocusAppearance(bool /*restorePreviousSelection*/)
return;
// FIXME: We should restore the previous selection if there is one.
- Selection newSelection = hasTagName(htmlTag) || hasTagName(bodyTag) ? Selection(Position(this, 0), DOWNSTREAM) : Selection::selectionFromContentsOfNode(this);
+ VisibleSelection newSelection = hasTagName(htmlTag) || hasTagName(bodyTag) ? VisibleSelection(Position(this, 0), DOWNSTREAM) : VisibleSelection::selectionFromContentsOfNode(this);
if (frame->shouldChangeSelection(newSelection)) {
frame->selection()->setSelection(newSelection);
frame->revealSelection();
}
- } else if (renderer() && !renderer()->isWidget())
+ }
+ // FIXME: I'm not sure all devices will want this off, but this is
+ // currently turned off for Andriod.
+#if !ENABLE(DIRECTIONAL_PAD_NAVIGATION)
+ else if (renderer() && !renderer()->isWidget())
renderer()->enclosingLayer()->scrollRectToVisible(getRect());
+#endif
}
void Element::blur()
@@ -1184,7 +1287,7 @@ void Element::cancelFocusAppearanceUpdate()
void Element::normalizeAttributes()
{
// Normalize attributes.
- NamedAttrMap* attrs = attributes(true);
+ NamedNodeMap* attrs = attributes(true);
if (!attrs)
return;
unsigned numAttrs = attrs->length();
@@ -1238,4 +1341,4 @@ unsigned Element::childElementCount() const
return count;
}
-}
+} // namespace WebCore