summaryrefslogtreecommitdiffstats
path: root/WebCore/html/HTMLBodyElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/HTMLBodyElement.cpp')
-rw-r--r--WebCore/html/HTMLBodyElement.cpp89
1 files changed, 47 insertions, 42 deletions
diff --git a/WebCore/html/HTMLBodyElement.cpp b/WebCore/html/HTMLBodyElement.cpp
index 6231fc2..7dca064 100644
--- a/WebCore/html/HTMLBodyElement.cpp
+++ b/WebCore/html/HTMLBodyElement.cpp
@@ -1,9 +1,9 @@
-/**
+/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann (hausmann@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -38,7 +38,6 @@
namespace WebCore {
-using namespace EventNames;
using namespace HTMLNames;
HTMLBodyElement::HTMLBodyElement(Document* doc)
@@ -56,7 +55,7 @@ HTMLBodyElement::~HTMLBodyElement()
void HTMLBodyElement::createLinkDecl()
{
- m_linkDecl = new CSSMutableStyleDeclaration;
+ m_linkDecl = CSSMutableStyleDeclaration::create();
m_linkDecl->setParent(document()->elementSheet());
m_linkDecl->setNode(this);
m_linkDecl->setStrictParsing(!document()->inCompatMode());
@@ -88,20 +87,20 @@ void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr)
if (attr->name() == backgroundAttr) {
String url = parseURL(attr->value());
if (!url.isEmpty())
- addCSSImageProperty(attr, CSS_PROP_BACKGROUND_IMAGE, document()->completeURL(url));
+ addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string());
} else if (attr->name() == marginwidthAttr || attr->name() == leftmarginAttr) {
- addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
- addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
+ addCSSLength(attr, CSSPropertyMarginRight, attr->value());
+ addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
} else if (attr->name() == marginheightAttr || attr->name() == topmarginAttr) {
- addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
- addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
+ addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
+ addCSSLength(attr, CSSPropertyMarginTop, attr->value());
} else if (attr->name() == bgcolorAttr) {
- addCSSColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value());
+ addCSSColor(attr, CSSPropertyBackgroundColor, attr->value());
} else if (attr->name() == textAttr) {
- addCSSColor(attr, CSS_PROP_COLOR, attr->value());
+ addCSSColor(attr, CSSPropertyColor, attr->value());
} else if (attr->name() == bgpropertiesAttr) {
if (equalIgnoringCase(attr->value(), "fixed"))
- addCSSProperty(attr, CSS_PROP_BACKGROUND_ATTACHMENT, CSS_VAL_FIXED);
+ addCSSProperty(attr, CSSPropertyBackgroundAttachment, CSSValueFixed);
} else if (attr->name() == vlinkAttr ||
attr->name() == alinkAttr ||
attr->name() == linkAttr) {
@@ -115,8 +114,8 @@ void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr)
} else {
if (!m_linkDecl)
createLinkDecl();
- m_linkDecl->setProperty(CSS_PROP_COLOR, attr->value(), false, false);
- RefPtr<CSSValue> val = m_linkDecl->getPropertyCSSValue(CSS_PROP_COLOR);
+ m_linkDecl->setProperty(CSSPropertyColor, attr->value(), false, false);
+ RefPtr<CSSValue> val = m_linkDecl->getPropertyCSSValue(CSSPropertyColor);
if (val && val->isPrimitiveValue()) {
Color col = document()->styleSelector()->getColorFromPrimitiveValue(static_cast<CSSPrimitiveValue*>(val.get()));
if (attr->name() == linkAttr)
@@ -130,20 +129,25 @@ void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr)
if (attached())
document()->recalcStyle(Force);
- } else if (attr->name() == onloadAttr) {
- document()->setHTMLWindowEventListener(loadEvent, attr);
- } else if (attr->name() == onbeforeunloadAttr) {
- document()->setHTMLWindowEventListener(beforeunloadEvent, attr);
- } else if (attr->name() == onunloadAttr) {
- document()->setHTMLWindowEventListener(unloadEvent, attr);
- } else if (attr->name() == onblurAttr) {
- document()->setHTMLWindowEventListener(blurEvent, attr);
- } else if (attr->name() == onfocusAttr) {
- document()->setHTMLWindowEventListener(focusEvent, attr);
- } else if (attr->name() == onresizeAttr) {
- document()->setHTMLWindowEventListener(resizeEvent, attr);
- } else if (attr->name() == onscrollAttr) {
- document()->setHTMLWindowEventListener(scrollEvent, attr);
+ } else if (attr->name() == onloadAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().loadEvent, attr);
+ else if (attr->name() == onbeforeunloadAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().beforeunloadEvent, attr);
+ else if (attr->name() == onunloadAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().unloadEvent, attr);
+ else if (attr->name() == onblurAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().blurEvent, attr);
+ else if (attr->name() == onfocusAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().focusEvent, attr);
+ else if (attr->name() == onresizeAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().resizeEvent, attr);
+ else if (attr->name() == onscrollAttr)
+ document()->setWindowInlineEventListenerForTypeAndAttribute(eventNames().scrollEvent, attr);
+ else if (attr->name() == onstorageAttr) {
+ // The HTML5 spec currently specifies that storage events are fired only at the body element of
+ // an HTMLDocument, which is why the onstorage attribute differs from the ones before it.
+ // The spec might change on this, and then so should we!
+ setInlineEventListenerForTypeAndAttribute(eventNames().storageEvent, attr);
} else
HTMLElement::parseMappedAttribute(attr);
}
@@ -180,7 +184,7 @@ String HTMLBodyElement::aLink() const
return getAttribute(alinkAttr);
}
-void HTMLBodyElement::setALink(const String &value)
+void HTMLBodyElement::setALink(const String& value)
{
setAttribute(alinkAttr, value);
}
@@ -190,7 +194,7 @@ String HTMLBodyElement::background() const
return getAttribute(backgroundAttr);
}
-void HTMLBodyElement::setBackground(const String &value)
+void HTMLBodyElement::setBackground(const String& value)
{
setAttribute(backgroundAttr, value);
}
@@ -200,7 +204,7 @@ String HTMLBodyElement::bgColor() const
return getAttribute(bgcolorAttr);
}
-void HTMLBodyElement::setBgColor(const String &value)
+void HTMLBodyElement::setBgColor(const String& value)
{
setAttribute(bgcolorAttr, value);
}
@@ -210,7 +214,7 @@ String HTMLBodyElement::link() const
return getAttribute(linkAttr);
}
-void HTMLBodyElement::setLink(const String &value)
+void HTMLBodyElement::setLink(const String& value)
{
setAttribute(linkAttr, value);
}
@@ -220,7 +224,7 @@ String HTMLBodyElement::text() const
return getAttribute(textAttr);
}
-void HTMLBodyElement::setText(const String &value)
+void HTMLBodyElement::setText(const String& value)
{
setAttribute(textAttr, value);
}
@@ -230,7 +234,7 @@ String HTMLBodyElement::vLink() const
return getAttribute(vlinkAttr);
}
-void HTMLBodyElement::setVLink(const String &value)
+void HTMLBodyElement::setVLink(const String& value)
{
setAttribute(vlinkAttr, value);
}
@@ -241,8 +245,7 @@ int HTMLBodyElement::scrollLeft() const
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
-
- return view ? view->contentsX() : 0;
+ return view ? view->scrollX() : 0;
}
void HTMLBodyElement::setScrollLeft(int scrollLeft)
@@ -251,7 +254,7 @@ void HTMLBodyElement::setScrollLeft(int scrollLeft)
if (sview) {
// Update the document's layout
document()->updateLayoutIgnorePendingStylesheets();
- sview->setContentsPos(scrollLeft, sview->contentsY());
+ sview->setScrollPosition(IntPoint(scrollLeft, sview->scrollY()));
}
}
@@ -261,8 +264,7 @@ int HTMLBodyElement::scrollTop() const
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
-
- return view ? view->contentsY() : 0;
+ return view ? view->scrollY() : 0;
}
void HTMLBodyElement::setScrollTop(int scrollTop)
@@ -271,7 +273,7 @@ void HTMLBodyElement::setScrollTop(int scrollTop)
if (sview) {
// Update the document's layout
document()->updateLayoutIgnorePendingStylesheets();
- sview->setContentsPos(sview->contentsX(), scrollTop);
+ sview->setScrollPosition(IntPoint(sview->scrollX(), scrollTop));
}
}
@@ -281,7 +283,6 @@ int HTMLBodyElement::scrollHeight() const
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
-
return view ? view->contentsHeight() : 0;
}
@@ -291,8 +292,12 @@ int HTMLBodyElement::scrollWidth() const
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
-
return view ? view->contentsWidth() : 0;
}
+void HTMLBodyElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+ urls.append(background());
+}
+
}