diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-24 13:09:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-24 13:09:44 +0200 |
commit | dc6262b587c71c14e30d93e57ed812e36a79a33e (patch) | |
tree | 03ff986e7aa38bba0c0ef374f44fda52aff93f01 /Source/WebCore/html | |
parent | 02e1fbbefd49229b102ef107bd70ce974a2d85fb (diff) | |
download | qtwebkit-dc6262b587c71c14e30d93e57ed812e36a79a33e.tar.gz |
Imported WebKit commit 6339232fec7f5d9984a33388aecfd2cbc7832053 (http://svn.webkit.org/repository/webkit/trunk@129343)
New snapshot with build fixes for latest qtbase
Diffstat (limited to 'Source/WebCore/html')
23 files changed, 180 insertions, 159 deletions
diff --git a/Source/WebCore/html/BaseButtonInputType.cpp b/Source/WebCore/html/BaseButtonInputType.cpp index d1ed27ba5..5fde8d799 100644 --- a/Source/WebCore/html/BaseButtonInputType.cpp +++ b/Source/WebCore/html/BaseButtonInputType.cpp @@ -36,62 +36,11 @@ #include "HTMLNames.h" #include "KeyboardEvent.h" #include "RenderButton.h" -#include "RenderTextFragment.h" -#include "ShadowRoot.h" -#include "Text.h" namespace WebCore { using namespace HTMLNames; -class TextForButtonInputType : public Text { -public: - static PassRefPtr<TextForButtonInputType> create(Document*, const String&); - -private: - TextForButtonInputType(Document*, const String&); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; -}; - -PassRefPtr<TextForButtonInputType> TextForButtonInputType::create(Document* document, const String& data) -{ - return adoptRef(new TextForButtonInputType(document, data)); -} - -TextForButtonInputType::TextForButtonInputType(Document* document, const String& data) - : Text(document, data) -{ -} - -RenderObject* TextForButtonInputType::createRenderer(RenderArena* arena, RenderStyle*) -{ - return new (arena) RenderTextFragment(document(), dataImpl()); -} - -BaseButtonInputType::BaseButtonInputType(HTMLInputElement* element) - : BaseClickableWithKeyInputType(element) -{ -} - -void BaseButtonInputType::createShadowSubtree() -{ - ASSERT(element()->userAgentShadowRoot()); - - RefPtr<TextForButtonInputType> text = TextForButtonInputType::create(element()->document(), defaultValue()); - element()->userAgentShadowRoot()->appendChild(text); -} - -void BaseButtonInputType::destroyShadowSubtree() -{ - InputType::destroyShadowSubtree(); -} - -void BaseButtonInputType::valueAttributeChanged() -{ - String value = element()->valueWithDefault(); - toText(element()->userAgentShadowRoot()->firstChild())->setData(value, ASSERT_NO_EXCEPTION); -} - bool BaseButtonInputType::shouldSaveAndRestoreFormControlState() const { return false; diff --git a/Source/WebCore/html/BaseButtonInputType.h b/Source/WebCore/html/BaseButtonInputType.h index 3b8384c4e..4dfbb043f 100644 --- a/Source/WebCore/html/BaseButtonInputType.h +++ b/Source/WebCore/html/BaseButtonInputType.h @@ -38,14 +38,9 @@ namespace WebCore { // Base of button, file, image, reset, and submit types. class BaseButtonInputType : public BaseClickableWithKeyInputType { protected: - BaseButtonInputType(HTMLInputElement*); + BaseButtonInputType(HTMLInputElement* element) : BaseClickableWithKeyInputType(element) { } private: - virtual void createShadowSubtree() OVERRIDE; - virtual void destroyShadowSubtree() OVERRIDE; - - virtual void valueAttributeChanged() OVERRIDE; - virtual bool shouldSaveAndRestoreFormControlState() const OVERRIDE; virtual bool appendFormData(FormDataList&, bool) const OVERRIDE; virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE; diff --git a/Source/WebCore/html/FileInputType.cpp b/Source/WebCore/html/FileInputType.cpp index cc19f2a35..89fcc878e 100644 --- a/Source/WebCore/html/FileInputType.cpp +++ b/Source/WebCore/html/FileInputType.cpp @@ -62,7 +62,6 @@ private: PassRefPtr<UploadButtonElement> UploadButtonElement::create(Document* document) { RefPtr<UploadButtonElement> button = adoptRef(new UploadButtonElement(document)); - button->createShadowSubtree(); button->setType("button"); button->setValue(fileButtonChooseFileLabel()); return button.release(); @@ -71,7 +70,6 @@ PassRefPtr<UploadButtonElement> UploadButtonElement::create(Document* document) PassRefPtr<UploadButtonElement> UploadButtonElement::createForMultiple(Document* document) { RefPtr<UploadButtonElement> button = adoptRef(new UploadButtonElement(document)); - button->createShadowSubtree(); button->setType("button"); button->setValue(fileButtonChooseMultipleFilesLabel()); return button.release(); diff --git a/Source/WebCore/html/HTMLDialogElement.cpp b/Source/WebCore/html/HTMLDialogElement.cpp index 537432960..7d4d6451b 100644 --- a/Source/WebCore/html/HTMLDialogElement.cpp +++ b/Source/WebCore/html/HTMLDialogElement.cpp @@ -62,6 +62,15 @@ void HTMLDialogElement::show() setBooleanAttribute(openAttr, true); } +void HTMLDialogElement::showModal(ExceptionCode& ec) +{ + if (fastHasAttribute(openAttr) || !inDocument()) { + ec = INVALID_STATE_ERR; + return; + } + setBooleanAttribute(openAttr, true); +} + bool HTMLDialogElement::isPresentationAttribute(const QualifiedName& name) const { // FIXME: Workaround for <https://bugs.webkit.org/show_bug.cgi?id=91058>: modifying an attribute for which there is an attribute selector diff --git a/Source/WebCore/html/HTMLDialogElement.h b/Source/WebCore/html/HTMLDialogElement.h index 7a7b0119f..e01045bce 100644 --- a/Source/WebCore/html/HTMLDialogElement.h +++ b/Source/WebCore/html/HTMLDialogElement.h @@ -41,6 +41,7 @@ public: void close(ExceptionCode&); void show(); + void showModal(ExceptionCode&); private: HTMLDialogElement(const QualifiedName&, Document*); diff --git a/Source/WebCore/html/HTMLDialogElement.idl b/Source/WebCore/html/HTMLDialogElement.idl index 442f93fd8..3c70c0c53 100644 --- a/Source/WebCore/html/HTMLDialogElement.idl +++ b/Source/WebCore/html/HTMLDialogElement.idl @@ -31,6 +31,7 @@ module html { attribute [Reflect] boolean open; void close() raises(DOMException); void show(); + void showModal() raises(DOMException); }; } diff --git a/Source/WebCore/html/HTMLElement.cpp b/Source/WebCore/html/HTMLElement.cpp index 641c0b890..caf4ac939 100644 --- a/Source/WebCore/html/HTMLElement.cpp +++ b/Source/WebCore/html/HTMLElement.cpp @@ -30,7 +30,6 @@ #include "CSSPropertyNames.h" #include "CSSValueKeywords.h" #include "CSSValuePool.h" -#include "ChildListMutationScope.h" #include "DOMSettableTokenList.h" #include "DocumentFragment.h" #include "Event.h" diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp index 4cfc2b7d8..d1ea76cae 100644 --- a/Source/WebCore/html/HTMLInputElement.cpp +++ b/Source/WebCore/html/HTMLInputElement.cpp @@ -677,7 +677,6 @@ void HTMLInputElement::parseAttribute(const Attribute& attribute) updatePlaceholderVisibility(false); setNeedsStyleRecalc(); } - m_inputType->valueAttributeChanged(); setFormControlValueMatchesRenderer(false); setNeedsValidityCheck(); m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress; diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index 5f5674517..66b8c4655 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -3675,6 +3675,7 @@ void HTMLMediaElement::stop() userCancelledLoad(); // Stop the playback without generating events + m_playing = false; setPausedInternal(true); if (renderer()) diff --git a/Source/WebCore/html/HTMLViewSourceDocument.cpp b/Source/WebCore/html/HTMLViewSourceDocument.cpp index 80cdd69cd..3de813770 100644 --- a/Source/WebCore/html/HTMLViewSourceDocument.cpp +++ b/Source/WebCore/html/HTMLViewSourceDocument.cpp @@ -70,24 +70,24 @@ PassRefPtr<DocumentParser> HTMLViewSourceDocument::createParser() void HTMLViewSourceDocument::createContainingTable() { RefPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(this); - parserAddChild(html); + parserAppendChild(html); html->attach(); RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(this); - html->parserAddChild(body); + html->parserAppendChild(body); body->attach(); // Create a line gutter div that can be used to make sure the gutter extends down the height of the whole // document. RefPtr<HTMLDivElement> div = HTMLDivElement::create(this); div->setAttribute(classAttr, "webkit-line-gutter-backdrop"); - body->parserAddChild(div); + body->parserAppendChild(div); div->attach(); RefPtr<HTMLTableElement> table = HTMLTableElement::create(this); - body->parserAddChild(table); + body->parserAppendChild(table); table->attach(); m_tbody = HTMLTableSectionElement::create(tbodyTag, this); - table->parserAddChild(m_tbody); + table->parserAppendChild(m_tbody); m_tbody->attach(); m_current = m_tbody; } @@ -186,7 +186,7 @@ PassRefPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(const AtomicStr RefPtr<HTMLElement> span = HTMLElement::create(spanTag, this); span->setAttribute(classAttr, className); - m_current->parserAddChild(span); + m_current->parserAppendChild(span); span->attach(); return span.release(); } @@ -195,19 +195,19 @@ void HTMLViewSourceDocument::addLine(const AtomicString& className) { // Create a table row. RefPtr<HTMLTableRowElement> trow = HTMLTableRowElement::create(this); - m_tbody->parserAddChild(trow); + m_tbody->parserAppendChild(trow); trow->attach(); // Create a cell that will hold the line number (it is generated in the stylesheet using counters). RefPtr<HTMLTableCellElement> td = HTMLTableCellElement::create(tdTag, this); td->setAttribute(classAttr, "webkit-line-number"); - trow->parserAddChild(td); + trow->parserAppendChild(td); td->attach(); // Create a second cell for the line contents td = HTMLTableCellElement::create(tdTag, this); td->setAttribute(classAttr, "webkit-line-content"); - trow->parserAddChild(td); + trow->parserAppendChild(td); td->attach(); m_current = m_td = td; @@ -229,7 +229,7 @@ void HTMLViewSourceDocument::finishLine() { if (!m_current->hasChildNodes()) { RefPtr<HTMLBRElement> br = HTMLBRElement::create(this); - m_current->parserAddChild(br); + m_current->parserAppendChild(br); br->attach(); } m_current = m_tbody; @@ -255,7 +255,7 @@ void HTMLViewSourceDocument::addText(const String& text, const AtomicString& cla continue; } RefPtr<Text> t = Text::create(this, substring); - m_current->parserAddChild(t); + m_current->parserAppendChild(t); t->attach(); if (i < size - 1) finishLine(); @@ -285,7 +285,7 @@ PassRefPtr<Element> HTMLViewSourceDocument::addBase(const AtomicString& href) { RefPtr<HTMLBaseElement> base = HTMLBaseElement::create(baseTag, this); base->setAttribute(hrefAttr, href); - m_current->parserAddChild(base); + m_current->parserAppendChild(base); base->attach(); return base.release(); } @@ -305,7 +305,7 @@ PassRefPtr<Element> HTMLViewSourceDocument::addLink(const AtomicString& url, boo anchor->setAttribute(classAttr, classValue); anchor->setAttribute(targetAttr, "_blank"); anchor->setAttribute(hrefAttr, url); - m_current->parserAddChild(anchor); + m_current->parserAppendChild(anchor); anchor->attach(); return anchor.release(); } diff --git a/Source/WebCore/html/InputType.cpp b/Source/WebCore/html/InputType.cpp index 1a078f250..38d79eea8 100644 --- a/Source/WebCore/html/InputType.cpp +++ b/Source/WebCore/html/InputType.cpp @@ -889,10 +889,6 @@ void InputType::updatePlaceholderText() { } -void InputType::valueAttributeChanged() -{ -} - void InputType::multipleAttributeChanged() { } diff --git a/Source/WebCore/html/InputType.h b/Source/WebCore/html/InputType.h index 29d8cc30c..87a4c12a8 100644 --- a/Source/WebCore/html/InputType.h +++ b/Source/WebCore/html/InputType.h @@ -278,7 +278,6 @@ public: virtual String fixedPlaceholder(); virtual void updateInnerTextValue(); virtual void updatePlaceholderText(); - virtual void valueAttributeChanged(); virtual void multipleAttributeChanged(); virtual void disabledAttributeChanged(); virtual void readonlyAttributeChanged(); diff --git a/Source/WebCore/html/TimeInputType.cpp b/Source/WebCore/html/TimeInputType.cpp index c1597ecbb..4b5bb1f15 100644 --- a/Source/WebCore/html/TimeInputType.cpp +++ b/Source/WebCore/html/TimeInputType.cpp @@ -46,6 +46,7 @@ #include "ElementShadow.h" #include "FormController.h" #include "KeyboardEvent.h" +#include "Localizer.h" #include "ShadowRoot.h" #endif @@ -304,14 +305,25 @@ void TimeInputType::updateInnerTextValue() return; Localizer& localizer = element()->document()->getLocalizer(element()->computeInheritedLanguage()); - const StepRange stepRange(createStepRange(AnyIsDefaultStep)); + DateTimeEditElement::LayoutParameters layoutParameters(localizer, createStepRange(AnyIsDefaultStep)); + DateComponents date; - if (parseToDateComponents(element()->value(), &date)) - m_dateTimeEditElement->setValueAsDate(stepRange, date, localizer); - else { - setMillisecondToDateComponents(stepRange.minimum().toDouble(), &date); - m_dateTimeEditElement->setEmptyValue(stepRange, date, localizer); + const bool hasValue = parseToDateComponents(element()->value(), &date); + if (!hasValue) + setMillisecondToDateComponents(layoutParameters.stepRange.minimum().toDouble(), &date); + + if (date.second() || layoutParameters.shouldHaveSecondField()) { + layoutParameters.dateTimeFormat = localizer.timeFormat(); + layoutParameters.fallbackDateTimeFormat = "HH:mm:ss"; + } else { + layoutParameters.dateTimeFormat = localizer.shortTimeFormat(); + layoutParameters.fallbackDateTimeFormat = "HH:mm"; } + + if (hasValue) + m_dateTimeEditElement->setValueAsDate(layoutParameters, date); + else + m_dateTimeEditElement->setEmptyValue(layoutParameters, date); } #else TimeInputType::TimeInputType(HTMLInputElement* element) diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp index 24b9c33f9..582ed5d39 100644 --- a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp +++ b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp @@ -1544,22 +1544,8 @@ void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) return; if (m_boundArrayBuffer == buffer) m_boundArrayBuffer = 0; - RefPtr<WebGLBuffer> elementArrayBuffer = m_boundVertexArrayObject->getElementArrayBuffer(); - if (elementArrayBuffer == buffer) - m_boundVertexArrayObject->setElementArrayBuffer(0); - if (!isGLES2Compliant()) { - WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0); - if (buffer == state.bufferBinding) { - state.bufferBinding = m_vertexAttrib0Buffer; - state.bytesPerElement = 0; - state.size = 4; - state.type = GraphicsContext3D::FLOAT; - state.normalized = false; - state.stride = 16; - state.originalStride = 0; - state.offset = 0; - } - } + + m_boundVertexArrayObject->unbindBuffer(buffer); } void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) @@ -4383,17 +4369,7 @@ void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC } GC3Dsizei bytesPerElement = size * typeSize; - GC3Dsizei validatedStride = stride ? stride : bytesPerElement; - - WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index); - state.bufferBinding = m_boundArrayBuffer; - state.bytesPerElement = bytesPerElement; - state.size = size; - state.type = type; - state.normalized = normalized; - state.stride = validatedStride; - state.originalStride = stride; - state.offset = static_cast<GC3Dintptr>(offset); + m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); m_context->vertexAttribPointer(index, size, type, normalized, stride, static_cast<GC3Dintptr>(offset)); cleanupAfterGraphicsCall(false); } diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.h b/Source/WebCore/html/canvas/WebGLRenderingContext.h index 6023b4462..45df6a582 100644 --- a/Source/WebCore/html/canvas/WebGLRenderingContext.h +++ b/Source/WebCore/html/canvas/WebGLRenderingContext.h @@ -322,6 +322,7 @@ public: friend class WebGLDebugShaders; friend class WebGLCompressedTextureS3TC; friend class WebGLRenderingContextErrorMessageCallback; + friend class WebGLVertexArrayObjectOES; WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes); void initializeNewContext(); diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp index 4aa03b8fe..a98d092e8 100644 --- a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp +++ b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp @@ -72,6 +72,75 @@ void WebGLVertexArrayObjectOES::deleteObjectImpl(GraphicsContext3D* context3d, P extensions->deleteVertexArrayOES(object); break; } + + if (m_boundElementArrayBuffer) + m_boundElementArrayBuffer->onDetached(context3d); + + for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { + VertexAttribState& state = m_vertexAttribState[i]; + if (state.bufferBinding) + state.bufferBinding->onDetached(context3d); + } +} + +void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer) +{ + if (buffer) + buffer->onAttached(); + if (m_boundElementArrayBuffer) + m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D()); + m_boundElementArrayBuffer = buffer; + +} + +void WebGLVertexArrayObjectOES::setVertexAttribState( + GC3Duint index, GC3Dsizei bytesPerElement, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, PassRefPtr<WebGLBuffer> buffer) +{ + GC3Dsizei validatedStride = stride ? stride : bytesPerElement; + + VertexAttribState& state = m_vertexAttribState[index]; + + if (buffer) + buffer->onAttached(); + if (state.bufferBinding) + state.bufferBinding->onDetached(context()->graphicsContext3D()); + + state.bufferBinding = buffer; + state.bytesPerElement = bytesPerElement; + state.size = size; + state.type = type; + state.normalized = normalized; + state.stride = validatedStride; + state.originalStride = stride; + state.offset = offset; +} + +void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer) +{ + if (m_boundElementArrayBuffer == buffer) { + m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D()); + m_boundElementArrayBuffer = 0; + } + + for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { + VertexAttribState& state = m_vertexAttribState[i]; + if (state.bufferBinding == buffer) { + buffer->onDetached(context()->graphicsContext3D()); + + if (!i && !context()->isGLES2Compliant()) { + state.bufferBinding = context()->m_vertexAttrib0Buffer; + state.bufferBinding->onAttached(); + state.bytesPerElement = 0; + state.size = 4; + state.type = GraphicsContext3D::FLOAT; + state.normalized = false; + state.stride = 16; + state.originalStride = 0; + state.offset = 0; + } else + state.bufferBinding = 0; + } + } } } diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h index 75ae42ff7..b660de588 100644 --- a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h +++ b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h @@ -76,9 +76,11 @@ public: void setHasEverBeenBound() { m_hasEverBeenBound = true; } PassRefPtr<WebGLBuffer> getElementArrayBuffer() const { return m_boundElementArrayBuffer; } - void setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer) { m_boundElementArrayBuffer = buffer; } + void setElementArrayBuffer(PassRefPtr<WebGLBuffer>); VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; } + void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>); + void unbindBuffer(PassRefPtr<WebGLBuffer>); private: WebGLVertexArrayObjectOES(WebGLRenderingContext*, VaoType); diff --git a/Source/WebCore/html/parser/HTMLConstructionSite.cpp b/Source/WebCore/html/parser/HTMLConstructionSite.cpp index fc9d7c664..0d66be471 100644 --- a/Source/WebCore/html/parser/HTMLConstructionSite.cpp +++ b/Source/WebCore/html/parser/HTMLConstructionSite.cpp @@ -80,7 +80,7 @@ static inline void executeTask(HTMLConstructionSiteTask& task) if (task.nextChild) task.parent->parserInsertBefore(task.child.get(), task.nextChild.get()); else - task.parent->parserAddChild(task.child.get()); + task.parent->parserAppendChild(task.child.get()); // JavaScript run from beforeload (or DOM Mutation or event handlers) // might have removed the child, in which case we should not attach it. diff --git a/Source/WebCore/html/parser/HTMLTreeBuilder.cpp b/Source/WebCore/html/parser/HTMLTreeBuilder.cpp index 3e9b303c6..131cdbff6 100644 --- a/Source/WebCore/html/parser/HTMLTreeBuilder.cpp +++ b/Source/WebCore/html/parser/HTMLTreeBuilder.cpp @@ -1488,7 +1488,7 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken* token) // 9.9 if (ContainerNode* parent = lastNode->element()->parentNode()) parent->parserRemoveChild(lastNode->element()); - node->element()->parserAddChild(lastNode->element()); + node->element()->parserAppendChild(lastNode->element()); if (lastNode->element()->parentElement()->attached() && !lastNode->element()->attached()) lastNode->element()->lazyAttach(); // 9.10 @@ -1500,7 +1500,7 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken* token) if (commonAncestor->causesFosterParenting()) m_tree.fosterParent(lastNode->element()); else { - commonAncestor->node()->parserAddChild(lastNode->element()); + commonAncestor->node()->parserAppendChild(lastNode->element()); ASSERT(lastNode->stackItem()->isElementNode()); ASSERT(lastNode->element()->parentNode()); if (lastNode->element()->parentNode()->attached() && !lastNode->element()->attached()) @@ -1512,10 +1512,10 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken* token) newItem->element()->takeAllChildrenFrom(furthestBlock->element()); // 13. Element* furthestBlockElement = furthestBlock->element(); - // FIXME: All this creation / parserAddChild / attach business should + // FIXME: All this creation / parserAppendChild / attach business should // be in HTMLConstructionSite. My guess is that steps 11--15 // should all be in some HTMLConstructionSite function. - furthestBlockElement->parserAddChild(newItem->element()); + furthestBlockElement->parserAppendChild(newItem->element()); // FIXME: Why is this attach logic necessary? Style resolve should attach us if needed. if (furthestBlockElement->attached() && !newItem->element()->attached()) { // Notice that newItem->element() might already be attached if, for example, one of the reparented diff --git a/Source/WebCore/html/shadow/CalendarPickerElement.cpp b/Source/WebCore/html/shadow/CalendarPickerElement.cpp index 28d78d1d5..7513f5b71 100644 --- a/Source/WebCore/html/shadow/CalendarPickerElement.cpp +++ b/Source/WebCore/html/shadow/CalendarPickerElement.cpp @@ -37,7 +37,9 @@ #include "ChromeClient.h" #include "Event.h" #include "FrameView.h" +#include "HTMLDataListElement.h" #include "HTMLInputElement.h" +#include "HTMLOptionElement.h" #include "Page.h" #include "RenderDetailsMarker.h" @@ -140,7 +142,16 @@ void CalendarPickerElement::openPopup() parameters.step = step.toDouble(); parameters.anchorRectInRootView = document()->view()->contentsToRootView(hostInput()->pixelSnappedBoundingBox()); parameters.currentValue = input->value(); - // FIXME: parameters.suggestionValues and suggestionLabels will be used when we support datalist. + if (HTMLDataListElement* dataList = input->dataList()) { + RefPtr<HTMLCollection> options = dataList->options(); + for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(options->item(i)); ++i) { + if (!input->isValidValue(option->value())) + continue; + parameters.suggestionValues.append(input->sanitizeValue(option->value())); + parameters.localizedSuggestionValues.append(input->localizeValue(option->value())); + parameters.suggestionLabels.append(option->value() == option->label() ? String() : option->label()); + } + } m_chooser = chrome->client()->openDateTimeChooser(this, parameters); } diff --git a/Source/WebCore/html/shadow/DateTimeEditElement.cpp b/Source/WebCore/html/shadow/DateTimeEditElement.cpp index e9aa858cc..07befd874 100644 --- a/Source/WebCore/html/shadow/DateTimeEditElement.cpp +++ b/Source/WebCore/html/shadow/DateTimeEditElement.cpp @@ -35,11 +35,8 @@ #include "EventHandler.h" #include "HTMLNames.h" #include "KeyboardEvent.h" -#include "LocalizedDate.h" -#include "LocalizedNumber.h" #include "Localizer.h" #include "MouseEvent.h" -#include "StepRange.h" #include "Text.h" #include <wtf/DateMath.h> #include <wtf/text/StringBuilder.h> @@ -52,14 +49,12 @@ class DateTimeEditBuilder : private DateTimeFormat::TokenHandler { WTF_MAKE_NONCOPYABLE(DateTimeEditBuilder); public: - DateTimeEditBuilder(DateTimeEditElement&, const StepRange&, const DateComponents&, Localizer&); + DateTimeEditBuilder(DateTimeEditElement&, const DateTimeEditElement::LayoutParameters&, const DateComponents&); bool build(const String&); - bool needSecondField() const; private: bool needMillisecondField() const; - bool needMinuteField() const; bool shouldMillisecondFieldReadOnly() const; bool shouldMinuteFieldReadOnly() const; bool shouldSecondFieldReadOnly() const; @@ -74,11 +69,11 @@ private: Localizer& m_localizer; }; -DateTimeEditBuilder::DateTimeEditBuilder(DateTimeEditElement& elemnt, const StepRange& stepRange, const DateComponents& dateValue, Localizer& localizer) +DateTimeEditBuilder::DateTimeEditBuilder(DateTimeEditElement& elemnt, const DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& dateValue) : m_editElement(elemnt) , m_dateValue(dateValue) - , m_stepRange(stepRange) - , m_localizer(localizer) + , m_stepRange(layoutParameters.stepRange) + , m_localizer(layoutParameters.localizer) { } @@ -95,20 +90,6 @@ bool DateTimeEditBuilder::needMillisecondField() const || !m_stepRange.step().remainder(static_cast<int>(msPerSecond)).isZero(); } -bool DateTimeEditBuilder::needMinuteField() const -{ - return m_dateValue.minute() - || !m_stepRange.minimum().remainder(static_cast<int>(msPerHour)).isZero() - || !m_stepRange.step().remainder(static_cast<int>(msPerHour)).isZero(); -} - -bool DateTimeEditBuilder::needSecondField() const -{ - return m_dateValue.second() - || !m_stepRange.minimum().remainder(static_cast<int>(msPerMinute)).isZero() - || !m_stepRange.step().remainder(static_cast<int>(msPerMinute)).isZero(); -} - void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int) { Document* const document = m_editElement.document(); @@ -191,6 +172,15 @@ void DateTimeEditBuilder::visitLiteral(const String& text) // ---------------------------- + +bool DateTimeEditElement::LayoutParameters::shouldHaveSecondField() const +{ + return !stepRange.minimum().remainder(static_cast<int>(msPerMinute)).isZero() + || !stepRange.step().remainder(static_cast<int>(msPerMinute)).isZero(); +} + +// ---------------------------- + DateTimeEditElement::EditControlOwner::~EditControlOwner() { } @@ -340,18 +330,17 @@ bool DateTimeEditElement::isReadOnly() const return m_editControlOwner && m_editControlOwner->isEditControlOwnerReadOnly(); } -void DateTimeEditElement::layout(const StepRange& stepRange, const DateComponents& dateValue, Localizer& localizer) +void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const DateComponents& dateValue) { size_t focusedFieldIndex = this->focusedFieldIndex(); DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex); const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseudoId() : nullAtom; - DateTimeEditBuilder builder(*this, stepRange, dateValue, localizer); - const String dateTimeFormat = builder.needSecondField() ? localizer.timeFormat() : localizer.shortTimeFormat(); + DateTimeEditBuilder builder(*this, layoutParameters, dateValue); Node* lastChildToBeRemoved = lastChild(); - if (!builder.build(dateTimeFormat) || m_fields.isEmpty()) { + if (!builder.build(layoutParameters.dateTimeFormat) || m_fields.isEmpty()) { lastChildToBeRemoved = lastChild(); - builder.build(builder.needSecondField() ? "HH:mm:ss" : "HH:mm"); + builder.build(layoutParameters.fallbackDateTimeFormat); } if (focusedFieldIndex != invalidFieldIndex) { @@ -407,9 +396,9 @@ void DateTimeEditElement::defaultEventHandler(Event* event) HTMLDivElement::defaultEventHandler(event); } -void DateTimeEditElement::setValueAsDate(const StepRange& stepRange, const DateComponents& date, Localizer& localizer) +void DateTimeEditElement::setValueAsDate(const LayoutParameters& layoutParameters, const DateComponents& date) { - layout(stepRange, date, localizer); + layout(layoutParameters, date); for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) m_fields[fieldIndex]->setValueAsDate(date); } @@ -420,9 +409,9 @@ void DateTimeEditElement::setValueAsDateTimeFieldsState(const DateTimeFieldsStat m_fields[fieldIndex]->setValueAsDateTimeFieldsState(dateTimeFieldsState, dateForReadOnlyField); } -void DateTimeEditElement::setEmptyValue(const StepRange& stepRange, const DateComponents& dateForReadOnlyField, Localizer& localizer) +void DateTimeEditElement::setEmptyValue(const LayoutParameters& layoutParameters, const DateComponents& dateForReadOnlyField) { - layout(stepRange, dateForReadOnlyField, localizer); + layout(layoutParameters, dateForReadOnlyField); for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) m_fields[fieldIndex]->setEmptyValue(dateForReadOnlyField, DateTimeFieldElement::DispatchNoEvent); } diff --git a/Source/WebCore/html/shadow/DateTimeEditElement.h b/Source/WebCore/html/shadow/DateTimeEditElement.h index c17bd7a7a..e547cbdea 100644 --- a/Source/WebCore/html/shadow/DateTimeEditElement.h +++ b/Source/WebCore/html/shadow/DateTimeEditElement.h @@ -29,11 +29,10 @@ #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) #include "DateTimeFieldElement.h" #include "SpinButtonElement.h" +#include "StepRange.h" namespace WebCore { -class DateComponents; -class DateTimeEditLayouter; class DateTimeFieldsState; class KeyboardEvent; class Localizer; @@ -60,6 +59,21 @@ public: virtual bool isEditControlOwnerReadOnly() const = 0; }; + struct LayoutParameters { + String dateTimeFormat; + String fallbackDateTimeFormat; + Localizer& localizer; + const StepRange& stepRange; + + LayoutParameters(Localizer& localizer, const StepRange& stepRange) + : localizer(localizer) + , stepRange(stepRange) + { + } + + bool shouldHaveSecondField() const; + }; + static PassRefPtr<DateTimeEditElement> create(Document*, EditControlOwner&); virtual ~DateTimeEditElement(); @@ -71,8 +85,8 @@ public: void readOnlyStateChanged(); void removeEditControlOwner() { m_editControlOwner = 0; } void resetFields(); - void setEmptyValue(const StepRange&, const DateComponents& dateForReadOnlyField, Localizer&); - void setValueAsDate(const StepRange&, const DateComponents&, Localizer&); + void setEmptyValue(const LayoutParameters&, const DateComponents& dateForReadOnlyField); + void setValueAsDate(const LayoutParameters&, const DateComponents&); void setValueAsDateTimeFieldsState(const DateTimeFieldsState&, const DateComponents& dateForReadOnlyField); DateTimeFieldsState valueAsDateTimeFieldsState() const; double valueAsDouble() const; @@ -99,7 +113,7 @@ private: size_t focusedFieldIndex() const; bool isDisabled() const; bool isReadOnly() const; - void layout(const StepRange&, const DateComponents&, Localizer&); + void layout(const LayoutParameters&, const DateComponents&); void updateUIState(); // DateTimeFieldElement::FieldOwner functions. diff --git a/Source/WebCore/html/track/WebVTTParser.cpp b/Source/WebCore/html/track/WebVTTParser.cpp index fe47d2258..297e5996b 100644 --- a/Source/WebCore/html/track/WebVTTParser.cpp +++ b/Source/WebCore/html/track/WebVTTParser.cpp @@ -351,7 +351,7 @@ void WebVTTParser::constructTreeFromToken(Document* document) case WebVTTTokenTypes::Character: { String content(m_token.characters().data(), m_token.characters().size()); RefPtr<Text> child = Text::create(document, content); - m_currentNode->parserAddChild(child); + m_currentNode->parserAppendChild(child); break; } case WebVTTTokenTypes::StartTag: { @@ -368,7 +368,7 @@ void WebVTTParser::constructTreeFromToken(Document* document) child->setAttribute(classAttr, AtomicString(m_token.classes().data(), m_token.classes().size())); if (child->hasTagName(qTag)) child->setAttribute(titleAttr, AtomicString(m_token.annotation().data(), m_token.annotation().size())); - m_currentNode->parserAddChild(child); + m_currentNode->parserAppendChild(child); m_currentNode = child; } break; @@ -385,7 +385,7 @@ void WebVTTParser::constructTreeFromToken(Document* document) unsigned position = 0; double time = collectTimeStamp(m_token.characters().data(), &position); if (time != malformedTime) - m_currentNode->parserAddChild(ProcessingInstruction::create(document, "timestamp", String(m_token.characters().data(), m_token.characters().size()))); + m_currentNode->parserAppendChild(ProcessingInstruction::create(document, "timestamp", String(m_token.characters().data(), m_token.characters().size()))); break; } default: |