Commit 1f643c79 authored by darin@apple.com's avatar darin@apple.com

2010-05-30 Darin Adler <darin@apple.com>

        Reviewed by Sam Weinig.

        Make more HTML DOM members private, especially constructors, third and final batch
        https://bugs.webkit.org/show_bug.cgi?id=39916

        * WebView/WebHTMLRepresentation.mm:
        (-[WebHTMLRepresentation elementWithName:inForm:]): Use the new HTMLFormElement
        function, associatedElements, rather than getting directly at a data member
        named formElements.
        (-[WebHTMLRepresentation controlsInForm:]): Ditto.
2010-05-30  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        Make more HTML DOM members private, especially constructors, third and final batch
        https://bugs.webkit.org/show_bug.cgi?id=39916

        * dom/Document.cpp:
        (WebCore::Document::implicitClose):
        * editing/DeleteButtonController.cpp:
        (WebCore::DeleteButtonController::createDeletionUI):
        * editing/EditorCommand.cpp:
        (WebCore::executeInsertHorizontalRule):
        (WebCore::executeInsertImage):
        * editing/htmlediting.cpp:
        (WebCore::createDefaultParagraphElement):
        (WebCore::createListItemElement):
        * html/HTMLParser.cpp:
        (WebCore::HTMLParser::handleError):
        (WebCore::HTMLParser::headCreateErrorCheck):
        (WebCore::HTMLParser::formCreateErrorCheck):
        (WebCore::HTMLParser::createHead):
        (WebCore::HTMLParser::handleIsindex):
        (WebCore::HTMLParser::finished):
        * html/HTMLViewSourceDocument.cpp:
        (WebCore::HTMLViewSourceDocument::createContainingTable):
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::createSubtreeIfNeeded):
        * rendering/RenderTextControlSingleLine.cpp:
        (WebCore::RenderTextControlSingleLine::createSubtreeIfNeeded):
        Use create instead of new to create HTML elements.

        * html/HTMLFormCollection.cpp:
        (WebCore::HTMLFormCollection::formCollectionInfo):
        (WebCore::HTMLFormCollection::item):
        (WebCore::HTMLFormCollection::getNamedFormItem):
        (WebCore::HTMLFormCollection::updateNameCache):
        * html/HTMLFormControlElement.h:
        Updated for name and privacy changes in HTMLFormElement.

        * html/HTMLFormElement.cpp:
        (WebCore::HTMLFormElement::HTMLFormElement):
        (WebCore::HTMLFormElement::create):
        (WebCore::HTMLFormElement::~HTMLFormElement):
        (WebCore::HTMLFormElement::length):
        (WebCore::HTMLFormElement::submitImplicitly):
        (WebCore::HTMLFormElement::createFormData):
        (WebCore::HTMLFormElement::submit):
        (WebCore::HTMLFormElement::reset):
        (WebCore::HTMLFormElement::formElementIndex):
        (WebCore::HTMLFormElement::registerFormElement):
        (WebCore::HTMLFormElement::removeFormElement):
        (WebCore::HTMLFormElement::registerImgElement):
        (WebCore::HTMLFormElement::removeImgElement):
        (WebCore::HTMLFormElement::defaultButton):
        (WebCore::HTMLFormElement::collectUnhandledInvalidControls):
        (WebCore::HTMLFormElement::addElementAlias):
        (WebCore::HTMLFormElement::documentDidBecomeActive):
        * html/HTMLFormElement.h:
        Added create functions. Made constructors and other members private.
        Used an OwnPtr for m_elementAliases. Renamed collectionInfo to
        m_collectionCache and used an OwnPtr for it. Renamed formElements to
        m_associatedElements (since its contents are what HTML5 calls
        "form-associated element", not form elements). Renamed imgElements to
        m_imageElements.

        * html/HTMLFrameSetElement.cpp:
        (WebCore::HTMLFrameSetElement::HTMLFrameSetElement):
        (WebCore::HTMLFrameSetElement::create):
        (WebCore::HTMLFrameSetElement::parseMappedAttribute):
        * html/HTMLFrameSetElement.h:
        Added create functions. Made constructors and other members private.
        Renamed m_rows and m_cols to m_rowLengths and m_colLengths and used
        OwnArrayPtr for both.

        * html/HTMLLabelElement.cpp:
        (WebCore::nodeAsLabelableFormControl): Made this cast to Element instead
        of HTMLElement, since isFormControlElement is available on Element.
        (WebCore::HTMLLabelElement::HTMLLabelElement):
        (WebCore::HTMLLabelElement::create):
        * html/HTMLLabelElement.h:
        Added create functions. Made constructors and other members private.

        * html/HTMLLegendElement.cpp:
        (WebCore::HTMLLegendElement::HTMLLegendElement):
        (WebCore::HTMLLegendElement::create):
        (WebCore::HTMLLegendElement::associatedControl):
        (WebCore::HTMLLegendElement::focus):
        (WebCore::HTMLLegendElement::accessKeyAction):
        * html/HTMLLegendElement.h:
        Added create functions. Made constructors and other members private.
        Renamed formElement to associatedControl since hte control associated
        with this legend is not a "form element".

        * editing/DeleteButton.cpp:
        (WebCore::DeleteButton::DeleteButton):
        (WebCore::DeleteButton::create):
        * editing/DeleteButton.h:
        * html/HTMLDivElement.cpp:
        (WebCore::HTMLDivElement::HTMLDivElement):
        (WebCore::HTMLDivElement::create):
        * html/HTMLDivElement.h:
        * html/HTMLFontElement.cpp:
        (WebCore::HTMLFontElement::create):
        * html/HTMLFontElement.h:
        * html/HTMLHRElement.cpp:
        (WebCore::HTMLHRElement::HTMLHRElement):
        (WebCore::HTMLHRElement::create):
        * html/HTMLHRElement.h:
        * html/HTMLHeadElement.cpp:
        (WebCore::HTMLHeadElement::HTMLHeadElement):
        (WebCore::HTMLHeadElement::create):
        * html/HTMLHeadElement.h:
        * html/HTMLHeadingElement.cpp:
        (WebCore::HTMLHeadingElement::HTMLHeadingElement):
        (WebCore::HTMLHeadingElement::create):
        * html/HTMLHeadingElement.h:
        * html/HTMLHtmlElement.cpp:
        (WebCore::HTMLHtmlElement::HTMLHtmlElement):
        (WebCore::HTMLHtmlElement::create):
        * html/HTMLHtmlElement.h:
        * html/HTMLImageElement.cpp:
        (WebCore::HTMLImageElement::HTMLImageElement):
        (WebCore::HTMLImageElement::create):
        * html/HTMLImageElement.h:
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::HTMLInputElement):
        (WebCore::HTMLInputElement::create):
        (WebCore::HTMLInputElement::createTemporaryFormForIsIndex):
        * html/HTMLInputElement.h:
        * html/HTMLIsIndexElement.cpp:
        (WebCore::HTMLIsIndexElement::HTMLIsIndexElement):
        (WebCore::HTMLIsIndexElement::create):
        * html/HTMLIsIndexElement.h:
        * html/HTMLLIElement.cpp:
        (WebCore::HTMLLIElement::HTMLLIElement):
        (WebCore::HTMLLIElement::create):
        * html/HTMLLIElement.h:
        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::HTMLLinkElement):
        (WebCore::HTMLLinkElement::create):
        * html/HTMLLinkElement.h:
        Added create functions. Made constructors and other members private.

        * html/HTMLTagNames.in: Removed the createWithNew flag from all the
        tags that were still using it: div, font, form, frameset, h1, h2, h3,
        h4, h5, h6, head, hr, html, image, img, input, ins, isindex, label,
        legend, li, and link.

        * html/HTMLTextAreaElement.h: Removed unneeded definition of the readOnly
        function, since the one in HTMLFormElement does the same thing.

        * loader/ImageDocument.cpp:
        (WebCore::ImageDocumentElement::ImageDocumentElement):
        (WebCore::ImageDocumentElement::create):
        (WebCore::ImageDocument::createDocumentStructure):
        Added create functions. Made constructors and other members private.

        * page/DragController.cpp:
        (WebCore::DragController::concludeEditDrag): Use the non-virtual disabled
        function instead of the virtual isEnabledFormControl function, which just
        turns around and calls the disabled function.

        * rendering/MediaControlElements.cpp:
        (WebCore::MediaControlShadowRootElement::MediaControlShadowRootElement):
        (WebCore::MediaControlShadowRootElement::create):
        (WebCore::MediaControlElement::MediaControlElement):
        (WebCore::MediaControlElement::create):
        (WebCore::MediaControlTimelineContainerElement::MediaControlTimelineContainerElement):
        (WebCore::MediaControlTimelineContainerElement::create):
        (WebCore::MediaControlTimelineContainerElement::rendererIsNeeded):
        (WebCore::MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement):
        (WebCore::MediaControlVolumeSliderContainerElement::create):
        (WebCore::MediaControlStatusDisplayElement::MediaControlStatusDisplayElement):
        (WebCore::MediaControlStatusDisplayElement::create):
        (WebCore::MediaControlStatusDisplayElement::update):
        (WebCore::MediaControlStatusDisplayElement::rendererIsNeeded):
        (WebCore::MediaControlInputElement::MediaControlInputElement):
        (WebCore::MediaControlInputElement::styleForElement):
        (WebCore::MediaControlInputElement::rendererIsNeeded):
        (WebCore::MediaControlInputElement::attach):
        (WebCore::MediaControlInputElement::updateStyle):
        (WebCore::MediaControlMuteButtonElement::MediaControlMuteButtonElement):
        (WebCore::MediaControlMuteButtonElement::create):
        (WebCore::MediaControlMuteButtonElement::defaultEventHandler):
        (WebCore::MediaControlMuteButtonElement::updateDisplayType):
        (WebCore::MediaControlPlayButtonElement::MediaControlPlayButtonElement):
        (WebCore::MediaControlPlayButtonElement::create):
        (WebCore::MediaControlPlayButtonElement::defaultEventHandler):
        (WebCore::MediaControlPlayButtonElement::updateDisplayType):
        (WebCore::MediaControlSeekButtonElement::MediaControlSeekButtonElement):
        (WebCore::MediaControlSeekButtonElement::create):
        (WebCore::MediaControlSeekButtonElement::isForwardButton):
        (WebCore::MediaControlSeekButtonElement::defaultEventHandler):
        (WebCore::MediaControlSeekButtonElement::seekTimerFired):
        (WebCore::MediaControlRewindButtonElement::MediaControlRewindButtonElement):
        (WebCore::MediaControlRewindButtonElement::create):
        (WebCore::MediaControlRewindButtonElement::defaultEventHandler):
        (WebCore::MediaControlReturnToRealtimeButtonElement::MediaControlReturnToRealtimeButtonElement):
        (WebCore::MediaControlReturnToRealtimeButtonElement::create):
        (WebCore::MediaControlReturnToRealtimeButtonElement::defaultEventHandler):
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement):
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::create):
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler):
        (WebCore::MediaControlToggleClosedCaptionsButtonElement::updateDisplayType):
        (WebCore::MediaControlTimelineElement::MediaControlTimelineElement):
        (WebCore::MediaControlTimelineElement::create):
        (WebCore::MediaControlTimelineElement::defaultEventHandler):
        (WebCore::MediaControlTimelineElement::update):
        (WebCore::MediaControlVolumeSliderElement::MediaControlVolumeSliderElement):
        (WebCore::MediaControlVolumeSliderElement::create):
        (WebCore::MediaControlVolumeSliderElement::defaultEventHandler):
        (WebCore::MediaControlVolumeSliderElement::update):
        (WebCore::MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement):
        (WebCore::MediaControlFullscreenButtonElement::create):
        (WebCore::MediaControlFullscreenButtonElement::defaultEventHandler):
        (WebCore::MediaControlTimeDisplayElement::MediaControlTimeDisplayElement):
        (WebCore::MediaControlTimeDisplayElement::create):
        * rendering/MediaControlElements.h:
        Added create functions. Made constructors and other members private.

        * rendering/RenderFileUploadControl.cpp:
        (WebCore::ShadowInputElement::ShadowInputElement):
        (WebCore::ShadowInputElement::create):
        (WebCore::RenderFileUploadControl::updateFromElement):
        Added create functions. Made constructors and other members private.

        * rendering/RenderMedia.cpp:
        (WebCore::RenderMedia::createControlsShadowRoot):
        (WebCore::RenderMedia::createPanel):
        (WebCore::RenderMedia::createMuteButton):
        (WebCore::RenderMedia::createPlayButton):
        (WebCore::RenderMedia::createSeekBackButton):
        (WebCore::RenderMedia::createSeekForwardButton):
        (WebCore::RenderMedia::createRewindButton):
        (WebCore::RenderMedia::createReturnToRealtimeButton):
        (WebCore::RenderMedia::createToggleClosedCaptionsButton):
        (WebCore::RenderMedia::createStatusDisplay):
        (WebCore::RenderMedia::createTimelineContainer):
        (WebCore::RenderMedia::createTimeline):
        (WebCore::RenderMedia::createVolumeSliderContainer):
        (WebCore::RenderMedia::createVolumeSlider):
        (WebCore::RenderMedia::createCurrentTimeDisplay):
        (WebCore::RenderMedia::createTimeRemainingDisplay):
        (WebCore::RenderMedia::createFullscreenButton):
        Use create instead of new.

        * rendering/RenderProgress.cpp:
        (WebCore::ProgressValueElement::ProgressValueElement):
        (WebCore::ProgressValueElement::create):
        (WebCore::RenderProgress::updateValuePartState):
        * rendering/RenderSlider.cpp:
        (WebCore::SliderThumbElement::SliderThumbElement):
        (WebCore::SliderThumbElement::create):
        (WebCore::RenderSlider::updateFromElement):
        Added create functions. Made constructors and other members private.

        * rendering/TextControlInnerElements.cpp:
        (WebCore::TextControlInnerElement::TextControlInnerElement):
        (WebCore::TextControlInnerElement::create):
        (WebCore::TextControlInnerTextElement::TextControlInnerTextElement):
        (WebCore::TextControlInnerTextElement::create):
        (WebCore::TextControlInnerTextElement::defaultEventHandler):
        (WebCore::SearchFieldResultsButtonElement::SearchFieldResultsButtonElement):
        (WebCore::SearchFieldResultsButtonElement::create):
        (WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
        (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
        (WebCore::SearchFieldCancelButtonElement::create):
        (WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
        (WebCore::SpinButtonElement::SpinButtonElement):
        (WebCore::SpinButtonElement::create):
        (WebCore::SpinButtonElement::defaultEventHandler):
        * rendering/TextControlInnerElements.h:
        Added create functions. Made constructors and other members private.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1e636bb6
This diff is collapsed.
......@@ -1816,7 +1816,7 @@ void Document::implicitClose()
// The implicit <head> isn't expected in older versions of Mail - <rdar://problem/6863795>
if (!head() && shouldCreateImplicitHead(this)) {
documentElement->appendChild(new HTMLHeadElement(headTag, this), ec);
documentElement->appendChild(HTMLHeadElement::create(this), ec);
ASSERT(!ec);
}
documentElement->appendChild(HTMLBodyElement::create(this), ec);
......
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -36,17 +36,27 @@
namespace WebCore {
DeleteButton::DeleteButton(Document* document)
: HTMLImageElement(HTMLNames::imgTag, document)
using namespace HTMLNames;
inline DeleteButton::DeleteButton(Document* document)
: HTMLImageElement(imgTag, document)
{
}
PassRefPtr<DeleteButton> DeleteButton::create(Document* document)
{
return new DeleteButton(document);
}
void DeleteButton::defaultEventHandler(Event* event)
{
// FIXME: Is it really import to check the type of the event?
// Seems OK to respond to any event named click even if it does not have the correct type.
if (event->isMouseEvent()) {
if (event->type() == eventNames().clickEvent) {
document()->frame()->editor()->deleteButtonController()->deleteTarget();
event->setDefaultHandled();
// FIXME: Shouldn't we return here instead of falling through?
}
}
......
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -32,6 +32,9 @@ namespace WebCore {
class DeleteButton : public HTMLImageElement {
public:
static PassRefPtr<DeleteButton> create(Document*);
private:
DeleteButton(Document*);
virtual void defaultEventHandler(Event*);
......
......@@ -186,7 +186,7 @@ void DeleteButtonController::respondToChangedSelection(const VisibleSelection& o
void DeleteButtonController::createDeletionUI()
{
RefPtr<HTMLDivElement> container = new HTMLDivElement(divTag, m_target->document());
RefPtr<HTMLDivElement> container = HTMLDivElement::create(m_target->document());
container->setAttribute(container->idAttributeName(), containerElementIdentifier);
CSSMutableStyleDeclaration* style = container->getInlineStyleDecl();
......@@ -201,7 +201,7 @@ void DeleteButtonController::createDeletionUI()
style->setProperty(CSSPropertyBottom, "0");
style->setProperty(CSSPropertyLeft, "0");
RefPtr<HTMLDivElement> outline = new HTMLDivElement(divTag, m_target->document());
RefPtr<HTMLDivElement> outline = HTMLDivElement::create(m_target->document());
outline->setAttribute(outline->idAttributeName(), outlineElementIdentifier);
const int borderWidth = 4;
......@@ -224,7 +224,7 @@ void DeleteButtonController::createDeletionUI()
if (ec)
return;
RefPtr<DeleteButton> button = new DeleteButton(m_target->document());
RefPtr<DeleteButton> button = DeleteButton::create(m_target->document());
button->setAttribute(button->idAttributeName(), buttonElementIdentifier);
const int buttonWidth = 30;
......
......@@ -472,10 +472,10 @@ static bool executeInsertBacktab(Frame* frame, Event* event, EditorCommandSource
static bool executeInsertHorizontalRule(Frame* frame, Event*, EditorCommandSource, const String& value)
{
RefPtr<HTMLHRElement> hr = new HTMLHRElement(hrTag, frame->document());
RefPtr<HTMLHRElement> rule = HTMLHRElement::create(frame->document());
if (!value.isEmpty())
hr->setAttribute(hr->idAttributeName(), value);
return executeInsertNode(frame, hr.release());
rule->setAttribute(rule->idAttributeName(), value);
return executeInsertNode(frame, rule.release());
}
static bool executeInsertHTML(Frame* frame, Event*, EditorCommandSource, const String& value)
......@@ -486,7 +486,7 @@ static bool executeInsertHTML(Frame* frame, Event*, EditorCommandSource, const S
static bool executeInsertImage(Frame* frame, Event*, EditorCommandSource, const String& value)
{
// FIXME: If userInterface is true, we should display a dialog box and let the user choose a local image.
RefPtr<HTMLImageElement> image = new HTMLImageElement(imgTag, frame->document());
RefPtr<HTMLImageElement> image = HTMLImageElement::create(frame->document());
image->setSrc(value);
return executeInsertNode(frame, image.release());
}
......
......@@ -874,7 +874,7 @@ bool isEmptyTableCell(const Node* node)
PassRefPtr<HTMLElement> createDefaultParagraphElement(Document* document)
{
return new HTMLDivElement(divTag, document);
return HTMLDivElement::create(document);
}
PassRefPtr<HTMLElement> createBreakElement(Document* document)
......@@ -894,7 +894,7 @@ PassRefPtr<HTMLElement> createUnorderedListElement(Document* document)
PassRefPtr<HTMLElement> createListItemElement(Document* document)
{
return new HTMLLIElement(liTag, document);
return HTMLLIElement::create(document);
}
PassRefPtr<HTMLElement> createHTMLElement(Document* document, const QualifiedName& name)
......
/**
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003 Apple Computer, Inc.
* Copyright (C) 2003, 2010 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
......@@ -32,14 +32,20 @@ namespace WebCore {
using namespace HTMLNames;
HTMLDivElement::HTMLDivElement(const QualifiedName& tagName, Document *doc)
: HTMLElement(tagName, doc)
HTMLDivElement::HTMLDivElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
{
ASSERT(hasTagName(divTag));
}
HTMLDivElement::~HTMLDivElement()
PassRefPtr<HTMLDivElement> HTMLDivElement::create(Document* document)
{
return new HTMLDivElement(divTag, document);
}
PassRefPtr<HTMLDivElement> HTMLDivElement::create(const QualifiedName& tagName, Document* document)
{
return new HTMLDivElement(tagName, document);
}
bool HTMLDivElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
......
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2010 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
......@@ -28,17 +29,21 @@ namespace WebCore {
class HTMLDivElement : public HTMLElement {
public:
static PassRefPtr<HTMLDivElement> create(Document*);
static PassRefPtr<HTMLDivElement> create(const QualifiedName&, Document*);
String align() const;
void setAlign(const String&);
protected:
HTMLDivElement(const QualifiedName&, Document*);
~HTMLDivElement();
private:
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 5; }
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
String align() const;
void setAlign(const String&);
};
} // namespace WebCore
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
* Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2006, 2008, 2010 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
......@@ -40,6 +40,11 @@ HTMLFontElement::HTMLFontElement(const QualifiedName& tagName, Document* documen
ASSERT(hasTagName(fontTag));
}
PassRefPtr<HTMLFontElement> HTMLFontElement::create(const QualifiedName& tagName, Document* document)
{
return new HTMLFontElement(tagName, document);
}
// Allows leading spaces.
// Allows trailing nonnumeric characters.
// Returns 10 for any size greater than 9.
......
......@@ -2,6 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
* Copyright (C) 2010 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
......@@ -19,6 +20,7 @@
* Boston, MA 02110-1301, USA.
*
*/
#ifndef HTMLFontElement_h
#define HTMLFontElement_h
......@@ -28,14 +30,8 @@ namespace WebCore {
class HTMLFontElement : public HTMLElement {
public:
HTMLFontElement(const QualifiedName&, Document*);
static PassRefPtr<HTMLFontElement> create(const QualifiedName&, Document*);
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 1; }
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
String color() const;
void setColor(const String&);
......@@ -46,8 +42,17 @@ public:
void setSize(const String&);
static bool cssValueFromFontSizeNumber(const String&, int&);
private:
HTMLFontElement(const QualifiedName&, Document*);
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 1; }
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
} //namespace
} // namespace
#endif
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 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,9 +38,9 @@ using namespace HTMLNames;
inline CollectionCache* HTMLFormCollection::formCollectionInfo(HTMLFormElement* form)
{
if (!form->collectionInfo)
form->collectionInfo = new CollectionCache;
return form->collectionInfo;
if (!form->m_collectionCache)
form->m_collectionCache.set(new CollectionCache);
return form->m_collectionCache.get();
}
HTMLFormCollection::HTMLFormCollection(PassRefPtr<HTMLFormElement> form)
......@@ -78,16 +78,17 @@ Node* HTMLFormCollection::item(unsigned index) const
info()->elementsArrayPosition = 0;
}
Vector<HTMLFormControlElement*>& l = static_cast<HTMLFormElement*>(base())->formElements;
Vector<HTMLFormControlElement*>& elementsArray = static_cast<HTMLFormElement*>(base())->m_associatedElements;
unsigned currentIndex = info()->position;
for (unsigned i = info()->elementsArrayPosition; i < l.size(); i++) {
if (l[i]->isEnumeratable() ) {
for (unsigned i = info()->elementsArrayPosition; i < elementsArray.size(); i++) {
HTMLFormControlElement* element = elementsArray[i];
if (element->isEnumeratable()) {
if (index == currentIndex) {
info()->position = index;
info()->current = l[i];
info()->current = element;
info()->elementsArrayPosition = i;
return l[i];
return element;
}
currentIndex++;
......@@ -108,8 +109,8 @@ Element* HTMLFormCollection::getNamedFormItem(const QualifiedName& attrName, con
HTMLFormElement* form = static_cast<HTMLFormElement*>(base());
bool foundInputElements = false;
for (unsigned i = 0; i < form->formElements.size(); ++i) {
HTMLFormControlElement* e = form->formElements[i];
for (unsigned i = 0; i < form->m_associatedElements.size(); ++i) {
HTMLFormControlElement* e = form->m_associatedElements[i];
const QualifiedName& attributeName = (attrName == idAttr) ? e->idAttributeName() : attrName;
if (e->isEnumeratable() && e->getAttribute(attributeName) == name) {
foundInputElements = true;
......@@ -120,8 +121,8 @@ Element* HTMLFormCollection::getNamedFormItem(const QualifiedName& attrName, con
}
if (!foundInputElements) {
for (unsigned i = 0; i < form->imgElements.size(); ++i) {
HTMLImageElement* e = form->imgElements[i];
for (unsigned i = 0; i < form->m_imageElements.size(); ++i) {
HTMLImageElement* e = form->m_imageElements[i];
const QualifiedName& attributeName = (attrName == idAttr) ? e->idAttributeName() : attrName;
if (e->getAttribute(attributeName) == name) {
if (!duplicateNumber)
......@@ -190,8 +191,8 @@ void HTMLFormCollection::updateNameCache() const
HTMLFormElement* f = static_cast<HTMLFormElement*>(base());
for (unsigned i = 0; i < f->formElements.size(); ++i) {
HTMLFormControlElement* e = f->formElements[i];
for (unsigned i = 0; i < f->m_associatedElements.size(); ++i) {
HTMLFormControlElement* e = f->m_associatedElements[i];
if (e->isEnumeratable()) {
const AtomicString& idAttrVal = e->getAttribute(e->idAttributeName());
const AtomicString& nameAttrVal = e->getAttribute(nameAttr);
......@@ -218,8 +219,8 @@ void HTMLFormCollection::updateNameCache() const
}
}
for (unsigned i = 0; i < f->imgElements.size(); ++i) {
HTMLImageElement* e = f->imgElements[i];
for (unsigned i = 0; i < f->m_imageElements.size(); ++i) {
HTMLImageElement* e = f->m_imageElements[i];
const AtomicString& idAttrVal = e->getAttribute(e->idAttributeName());
const AtomicString& nameAttrVal = e->getAttribute(nameAttr);
if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.impl())) {
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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
......@@ -36,26 +36,14 @@ class VisibleSelection;
class HTMLFormControlElement : public HTMLElement {
public:
HTMLFormControlElement(const QualifiedName& tagName, Document*, HTMLFormElement*, ConstructionType = CreateHTMLElementZeroRefCount);
virtual ~HTMLFormControlElement();
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 1; }
HTMLFormElement* form() const { return m_form; }
ValidityState* validity();
bool formNoValidate() const;
void setFormNoValidate(bool);
virtual bool isTextFormControl() const { return false; }
virtual bool isEnabledFormControl() const { return !disabled(); }
virtual void parseMappedAttribute(Attribute*);
virtual void attach();
virtual void insertedIntoTree(bool deep);
virtual void removedFromTree(bool deep);
virtual void reset() {}
virtual bool formControlValueMatchesRenderer() const { return m_valueMatchesRenderer; }
......@@ -66,13 +54,9 @@ public:
bool disabled() const { return m_disabled; }
void setDisabled(bool);
virtual bool supportsFocus() const;
virtual bool isFocusable() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual bool isEnumeratable() const { return false; }
virtual bool isReadOnlyFormControl() const { return m_readOnly; }
void setReadOnly(bool);
// Determines whether or not a control will be automatically focused
......@@ -82,17 +66,11 @@ public:
bool required() const;
void setRequired(bool);
virtual void recalcStyle(StyleChange);
virtual const AtomicString& formControlName() const;
virtual const AtomicString& formControlType() const = 0;
const AtomicString& type() const { return formControlType(); }
const AtomicString& name() const { return formControlName(); }
void setName(const AtomicString& name);
virtual bool isFormControlElement() const { return true; }
virtual bool isRadioButton() const { return false; }
virtual bool canTriggerImplicitSubmission() const { return false; }
......@@ -105,8 +83,6 @@ public:
virtual bool isActivatedSubmit() const { return false; }
virtual void setActivatedSubmit(bool) { }
virtual short tabIndex() const;
virtual bool willValidate() const;
String validationMessage();
bool checkValidity(Vector<RefPtr<HTMLFormControlElement> >* unhandledInvalidControls = 0);
......@@ -119,19 +95,47 @@ public:
void formDestroyed() { m_form = 0; }
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
bool isLabelable() const;
PassRefPtr<NodeList> labels();
bool readOnly() const { return m_readOnly; }
protected:
HTMLFormControlElement(const QualifiedName& tagName, Document*, HTMLFormElement*, ConstructionType = CreateHTMLElementZeroRefCount);
virtual void parseMappedAttribute(Attribute*);
virtual void attach();
virtual void insertedIntoTree(bool deep);
virtual void removedFromTree(bool deep);
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual void recalcStyle(StyleChange);
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
void removeFromForm();
// This must be called any time the result of willValidate() has changed.
void setNeedsWillValidateCheck();
virtual bool recalcWillValidate() const;
private:
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 1; }
virtual const AtomicString& formControlName() const;
virtual const AtomicString& formControlType() const = 0;
virtual bool isFormControlElement() const { return true; }
virtual bool isEnabledFormControl() const { return !disabled(); }
virtual bool isReadOnlyFormControl() const { return readOnly(); }
virtual bool supportsFocus() const;
virtual short tabIndex() const;
virtual HTMLFormElement* virtualForm() const;
virtual bool isDefaultButtonForForm() const;
virtual bool isValidFormControlElement();
......@@ -154,25 +158,25 @@ private:
class HTMLFormControlElementWithState : public HTMLFormControlElement {
public:
HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
virtual ~HTMLFormControlElementWithState();
protected:
HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
virtual bool autoComplete() const;
virtual bool shouldSaveAndRestoreFormControlState() const;
virtual void finishParsingChildren();
protected:
virtual void willMoveToNewOwnerDocument();
virtual void didMoveToNewOwnerDocument();
virtual void defaultEventHandler(Event*);
private:
virtual bool shouldSaveAndRestoreFormControlState() const;
virtual void finishParsingChildren();
};
class HTMLTextFormControlElement : public HTMLFormControlElementWithState {
public:
HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
virtual ~HTMLTextFormControlElement();
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
String strippedPlaceholder() const;
......@@ -185,14 +189,22 @@ public:
VisibleSelection selection() const;
protected:
bool isPlaceholderEmpty() const;
HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
bool placeholderShouldBeVisible() const;
void updatePlaceholderVisibility(bool);
virtual int cachedSelectionStart() const = 0;
virtual int cachedSelectionEnd() const = 0;
virtual void parseMappedAttribute(Attribute*);
private:
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
bool isPlaceholderEmpty() const;
virtual int cachedSelectionStart() const = 0;
virtual int cachedSelectionEnd() const = 0;
// A subclass should return true if placeholder processing is needed.
virtual bool supportsPlaceholder() const = 0;
// Returns true if user-editable value is empty. This is used to check placeholder visibility.
......@@ -204,6 +216,6 @@ private:
RenderTextControl* textRendererAfterUpdateLayout();
};
} //namespace
} // namespace
#endif
......@@ -72,10 +72,8 @@ static int64_t generateFormDataIdentifier()
return ++nextIdentifier;
}
HTMLFormElement::HTMLFormElement(const QualifiedName& tagName, Document* doc)
: HTMLElement(tagName, doc)
, m_elementAliases(0)
, collectionInfo(0)
HTMLFormElement::HTMLFormElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
, m_autocomplete(true)
, m_insubmit(false)
, m_doingsubmit(false)
......@@ -86,18 +84,25 @@ HTMLFormElement::HTMLFormElement(const QualifiedName& tagName, Document* doc)
ASSERT(hasTagName(formTag));
}
PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document* document)
{
return new HTMLFormElement(formTag, document);
}
PassRefPtr<HTMLFormElement> HTMLFormElement::create(const QualifiedName& tagName, Document* document)
{
return new HTMLFormElement(tagName, document);
}
HTMLFormElement::~HTMLFormElement()
{
if (!m_autocomplete)
document()->unregisterForDocumentActivationCallbacks(this);
delete m_elementAliases;
delete collectionInfo;
for (unsigned i = 0; i < formElements.size(); ++i)
formElements[i]->formDestroyed();
for (unsigned i = 0; i < imgElements.size(); ++i)
imgElements[i]->m_form = 0;
for (unsigned i = 0; i < m_associatedElements.size(); ++i)
m_associatedElements[i]->formDestroyed();
for (unsigned i = 0; i < m_imageElements.size(); ++i)
m_imageElements[i]->m_form = 0;
}
bool HTMLFormElement::formWouldHaveSecureSubmission(const String& url)
......@@ -105,11 +110,6 @@ bool HTMLFormElement::formWouldHaveSecureSubmission(const String& url)
return document()->completeURL(url).protocolIs("https");
}
void HTMLFormElement::attach()
{
HTMLElement::attach();
}
bool HTMLFormElement::rendererIsNeeded(RenderStyle* style)
{
if (!isDemoted())
......@@ -163,11 +163,10 @@ void HTMLFormElement::handleLocalEvents(Event* event)
unsigned HTMLFormElement::length() const
{
int len = 0;
for (unsigned i = 0; i < formElements.size(); ++i)
if (formElements[i]->isEnumeratable())
unsigned len = 0;
for (unsigned i = 0; i < m_associatedElements.size(); ++i)
if (m_associatedElements[i]->isEnumeratable())
++len;
return len;
}
......@@ -179,8 +178,8 @@ Node* HTMLFormElement::item(unsigned index)
void HTMLFormElement::submitImplicitly(Event* event, bool fromImplicitSubmissionTrigger)
{
int submissionTriggerCount = 0;
for (unsigned i = 0; i < formElements.size(); ++i) {
HTMLFormControlElement* formElement = formElements[i];
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
HTMLFormControlElement* formElement = m_associatedElements[i];
if (formElement->isSuccessfulSubmitButton()) {
if (formElement->renderer()) {
formElement->dispatchSimulatedClick(event);
......@@ -204,8 +203,8 @@ TextEncoding HTMLFormElement::dataEncoding() const
PassRefPtr<FormData> HTMLFormElement::createFormData()
{
RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding().encodingForFormSubmission());
for (unsigned i = 0; i < formElements.size(); ++i) {
HTMLFormControlElement* control = formElements[i];
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
HTMLFormControlElement* control = m_associatedElements[i];
if (!control->disabled())