+2006-05-15 Sam Weinig <sam.weinig@gmail.com>
+
+ Reviewed by eseidel.
+
+ Split render_form.* into separate files (one per class).
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=8889
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/HTMLButtonElement.cpp:
+ (WebCore::HTMLButtonElement::HTMLButtonElement):
+ * html/HTMLFieldSetElement.cpp:
+ * html/HTMLFormElement.cpp:
+ * html/HTMLInputElement.cpp:
+ * html/HTMLLabelElement.cpp:
+ * html/HTMLLegendElement.cpp:
+ (WebCore::HTMLLegendElement::createRenderer):
+ * html/HTMLOptionElement.cpp:
+ * html/HTMLSelectElement.cpp:
+ * html/HTMLTextAreaElement.cpp:
+ (WebCore::HTMLTextAreaElement::selectionStart):
+ (WebCore::HTMLTextAreaElement::selectionEnd):
+ (WebCore::HTMLTextAreaElement::setSelectionStart):
+ (WebCore::HTMLTextAreaElement::setSelectionEnd):
+ (WebCore::HTMLTextAreaElement::setSelectionRange):
+ (WebCore::HTMLTextAreaElement::parseMappedAttribute):
+ (WebCore::HTMLTextAreaElement::createRenderer):
+ (WebCore::HTMLTextAreaElement::setValue):
+ (WebCore::HTMLTextAreaElement::setDefaultValue):
+ (WebCore::HTMLTextAreaElement::setAccessKey):
+ * kwq/KWQComboBox.mm:
+ * kwq/KWQFileButton.mm:
+ * kwq/KWQListBox.mm:
+ * kwq/KWQSlider.mm:
+ * platform/mac/WebCoreTextField.mm:
+ * rendering/RenderFieldset.cpp: Added.
+ (WebCore::RenderFieldset::RenderFieldset):
+ (WebCore::RenderFieldset::findLegend):
+ (WebCore::RenderFieldset::paintBorderMinusLegend):
+ (WebCore::RenderFieldset::setStyle):
+ * rendering/RenderFieldset.h: Added.
+ (WebCore::RenderFieldset::renderName):
+ * rendering/RenderFileButton.cpp: Added.
+ (WebCore::RenderFileButton::RenderFileButton):
+ (WebCore::RenderFileButton::calcMinMaxWidth):
+ (WebCore::RenderFileButton::updateFromElement):
+ (WebCore::RenderFileButton::click):
+ * rendering/RenderFileButton.h: Added.
+ (WebCore::RenderFileButton::renderName):
+ (WebCore::RenderFileButton::calcReplacedHeight):
+ (WebCore::RenderFileButton::isEditable):
+ * rendering/RenderFormElement.cpp: Added.
+ (WebCore::RenderFormElement::RenderFormElement):
+ (WebCore::RenderFormElement::baselinePosition):
+ (WebCore::RenderFormElement::layout):
+ * rendering/RenderFormElement.h: Added.
+ (WebCore::RenderFormElement::renderName):
+ (WebCore::RenderFormElement::isFormElement):
+ (WebCore::RenderFormElement::borderTop):
+ (WebCore::RenderFormElement::borderBottom):
+ (WebCore::RenderFormElement::borderLeft):
+ (WebCore::RenderFormElement::borderRight):
+ (WebCore::RenderFormElement::paddingTop):
+ (WebCore::RenderFormElement::paddingBottom):
+ (WebCore::RenderFormElement::paddingLeft):
+ (WebCore::RenderFormElement::paddingRight):
+ (WebCore::RenderFormElement::canHaveIntrinsicMargins):
+ (WebCore::RenderFormElement::intrinsicMargin):
+ (WebCore::RenderFormElement::isEditable):
+ * rendering/RenderImageButton.cpp: Added.
+ (WebCore::RenderImageButton::RenderImageButton):
+ * rendering/RenderImageButton.h: Added.
+ (WebCore::RenderImageButton::renderName):
+ (WebCore::RenderImageButton::isImageButton):
+ * rendering/RenderLabel.cpp: Added.
+ (WebCore::RenderLabel::RenderLabel):
+ * rendering/RenderLabel.h: Added.
+ (WebCore::RenderLabel::renderName):
+ * rendering/RenderLegend.cpp: Added.
+ (WebCore::RenderLegend::RenderLegend):
+ * rendering/RenderLegend.h: Added.
+ (WebCore::RenderLegend::renderName):
+ * rendering/RenderLineEdit.cpp: Added.
+ (WebCore::RenderLineEdit::RenderLineEdit):
+ * rendering/RenderLineEdit.h: Added.
+ (WebCore::RenderLineEdit::renderName):
+ (WebCore::RenderLineEdit::calcReplacedHeight):
+ (WebCore::RenderLineEdit::canHaveIntrinsicMargins):
+ (WebCore::RenderLineEdit::isTextField):
+ (WebCore::RenderLineEdit::isEditable):
+ * rendering/RenderSelect.cpp: Added.
+ (WebCore::RenderSelect::RenderSelect):
+ (WebCore::RenderSelect::setWidgetWritingDirection):
+ (WebCore::RenderSelect::setStyle):
+ (WebCore::RenderSelect::updateFromElement):
+ (WebCore::RenderSelect::baselinePosition):
+ (WebCore::RenderSelect::calcMinMaxWidth):
+ (WebCore::RenderSelect::layout):
+ (WebCore::RenderSelect::valueChanged):
+ (WebCore::RenderSelect::selectionChanged):
+ (WebCore::RenderSelect::updateSelection):
+ * rendering/RenderSelect.h: Added.
+ (WebCore::RenderSelect::renderName):
+ (WebCore::RenderSelect::calcReplacedHeight):
+ (WebCore::RenderSelect::canHaveIntrinsicMargins):
+ (WebCore::RenderSelect::selectionChanged):
+ (WebCore::RenderSelect::setSelectionChanged):
+ * rendering/RenderSlider.cpp: Added.
+ (WebCore::RenderSlider::calcMinMaxWidth):
+ (WebCore::RenderSlider::updateFromElement):
+ * rendering/RenderSlider.h: Added.
+ (WebCore::RenderSlider::renderName):
+ (WebCore::RenderSlider::canHaveIntrinsicMargins):
+ * rendering/RenderTextArea.cpp: Added.
+ (WebCore::RenderTextArea::RenderTextArea):
+ (WebCore::RenderTextArea::calcMinMaxWidth):
+ (WebCore::RenderTextArea::setStyle):
+ (WebCore::RenderTextArea::updateFromElement):
+ (WebCore::RenderTextArea::selectionStart):
+ (WebCore::RenderTextArea::selectionEnd):
+ (WebCore::RenderTextArea::setSelectionStart):
+ (WebCore::RenderTextArea::setSelectionEnd):
+ (WebCore::RenderTextArea::select):
+ (WebCore::RenderTextArea::setSelectionRange):
+ * rendering/RenderTextArea.h: Added.
+ (WebCore::RenderTextArea::renderName):
+ (WebCore::RenderTextArea::isTextArea):
+ (WebCore::RenderTextArea::isEdited):
+ (WebCore::RenderTextArea::canHaveIntrinsicMargins):
+ (WebCore::RenderTextArea::isEditable):
+ * rendering/render_form.cpp: Removed.
+ * rendering/render_form.h: Removed.
+
2006-05-15 Anders Carlsson <acarlsson@apple.com>
Reviewed by Eric.
>\r
</File>\r
<File\r
- RelativePath="..\..\rendering\render_form.cpp"\r
+ RelativePath="..\..\rendering\RenderFieldset.cpp"\r
>\r
</File>\r
<File\r
- RelativePath="..\..\rendering\render_form.h"\r
+ RelativePath="..\..\rendering\RenderFieldset.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderFileButton.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderFileButton.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderFormElement.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderFormElement.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderImageButton.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderImageButton.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderLabel.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderLabel.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderLegend.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderLegend.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderLineEdit.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderLineEdit.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderSelect.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderSelect.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderSlider.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderSlider.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderTextArea.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\..\rendering\RenderTextArea.h"\r
>\r
</File>\r
<File\r
A8DF5F4A098448C80052981B /* JSSVGLazyEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF545C0983A7510052981B /* JSSVGLazyEventListener.h */; };
A8DF5FA3098460AA0052981B /* SVGDocumentExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF5FA1098460AA0052981B /* SVGDocumentExtensions.h */; };
A8DF5FA4098460AA0052981B /* SVGDocumentExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF5FA2098460AA0052981B /* SVGDocumentExtensions.cpp */; };
+ A8EA73C30A1900E300A8EF5F /* RenderFieldset.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */; };
+ A8EA73C40A1900E300A8EF5F /* RenderFieldset.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */; };
+ A8EA73C50A1900E300A8EF5F /* RenderLineEdit.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B10A1900E300A8EF5F /* RenderLineEdit.h */; };
+ A8EA73C60A1900E300A8EF5F /* RenderFileButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73B20A1900E300A8EF5F /* RenderFileButton.cpp */; };
+ A8EA73C70A1900E300A8EF5F /* RenderFileButton.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B30A1900E300A8EF5F /* RenderFileButton.h */; };
+ A8EA73C80A1900E300A8EF5F /* RenderTextArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73B40A1900E300A8EF5F /* RenderTextArea.cpp */; };
+ A8EA73C90A1900E300A8EF5F /* RenderFormElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B50A1900E300A8EF5F /* RenderFormElement.h */; };
+ A8EA73CA0A1900E300A8EF5F /* RenderLegend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73B60A1900E300A8EF5F /* RenderLegend.cpp */; };
+ A8EA73CB0A1900E300A8EF5F /* RenderLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B70A1900E300A8EF5F /* RenderLabel.h */; };
+ A8EA73CC0A1900E300A8EF5F /* RenderSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B80A1900E300A8EF5F /* RenderSlider.h */; };
+ A8EA73CD0A1900E300A8EF5F /* RenderImageButton.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B90A1900E300A8EF5F /* RenderImageButton.h */; };
+ A8EA73CE0A1900E300A8EF5F /* RenderTextArea.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73BA0A1900E300A8EF5F /* RenderTextArea.h */; };
+ A8EA73CF0A1900E300A8EF5F /* RenderImageButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73BB0A1900E300A8EF5F /* RenderImageButton.cpp */; };
+ A8EA73D00A1900E300A8EF5F /* RenderSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73BC0A1900E300A8EF5F /* RenderSelect.cpp */; };
+ A8EA73D10A1900E300A8EF5F /* RenderLegend.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73BD0A1900E300A8EF5F /* RenderLegend.h */; };
+ A8EA73D20A1900E300A8EF5F /* RenderLineEdit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73BE0A1900E300A8EF5F /* RenderLineEdit.cpp */; };
+ A8EA73D30A1900E300A8EF5F /* RenderFormElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73BF0A1900E300A8EF5F /* RenderFormElement.cpp */; };
+ A8EA73D40A1900E300A8EF5F /* RenderLabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73C00A1900E300A8EF5F /* RenderLabel.cpp */; };
+ A8EA73D50A1900E300A8EF5F /* RenderSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73C10A1900E300A8EF5F /* RenderSlider.cpp */; };
+ A8EA73D60A1900E300A8EF5F /* RenderSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73C20A1900E300A8EF5F /* RenderSelect.h */; };
A8FD8B86087CB44C00DC3707 /* KWQWMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A85D7A8C0879EC64006A9172 /* KWQWMatrix.cpp */; };
A8FD8B87087CB45700DC3707 /* KWQWMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = A85D7A8D0879EC64006A9172 /* KWQWMatrix.h */; };
A8FEFB0A0979F472005839FD /* RenderForeignObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FEFB080979F472005839FD /* RenderForeignObject.h */; };
BCEA486E097D93020094C9E4 /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA482F097D93020094C9E4 /* RenderFlexibleBox.h */; };
BCEA486F097D93020094C9E4 /* RenderFlow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4830097D93020094C9E4 /* RenderFlow.cpp */; };
BCEA4870097D93020094C9E4 /* RenderFlow.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4831097D93020094C9E4 /* RenderFlow.h */; };
- BCEA4871097D93020094C9E4 /* render_form.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4832097D93020094C9E4 /* render_form.cpp */; };
- BCEA4872097D93020094C9E4 /* render_form.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4833097D93020094C9E4 /* render_form.h */; };
BCEA4875097D93020094C9E4 /* RenderImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4836097D93020094C9E4 /* RenderImage.cpp */; };
BCEA4876097D93020094C9E4 /* RenderImage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4837097D93020094C9E4 /* RenderImage.h */; };
BCEA4877097D93020094C9E4 /* RenderInline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4838097D93020094C9E4 /* RenderInline.cpp */; };
A8DF545D0983A7510052981B /* JSSVGLazyEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLazyEventListener.cpp; sourceTree = "<group>"; };
A8DF5FA1098460AA0052981B /* SVGDocumentExtensions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGDocumentExtensions.h; sourceTree = "<group>"; };
A8DF5FA2098460AA0052981B /* SVGDocumentExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGDocumentExtensions.cpp; sourceTree = "<group>"; };
+ A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFieldset.cpp; sourceTree = "<group>"; };
+ A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFieldset.h; sourceTree = "<group>"; };
+ A8EA73B10A1900E300A8EF5F /* RenderLineEdit.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderLineEdit.h; sourceTree = "<group>"; };
+ A8EA73B20A1900E300A8EF5F /* RenderFileButton.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFileButton.cpp; sourceTree = "<group>"; };
+ A8EA73B30A1900E300A8EF5F /* RenderFileButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFileButton.h; sourceTree = "<group>"; };
+ A8EA73B40A1900E300A8EF5F /* RenderTextArea.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextArea.cpp; sourceTree = "<group>"; };
+ A8EA73B50A1900E300A8EF5F /* RenderFormElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFormElement.h; sourceTree = "<group>"; };
+ A8EA73B60A1900E300A8EF5F /* RenderLegend.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderLegend.cpp; sourceTree = "<group>"; };
+ A8EA73B70A1900E300A8EF5F /* RenderLabel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderLabel.h; sourceTree = "<group>"; };
+ A8EA73B80A1900E300A8EF5F /* RenderSlider.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSlider.h; sourceTree = "<group>"; };
+ A8EA73B90A1900E300A8EF5F /* RenderImageButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderImageButton.h; sourceTree = "<group>"; };
+ A8EA73BA0A1900E300A8EF5F /* RenderTextArea.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTextArea.h; sourceTree = "<group>"; };
+ A8EA73BB0A1900E300A8EF5F /* RenderImageButton.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImageButton.cpp; sourceTree = "<group>"; };
+ A8EA73BC0A1900E300A8EF5F /* RenderSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSelect.cpp; sourceTree = "<group>"; };
+ A8EA73BD0A1900E300A8EF5F /* RenderLegend.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderLegend.h; sourceTree = "<group>"; };
+ A8EA73BE0A1900E300A8EF5F /* RenderLineEdit.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderLineEdit.cpp; sourceTree = "<group>"; };
+ A8EA73BF0A1900E300A8EF5F /* RenderFormElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFormElement.cpp; sourceTree = "<group>"; };
+ A8EA73C00A1900E300A8EF5F /* RenderLabel.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderLabel.cpp; sourceTree = "<group>"; };
+ A8EA73C10A1900E300A8EF5F /* RenderSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSlider.cpp; sourceTree = "<group>"; };
+ A8EA73C20A1900E300A8EF5F /* RenderSelect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSelect.h; sourceTree = "<group>"; };
A8FEFB080979F472005839FD /* RenderForeignObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderForeignObject.h; sourceTree = "<group>"; };
A8FEFB090979F472005839FD /* RenderForeignObject.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderForeignObject.cpp; sourceTree = "<group>"; };
A8FEFB2F0979F4F6005839FD /* SVGForeignObjectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGForeignObjectElement.cpp; sourceTree = "<group>"; };
BCEA482F097D93020094C9E4 /* RenderFlexibleBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFlexibleBox.h; sourceTree = "<group>"; };
BCEA4830097D93020094C9E4 /* RenderFlow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlow.cpp; sourceTree = "<group>"; };
BCEA4831097D93020094C9E4 /* RenderFlow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFlow.h; sourceTree = "<group>"; };
- BCEA4832097D93020094C9E4 /* render_form.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = render_form.cpp; sourceTree = "<group>"; };
- BCEA4833097D93020094C9E4 /* render_form.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = render_form.h; sourceTree = "<group>"; };
BCEA4836097D93020094C9E4 /* RenderImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImage.cpp; sourceTree = "<group>"; };
BCEA4837097D93020094C9E4 /* RenderImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderImage.h; sourceTree = "<group>"; };
BCEA4838097D93020094C9E4 /* RenderInline.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderInline.cpp; sourceTree = "<group>"; };
BCEA481A097D93020094C9E4 /* InlineTextBox.cpp */,
BCEA481B097D93020094C9E4 /* InlineTextBox.h */,
935C476009AC4CD100A6AAB4 /* Length.h */,
- BCEA4832097D93020094C9E4 /* render_form.cpp */,
- BCEA4833097D93020094C9E4 /* render_form.h */,
BCEA483E097D93020094C9E4 /* render_list.cpp */,
BCEA483F097D93020094C9E4 /* render_list.h */,
BCEA4844097D93020094C9E4 /* render_style.cpp */,
BCEA482D097D93020094C9E4 /* RenderContainer.h */,
93B70EB009EEE5B5009D8468 /* RenderEmptyApplet.cpp */,
93B70EB109EEE5B5009D8468 /* RenderEmptyApplet.h */,
+ A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */,
+ A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */,
+ A8EA73B20A1900E300A8EF5F /* RenderFileButton.cpp */,
+ A8EA73B30A1900E300A8EF5F /* RenderFileButton.h */,
BCEA482E097D93020094C9E4 /* RenderFlexibleBox.cpp */,
BCEA482F097D93020094C9E4 /* RenderFlexibleBox.h */,
BCEA4830097D93020094C9E4 /* RenderFlow.cpp */,
BCEA4831097D93020094C9E4 /* RenderFlow.h */,
+ A8EA73BF0A1900E300A8EF5F /* RenderFormElement.cpp */,
+ A8EA73B50A1900E300A8EF5F /* RenderFormElement.h */,
A871DECC0A1530C700B12A68 /* RenderFrame.cpp */,
A871DECB0A1530C700B12A68 /* RenderFrame.h */,
A871DECA0A1530C700B12A68 /* RenderFrameSet.cpp */,
BCEA482B097D93020094C9E4 /* RenderHTMLCanvas.h */,
BCEA4836097D93020094C9E4 /* RenderImage.cpp */,
BCEA4837097D93020094C9E4 /* RenderImage.h */,
+ A8EA73BB0A1900E300A8EF5F /* RenderImageButton.cpp */,
+ A8EA73B90A1900E300A8EF5F /* RenderImageButton.h */,
BCEA4838097D93020094C9E4 /* RenderInline.cpp */,
BCEA4839097D93020094C9E4 /* RenderInline.h */,
+ A8EA73C00A1900E300A8EF5F /* RenderLabel.cpp */,
+ A8EA73B70A1900E300A8EF5F /* RenderLabel.h */,
BCEA483A097D93020094C9E4 /* RenderLayer.cpp */,
BCEA483B097D93020094C9E4 /* RenderLayer.h */,
+ A8EA73B60A1900E300A8EF5F /* RenderLegend.cpp */,
+ A8EA73BD0A1900E300A8EF5F /* RenderLegend.h */,
+ A8EA73BE0A1900E300A8EF5F /* RenderLineEdit.cpp */,
+ A8EA73B10A1900E300A8EF5F /* RenderLineEdit.h */,
BCEA4840097D93020094C9E4 /* RenderObject.cpp */,
BCEA4841097D93020094C9E4 /* RenderObject.h */,
A871DEC80A1530C700B12A68 /* RenderPart.cpp */,
A871DECD0A1530C700B12A68 /* RenderPartObject.h */,
A871DFDE0A15376B00B12A68 /* RenderReplaced.cpp */,
A871DFDF0A15376B00B12A68 /* RenderReplaced.h */,
+ A8EA73BC0A1900E300A8EF5F /* RenderSelect.cpp */,
+ A8EA73C20A1900E300A8EF5F /* RenderSelect.h */,
+ A8EA73C10A1900E300A8EF5F /* RenderSlider.cpp */,
+ A8EA73B80A1900E300A8EF5F /* RenderSlider.h */,
A8DF4AE20980C42C0052981B /* RenderTable.cpp */,
A8DF4AE10980C42C0052981B /* RenderTable.h */,
A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */,
A8DF4AE50980C42C0052981B /* RenderTableSection.h */,
BCEA484C097D93020094C9E4 /* RenderText.cpp */,
BCEA484D097D93020094C9E4 /* RenderText.h */,
+ A8EA73B40A1900E300A8EF5F /* RenderTextArea.cpp */,
+ A8EA73BA0A1900E300A8EF5F /* RenderTextArea.h */,
AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */,
AB67D1A7097F3AE300F9392E /* RenderTextField.h */,
BCEA484E097D93020094C9E4 /* RenderTextFragment.cpp */,
BCEA486C097D93020094C9E4 /* RenderContainer.h in Headers */,
BCEA486E097D93020094C9E4 /* RenderFlexibleBox.h in Headers */,
BCEA4870097D93020094C9E4 /* RenderFlow.h in Headers */,
- BCEA4872097D93020094C9E4 /* render_form.h in Headers */,
BCEA4876097D93020094C9E4 /* RenderImage.h in Headers */,
BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */,
BCEA487A097D93020094C9E4 /* RenderLayer.h in Headers */,
A8CFF7A70A156978000A4234 /* HTMLModElement.h in Headers */,
A8CFF7AA0A156978000A4234 /* HTMLBRElement.h in Headers */,
A8CFF7AB0A156978000A4234 /* HTMLAnchorElement.h in Headers */,
+ A8EA73C40A1900E300A8EF5F /* RenderFieldset.h in Headers */,
+ A8EA73C50A1900E300A8EF5F /* RenderLineEdit.h in Headers */,
+ A8EA73C70A1900E300A8EF5F /* RenderFileButton.h in Headers */,
+ A8EA73C90A1900E300A8EF5F /* RenderFormElement.h in Headers */,
+ A8EA73CB0A1900E300A8EF5F /* RenderLabel.h in Headers */,
+ A8EA73CC0A1900E300A8EF5F /* RenderSlider.h in Headers */,
+ A8EA73CD0A1900E300A8EF5F /* RenderImageButton.h in Headers */,
+ A8EA73CE0A1900E300A8EF5F /* RenderTextArea.h in Headers */,
+ A8EA73D10A1900E300A8EF5F /* RenderLegend.h in Headers */,
+ A8EA73D60A1900E300A8EF5F /* RenderSelect.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
BCEA486B097D93020094C9E4 /* RenderContainer.cpp in Sources */,
BCEA486D097D93020094C9E4 /* RenderFlexibleBox.cpp in Sources */,
BCEA486F097D93020094C9E4 /* RenderFlow.cpp in Sources */,
- BCEA4871097D93020094C9E4 /* render_form.cpp in Sources */,
BCEA4875097D93020094C9E4 /* RenderImage.cpp in Sources */,
BCEA4877097D93020094C9E4 /* RenderInline.cpp in Sources */,
BCEA4879097D93020094C9E4 /* RenderLayer.cpp in Sources */,
A8CFF7A50A156978000A4234 /* HTMLQuoteElement.cpp in Sources */,
A8CFF7A80A156978000A4234 /* HTMLBRElement.cpp in Sources */,
A8CFF7A90A156978000A4234 /* HTMLModElement.cpp in Sources */,
+ A8EA73C30A1900E300A8EF5F /* RenderFieldset.cpp in Sources */,
+ A8EA73C60A1900E300A8EF5F /* RenderFileButton.cpp in Sources */,
+ A8EA73C80A1900E300A8EF5F /* RenderTextArea.cpp in Sources */,
+ A8EA73CA0A1900E300A8EF5F /* RenderLegend.cpp in Sources */,
+ A8EA73CF0A1900E300A8EF5F /* RenderImageButton.cpp in Sources */,
+ A8EA73D00A1900E300A8EF5F /* RenderSelect.cpp in Sources */,
+ A8EA73D20A1900E300A8EF5F /* RenderLineEdit.cpp in Sources */,
+ A8EA73D30A1900E300A8EF5F /* RenderFormElement.cpp in Sources */,
+ A8EA73D40A1900E300A8EF5F /* RenderLabel.cpp in Sources */,
+ A8EA73D50A1900E300A8EF5F /* RenderSlider.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "dom2_eventsimpl.h"
#include "FormDataList.h"
-#include "rendering/render_form.h"
#include "RenderButton.h"
#include "EventNames.h"
using namespace EventNames;
using namespace HTMLNames;
-HTMLButtonElement::HTMLButtonElement(Document *doc, HTMLFormElement *f)
+HTMLButtonElement::HTMLButtonElement(Document* doc, HTMLFormElement* f)
: HTMLGenericFormElement(buttonTag, doc, f)
+ , m_type(SUBMIT)
+ , m_dirty(true)
+ , m_activeSubmit(false)
{
- m_type = SUBMIT;
- m_dirty = true;
- m_activeSubmit = false;
}
HTMLButtonElement::~HTMLButtonElement()
#include "config.h"
#include "HTMLFieldSetElement.h"
-#include "rendering/render_form.h"
#include "HTMLNames.h"
+#include "RenderFieldset.h"
namespace WebCore {
#include "HTMLNames.h"
#include "csshelper.h"
#include "html_imageimpl.h"
-#include "render_form.h"
+#include "RenderLineEdit.h"
namespace WebCore {
#include "HTMLFormElement.h"
#include "HTMLNames.h"
#include "LocalizedStrings.h"
+#include "RenderFileButton.h"
+#include "RenderImageButton.h"
+#include "RenderLineEdit.h"
#include "RenderText.h"
#include "RenderTextField.h"
#include "RenderTheme.h"
+#include "RenderSlider.h"
#include "SelectionController.h"
#include "html_imageimpl.h"
#include "RenderButton.h"
-#include "render_form.h"
#include <unicode/ubrk.h>
using namespace std;
#include "HTMLLabelElement.h"
#include "HTMLFormElement.h"
-#include "rendering/render_form.h"
#include "HTMLNames.h"
#include "EventNames.h"
#include "Document.h"
#include "config.h"
#include "HTMLLegendElement.h"
-#include "rendering/render_form.h"
#include "HTMLNames.h"
+#include "RenderLegend.h"
namespace WebCore {
return false;
}
-RenderObject* HTMLLegendElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* HTMLLegendElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderLegend(this);
}
#include "ExceptionCode.h"
#include "HTMLSelectElement.h"
#include "Text.h"
-#include "render_form.h"
namespace WebCore {
#include "HTMLFormElement.h"
#include "HTMLOptionElement.h"
#include "HTMLOptionsCollection.h"
+#include "RenderSelect.h"
#include "CSSPropertyNames.h"
#include "cssstyleselector.h"
#include "dom2_eventsimpl.h"
-#include "render_form.h"
namespace WebCore {
#include "config.h"
#include "HTMLTextAreaElement.h"
-#include "rendering/render_form.h"
-#include "Text.h"
-#include "FormDataList.h"
-#include "Document.h"
+#include "Document.h"
#include "EventNames.h"
+#include "FormDataList.h"
#include "HTMLNames.h"
+#include "RenderTextArea.h"
+#include "Text.h"
namespace WebCore {
int HTMLTextAreaElement::selectionStart()
{
if (renderer())
- return static_cast<RenderTextArea *>(renderer())->selectionStart();
+ return static_cast<RenderTextArea*>(renderer())->selectionStart();
return 0;
}
int HTMLTextAreaElement::selectionEnd()
{
if (renderer())
- return static_cast<RenderTextArea *>(renderer())->selectionEnd();
+ return static_cast<RenderTextArea*>(renderer())->selectionEnd();
return 0;
}
void HTMLTextAreaElement::setSelectionStart(int start)
{
if (renderer())
- static_cast<RenderTextArea *>(renderer())->setSelectionStart(start);
+ static_cast<RenderTextArea*>(renderer())->setSelectionStart(start);
}
void HTMLTextAreaElement::setSelectionEnd(int end)
{
if (renderer())
- static_cast<RenderTextArea *>(renderer())->setSelectionEnd(end);
+ static_cast<RenderTextArea*>(renderer())->setSelectionEnd(end);
}
void HTMLTextAreaElement::select()
void HTMLTextAreaElement::setSelectionRange(int start, int end)
{
if (renderer())
- static_cast<RenderTextArea *>(renderer())->setSelectionRange(start, end);
+ static_cast<RenderTextArea*>(renderer())->setSelectionRange(start, end);
}
void HTMLTextAreaElement::childrenChanged()
renderer()->setNeedsLayoutAndMinMaxRecalc();
} else if (attr->name() == accesskeyAttr) {
// ignore for the moment
- } else if (attr->name() == onfocusAttr) {
+ } else if (attr->name() == onfocusAttr)
setHTMLEventListener(focusEvent, attr);
- } else if (attr->name() == onblurAttr) {
+ else if (attr->name() == onblurAttr)
setHTMLEventListener(blurEvent, attr);
- } else if (attr->name() == onselectAttr) {
+ else if (attr->name() == onselectAttr)
setHTMLEventListener(selectEvent, attr);
- } else if (attr->name() == onchangeAttr) {
+ else if (attr->name() == onchangeAttr)
setHTMLEventListener(changeEvent, attr);
- } else
+ else
HTMLGenericFormElement::parseMappedAttribute(attr);
}
-RenderObject *HTMLTextAreaElement::createRenderer(RenderArena *arena, RenderStyle *style)
+RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderTextArea(this);
}
return m_value;
}
-void HTMLTextAreaElement::setValue(const String &value)
+void HTMLTextAreaElement::setValue(const String& value)
{
DeprecatedString string = value.deprecatedString();
// WebCoreTextArea normalizes line endings added by the user via the keyboard or pasting.
return val;
}
-void HTMLTextAreaElement::setDefaultValue(const String &defaultValue)
+void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
{
// there may be comments - remove all the text nodes and replace them with one
DeprecatedPtrList<Node> toRemove;
return getAttribute(accesskeyAttr);
}
-void HTMLTextAreaElement::setAccessKey(const String &value)
+void HTMLTextAreaElement::setAccessKey(const String& value)
{
setAttribute(accesskeyAttr, value);
}
#import "FontData.h"
#import "WebTextRendererFactory.h"
#import "WebCoreWidgetHolder.h"
-#import "render_form.h"
+#import "WidgetClient.h"
#import "Font.h"
using namespace WebCore;
#import "WebCoreFrameBridge.h"
#import "WebCoreStringTruncator.h"
#import "WebCoreViewFactory.h"
-#import "render_form.h"
+#import "WidgetClient.h"
using namespace WebCore;
#import "FontData.h"
#import "WebTextRendererFactory.h"
#import "WebCoreWidgetHolder.h"
+#import "WidgetClient.h"
#import <wtf/Assertions.h>
-#import "render_form.h"
#import "GraphicsContext.h"
using namespace WebCore;
#import "FrameMac.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreWidgetHolder.h"
-#import "render_form.h"
+#import "WidgetClient.h"
using namespace std;
using namespace WebCore;
#import "KWQKHTMLSettings.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreWidgetHolder.h"
-#import "render_form.h"
+#import "WidgetClient.h"
#import <wtf/Assertions.h>
using namespace WebCore;
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderFieldset.h"
+
+#include "HTMLGenericFormElement.h"
+#include "HTMLNames.h"
+
+using std::min;
+using std::max;
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderFieldset::RenderFieldset(HTMLGenericFormElement* element)
+ : RenderBlock(element)
+{
+}
+
+RenderObject* RenderFieldset::layoutLegend(bool relayoutChildren)
+{
+ RenderObject* legend = findLegend();
+ if (legend) {
+ if (relayoutChildren)
+ legend->setNeedsLayout(true);
+ legend->layoutIfNeeded();
+
+ int xPos = borderLeft() + paddingLeft() + legend->marginLeft();
+ if (style()->direction() == RTL)
+ xPos = m_width - paddingRight() - borderRight() - legend->width() - legend->marginRight();
+ int b = borderTop();
+ int h = legend->height();
+ legend->setPos(xPos, max((b-h)/2, 0));
+ m_height = max(b,h) + paddingTop();
+ }
+ return legend;
+}
+
+RenderObject* RenderFieldset::findLegend()
+{
+ for (RenderObject* legend = firstChild(); legend; legend = legend->nextSibling()) {
+ if (!legend->isFloatingOrPositioned() && legend->element() &&
+ legend->element()->hasTagName(legendTag))
+ return legend;
+ }
+ return 0;
+}
+
+void RenderFieldset::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
+{
+ int w = width();
+ int h = height() + borderTopExtra() + borderBottomExtra();
+ RenderObject* legend = findLegend();
+ if (!legend)
+ return RenderBlock::paintBoxDecorations(i, _tx, _ty);
+
+ int yOff = (legend->yPos() > 0) ? 0 : (legend->height()-borderTop())/2;
+ h -= yOff;
+ _ty += yOff - borderTopExtra();
+
+ int my = max(_ty, i.r.y());
+ int end = min(i.r.bottom(), _ty + h);
+ int mh = end - my;
+
+ paintBackground(i.p, style()->backgroundColor(), style()->backgroundLayers(), my, mh, _tx, _ty, w, h);
+
+ if (style()->hasBorder())
+ paintBorderMinusLegend(i.p, _tx, _ty, w, h, style(), legend->xPos(), legend->width());
+}
+
+void RenderFieldset::paintBorderMinusLegend(GraphicsContext* p, int _tx, int _ty, int w, int h,
+ const RenderStyle* style, int lx, int lw)
+{
+
+ const Color& tc = style->borderTopColor();
+ const Color& bc = style->borderBottomColor();
+
+ EBorderStyle ts = style->borderTopStyle();
+ EBorderStyle bs = style->borderBottomStyle();
+ EBorderStyle ls = style->borderLeftStyle();
+ EBorderStyle rs = style->borderRightStyle();
+
+ bool render_t = ts > BHIDDEN;
+ bool render_l = ls > BHIDDEN;
+ bool render_r = rs > BHIDDEN;
+ bool render_b = bs > BHIDDEN;
+
+ if (render_t) {
+ drawBorder(p, _tx, _ty, _tx + lx, _ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
+ (render_l && (ls == DOTTED || ls == DASHED || ls == DOUBLE)?style->borderLeftWidth():0), 0);
+ drawBorder(p, _tx+lx+lw, _ty, _tx + w, _ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
+ 0, (render_r && (rs == DOTTED || rs == DASHED || rs == DOUBLE)?style->borderRightWidth():0));
+ }
+
+ if (render_b)
+ drawBorder(p, _tx, _ty + h - style->borderBottomWidth(), _tx + w, _ty + h, BSBottom, bc, style->color(), bs,
+ (render_l && (ls == DOTTED || ls == DASHED || ls == DOUBLE)?style->borderLeftWidth():0),
+ (render_r && (rs == DOTTED || rs == DASHED || rs == DOUBLE)?style->borderRightWidth():0));
+
+ if (render_l) {
+ const Color& lc = style->borderLeftColor();
+
+ bool ignore_top =
+ (tc == lc) &&
+ (ls >= OUTSET) &&
+ (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
+
+ bool ignore_bottom =
+ (bc == lc) &&
+ (ls >= OUTSET) &&
+ (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
+
+ drawBorder(p, _tx, _ty, _tx + style->borderLeftWidth(), _ty + h, BSLeft, lc, style->color(), ls,
+ ignore_top?0:style->borderTopWidth(),
+ ignore_bottom?0:style->borderBottomWidth());
+ }
+
+ if (render_r) {
+ const Color& rc = style->borderRightColor();
+
+ bool ignore_top =
+ (tc == rc) &&
+ (rs >= DOTTED || rs == INSET) &&
+ (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
+
+ bool ignore_bottom =
+ (bc == rc) &&
+ (rs >= DOTTED || rs == INSET) &&
+ (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
+
+ drawBorder(p, _tx + w - style->borderRightWidth(), _ty, _tx + w, _ty + h, BSRight, rc, style->color(), rs,
+ ignore_top?0:style->borderTopWidth(),
+ ignore_bottom?0:style->borderBottomWidth());
+ }
+}
+
+void RenderFieldset::setStyle(RenderStyle* _style)
+{
+ RenderBlock::setStyle(_style);
+
+ // WinIE renders fieldsets with display:inline like they're inline-blocks. For us,
+ // an inline-block is just a block element with replaced set to true and inline set
+ // to true. Ensure that if we ended up being inline that we set our replaced flag
+ // so that we're treated like an inline-block.
+ if (isInline())
+ setReplaced(true);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderFieldset_h
+#define RenderFieldset_h
+
+#include "RenderBlock.h"
+
+namespace WebCore {
+
+ class HTMLGenericFormElement;
+
+ class RenderFieldset : public RenderBlock {
+ public:
+ RenderFieldset(HTMLGenericFormElement*);
+
+ virtual const char* renderName() const { return "RenderFieldSet"; }
+
+ virtual RenderObject* layoutLegend(bool relayoutChildren);
+
+ virtual void setStyle(RenderStyle*);
+
+ private:
+ virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
+ void paintBorderMinusLegend(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, int lx, int lw);
+ RenderObject* findLegend();
+ };
+
+} // namespace WebCore
+
+#endif // RenderFieldset_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderFileButton.h"
+
+#include "FrameView.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "KWQFileButton.h"
+
+namespace WebCore {
+
+RenderFileButton::RenderFileButton(HTMLInputElement* element)
+ : RenderFormElement(element)
+{
+ setWidget(new KWQFileButton(view()->frame()));
+}
+
+void RenderFileButton::calcMinMaxWidth()
+{
+ ASSERT(!minMaxKnown());
+
+ // Let the widget tell us how big it wants to be.
+ int size = static_cast<HTMLInputElement*>(node())->size();
+ IntSize s(static_cast<KWQFileButton*>(widget())->sizeForCharacterWidth(size > 0 ? size : 20));
+
+ setIntrinsicWidth(s.width());
+ setIntrinsicHeight(s.height());
+
+ RenderFormElement::calcMinMaxWidth();
+}
+
+void RenderFileButton::updateFromElement()
+{
+ static_cast<KWQFileButton*>(widget())->setFilename(
+ static_cast<HTMLInputElement*>(node())->value().deprecatedString());
+
+ RenderFormElement::updateFromElement();
+}
+
+void RenderFileButton::returnPressed(Widget*)
+{
+ if (static_cast<HTMLInputElement*>(node())->form())
+ static_cast<HTMLInputElement*>(node())->form()->prepareSubmit();
+}
+
+void RenderFileButton::valueChanged(Widget*)
+{
+ static_cast<HTMLInputElement*>(node())->setValueFromRenderer(static_cast<KWQFileButton*>(widget())->filename());
+ static_cast<HTMLInputElement*>(node())->onChange();
+}
+
+void RenderFileButton::select()
+{
+}
+
+void RenderFileButton::click(bool sendMouseEvents)
+{
+ static_cast<KWQFileButton*>(widget())->click(sendMouseEvents);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderFileButton_h
+#define RenderFileButton_h
+
+#include "RenderFormElement.h"
+
+namespace WebCore {
+
+ class HTMLInputElement;
+
+ class RenderFileButton : public RenderFormElement {
+ public:
+ RenderFileButton(HTMLInputElement*);
+
+ virtual const char* renderName() const { return "RenderFileButton"; }
+
+ virtual void calcMinMaxWidth();
+ virtual void updateFromElement();
+ void select();
+
+ int calcReplacedHeight() const { return intrinsicHeight(); }
+
+ void click(bool sendMouseEvents);
+
+ protected:
+ virtual bool isEditable() const { return true; }
+
+ private:
+ virtual void returnPressed(Widget*);
+ virtual void valueChanged(Widget*);
+ };
+
+} // namespace WebCore
+
+#endif // RenderFileButton_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderFormElement.h"
+
+#include "EventNames.h"
+#include "HTMLGenericFormElement.h"
+#include "PlatformMouseEvent.h"
+
+namespace WebCore {
+
+using namespace EventNames;
+
+RenderFormElement::RenderFormElement(HTMLGenericFormElement* element)
+ : RenderWidget(element)
+{
+ setInline(true);
+}
+
+RenderFormElement::~RenderFormElement()
+{
+}
+
+short RenderFormElement::baselinePosition(bool f, bool isRootLineBox) const
+{
+ return marginTop() + widget()->baselinePosition(m_height);
+}
+
+void RenderFormElement::setStyle(RenderStyle* s)
+{
+ if (canHaveIntrinsicMargins())
+ addIntrinsicMarginsIfAllowed(s);
+
+ RenderWidget::setStyle(s);
+
+ // Do not paint a background or border for Aqua form elements
+ setShouldPaintBackgroundOrBorder(false);
+
+ m_widget->setFont(style()->font());
+}
+
+void RenderFormElement::updateFromElement()
+{
+ m_widget->setEnabled(!static_cast<HTMLGenericFormElement*>(node())->disabled());
+}
+
+void RenderFormElement::layout()
+{
+ KHTMLAssert(needsLayout());
+ KHTMLAssert(minMaxKnown());
+
+ // minimum height
+ m_height = 0;
+
+ calcWidth();
+ calcHeight();
+
+ setNeedsLayout(false);
+}
+
+void RenderFormElement::clicked(Widget*)
+{
+ RenderArena* arena = ref();
+ PlatformMouseEvent event; // gets "current event"
+ if (node())
+ static_cast<EventTargetNode*>(node())->dispatchMouseEvent(event, clickEvent, event.clickCount());
+ deref(arena);
+}
+
+HorizontalAlignment RenderFormElement::textAlignment() const
+{
+ switch (style()->textAlign()) {
+ case LEFT:
+ case KHTML_LEFT:
+ return AlignLeft;
+ case RIGHT:
+ case KHTML_RIGHT:
+ return AlignRight;
+ case CENTER:
+ case KHTML_CENTER:
+ return AlignHCenter;
+ case JUSTIFY:
+ // Just fall into the auto code for justify.
+ case TAAUTO:
+ return style()->direction() == RTL ? AlignRight : AlignLeft;
+ }
+ ASSERT(false); // Should never be reached.
+ return AlignLeft;
+}
+
+
+void RenderFormElement::addIntrinsicMarginsIfAllowed(RenderStyle* _style)
+{
+ // Cut out the intrinsic margins completely if we end up using mini controls.
+ if (_style->fontSize() < 11)
+ return;
+
+ // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
+ int m = intrinsicMargin();
+ if (_style->width().isIntrinsicOrAuto()) {
+ if (_style->marginLeft().quirk())
+ _style->setMarginLeft(Length(m, Fixed));
+ if (_style->marginRight().quirk())
+ _style->setMarginRight(Length(m, Fixed));
+ }
+
+ if (_style->height().isAuto()) {
+ if (_style->marginTop().quirk())
+ _style->setMarginTop(Length(m, Fixed));
+ if (_style->marginBottom().quirk())
+ _style->setMarginBottom(Length(m, Fixed));
+ }
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderFormElement_h
+#define RenderFormElement_h
+
+#include "RenderWidget.h"
+#include "GraphicsTypes.h"
+
+namespace WebCore {
+
+ class HTMLGenericFormElement;
+
+ class RenderFormElement : public RenderWidget {
+ public:
+ RenderFormElement(HTMLGenericFormElement*);
+ virtual ~RenderFormElement();
+
+ virtual const char* renderName() const { return "RenderForm"; }
+
+ virtual bool isFormElement() const { return true; }
+
+ // Aqua form controls never have border/padding.
+ int borderTop() const { return 0; }
+ int borderBottom() const { return 0; }
+ int borderLeft() const { return 0; }
+ int borderRight() const { return 0; }
+ int paddingTop() const { return 0; }
+ int paddingBottom() const { return 0; }
+ int paddingLeft() const { return 0; }
+ int paddingRight() const { return 0; }
+
+ // Aqua controls use intrinsic margin values in order to leave space for focus rings
+ // and to keep controls from butting up against one another. This intrinsic margin
+ // is only applied if the Web page allows the control to size intrinsically. If the
+ // Web page specifies an explicit width for a control, then we go ahead and honor that
+ // precise width. Similarly, if a Web page uses a specific margin value, we will go ahead
+ // and honor that value.
+ void addIntrinsicMarginsIfAllowed(RenderStyle*);
+ virtual bool canHaveIntrinsicMargins() const { return false; }
+ int intrinsicMargin() const { return 2; }
+
+ virtual void setStyle(RenderStyle*);
+ virtual void updateFromElement();
+
+ virtual void layout();
+ virtual short baselinePosition(bool, bool) const;
+
+ protected:
+ virtual bool isEditable() const { return false; }
+
+ HorizontalAlignment textAlignment() const;
+
+ private:
+ virtual void clicked(Widget*);
+ };
+
+} // namespace WebCore
+
+#endif // RenderFormElement_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderImageButton.h"
+
+#include "HTMLInputElement.h"
+
+namespace WebCore {
+
+RenderImageButton::RenderImageButton(HTMLInputElement* element)
+ : RenderImage(element)
+{
+ // ### support DOMActivate event when clicked
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderImageButton_h
+#define RenderImageButton_h
+
+#include "RenderImage.h"
+
+namespace WebCore {
+
+ class HTMLInputElement;
+
+ class RenderImageButton : public RenderImage {
+ public:
+ RenderImageButton(HTMLInputElement*);
+
+ virtual const char* renderName() const { return "RenderImageButton"; }
+ virtual bool isImageButton() const { return true; }
+ };
+
+} // namespace WebCore
+
+#endif // RenderImageButton_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderLabel.h"
+
+namespace WebCore {
+
+RenderLabel::RenderLabel(HTMLGenericFormElement* element)
+ : RenderFormElement(element)
+{
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderLabel_h
+#define RenderLabel_h
+
+#include "RenderFormElement.h"
+
+namespace WebCore {
+
+ class RenderLabel : public RenderFormElement {
+ public:
+ RenderLabel(HTMLGenericFormElement*);
+
+ virtual const char* renderName() const { return "RenderLabel"; }
+ };
+
+} // namespace WebCore
+
+#endif // RenderLabel_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderLegend.h"
+
+#include "HTMLGenericFormElement.h"
+
+namespace WebCore {
+
+RenderLegend::RenderLegend(HTMLGenericFormElement* element)
+ : RenderBlock(element)
+{
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderLegend_h
+#define RenderLegend_h
+
+#include "RenderBlock.h"
+
+namespace WebCore {
+
+ class HTMLGenericFormElement;
+
+ class RenderLegend : public RenderBlock {
+ public:
+ RenderLegend(HTMLGenericFormElement*);
+
+ virtual const char* renderName() const { return "RenderLegend"; }
+ };
+
+} // namespace WebCore
+
+#endif // RenderLegend_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderLineEdit.h"
+
+#include "EventNames.h"
+#include "HTMLNames.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "KWQLineEdit.h"
+
+namespace WebCore {
+
+using namespace EventNames;
+using namespace HTMLNames;
+
+RenderLineEdit::RenderLineEdit(HTMLInputElement* element)
+ : RenderFormElement(element)
+ , m_updating(false)
+{
+ QLineEdit::Type type;
+ switch (element->inputType()) {
+ case HTMLInputElement::PASSWORD:
+ type = QLineEdit::Password;
+ break;
+ case HTMLInputElement::SEARCH:
+ type = QLineEdit::Search;
+ break;
+ default:
+ type = QLineEdit::Normal;
+ }
+ QLineEdit* edit = new QLineEdit(type);
+ if (type == QLineEdit::Search)
+ edit->setLiveSearch(false);
+ setWidget(edit);
+}
+
+void RenderLineEdit::selectionChanged(Widget*)
+{
+ // We only want to call onselect if there actually is a selection
+ QLineEdit* w = static_cast<QLineEdit*>(m_widget);
+ if (w->hasSelectedText())
+ static_cast<HTMLGenericFormElement*>(node())->onSelect();
+}
+
+void RenderLineEdit::returnPressed(Widget*)
+{
+ // Emit onChange if necessary
+ // Works but might not be enough, dirk said he had another solution at
+ // hand (can't remember which) - David
+ if (isTextField() && isEdited()) {
+ static_cast<HTMLGenericFormElement*>(node())->onChange();
+ setEdited(false);
+ }
+
+ if (HTMLFormElement* fe = static_cast<HTMLGenericFormElement*>(node())->form())
+ fe->submitClick();
+}
+
+void RenderLineEdit::performSearch(Widget*)
+{
+ // Fire the "search" DOM event.
+ static_cast<EventTargetNode*>(node())->dispatchHTMLEvent(searchEvent, true, false);
+}
+
+void RenderLineEdit::addSearchResult()
+{
+ if (widget())
+ static_cast<QLineEdit*>(widget())->addSearchResult();
+}
+
+void RenderLineEdit::calcMinMaxWidth()
+{
+ KHTMLAssert(!minMaxKnown());
+
+ // Let the widget tell us how big it wants to be.
+ m_updating = true;
+ int size = static_cast<HTMLInputElement*>(node())->size();
+ IntSize s(static_cast<QLineEdit*>(widget())->sizeForCharacterWidth(size > 0 ? size : 20));
+ m_updating = false;
+
+ setIntrinsicWidth(s.width());
+ setIntrinsicHeight(s.height());
+
+ RenderFormElement::calcMinMaxWidth();
+}
+
+void RenderLineEdit::setStyle(RenderStyle *s)
+{
+ RenderFormElement::setStyle(s);
+
+ QLineEdit* w = static_cast<QLineEdit*>(widget());
+ w->setAlignment(textAlignment());
+ w->setWritingDirection(style()->direction() == RTL ? RTL : LTR);
+}
+
+void RenderLineEdit::updateFromElement()
+{
+ HTMLInputElement* e = static_cast<HTMLInputElement*>(node());
+ QLineEdit* w = static_cast<QLineEdit*>(widget());
+
+ int ml = e->maxLength();
+ if (ml <= 0 || ml > 1024)
+ ml = 1024;
+ if (w->maxLength() != ml)
+ w->setMaxLength(ml);
+
+ if (!e->valueMatchesRenderer()) {
+ String widgetText = w->text();
+ String newText = e->value();
+ newText.replace('\\', backslashAsCurrencySymbol());
+ if (widgetText != newText) {
+ int pos = w->cursorPosition();
+
+ m_updating = true;
+ w->setText(newText);
+ m_updating = false;
+
+ w->setEdited( false );
+
+ w->setCursorPosition(pos);
+ }
+ e->setValueMatchesRenderer();
+ }
+
+ w->setReadOnly(e->isReadOnlyControl());
+
+ // Handle updating the search attributes.
+ w->setPlaceholderString(e->getAttribute(placeholderAttr).deprecatedString());
+ if (w->type() == QLineEdit::Search) {
+ w->setLiveSearch(!e->getAttribute(incrementalAttr).isNull());
+ w->setAutoSaveName(e->getAttribute(autosaveAttr));
+ w->setMaxResults(e->maxResults());
+ }
+
+ w->setColors(style()->backgroundColor(), style()->color());
+
+ RenderFormElement::updateFromElement();
+}
+
+void RenderLineEdit::valueChanged(Widget*)
+{
+ if (m_updating) // Don't alter the value if we are in the middle of initing the control, since
+ return; // we are getting the value from the DOM and it's not user input.
+
+ String newText = static_cast<QLineEdit*>(widget())->text();
+
+ // A null string value is used to indicate that the form control has not altered the original
+ // default value. That means that we should never use the null string value when the user
+ // empties a textfield, but should always force an empty textfield to use the empty string.
+ if (newText.isNull())
+ newText = "";
+
+ newText.replace(backslashAsCurrencySymbol(), '\\');
+ static_cast<HTMLInputElement*>(node())->setValueFromRenderer(newText);
+}
+
+int RenderLineEdit::selectionStart()
+{
+ QLineEdit *lineEdit = static_cast<QLineEdit *>(m_widget);
+ int start = lineEdit->selectionStart();
+ if (start == -1)
+ start = lineEdit->cursorPosition();
+ return start;
+}
+
+int RenderLineEdit::selectionEnd()
+{
+ QLineEdit *lineEdit = static_cast<QLineEdit *>(m_widget);
+ int start = lineEdit->selectionStart();
+ if (start == -1)
+ return lineEdit->cursorPosition();
+ return start + (int)lineEdit->selectedText().length();
+}
+
+void RenderLineEdit::setSelectionStart(int start)
+{
+ int realStart = max(start, 0);
+ int length = max(selectionEnd() - realStart, 0);
+ static_cast<QLineEdit *>(m_widget)->setSelection(realStart, length);
+}
+
+void RenderLineEdit::setSelectionEnd(int end)
+{
+ int start = selectionStart();
+ int realEnd = max(end, 0);
+ int length = realEnd - start;
+ if (length < 0) {
+ start = realEnd;
+ length = 0;
+ }
+ static_cast<QLineEdit *>(m_widget)->setSelection(start, length);
+}
+
+void RenderLineEdit::select()
+{
+ static_cast<QLineEdit*>(m_widget)->selectAll();
+}
+
+bool RenderLineEdit::isEdited() const
+{
+ return static_cast<QLineEdit*>(m_widget)->edited();
+}
+void RenderLineEdit::setEdited(bool x)
+{
+ static_cast<QLineEdit*>(m_widget)->setEdited(x);
+}
+
+void RenderLineEdit::setSelectionRange(int start, int end)
+{
+ int realStart = max(start, 0);
+ int length = max(end - realStart, 0);
+ static_cast<QLineEdit *>(m_widget)->setSelection(realStart, length);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderLineEdit_h
+#define RenderLineEdit_h
+
+#include "RenderFormElement.h"
+
+namespace WebCore {
+
+ class HTMLInputElement;
+
+ class RenderLineEdit : public RenderFormElement {
+ public:
+ RenderLineEdit(HTMLInputElement*);
+
+ virtual const char* renderName() const { return "RenderLineEdit"; }
+
+ virtual void calcMinMaxWidth();
+ int calcReplacedHeight() const { return intrinsicHeight(); }
+ virtual bool canHaveIntrinsicMargins() const { return true; }
+
+ virtual void updateFromElement();
+ virtual void setStyle(RenderStyle*);
+
+ int selectionStart();
+ int selectionEnd();
+ void setSelectionStart(int);
+ void setSelectionEnd(int);
+
+ bool isEdited() const;
+ void setEdited(bool);
+ bool isTextField() const { return true; }
+ void select();
+ void setSelectionRange(int, int);
+
+ void addSearchResult();
+
+ private:
+ virtual void returnPressed(Widget*);
+ virtual void valueChanged(Widget*);
+ virtual void selectionChanged(Widget*);
+ virtual void performSearch(Widget*);
+
+ virtual bool isEditable() const { return true; }
+
+ bool m_updating;
+ };
+
+} // namespace WebCore
+
+#endif // RenderLineEdit_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderSelect.h"
+
+#include "HTMLNames.h"
+#include "HTMLOptGroupElement.h"
+#include "HTMLOptionElement.h"
+#include "HTMLSelectElement.h"
+#include "KWQComboBox.h"
+
+using std::min;
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderSelect::RenderSelect(HTMLSelectElement* element)
+ : RenderFormElement(element)
+ , m_size(element->size())
+ , m_multiple(element->multiple())
+ , m_useListBox(m_multiple || m_size > 1)
+ , m_selectionChanged(true)
+ , m_ignoreSelectEvents(false)
+ , m_optionsChanged(true)
+{
+ if (m_useListBox)
+ setWidget(createListBox());
+ else
+ setWidget(new QComboBox);
+}
+
+void RenderSelect::setWidgetWritingDirection()
+{
+ TextDirection d = style()->direction() == RTL ? RTL : LTR;
+ if (m_useListBox)
+ static_cast<QListBox*>(m_widget)->setWritingDirection(d);
+ else
+ static_cast<QComboBox*>(m_widget)->setWritingDirection(d);
+}
+
+void RenderSelect::setStyle(RenderStyle* s)
+{
+ RenderFormElement::setStyle(s);
+ setWidgetWritingDirection();
+}
+
+void RenderSelect::updateFromElement()
+{
+ m_ignoreSelectEvents = true;
+
+ // change widget type
+ bool oldMultiple = m_multiple;
+ unsigned oldSize = m_size;
+ bool oldListbox = m_useListBox;
+
+ m_multiple = static_cast<HTMLSelectElement*>(node())->multiple();
+ m_size = static_cast<HTMLSelectElement*>(node())->size();
+ m_useListBox = (m_multiple || m_size > 1);
+
+ if (oldMultiple != m_multiple || oldSize != m_size) {
+ if (m_useListBox != oldListbox) {
+ // type of select has changed
+ delete m_widget;
+
+ if (m_useListBox)
+ setWidget(createListBox());
+ else
+ setWidget(new QComboBox);
+ setWidgetWritingDirection();
+ }
+
+ if (m_useListBox && oldMultiple != m_multiple) {
+ static_cast<QListBox*>(m_widget)->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
+ }
+ m_selectionChanged = true;
+ m_optionsChanged = true;
+ }
+
+ // update contents listbox/combobox based on options in m_element
+ if (m_optionsChanged) {
+ if (static_cast<HTMLSelectElement*>(node())->m_recalcListItems)
+ static_cast<HTMLSelectElement*>(node())->recalcListItems();
+ DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
+ int listIndex;
+
+ if (m_useListBox)
+ static_cast<QListBox*>(m_widget)->clear();
+ else
+ static_cast<QComboBox*>(m_widget)->clear();
+
+ bool groupEnabled = true;
+ for (listIndex = 0; listIndex < int(listItems.size()); listIndex++) {
+ if (listItems[listIndex]->hasTagName(optgroupTag)) {
+ HTMLOptGroupElement* optgroupElement = static_cast<HTMLOptGroupElement*>(listItems[listIndex]);
+ DeprecatedString label = optgroupElement->getAttribute(labelAttr).deprecatedString();
+ label.replace('\\', backslashAsCurrencySymbol());
+
+ // In WinIE, an optgroup can't start or end with whitespace (other than the indent
+ // we give it). We match this behavior.
+ label = label.stripWhiteSpace();
+ // We want to collapse our whitespace too. This will match other browsers.
+ label = label.simplifyWhiteSpace();
+
+ groupEnabled = optgroupElement->isEnabled();
+
+ if (m_useListBox)
+ static_cast<QListBox*>(m_widget)->appendGroupLabel(label, groupEnabled);
+ else
+ static_cast<QComboBox*>(m_widget)->appendGroupLabel(label);
+ } else if (listItems[listIndex]->hasTagName(optionTag)) {
+ HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(listItems[listIndex]);
+ DeprecatedString itemText;
+ if (optionElement->hasAttribute(labelAttr))
+ itemText = optionElement->getAttribute(labelAttr).deprecatedString();
+ else
+ itemText = optionElement->text().deprecatedString();
+
+ itemText.replace('\\', backslashAsCurrencySymbol());
+
+ // In WinIE, leading and trailing whitespace is ignored in options. We match this behavior.
+ itemText = itemText.stripWhiteSpace();
+ // We want to collapse our whitespace too. This will match other browsers.
+ itemText = itemText.simplifyWhiteSpace();
+
+ if (listItems[listIndex]->parentNode()->hasTagName(optgroupTag))
+ itemText.prepend(" ");
+
+ if (m_useListBox)
+ static_cast<QListBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
+ else
+ static_cast<QComboBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
+ } else if (listItems[listIndex]->hasTagName(hrTag)) {
+ if (!m_useListBox)
+ static_cast<QComboBox*>(m_widget)->appendSeparator();
+ } else
+ ASSERT(false);
+ m_selectionChanged = true;
+ }
+ if (m_useListBox)
+ static_cast<QListBox*>(m_widget)->doneAppendingItems();
+ setNeedsLayoutAndMinMaxRecalc();
+ m_optionsChanged = false;
+ }
+
+ // update selection
+ if (m_selectionChanged)
+ updateSelection();
+
+ m_ignoreSelectEvents = false;
+
+ RenderFormElement::updateFromElement();
+}
+
+short RenderSelect::baselinePosition(bool f, bool isRootLineBox) const
+{
+ if (m_useListBox) {
+ // FIXME: Should get the hardcoded constant of 7 by calling a QListBox function,
+ // as we do for other widget classes.
+ return RenderWidget::baselinePosition(f, isRootLineBox) - 7;
+ }
+ return RenderFormElement::baselinePosition(f, isRootLineBox);
+}
+
+void RenderSelect::calcMinMaxWidth()
+{
+ ASSERT(!minMaxKnown());
+
+ if (m_optionsChanged)
+ updateFromElement();
+
+ // ### ugly HACK FIXME!!!
+ setMinMaxKnown();
+ layoutIfNeeded();
+ setNeedsLayoutAndMinMaxRecalc();
+ // ### end FIXME
+
+ RenderFormElement::calcMinMaxWidth();
+}
+
+void RenderSelect::layout()
+{
+ ASSERT(needsLayout());
+ ASSERT(minMaxKnown());
+
+ // ### maintain selection properly between type/size changes, and work
+ // out how to handle multiselect->singleselect (probably just select
+ // first selected one)
+
+ // calculate size
+ if (m_useListBox) {
+ QListBox* w = static_cast<QListBox*>(m_widget);
+
+
+ int size = m_size;
+ // check if multiple and size was not given or invalid
+ // Internet Exploder sets size to min(number of elements, 4)
+ // Netscape seems to simply set it to "number of elements"
+ // the average of that is IMHO min(number of elements, 10)
+ // so I did that ;-)
+ if (size < 1)
+ size = min(static_cast<QListBox*>(m_widget)->count(), 10U);
+
+ // Let the widget tell us how big it wants to be.
+ IntSize s(w->sizeForNumberOfLines(size));
+ setIntrinsicWidth(s.width());
+ setIntrinsicHeight(s.height());
+ } else {
+ IntSize s(m_widget->sizeHint());
+ setIntrinsicWidth(s.width());
+ setIntrinsicHeight(s.height());
+ }
+
+ RenderFormElement::layout();
+
+ // and now disable the widget in case there is no <option> given
+ DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
+
+ bool foundOption = false;
+ for (unsigned i = 0; i < listItems.size() && !foundOption; i++)
+ foundOption = (listItems[i]->hasTagName(optionTag));
+
+ m_widget->setEnabled(foundOption && ! static_cast<HTMLSelectElement*>(node())->disabled());
+}
+
+void RenderSelect::valueChanged(Widget*)
+{
+ if (m_ignoreSelectEvents)
+ return;
+
+ ASSERT(!m_useListBox);
+
+ int index = static_cast<QComboBox*>(m_widget)->currentItem();
+
+ DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
+ if (index >= 0 && index < (int)listItems.size()) {
+ bool found = listItems[index]->hasTagName(optionTag);
+ if (!found) {
+ // this one is not selectable, we need to find an option element
+ while ((unsigned) index < listItems.size()) {
+ if (listItems[index]->hasTagName(optionTag)) {
+ found = true;
+ break;
+ }
+ ++index;
+ }
+
+ if (!found) {
+ while (index >= 0) {
+ if (listItems[index]->hasTagName(optionTag)) {
+ found = true;
+ break;
+ }
+ --index;
+ }
+ }
+ }
+
+ if (found) {
+ if (index != static_cast<QComboBox*>(m_widget)->currentItem())
+ static_cast<QComboBox*>(m_widget)->setCurrentItem(index);
+
+ for (unsigned i = 0; i < listItems.size(); ++i)
+ if (listItems[i]->hasTagName(optionTag) && i != (unsigned int) index)
+ static_cast<HTMLOptionElement*>(listItems[i])->m_selected = false;
+
+ static_cast<HTMLOptionElement*>(listItems[index])->m_selected = true;
+ }
+ }
+
+ static_cast<HTMLSelectElement*>(node())->onChange();
+}
+
+void RenderSelect::selectionChanged(Widget*)
+{
+ if (m_ignoreSelectEvents)
+ return;
+
+ // don't use listItems() here as we have to avoid recalculations - changing the
+ // option list will make use update options not in the way the user expects them
+ DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->m_listItems;
+ int j = 0;
+ for (unsigned i = 0; i < listItems.count(); i++) {
+ // don't use setSelected() here because it will cause us to be called
+ // again with updateSelection.
+ if (listItems[i]->hasTagName(optionTag))
+ static_cast<HTMLOptionElement*>(listItems[i])
+ ->m_selected = static_cast<QListBox*>(m_widget)->isSelected(j);
+ if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
+ ++j;
+ }
+ static_cast<HTMLSelectElement*>(node())->onChange();
+}
+
+void RenderSelect::setOptionsChanged(bool _optionsChanged)
+{
+ m_optionsChanged = _optionsChanged;
+}
+
+QListBox* RenderSelect::createListBox()
+{
+ QListBox *lb = new QListBox();
+ lb->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
+ m_ignoreSelectEvents = false;
+ return lb;
+}
+
+void RenderSelect::updateSelection()
+{
+ DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
+ int i;
+ if (m_useListBox) {
+ // if multi-select, we select only the new selected index
+ QListBox *listBox = static_cast<QListBox*>(m_widget);
+ int j = 0;
+ for (i = 0; i < int(listItems.size()); i++) {
+ listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
+ static_cast<HTMLOptionElement*>(listItems[i])->selected());
+ if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
+ ++j;
+
+ }
+ } else {
+ bool found = false;
+ unsigned firstOption = listItems.size();
+ i = listItems.size();
+ while (i--)
+ if (listItems[i]->hasTagName(optionTag)) {
+ if (found)
+ static_cast<HTMLOptionElement*>(listItems[i])->m_selected = false;
+ else if (static_cast<HTMLOptionElement*>(listItems[i])->selected()) {
+ static_cast<QComboBox*>(m_widget)->setCurrentItem(i);
+ found = true;
+ }
+ firstOption = i;
+ }
+
+ ASSERT(firstOption == listItems.size() || found);
+ }
+
+ m_selectionChanged = false;
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderSelect_h
+#define RenderSelect_h
+
+#include "RenderFormElement.h"
+
+class QListBox;
+
+namespace WebCore {
+
+ class HTMLSelectElement;
+
+ class RenderSelect : public RenderFormElement {
+ public:
+ RenderSelect(HTMLSelectElement*);
+
+ virtual const char* renderName() const { return "RenderSelect"; }
+
+ short baselinePosition(bool f, bool b) const;
+ int calcReplacedHeight() const { if (!m_useListBox) return intrinsicHeight(); return RenderFormElement::calcReplacedHeight(); }
+ virtual bool canHaveIntrinsicMargins() const { return true; }
+
+ virtual void calcMinMaxWidth();
+ virtual void layout();
+
+ void setOptionsChanged(bool);
+
+ bool selectionChanged() { return m_selectionChanged; }
+ void setSelectionChanged(bool selectionChanged) { m_selectionChanged = selectionChanged; }
+ virtual void updateFromElement();
+ virtual void setStyle(RenderStyle*);
+
+ void updateSelection();
+
+ private:
+ virtual void valueChanged(Widget*);
+ virtual void selectionChanged(Widget*);
+
+ protected:
+ QListBox* createListBox();
+ void setWidgetWritingDirection();
+
+ unsigned m_size;
+ bool m_multiple;
+ bool m_useListBox;
+ bool m_selectionChanged;
+ bool m_ignoreSelectEvents;
+ bool m_optionsChanged;
+ };
+
+} // namespace WebCore
+
+#endif // RenderSelect_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderSlider.h"
+
+#include "EventNames.h"
+#include "HTMLNames.h"
+#include "HTMLInputElement.h"
+#include "KWQSlider.h"
+
+using std::min;
+
+namespace WebCore {
+
+using namespace EventNames;
+using namespace HTMLNames;
+
+RenderSlider::RenderSlider(HTMLInputElement* element)
+ : RenderFormElement(element)
+{
+ setWidget(new QSlider);
+}
+
+void RenderSlider::calcMinMaxWidth()
+{
+ ASSERT(!minMaxKnown());
+
+ // Let the widget tell us how big it wants to be.
+ IntSize s(widget()->sizeHint());
+ bool widthSet = !style()->width().isAuto();
+ bool heightSet = !style()->height().isAuto();
+ if (heightSet && !widthSet) {
+ // Flip the intrinsic dimensions.
+ int barLength = s.width();
+ s = IntSize(s.height(), barLength);
+ }
+ setIntrinsicWidth(s.width());
+ setIntrinsicHeight(s.height());
+
+ RenderFormElement::calcMinMaxWidth();
+}
+
+void RenderSlider::updateFromElement()
+{
+ String value = static_cast<HTMLInputElement*>(node())->value();
+ const AtomicString& minStr = static_cast<HTMLInputElement*>(node())->getAttribute(minAttr);
+ const AtomicString& maxStr = static_cast<HTMLInputElement*>(node())->getAttribute(maxAttr);
+ const AtomicString& precision = static_cast<HTMLInputElement*>(node())->getAttribute(precisionAttr);
+
+ double minVal = minStr.isNull() ? 0.0 : minStr.deprecatedString().toDouble();
+ double maxVal = maxStr.isNull() ? 100.0 : maxStr.deprecatedString().toDouble();
+ minVal = min(minVal, maxVal); // Make sure the range is sane.
+
+ double val = value.isNull() ? (maxVal + minVal)/2.0 : value.deprecatedString().toDouble();
+ val = max(minVal, min(val, maxVal)); // Make sure val is within min/max.
+
+ // Force integer value if not float.
+ if (!equalIgnoringCase(precision, "float"))
+ val = (int)(val + 0.5);
+
+ static_cast<HTMLInputElement*>(node())->setValue(String::number(val));
+
+ QSlider* slider = static_cast<QSlider*>(widget());
+
+ slider->setMinValue(minVal);
+ slider->setMaxValue(maxVal);
+ slider->setValue(val);
+
+ RenderFormElement::updateFromElement();
+}
+
+void RenderSlider::valueChanged(Widget*)
+{
+ QSlider* slider = static_cast<QSlider*>(widget());
+
+ double val = slider->value();
+ const AtomicString& precision = static_cast<HTMLInputElement*>(node())->getAttribute(precisionAttr);
+
+ // Force integer value if not float.
+ if (!equalIgnoringCase(precision, "float"))
+ val = (int)(val + 0.5);
+
+ static_cast<HTMLInputElement*>(node())->setValue(String::number(val));
+
+ // Fire the "input" DOM event.
+ static_cast<HTMLInputElement*>(node())->dispatchHTMLEvent(inputEvent, true, false);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderSlider_h
+#define RenderSlider_h
+
+#include "RenderFormElement.h"
+
+namespace WebCore {
+
+ class HTMLInputElement;
+
+ class RenderSlider : public RenderFormElement {
+ public:
+ RenderSlider(HTMLInputElement*);
+
+ virtual const char* renderName() const { return "RenderSlider"; }
+
+ virtual bool canHaveIntrinsicMargins() const { return true; }
+ virtual void calcMinMaxWidth();
+ virtual void updateFromElement();
+
+ private:
+ virtual void valueChanged(Widget*);
+ };
+
+
+} // namespace WebCore
+
+#endif // RenderSlider_h
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderTextArea.h"
+
+#include "KWQTextEdit.h"
+#include "HTMLTextAreaElement.h"
+#include "FrameView.h"
+
+namespace WebCore {
+
+RenderTextArea::RenderTextArea(HTMLTextAreaElement* element)
+ : RenderFormElement(element)
+ , m_dirty(false)
+ , m_updating(false)
+{
+ QTextEdit* edit = new QTextEdit(view());
+
+ if (element->wrap() != HTMLTextAreaElement::ta_NoWrap)
+ edit->setWordWrap(QTextEdit::WidgetWidth);
+ else
+ edit->setWordWrap(QTextEdit::NoWrap);
+
+ setWidget(edit);
+}
+
+void RenderTextArea::destroy()
+{
+ static_cast<HTMLTextAreaElement*>(node())->rendererWillBeDestroyed();
+ RenderFormElement::destroy();
+}
+
+void RenderTextArea::calcMinMaxWidth()
+{
+ ASSERT(!minMaxKnown());
+
+ QTextEdit* w = static_cast<QTextEdit*>(m_widget);
+ IntSize size(w->sizeWithColumnsAndRows(
+ max(static_cast<HTMLTextAreaElement*>(node())->cols(), 1),
+ max(static_cast<HTMLTextAreaElement*>(node())->rows(), 1)));
+
+ setIntrinsicWidth(size.width());
+ setIntrinsicHeight(size.height());
+
+ RenderFormElement::calcMinMaxWidth();
+}
+
+void RenderTextArea::setStyle(RenderStyle* s)
+{
+ RenderFormElement::setStyle(s);
+
+ QTextEdit* w = static_cast<QTextEdit*>(m_widget);
+ w->setAlignment(textAlignment());
+ w->setLineHeight(RenderObject::lineHeight(true));
+
+ w->setWritingDirection(style()->direction() == RTL ? RTL : LTR);
+
+ ScrollBarMode scrollMode = ScrollBarAuto;
+ switch (style()->overflow()) {
+ case OAUTO:
+ case OMARQUEE: // makes no sense, map to auto
+ case OOVERLAY: // not implemented for text, map to auto
+ case OVISIBLE:
+ break;
+ case OHIDDEN:
+ scrollMode = ScrollBarAlwaysOff;
+ break;
+ case OSCROLL:
+ scrollMode = ScrollBarAlwaysOn;
+ break;
+ }
+ ScrollBarMode horizontalScrollMode = scrollMode;
+ if (static_cast<HTMLTextAreaElement*>(node())->wrap() != HTMLTextAreaElement::ta_NoWrap)
+ horizontalScrollMode = ScrollBarAlwaysOff;
+
+ w->setScrollBarModes(horizontalScrollMode, scrollMode);
+}
+
+void RenderTextArea::setEdited(bool x)
+{
+ m_dirty = x;
+}
+
+void RenderTextArea::updateFromElement()
+{
+ HTMLTextAreaElement* e = static_cast<HTMLTextAreaElement*>(node());
+ QTextEdit* w = static_cast<QTextEdit*>(m_widget);
+
+ w->setReadOnly(e->isReadOnlyControl());
+ w->setDisabled(e->disabled());
+
+ String widgetText = text();
+ String text = e->value();
+ text.replace('\\', backslashAsCurrencySymbol());
+ if (widgetText != text) {
+ int line, col;
+ w->getCursorPosition(&line, &col);
+ m_updating = true;
+ w->setText(text);
+ m_updating = false;
+ w->setCursorPosition(line, col);
+ }
+ m_dirty = false;
+
+ w->setColors(style()->backgroundColor(), style()->color());
+
+ RenderFormElement::updateFromElement();
+}
+
+String RenderTextArea::text()
+{
+ String txt = static_cast<QTextEdit*>(m_widget)->text();
+ return txt.replace(backslashAsCurrencySymbol(), '\\');
+}
+
+String RenderTextArea::textWithHardLineBreaks()
+{
+ String txt = static_cast<QTextEdit*>(m_widget)->textWithHardLineBreaks();
+ return txt.replace(backslashAsCurrencySymbol(), '\\');
+}
+
+void RenderTextArea::valueChanged(Widget*)
+{
+ if (m_updating)
+ return;
+ static_cast<HTMLTextAreaElement*>(node())->invalidateValue();
+ m_dirty = true;
+}
+
+int RenderTextArea::selectionStart()
+{
+ return static_cast<QTextEdit*>(m_widget)->selectionStart();
+}
+
+int RenderTextArea::selectionEnd()
+{
+ return static_cast<QTextEdit*>(m_widget)->selectionEnd();
+}
+
+void RenderTextArea::setSelectionStart(int start)
+{
+ static_cast<QTextEdit*>(m_widget)->setSelectionStart(start);
+}
+
+void RenderTextArea::setSelectionEnd(int end)
+{
+ static_cast<QTextEdit*>(m_widget)->setSelectionEnd(end);
+}
+
+void RenderTextArea::select()
+{
+ static_cast<QTextEdit*>(m_widget)->selectAll();
+}
+
+void RenderTextArea::setSelectionRange(int start, int end)
+{
+ QTextEdit* textEdit = static_cast<QTextEdit*>(m_widget);
+ textEdit->setSelectionRange(start, end-start);
+}
+
+void RenderTextArea::selectionChanged(Widget*)
+{
+ QTextEdit* w = static_cast<QTextEdit*>(m_widget);
+
+ // We only want to call onselect if there actually is a selection
+ if (!w->hasSelectedText())
+ return;
+
+ static_cast<HTMLTextAreaElement*>(node())->onSelect();
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * 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, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderTextArea_h
+#define RenderTextArea_h
+
+#include "RenderFormElement.h"
+
+namespace WebCore {
+
+ class HTMLTextAreaElement;
+
+ class RenderTextArea : public RenderFormElement {
+ public:
+ RenderTextArea(HTMLTextAreaElement*);
+
+ virtual const char* renderName() const { return "RenderTextArea"; }
+
+ virtual void destroy();
+
+ virtual void calcMinMaxWidth();
+ virtual void updateFromElement();
+ virtual void setStyle(RenderStyle*);
+
+ bool isTextArea() const { return true; }
+ bool isEdited() const { return m_dirty; }
+ void setEdited(bool);
+
+ String text();
+ String textWithHardLineBreaks();
+
+ int selectionStart();
+ int selectionEnd();
+ void setSelectionStart(int);
+ void setSelectionEnd(int);
+
+ void select();
+ void setSelectionRange(int, int);
+
+ virtual bool canHaveIntrinsicMargins() const { return true; }
+
+ private:
+ virtual void valueChanged(Widget*);
+ virtual void selectionChanged(Widget*);
+
+ protected:
+ virtual bool isEditable() const { return true; }
+
+ bool m_dirty;
+ bool m_updating;
+ };
+
+
+} // namespace WebCore
+
+#endif // RenderTextArea_h
+++ /dev/null
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * 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 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-#include "render_form.h"
-
-#include "BrowserExtension.h"
-#include "EventNames.h"
-#include "FrameView.h"
-#include "HTMLFormElement.h"
-#include "HTMLInputElement.h"
-#include "HTMLOptGroupElement.h"
-#include "HTMLOptionElement.h"
-#include "HTMLSelectElement.h"
-#include "HTMLTextAreaElement.h"
-#include "KWQComboBox.h"
-#include "KWQFileButton.h"
-#include "KWQLineEdit.h"
-#include "KWQSlider.h"
-#include "KWQTextEdit.h"
-#include "PlatformMouseEvent.h"
-#include "dom2_eventsimpl.h"
-
-using namespace std;
-
-namespace WebCore {
-
-using namespace EventNames;
-using namespace HTMLNames;
-
-RenderFormElement::RenderFormElement(HTMLGenericFormElement *element)
- : RenderWidget(element)
-{
- setInline(true);
-}
-
-RenderFormElement::~RenderFormElement()
-{
-}
-
-short RenderFormElement::baselinePosition( bool f, bool isRootLineBox ) const
-{
- return marginTop() + widget()->baselinePosition(m_height);
-}
-
-void RenderFormElement::setStyle(RenderStyle* s)
-{
- if (canHaveIntrinsicMargins())
- addIntrinsicMarginsIfAllowed(s);
-
- RenderWidget::setStyle(s);
-
- // Do not paint a background or border for Aqua form elements
- setShouldPaintBackgroundOrBorder(false);
-
- m_widget->setFont(style()->font());
-}
-
-void RenderFormElement::updateFromElement()
-{
- m_widget->setEnabled(!static_cast<HTMLGenericFormElement*>(node())->disabled());
-}
-
-void RenderFormElement::layout()
-{
- KHTMLAssert( needsLayout() );
- KHTMLAssert( minMaxKnown() );
-
- // minimum height
- m_height = 0;
-
- calcWidth();
- calcHeight();
-
- setNeedsLayout(false);
-}
-
-void RenderFormElement::clicked(Widget*)
-{
- RenderArena* arena = ref();
- PlatformMouseEvent event; // gets "current event"
- if (node())
- static_cast<EventTargetNode*>(node())->dispatchMouseEvent(event, clickEvent, event.clickCount());
- deref(arena);
-}
-
-HorizontalAlignment RenderFormElement::textAlignment() const
-{
- switch (style()->textAlign()) {
- case LEFT:
- case KHTML_LEFT:
- return AlignLeft;
- case RIGHT:
- case KHTML_RIGHT:
- return AlignRight;
- case CENTER:
- case KHTML_CENTER:
- return AlignHCenter;
- case JUSTIFY:
- // Just fall into the auto code for justify.
- case TAAUTO:
- return style()->direction() == RTL ? AlignRight : AlignLeft;
- }
- ASSERT(false); // Should never be reached.
- return AlignLeft;
-}
-
-
-void RenderFormElement::addIntrinsicMarginsIfAllowed(RenderStyle* _style)
-{
- // Cut out the intrinsic margins completely if we end up using mini controls.
- if (_style->fontSize() < 11)
- return;
-
- // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
- int m = intrinsicMargin();
- if (_style->width().isIntrinsicOrAuto()) {
- if (_style->marginLeft().quirk())
- _style->setMarginLeft(Length(m, Fixed));
- if (_style->marginRight().quirk())
- _style->setMarginRight(Length(m, Fixed));
- }
-
- if (_style->height().isAuto()) {
- if (_style->marginTop().quirk())
- _style->setMarginTop(Length(m, Fixed));
- if (_style->marginBottom().quirk())
- _style->setMarginBottom(Length(m, Fixed));
- }
-}
-
-// -------------------------------------------------------------------------------
-
-RenderImageButton::RenderImageButton(HTMLInputElement *element)
- : RenderImage(element)
-{
- // ### support DOMActivate event when clicked
-}
-
-// -------------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------
-
-RenderLineEdit::RenderLineEdit(HTMLInputElement *element)
- : RenderFormElement(element), m_updating(false)
-{
- QLineEdit::Type type;
- switch (element->inputType()) {
- case HTMLInputElement::PASSWORD:
- type = QLineEdit::Password;
- break;
- case HTMLInputElement::SEARCH:
- type = QLineEdit::Search;
- break;
- default:
- type = QLineEdit::Normal;
- }
- QLineEdit* edit = new QLineEdit(type);
- if (type == QLineEdit::Search)
- edit->setLiveSearch(false);
- setWidget(edit);
-}
-
-void RenderLineEdit::selectionChanged(Widget*)
-{
- // We only want to call onselect if there actually is a selection
- QLineEdit* w = static_cast<QLineEdit*>(m_widget);
- if (w->hasSelectedText())
- static_cast<HTMLGenericFormElement*>(node())->onSelect();
-}
-
-void RenderLineEdit::returnPressed(Widget*)
-{
- // Emit onChange if necessary
- // Works but might not be enough, dirk said he had another solution at
- // hand (can't remember which) - David
- if (isTextField() && isEdited()) {
- static_cast<HTMLGenericFormElement*>(node())->onChange();
- setEdited(false);
- }
-
- if (HTMLFormElement* fe = static_cast<HTMLGenericFormElement*>(node())->form())
- fe->submitClick();
-}
-
-void RenderLineEdit::performSearch(Widget*)
-{
- // Fire the "search" DOM event.
- static_cast<EventTargetNode*>(node())->dispatchHTMLEvent(searchEvent, true, false);
-}
-
-void RenderLineEdit::addSearchResult()
-{
- if (widget())
- static_cast<QLineEdit*>(widget())->addSearchResult();
-}
-
-void RenderLineEdit::calcMinMaxWidth()
-{
- KHTMLAssert(!minMaxKnown());
-
- // Let the widget tell us how big it wants to be.
- m_updating = true;
- int size = static_cast<HTMLInputElement*>(node())->size();
- IntSize s(static_cast<QLineEdit*>(widget())->sizeForCharacterWidth(size > 0 ? size : 20));
- m_updating = false;
-
- setIntrinsicWidth(s.width());
- setIntrinsicHeight(s.height());
-
- RenderFormElement::calcMinMaxWidth();
-}
-
-void RenderLineEdit::setStyle(RenderStyle *s)
-{
- RenderFormElement::setStyle(s);
-
- QLineEdit* w = static_cast<QLineEdit*>(widget());
- w->setAlignment(textAlignment());
- w->setWritingDirection(style()->direction() == RTL ? RTL : LTR);
-}
-
-void RenderLineEdit::updateFromElement()
-{
- HTMLInputElement* e = static_cast<HTMLInputElement*>(node());
- QLineEdit* w = static_cast<QLineEdit*>(widget());
-
- int ml = e->maxLength();
- if (ml <= 0 || ml > 1024)
- ml = 1024;
- if (w->maxLength() != ml)
- w->setMaxLength(ml);
-
- if (!e->valueMatchesRenderer()) {
- String widgetText = w->text();
- String newText = e->value();
- newText.replace('\\', backslashAsCurrencySymbol());
- if (widgetText != newText) {
- int pos = w->cursorPosition();
-
- m_updating = true;
- w->setText(newText);
- m_updating = false;
-
- w->setEdited( false );
-
- w->setCursorPosition(pos);
- }
- e->setValueMatchesRenderer();
- }
-
- w->setReadOnly(e->isReadOnlyControl());
-
- // Handle updating the search attributes.
- w->setPlaceholderString(e->getAttribute(placeholderAttr).deprecatedString());
- if (w->type() == QLineEdit::Search) {
- w->setLiveSearch(!e->getAttribute(incrementalAttr).isNull());
- w->setAutoSaveName(e->getAttribute(autosaveAttr));
- w->setMaxResults(e->maxResults());
- }
-
- w->setColors(style()->backgroundColor(), style()->color());
-
- RenderFormElement::updateFromElement();
-}
-
-void RenderLineEdit::valueChanged(Widget*)
-{
- if (m_updating) // Don't alter the value if we are in the middle of initing the control, since
- return; // we are getting the value from the DOM and it's not user input.
-
- String newText = static_cast<QLineEdit*>(widget())->text();
-
- // A null string value is used to indicate that the form control has not altered the original
- // default value. That means that we should never use the null string value when the user
- // empties a textfield, but should always force an empty textfield to use the empty string.
- if (newText.isNull())
- newText = "";
-
- newText.replace(backslashAsCurrencySymbol(), '\\');
- static_cast<HTMLInputElement*>(node())->setValueFromRenderer(newText);
-}
-
-int RenderLineEdit::selectionStart()
-{
- QLineEdit *lineEdit = static_cast<QLineEdit *>(m_widget);
- int start = lineEdit->selectionStart();
- if (start == -1)
- start = lineEdit->cursorPosition();
- return start;
-}
-
-int RenderLineEdit::selectionEnd()
-{
- QLineEdit *lineEdit = static_cast<QLineEdit *>(m_widget);
- int start = lineEdit->selectionStart();
- if (start == -1)
- return lineEdit->cursorPosition();
- return start + (int)lineEdit->selectedText().length();
-}
-
-void RenderLineEdit::setSelectionStart(int start)
-{
- int realStart = max(start, 0);
- int length = max(selectionEnd() - realStart, 0);
- static_cast<QLineEdit *>(m_widget)->setSelection(realStart, length);
-}
-
-void RenderLineEdit::setSelectionEnd(int end)
-{
- int start = selectionStart();
- int realEnd = max(end, 0);
- int length = realEnd - start;
- if (length < 0) {
- start = realEnd;
- length = 0;
- }
- static_cast<QLineEdit *>(m_widget)->setSelection(start, length);
-}
-
-void RenderLineEdit::select()
-{
- static_cast<QLineEdit*>(m_widget)->selectAll();
-}
-
-bool RenderLineEdit::isEdited() const
-{
- return static_cast<QLineEdit*>(m_widget)->edited();
-}
-void RenderLineEdit::setEdited(bool x)
-{
- static_cast<QLineEdit*>(m_widget)->setEdited(x);
-}
-
-void RenderLineEdit::setSelectionRange(int start, int end)
-{
- int realStart = max(start, 0);
- int length = max(end - realStart, 0);
- static_cast<QLineEdit *>(m_widget)->setSelection(realStart, length);
-}
-
-// ---------------------------------------------------------------------------
-
-RenderFieldset::RenderFieldset(HTMLGenericFormElement *element)
-: RenderBlock(element)
-{
-}
-
-RenderObject* RenderFieldset::layoutLegend(bool relayoutChildren)
-{
- RenderObject* legend = findLegend();
- if (legend) {
- if (relayoutChildren)
- legend->setNeedsLayout(true);
- legend->layoutIfNeeded();
-
- int xPos = borderLeft() + paddingLeft() + legend->marginLeft();
- if (style()->direction() == RTL)
- xPos = m_width - paddingRight() - borderRight() - legend->width() - legend->marginRight();
- int b = borderTop();
- int h = legend->height();
- legend->setPos(xPos, max((b-h)/2, 0));
- m_height = max(b,h) + paddingTop();
- }
- return legend;
-}
-
-RenderObject* RenderFieldset::findLegend()
-{
- for (RenderObject* legend = firstChild(); legend; legend = legend->nextSibling()) {
- if (!legend->isFloatingOrPositioned() && legend->element() &&
- legend->element()->hasTagName(legendTag))
- return legend;
- }
- return 0;
-}
-
-void RenderFieldset::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
-{
- int w = width();
- int h = height() + borderTopExtra() + borderBottomExtra();
- RenderObject* legend = findLegend();
- if (!legend)
- return RenderBlock::paintBoxDecorations(i, _tx, _ty);
-
- int yOff = (legend->yPos() > 0) ? 0 : (legend->height()-borderTop())/2;
- h -= yOff;
- _ty += yOff - borderTopExtra();
-
- int my = max(_ty, i.r.y());
- int end = min(i.r.bottom(), _ty + h);
- int mh = end - my;
-
- paintBackground(i.p, style()->backgroundColor(), style()->backgroundLayers(), my, mh, _tx, _ty, w, h);
-
- if (style()->hasBorder())
- paintBorderMinusLegend(i.p, _tx, _ty, w, h, style(), legend->xPos(), legend->width());
-}
-
-void RenderFieldset::paintBorderMinusLegend(GraphicsContext* p, int _tx, int _ty, int w, int h,
- const RenderStyle* style, int lx, int lw)
-{
-
- const Color& tc = style->borderTopColor();
- const Color& bc = style->borderBottomColor();
-
- EBorderStyle ts = style->borderTopStyle();
- EBorderStyle bs = style->borderBottomStyle();
- EBorderStyle ls = style->borderLeftStyle();
- EBorderStyle rs = style->borderRightStyle();
-
- bool render_t = ts > BHIDDEN;
- bool render_l = ls > BHIDDEN;
- bool render_r = rs > BHIDDEN;
- bool render_b = bs > BHIDDEN;
-
- if(render_t) {
- drawBorder(p, _tx, _ty, _tx + lx, _ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
- (render_l && (ls == DOTTED || ls == DASHED || ls == DOUBLE)?style->borderLeftWidth():0), 0);
- drawBorder(p, _tx+lx+lw, _ty, _tx + w, _ty + style->borderTopWidth(), BSTop, tc, style->color(), ts,
- 0, (render_r && (rs == DOTTED || rs == DASHED || rs == DOUBLE)?style->borderRightWidth():0));
- }
-
- if(render_b)
- drawBorder(p, _tx, _ty + h - style->borderBottomWidth(), _tx + w, _ty + h, BSBottom, bc, style->color(), bs,
- (render_l && (ls == DOTTED || ls == DASHED || ls == DOUBLE)?style->borderLeftWidth():0),
- (render_r && (rs == DOTTED || rs == DASHED || rs == DOUBLE)?style->borderRightWidth():0));
-
- if(render_l)
- {
- const Color& lc = style->borderLeftColor();
-
- bool ignore_top =
- (tc == lc) &&
- (ls >= OUTSET) &&
- (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
-
- bool ignore_bottom =
- (bc == lc) &&
- (ls >= OUTSET) &&
- (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
-
- drawBorder(p, _tx, _ty, _tx + style->borderLeftWidth(), _ty + h, BSLeft, lc, style->color(), ls,
- ignore_top?0:style->borderTopWidth(),
- ignore_bottom?0:style->borderBottomWidth());
- }
-
- if(render_r)
- {
- const Color& rc = style->borderRightColor();
-
- bool ignore_top =
- (tc == rc) &&
- (rs >= DOTTED || rs == INSET) &&
- (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
-
- bool ignore_bottom =
- (bc == rc) &&
- (rs >= DOTTED || rs == INSET) &&
- (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
-
- drawBorder(p, _tx + w - style->borderRightWidth(), _ty, _tx + w, _ty + h, BSRight, rc, style->color(), rs,
- ignore_top?0:style->borderTopWidth(),
- ignore_bottom?0:style->borderBottomWidth());
- }
-}
-
-void RenderFieldset::setStyle(RenderStyle* _style)
-{
- RenderBlock::setStyle(_style);
-
- // WinIE renders fieldsets with display:inline like they're inline-blocks. For us,
- // an inline-block is just a block element with replaced set to true and inline set
- // to true. Ensure that if we ended up being inline that we set our replaced flag
- // so that we're treated like an inline-block.
- if (isInline())
- setReplaced(true);
-}
-
-// -------------------------------------------------------------------------
-
-RenderFileButton::RenderFileButton(HTMLInputElement *element)
- : RenderFormElement(element)
-{
- setWidget(new KWQFileButton(view()->frame()));
-}
-
-void RenderFileButton::calcMinMaxWidth()
-{
- KHTMLAssert(!minMaxKnown());
-
- // Let the widget tell us how big it wants to be.
- int size = static_cast<HTMLInputElement*>(node())->size();
- IntSize s(static_cast<KWQFileButton *>(widget())->sizeForCharacterWidth(size > 0 ? size : 20));
-
- setIntrinsicWidth(s.width());
- setIntrinsicHeight(s.height());
-
- RenderFormElement::calcMinMaxWidth();
-}
-
-void RenderFileButton::updateFromElement()
-{
- static_cast<KWQFileButton*>(widget())->setFilename(
- static_cast<HTMLInputElement*>(node())->value().deprecatedString());
-
- static_cast<KWQFileButton*>(widget())->setDisabled(
- static_cast<HTMLInputElement*>(node())->disabled());
-
- RenderFormElement::updateFromElement();
-}
-
-void RenderFileButton::returnPressed(Widget*)
-{
- if (static_cast<HTMLInputElement*>(node())->form())
- static_cast<HTMLInputElement*>(node())->form()->prepareSubmit();
-}
-
-void RenderFileButton::valueChanged(Widget*)
-{
- static_cast<HTMLInputElement*>(node())->setValueFromRenderer(static_cast<KWQFileButton*>(widget())->filename());
- static_cast<HTMLInputElement*>(node())->onChange();
-}
-
-void RenderFileButton::select()
-{
-}
-
-
-void RenderFileButton::click(bool sendMouseEvents)
-{
- static_cast<KWQFileButton *>(widget())->click(sendMouseEvents);
-}
-
-
-// -------------------------------------------------------------------------
-
-RenderLabel::RenderLabel(HTMLGenericFormElement *element)
- : RenderFormElement(element)
-{
-
-}
-
-// -------------------------------------------------------------------------
-
-RenderLegend::RenderLegend(HTMLGenericFormElement *element)
- : RenderBlock(element)
-{
-}
-
-// -------------------------------------------------------------------------
-
-RenderSelect::RenderSelect(HTMLSelectElement *element)
- : RenderFormElement(element)
-{
- m_ignoreSelectEvents = false;
- m_multiple = element->multiple();
- m_size = element->size();
- m_useListBox = (m_multiple || m_size > 1);
- m_selectionChanged = true;
- m_optionsChanged = true;
-
- if (m_useListBox)
- setWidget(createListBox());
- else
- setWidget(new QComboBox);
-}
-
-
-void RenderSelect::setWidgetWritingDirection()
-{
- TextDirection d = style()->direction() == RTL ? RTL : LTR;
- if (m_useListBox)
- static_cast<QListBox *>(m_widget)->setWritingDirection(d);
- else
- static_cast<QComboBox *>(m_widget)->setWritingDirection(d);
-}
-
-void RenderSelect::setStyle(RenderStyle *s)
-{
- RenderFormElement::setStyle(s);
- setWidgetWritingDirection();
-}
-
-
-void RenderSelect::updateFromElement()
-{
- m_ignoreSelectEvents = true;
-
- // change widget type
- bool oldMultiple = m_multiple;
- unsigned oldSize = m_size;
- bool oldListbox = m_useListBox;
-
- m_multiple = static_cast<HTMLSelectElement*>(node())->multiple();
- m_size = static_cast<HTMLSelectElement*>(node())->size();
- m_useListBox = (m_multiple || m_size > 1);
-
- if (oldMultiple != m_multiple || oldSize != m_size) {
- if (m_useListBox != oldListbox) {
- // type of select has changed
- delete m_widget;
-
- if (m_useListBox)
- setWidget(createListBox());
- else
- setWidget(new QComboBox);
- setWidgetWritingDirection();
- }
-
- if (m_useListBox && oldMultiple != m_multiple) {
- static_cast<QListBox*>(m_widget)->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
- }
- m_selectionChanged = true;
- m_optionsChanged = true;
- }
-
- // update contents listbox/combobox based on options in m_element
- if ( m_optionsChanged ) {
- if (static_cast<HTMLSelectElement*>(node())->m_recalcListItems)
- static_cast<HTMLSelectElement*>(node())->recalcListItems();
- DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
- int listIndex;
-
- if (m_useListBox)
- static_cast<QListBox*>(m_widget)->clear();
- else
- static_cast<QComboBox*>(m_widget)->clear();
-
- bool groupEnabled = true;
- for (listIndex = 0; listIndex < int(listItems.size()); listIndex++) {
- if (listItems[listIndex]->hasTagName(optgroupTag)) {
- HTMLOptGroupElement *optgroupElement = static_cast<HTMLOptGroupElement*>(listItems[listIndex]);
- DeprecatedString label = optgroupElement->getAttribute(labelAttr).deprecatedString();
- label.replace('\\', backslashAsCurrencySymbol());
-
- // In WinIE, an optgroup can't start or end with whitespace (other than the indent
- // we give it). We match this behavior.
- label = label.stripWhiteSpace();
- // We want to collapse our whitespace too. This will match other browsers.
- label = label.simplifyWhiteSpace();
-
- groupEnabled = optgroupElement->isEnabled();
-
- if (m_useListBox)
- static_cast<QListBox*>(m_widget)->appendGroupLabel(label, groupEnabled);
- else
- static_cast<QComboBox*>(m_widget)->appendGroupLabel(label);
- }
- else if (listItems[listIndex]->hasTagName(optionTag)) {
- HTMLOptionElement *optionElement = static_cast<HTMLOptionElement*>(listItems[listIndex]);
- DeprecatedString itemText;
- if (optionElement->hasAttribute(labelAttr))
- itemText = optionElement->getAttribute(labelAttr).deprecatedString();
- else
- itemText = optionElement->text().deprecatedString();
-
- itemText.replace('\\', backslashAsCurrencySymbol());
-
- // In WinIE, leading and trailing whitespace is ignored in options. We match this behavior.
- itemText = itemText.stripWhiteSpace();
- // We want to collapse our whitespace too. This will match other browsers.
- itemText = itemText.simplifyWhiteSpace();
-
- if (listItems[listIndex]->parentNode()->hasTagName(optgroupTag))
- itemText.prepend(" ");
-
- if (m_useListBox)
- static_cast<QListBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
- else
- static_cast<QComboBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
- }
- else if (listItems[listIndex]->hasTagName(hrTag)) {
- if (!m_useListBox)
- static_cast<QComboBox*>(m_widget)->appendSeparator();
- }
- else
- KHTMLAssert(false);
- m_selectionChanged = true;
- }
- if (m_useListBox)
- static_cast<QListBox*>(m_widget)->doneAppendingItems();
- setNeedsLayoutAndMinMaxRecalc();
- m_optionsChanged = false;
- }
-
- // update selection
- if (m_selectionChanged) {
- updateSelection();
- }
-
- m_ignoreSelectEvents = false;
-
- RenderFormElement::updateFromElement();
-}
-
-
-short RenderSelect::baselinePosition( bool f, bool isRootLineBox ) const
-{
- if (m_useListBox) {
- // FIXME: Should get the hardcoded constant of 7 by calling a QListBox function,
- // as we do for other widget classes.
- return RenderWidget::baselinePosition( f, isRootLineBox ) - 7;
- }
- return RenderFormElement::baselinePosition( f, isRootLineBox );
-}
-
-
-void RenderSelect::calcMinMaxWidth()
-{
- KHTMLAssert( !minMaxKnown() );
-
- if (m_optionsChanged)
- updateFromElement();
-
- // ### ugly HACK FIXME!!!
- setMinMaxKnown();
- layoutIfNeeded();
- setNeedsLayoutAndMinMaxRecalc();
- // ### end FIXME
-
- RenderFormElement::calcMinMaxWidth();
-}
-
-void RenderSelect::layout( )
-{
- KHTMLAssert(needsLayout());
- KHTMLAssert(minMaxKnown());
-
- // ### maintain selection properly between type/size changes, and work
- // out how to handle multiselect->singleselect (probably just select
- // first selected one)
-
- // calculate size
- if(m_useListBox) {
- QListBox* w = static_cast<QListBox*>(m_widget);
-
-
- int size = m_size;
- // check if multiple and size was not given or invalid
- // Internet Exploder sets size to min(number of elements, 4)
- // Netscape seems to simply set it to "number of elements"
- // the average of that is IMHO min(number of elements, 10)
- // so I did that ;-)
- if(size < 1)
- size = min(static_cast<QListBox*>(m_widget)->count(), 10U);
-
- // Let the widget tell us how big it wants to be.
- IntSize s(w->sizeForNumberOfLines(size));
- setIntrinsicWidth( s.width() );
- setIntrinsicHeight( s.height() );
- }
- else {
- IntSize s(m_widget->sizeHint());
- setIntrinsicWidth( s.width() );
- setIntrinsicHeight( s.height() );
- }
-
- RenderFormElement::layout();
-
- // and now disable the widget in case there is no <option> given
- DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
-
- bool foundOption = false;
- for (unsigned i = 0; i < listItems.size() && !foundOption; i++)
- foundOption = (listItems[i]->hasTagName(optionTag));
-
- m_widget->setEnabled(foundOption && ! static_cast<HTMLSelectElement*>(node())->disabled());
-}
-
-void RenderSelect::valueChanged(Widget*)
-{
- if (m_ignoreSelectEvents)
- return;
-
- KHTMLAssert(!m_useListBox);
-
- int index = static_cast<QComboBox*>(m_widget)->currentItem();
-
- DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
- if (index >= 0 && index < (int)listItems.size()) {
- bool found = listItems[index]->hasTagName(optionTag);
- if (!found) {
- // this one is not selectable, we need to find an option element
- while ((unsigned) index < listItems.size()) {
- if (listItems[index]->hasTagName(optionTag)) {
- found = true;
- break;
- }
- ++index;
- }
-
- if (!found) {
- while (index >= 0) {
- if (listItems[index]->hasTagName(optionTag)) {
- found = true;
- break;
- }
- --index;
- }
- }
- }
-
- if (found) {
- if ( index != static_cast<QComboBox*>(m_widget)->currentItem() )
- static_cast<QComboBox*>(m_widget)->setCurrentItem( index );
-
- for (unsigned i = 0; i < listItems.size(); ++i)
- if (listItems[i]->hasTagName(optionTag) && i != (unsigned int) index)
- static_cast<HTMLOptionElement*>( listItems[i] )->m_selected = false;
-
- static_cast<HTMLOptionElement*>(listItems[index])->m_selected = true;
- }
- }
-
- static_cast<HTMLSelectElement*>(node())->onChange();
-}
-
-
-void RenderSelect::selectionChanged(Widget*)
-{
- if (m_ignoreSelectEvents)
- return;
-
- // don't use listItems() here as we have to avoid recalculations - changing the
- // option list will make use update options not in the way the user expects them
- DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->m_listItems;
- int j = 0;
- for (unsigned i = 0; i < listItems.count(); i++) {
- // don't use setSelected() here because it will cause us to be called
- // again with updateSelection.
- if (listItems[i]->hasTagName(optionTag))
- static_cast<HTMLOptionElement*>( listItems[i] )
- ->m_selected = static_cast<QListBox*>( m_widget )->isSelected( j );
- if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
- ++j;
- }
- static_cast<HTMLSelectElement*>(node())->onChange();
-}
-
-
-void RenderSelect::setOptionsChanged(bool _optionsChanged)
-{
- m_optionsChanged = _optionsChanged;
-}
-
-QListBox* RenderSelect::createListBox()
-{
- QListBox *lb = new QListBox();
- lb->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
- m_ignoreSelectEvents = false;
- return lb;
-}
-
-void RenderSelect::updateSelection()
-{
- DeprecatedArray<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
- int i;
- if (m_useListBox) {
- // if multi-select, we select only the new selected index
- QListBox *listBox = static_cast<QListBox*>(m_widget);
- int j = 0;
- for (i = 0; i < int(listItems.size()); i++) {
- listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
- static_cast<HTMLOptionElement*>(listItems[i])->selected());
- if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
- ++j;
-
- }
- }
- else {
- bool found = false;
- unsigned firstOption = listItems.size();
- i = listItems.size();
- while (i--)
- if (listItems[i]->hasTagName(optionTag)) {
- if (found)
- static_cast<HTMLOptionElement*>(listItems[i])->m_selected = false;
- else if (static_cast<HTMLOptionElement*>(listItems[i])->selected()) {
- static_cast<QComboBox*>( m_widget )->setCurrentItem(i);
- found = true;
- }
- firstOption = i;
- }
-
- ASSERT(firstOption == listItems.size() || found);
- }
-
- m_selectionChanged = false;
-}
-
-
-// -------------------------------------------------------------------------
-
-
-// -------------------------------------------------------------------------
-
-RenderTextArea::RenderTextArea(HTMLTextAreaElement *element)
- : RenderFormElement(element), m_dirty(false), m_updating(false)
-{
- QTextEdit *edit = new QTextEdit(view());
-
- if (element->wrap() != HTMLTextAreaElement::ta_NoWrap)
- edit->setWordWrap(QTextEdit::WidgetWidth);
- else
- edit->setWordWrap(QTextEdit::NoWrap);
-
- setWidget(edit);
-}
-
-void RenderTextArea::destroy()
-{
- static_cast<HTMLTextAreaElement*>(node())->rendererWillBeDestroyed();
- RenderFormElement::destroy();
-}
-
-void RenderTextArea::calcMinMaxWidth()
-{
- KHTMLAssert( !minMaxKnown() );
-
- QTextEdit* w = static_cast<QTextEdit*>(m_widget);
- IntSize size(w->sizeWithColumnsAndRows(
- max(static_cast<HTMLTextAreaElement*>(node())->cols(), 1),
- max(static_cast<HTMLTextAreaElement*>(node())->rows(), 1)));
-
- setIntrinsicWidth( size.width() );
- setIntrinsicHeight( size.height() );
-
- RenderFormElement::calcMinMaxWidth();
-}
-
-void RenderTextArea::setStyle(RenderStyle *s)
-{
- RenderFormElement::setStyle(s);
-
- QTextEdit* w = static_cast<QTextEdit*>(m_widget);
- w->setAlignment(textAlignment());
- w->setLineHeight(RenderObject::lineHeight(true));
-
- w->setWritingDirection(style()->direction() == RTL ? RTL : LTR);
-
- ScrollBarMode scrollMode = ScrollBarAuto;
- switch (style()->overflow()) {
- case OAUTO:
- case OMARQUEE: // makes no sense, map to auto
- case OOVERLAY: // not implemented for text, map to auto
- case OVISIBLE:
- break;
- case OHIDDEN:
- scrollMode = ScrollBarAlwaysOff;
- break;
- case OSCROLL:
- scrollMode = ScrollBarAlwaysOn;
- break;
- }
- ScrollBarMode horizontalScrollMode = scrollMode;
- if (static_cast<HTMLTextAreaElement*>(node())->wrap() != HTMLTextAreaElement::ta_NoWrap)
- horizontalScrollMode = ScrollBarAlwaysOff;
-
- w->setScrollBarModes(horizontalScrollMode, scrollMode);
-}
-
-void RenderTextArea::setEdited(bool x)
-{
- m_dirty = x;
-}
-
-void RenderTextArea::updateFromElement()
-{
- HTMLTextAreaElement* e = static_cast<HTMLTextAreaElement*>(node());
- QTextEdit* w = static_cast<QTextEdit*>(m_widget);
-
- w->setReadOnly(e->isReadOnlyControl());
- w->setDisabled(e->disabled());
-
- String widgetText = text();
- String text = e->value();
- text.replace('\\', backslashAsCurrencySymbol());
- if (widgetText != text) {
- int line, col;
- w->getCursorPosition( &line, &col );
- m_updating = true;
- w->setText(text);
- m_updating = false;
- w->setCursorPosition( line, col );
- }
- m_dirty = false;
-
- w->setColors(style()->backgroundColor(), style()->color());
-
- RenderFormElement::updateFromElement();
-}
-
-String RenderTextArea::text()
-{
- String txt = static_cast<QTextEdit*>(m_widget)->text();
- return txt.replace(backslashAsCurrencySymbol(), '\\');
-}
-
-String RenderTextArea::textWithHardLineBreaks()
-{
- String txt = static_cast<QTextEdit*>(m_widget)->textWithHardLineBreaks();
- return txt.replace(backslashAsCurrencySymbol(), '\\');
-}
-
-void RenderTextArea::valueChanged(Widget*)
-{
- if (m_updating)
- return;
- static_cast<HTMLTextAreaElement*>(node())->invalidateValue();
- m_dirty = true;
-}
-
-int RenderTextArea::selectionStart()
-{
- QTextEdit *textEdit = static_cast<QTextEdit *>(m_widget);
- return textEdit->selectionStart();
-}
-
-int RenderTextArea::selectionEnd()
-{
- QTextEdit *textEdit = static_cast<QTextEdit *>(m_widget);
- return textEdit->selectionEnd();
-}
-
-void RenderTextArea::setSelectionStart(int start)
-{
- QTextEdit *textEdit = static_cast<QTextEdit *>(m_widget);
- textEdit->setSelectionStart(start);
-}
-
-void RenderTextArea::setSelectionEnd(int end)
-{
- QTextEdit *textEdit = static_cast<QTextEdit *>(m_widget);
- textEdit->setSelectionEnd(end);
-}
-
-void RenderTextArea::select()
-{
- static_cast<QTextEdit *>(m_widget)->selectAll();
-}
-
-void RenderTextArea::setSelectionRange(int start, int end)
-{
- QTextEdit *textEdit = static_cast<QTextEdit *>(m_widget);
- textEdit->setSelectionRange(start, end-start);
-}
-
-void RenderTextArea::selectionChanged(Widget*)
-{
- QTextEdit* w = static_cast<QTextEdit*>(m_widget);
-
- // We only want to call onselect if there actually is a selection
- if (!w->hasSelectedText())
- return;
-
- static_cast<HTMLTextAreaElement*>(node())->onSelect();
-}
-
-// ---------------------------------------------------------------------------
-
-RenderSlider::RenderSlider(HTMLInputElement* element)
- : RenderFormElement(element)
-{
- setWidget(new QSlider);
-}
-
-void RenderSlider::calcMinMaxWidth()
-{
- KHTMLAssert(!minMaxKnown());
-
- // Let the widget tell us how big it wants to be.
- IntSize s(widget()->sizeHint());
- bool widthSet = !style()->width().isAuto();
- bool heightSet = !style()->height().isAuto();
- if (heightSet && !widthSet) {
- // Flip the intrinsic dimensions.
- int barLength = s.width();
- s = IntSize(s.height(), barLength);
- }
- setIntrinsicWidth(s.width());
- setIntrinsicHeight(s.height());
-
- RenderFormElement::calcMinMaxWidth();
-}
-
-void RenderSlider::updateFromElement()
-{
- String value = static_cast<HTMLInputElement*>(node())->value();
- const AtomicString& minStr = static_cast<HTMLInputElement*>(node())->getAttribute(minAttr);
- const AtomicString& maxStr = static_cast<HTMLInputElement*>(node())->getAttribute(maxAttr);
- const AtomicString& precision = static_cast<HTMLInputElement*>(node())->getAttribute(precisionAttr);
-
- double minVal = minStr.isNull() ? 0.0 : minStr.deprecatedString().toDouble();
- double maxVal = maxStr.isNull() ? 100.0 : maxStr.deprecatedString().toDouble();
- minVal = min(minVal, maxVal); // Make sure the range is sane.
-
- double val = value.isNull() ? (maxVal + minVal)/2.0 : value.deprecatedString().toDouble();
- val = max(minVal, min(val, maxVal)); // Make sure val is within min/max.
-
- // Force integer value if not float.
- if (!equalIgnoringCase(precision, "float"))
- val = (int)(val + 0.5);
-
- static_cast<HTMLInputElement*>(node())->setValue(String::number(val));
-
- QSlider* slider = (QSlider*)widget();
-
- slider->setMinValue(minVal);
- slider->setMaxValue(maxVal);
- slider->setValue(val);
-
- RenderFormElement::updateFromElement();
-}
-
-void RenderSlider::valueChanged(Widget*)
-{
- QSlider* slider = static_cast<QSlider*>(widget());
-
- double val = slider->value();
- const AtomicString& precision = static_cast<HTMLInputElement*>(node())->getAttribute(precisionAttr);
-
- // Force integer value if not float.
- if (!equalIgnoringCase(precision, "float"))
- val = (int)(val + 0.5);
-
- static_cast<HTMLInputElement*>(node())->setValue(String::number(val));
-
- // Fire the "input" DOM event.
- static_cast<HTMLInputElement*>(node())->dispatchHTMLEvent(inputEvent, true, false);
-}
-
-}
+++ /dev/null
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * 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, 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef RENDER_FORM_H
-#define RENDER_FORM_H
-
-#include "RenderWidget.h"
-#include "GraphicsTypes.h"
-#include "RenderBlock.h"
-#include "RenderImage.h"
-
-class QListBox;
-
-namespace WebCore {
-
-class DocLoader;
-class HTMLFormElement;
-class HTMLGenericFormElement;
-class HTMLInputElement;
-class HTMLSelectElement;
-class HTMLTextAreaElement;
-
-// -------------------------------------------------------------------------
-
-class RenderFormElement : public RenderWidget
-{
-public:
- RenderFormElement(HTMLGenericFormElement* node);
- virtual ~RenderFormElement();
-
- virtual const char *renderName() const { return "RenderForm"; }
-
- virtual bool isFormElement() const { return true; }
-
- // Aqua form controls never have border/padding.
- int borderTop() const { return 0; }
- int borderBottom() const { return 0; }
- int borderLeft() const { return 0; }
- int borderRight() const { return 0; }
- int paddingTop() const { return 0; }
- int paddingBottom() const { return 0; }
- int paddingLeft() const { return 0; }
- int paddingRight() const { return 0; }
-
- // Aqua controls use intrinsic margin values in order to leave space for focus rings
- // and to keep controls from butting up against one another. This intrinsic margin
- // is only applied if the Web page allows the control to size intrinsically. If the
- // Web page specifies an explicit width for a control, then we go ahead and honor that
- // precise width. Similarly, if a Web page uses a specific margin value, we will go ahead
- // and honor that value.
- void addIntrinsicMarginsIfAllowed(RenderStyle* _style);
- virtual bool canHaveIntrinsicMargins() const { return false; }
- int intrinsicMargin() const { return 2; }
-
- virtual void setStyle(RenderStyle *);
- virtual void updateFromElement();
-
- virtual void layout();
- virtual short baselinePosition( bool, bool ) const;
-
-private:
- virtual void clicked(Widget*);
-
-protected:
- virtual bool isEditable() const { return false; }
-
- HorizontalAlignment textAlignment() const;
-};
-
-// -------------------------------------------------------------------------
-
-class RenderImageButton : public RenderImage
-{
-public:
- RenderImageButton(HTMLInputElement*);
-
- virtual const char *renderName() const { return "RenderImageButton"; }
- virtual bool isImageButton() const { return true; }
-};
-
-// -------------------------------------------------------------------------
-
-class RenderLineEdit : public RenderFormElement
-{
-public:
- RenderLineEdit(HTMLInputElement*);
-
- virtual void calcMinMaxWidth();
- int calcReplacedHeight() const { return intrinsicHeight(); }
- virtual bool canHaveIntrinsicMargins() const { return true; }
-
- virtual const char *renderName() const { return "RenderLineEdit"; }
- virtual void updateFromElement();
- virtual void setStyle(RenderStyle *);
-
- int selectionStart();
- int selectionEnd();
- void setSelectionStart(int);
- void setSelectionEnd(int);
-
- bool isEdited() const;
- void setEdited(bool);
- bool isTextField() const { return true; }
- void select();
- void setSelectionRange(int, int);
-
-public:
- void addSearchResult();
-
-private:
- virtual void returnPressed(Widget*);
- virtual void valueChanged(Widget*);
- virtual void selectionChanged(Widget*);
- virtual void performSearch(Widget*);
-
- virtual bool isEditable() const { return true; }
-
- bool m_updating;
-};
-
-// -------------------------------------------------------------------------
-
-class RenderFieldset : public RenderBlock
-{
-public:
- RenderFieldset(HTMLGenericFormElement*);
-
- virtual const char* renderName() const { return "RenderFieldSet"; }
-
- virtual RenderObject* layoutLegend(bool relayoutChildren);
-
- virtual void setStyle(RenderStyle*);
-
-private:
- virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
- void paintBorderMinusLegend(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle *, int lx, int lw);
- RenderObject* findLegend();
-};
-
-// -------------------------------------------------------------------------
-
-class RenderFileButton : public RenderFormElement
-{
-public:
- RenderFileButton(HTMLInputElement*);
-
- virtual const char *renderName() const { return "RenderFileButton"; }
- virtual void calcMinMaxWidth();
- virtual void updateFromElement();
- void select();
-
- int calcReplacedHeight() const { return intrinsicHeight(); }
-
- void click(bool sendMouseEvents);
-
-protected:
- virtual bool isEditable() const { return true; }
-
-private:
- virtual void returnPressed(Widget*);
- virtual void valueChanged(Widget*);
-};
-
-// -------------------------------------------------------------------------
-
-class RenderLabel : public RenderFormElement
-{
-public:
- RenderLabel(HTMLGenericFormElement *element);
-
- virtual const char *renderName() const { return "RenderLabel"; }
-};
-
-
-// -------------------------------------------------------------------------
-
-class RenderLegend : public RenderBlock
-{
-public:
- RenderLegend(HTMLGenericFormElement *element);
-
- virtual const char *renderName() const { return "RenderLegend"; }
-};
-
-// -------------------------------------------------------------------------
-
-class RenderSelect : public RenderFormElement
-{
-public:
- RenderSelect(HTMLSelectElement*);
-
- virtual const char *renderName() const { return "RenderSelect"; }
-
- short baselinePosition( bool f, bool b ) const;
- int calcReplacedHeight() const { if (!m_useListBox) return intrinsicHeight(); return RenderFormElement::calcReplacedHeight(); }
- virtual bool canHaveIntrinsicMargins() const { return true; }
-
- virtual void calcMinMaxWidth();
- virtual void layout();
-
- void setOptionsChanged(bool _optionsChanged);
-
- bool selectionChanged() { return m_selectionChanged; }
- void setSelectionChanged(bool _selectionChanged) { m_selectionChanged = _selectionChanged; }
- virtual void updateFromElement();
- virtual void setStyle(RenderStyle *);
-
- void updateSelection();
-
-protected:
- QListBox *createListBox();
- void setWidgetWritingDirection();
-
- unsigned m_size;
- bool m_multiple;
- bool m_useListBox;
- bool m_selectionChanged;
- bool m_ignoreSelectEvents;
- bool m_optionsChanged;
-
-private:
- virtual void valueChanged(Widget*);
- virtual void selectionChanged(Widget*);
-};
-
-// -------------------------------------------------------------------------
-
-class RenderTextArea : public RenderFormElement
-{
-public:
- RenderTextArea(HTMLTextAreaElement*);
-
- virtual void destroy();
-
- virtual const char *renderName() const { return "RenderTextArea"; }
- virtual void calcMinMaxWidth();
- virtual void updateFromElement();
- virtual void setStyle(RenderStyle *);
-
- bool isTextArea() const { return true; }
- bool isEdited() const { return m_dirty; }
- void setEdited (bool);
-
- String text();
- String textWithHardLineBreaks();
-
- int selectionStart();
- int selectionEnd();
- void setSelectionStart(int);
- void setSelectionEnd(int);
-
- void select();
- void setSelectionRange(int, int);
-
- virtual bool canHaveIntrinsicMargins() const { return true; }
-
-private:
- virtual void valueChanged(Widget*);
- virtual void selectionChanged(Widget*);
-
-protected:
- virtual bool isEditable() const { return true; }
-
- bool m_dirty;
- bool m_updating;
-};
-
-// -------------------------------------------------------------------------
-
-class RenderSlider : public RenderFormElement
-{
-public:
- RenderSlider(HTMLInputElement*);
-
- virtual const char *renderName() const { return "RenderSlider"; }
- virtual bool canHaveIntrinsicMargins() const { return true; }
- virtual void calcMinMaxWidth();
- virtual void updateFromElement();
-
-private:
- virtual void valueChanged(Widget*);
-};
-
-} //namespace
-
-#endif