diff options
Diffstat (limited to 'WebCore/html')
-rw-r--r-- | WebCore/html/HTMLAudioElement.cpp | 20 | ||||
-rw-r--r-- | WebCore/html/HTMLAudioElement.h | 10 | ||||
-rw-r--r-- | WebCore/html/HTMLFrameElementBase.cpp | 19 | ||||
-rw-r--r-- | WebCore/html/HTMLFrameElementBase.h | 3 | ||||
-rw-r--r-- | WebCore/html/HTMLFrameOwnerElement.h | 1 | ||||
-rw-r--r-- | WebCore/html/HTMLImageElement.cpp | 27 | ||||
-rw-r--r-- | WebCore/html/HTMLImageElement.h | 7 | ||||
-rw-r--r-- | WebCore/html/HTMLInputElement.cpp | 187 | ||||
-rw-r--r-- | WebCore/html/HTMLInputElement.h | 19 | ||||
-rw-r--r-- | WebCore/html/HTMLMediaElement.cpp | 28 | ||||
-rw-r--r-- | WebCore/html/HTMLMediaElement.h | 11 | ||||
-rw-r--r-- | WebCore/html/HTMLOptionElement.cpp | 41 | ||||
-rw-r--r-- | WebCore/html/HTMLOptionElement.h | 10 | ||||
-rw-r--r-- | WebCore/html/HTMLPlugInElement.cpp | 6 | ||||
-rw-r--r-- | WebCore/html/HTMLVideoElement.h | 2 | ||||
-rw-r--r-- | WebCore/html/ValidityState.cpp | 4 |
16 files changed, 269 insertions, 126 deletions
diff --git a/WebCore/html/HTMLAudioElement.cpp b/WebCore/html/HTMLAudioElement.cpp index 6adf9ea..347b8c4 100644 --- a/WebCore/html/HTMLAudioElement.cpp +++ b/WebCore/html/HTMLAudioElement.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,7 +21,7 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" @@ -34,11 +35,22 @@ namespace WebCore { using namespace HTMLNames; -HTMLAudioElement::HTMLAudioElement(const QualifiedName& tagName, Document* doc) - : HTMLMediaElement(tagName, doc) +HTMLAudioElement::HTMLAudioElement(const QualifiedName& tagName, Document* document) + : HTMLMediaElement(tagName, document) { ASSERT(hasTagName(audioTag)); } +PassRefPtr<HTMLAudioElement> HTMLAudioElement::createForJSConstructor(Document* document, const String& src) +{ + RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(audioTag, document); + audio->setAutobuffer(true); + if (!src.isNull()) { + audio->setSrc(src); + audio->scheduleLoad(); + } + return audio.release(); +} + } #endif diff --git a/WebCore/html/HTMLAudioElement.h b/WebCore/html/HTMLAudioElement.h index 1dbe44f..2f06f1a 100644 --- a/WebCore/html/HTMLAudioElement.h +++ b/WebCore/html/HTMLAudioElement.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,7 +21,7 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef HTMLAudioElement_h @@ -28,14 +29,17 @@ #if ENABLE(VIDEO) +#include "Document.h" #include "HTMLMediaElement.h" namespace WebCore { class HTMLAudioElement : public HTMLMediaElement { public: + static PassRefPtr<HTMLAudioElement> createForJSConstructor(Document*, const String& src); HTMLAudioElement(const QualifiedName&, Document*); - +private: + virtual bool isVideo() const { return false; } virtual int tagPriority() const { return 5; } }; diff --git a/WebCore/html/HTMLFrameElementBase.cpp b/WebCore/html/HTMLFrameElementBase.cpp index 3890850..9d84b62 100644 --- a/WebCore/html/HTMLFrameElementBase.cpp +++ b/WebCore/html/HTMLFrameElementBase.cpp @@ -150,7 +150,7 @@ void HTMLFrameElementBase::parseMappedAttribute(MappedAttribute *attr) HTMLFrameOwnerElement::parseMappedAttribute(attr); } -void HTMLFrameElementBase::setNameAndOpenURL() +void HTMLFrameElementBase::setName() { m_frameName = getAttribute(nameAttr); if (m_frameName.isNull()) @@ -158,7 +158,11 @@ void HTMLFrameElementBase::setNameAndOpenURL() if (Frame* parentFrame = document()->frame()) m_frameName = parentFrame->tree()->uniqueChildName(m_frameName); - +} + +void HTMLFrameElementBase::setNameAndOpenURL() +{ + setName(); openURL(); } @@ -167,6 +171,14 @@ void HTMLFrameElementBase::setNameAndOpenURLCallback(Node* n) static_cast<HTMLFrameElementBase*>(n)->setNameAndOpenURL(); } +void HTMLFrameElementBase::updateOnReparenting() +{ + ASSERT(m_remainsAliveOnRemovalFromTree); + + if (Frame* frame = contentFrame()) + frame->transferChildFrameToNewDocument(); +} + void HTMLFrameElementBase::insertedIntoDocument() { HTMLFrameOwnerElement::insertedIntoDocument(); @@ -175,6 +187,9 @@ void HTMLFrameElementBase::insertedIntoDocument() // Othewise, a synchronous load that executed JavaScript would see incorrect // (0) values for the frame's renderer-dependent properties, like width. m_shouldOpenURLAfterAttach = true; + + if (m_remainsAliveOnRemovalFromTree) + updateOnReparenting(); } void HTMLFrameElementBase::removedFromDocument() diff --git a/WebCore/html/HTMLFrameElementBase.h b/WebCore/html/HTMLFrameElementBase.h index ea93ae7..7717df0 100644 --- a/WebCore/html/HTMLFrameElementBase.h +++ b/WebCore/html/HTMLFrameElementBase.h @@ -64,8 +64,11 @@ private: virtual bool isURLAttribute(Attribute*) const; + virtual void setName(); + virtual void willRemove(); void checkAttachedTimerFired(Timer<HTMLFrameElementBase>*); + void updateOnReparenting(); bool viewSourceMode() const { return m_viewSource; } diff --git a/WebCore/html/HTMLFrameOwnerElement.h b/WebCore/html/HTMLFrameOwnerElement.h index 4a56e45..804ab22 100644 --- a/WebCore/html/HTMLFrameOwnerElement.h +++ b/WebCore/html/HTMLFrameOwnerElement.h @@ -59,6 +59,7 @@ protected: private: friend class Frame; + virtual void setName() { } virtual bool isFrameOwnerElement() const { return true; } virtual bool isKeyboardFocusable(KeyboardEvent*) const { return m_contentFrame; } diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp index 4592461..d3cea92 100644 --- a/WebCore/html/HTMLImageElement.cpp +++ b/WebCore/html/HTMLImageElement.cpp @@ -1,7 +1,8 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -58,6 +59,16 @@ HTMLImageElement::~HTMLImageElement() m_form->removeImgElement(this); } +PassRefPtr<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document* document, const int* optionalWidth, const int* optionalHeight) +{ + RefPtr<HTMLImageElement> image = new HTMLImageElement(imgTag, document); + if (optionalWidth) + image->setWidth(*optionalWidth); + if (optionalHeight > 0) + image->setHeight(*optionalHeight); + return image.release(); +} + bool HTMLImageElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const { if (attrName == widthAttr || @@ -68,7 +79,7 @@ bool HTMLImageElement::mapToEntry(const QualifiedName& attrName, MappedAttribute result = eUniversal; return false; } - + if (attrName == borderAttr || attrName == alignAttr) { result = eReplaced; // Shared with embed and iframe elements. return false; @@ -161,7 +172,7 @@ RenderObject* HTMLImageElement::createRenderer(RenderArena* arena, RenderStyle* { if (style->contentData()) return RenderObject::createObject(this, style); - + return new (arena) RenderImage(this); } @@ -174,7 +185,7 @@ void HTMLImageElement::attach() if (imageObj->hasImage()) return; imageObj->setCachedImage(m_imageLoader.image()); - + // If we have no image at all because we have no src attribute, set // image height and width for the alt text instead. if (!m_imageLoader.image() && !imageObj->cachedImage()) @@ -241,7 +252,7 @@ int HTMLImageElement::width(bool ignorePendingStylesheets) const int width = getAttribute(widthAttr).toInt(&ok); if (ok) return width; - + // if the image is available, use its width if (m_imageLoader.image()) { float zoomFactor = document()->frame() ? document()->frame()->pageZoomFactor() : 1.0f; @@ -265,7 +276,7 @@ int HTMLImageElement::height(bool ignorePendingStylesheets) const int height = getAttribute(heightAttr).toInt(&ok); if (ok) return height; - + // if the image is available, use its height if (m_imageLoader.image()) { float zoomFactor = document()->frame() ? document()->frame()->pageZoomFactor() : 1.0f; @@ -293,10 +304,10 @@ int HTMLImageElement::naturalHeight() const { if (!m_imageLoader.image()) return 0; - + return m_imageLoader.image()->imageSize(1.0f).height(); } - + bool HTMLImageElement::isURLAttribute(Attribute* attr) const { return attr->name() == srcAttr diff --git a/WebCore/html/HTMLImageElement.h b/WebCore/html/HTMLImageElement.h index 14e5fa3..d7df1dc 100644 --- a/WebCore/html/HTMLImageElement.h +++ b/WebCore/html/HTMLImageElement.h @@ -1,7 +1,8 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -34,6 +35,8 @@ class HTMLFormElement; class HTMLImageElement : public HTMLElement { friend class HTMLFormElement; public: + static PassRefPtr<HTMLImageElement> createForJSConstructor(Document*, const int* optionalWidth, const int* optionalHeight); + HTMLImageElement(const QualifiedName&, Document*, HTMLFormElement* = 0); ~HTMLImageElement(); @@ -53,7 +56,7 @@ public: int naturalWidth() const; int naturalHeight() const; - + bool isServerMap() const { return ismap && usemap.isEmpty(); } String altText() const; diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp index ee0c75d..c3f6703 100644 --- a/WebCore/html/HTMLInputElement.cpp +++ b/WebCore/html/HTMLInputElement.cpp @@ -503,7 +503,7 @@ bool HTMLInputElement::stepMismatch() const return false; case NUMBER: { double doubleValue; - if (!formStringToDouble(value(), &doubleValue)) + if (!parseToDoubleForNumberType(value(), &doubleValue)) return false; doubleValue = fabs(doubleValue - stepBase()); if (isinf(doubleValue)) @@ -624,7 +624,7 @@ bool HTMLInputElement::getAllowedValueStep(double* step) const if (equalIgnoringCase(stepString, "any")) return false; double parsed; - if (!formStringToDouble(stepString, &parsed) || parsed <= 0.0) { + if (!parseToDoubleForNumberType(stepString, &parsed) || parsed <= 0.0) { *step = defaultStep * stepScaleFactor; return true; } @@ -1618,7 +1618,7 @@ double HTMLInputElement::parseToDouble(const String& src, double defaultValue) c case TIME: case WEEK: { DateComponents date; - if (!formStringToDateComponents(inputType(), src, &date)) + if (!parseToDateComponents(inputType(), src, &date)) return defaultValue; double msec = date.millisecondsSinceEpoch(); ASSERT(isfinite(msec)); @@ -1626,7 +1626,7 @@ double HTMLInputElement::parseToDouble(const String& src, double defaultValue) c } case MONTH: { DateComponents date; - if (!formStringToDateComponents(inputType(), src, &date)) + if (!parseToDateComponents(inputType(), src, &date)) return defaultValue; double months = date.monthsSinceEpoch(); ASSERT(isfinite(months)); @@ -1635,7 +1635,7 @@ double HTMLInputElement::parseToDouble(const String& src, double defaultValue) c case NUMBER: case RANGE: { double numberValue; - if (!formStringToDouble(src, &numberValue)) + if (!parseToDoubleForNumberType(src, &numberValue)) return defaultValue; ASSERT(isfinite(numberValue)); return numberValue; @@ -1673,7 +1673,7 @@ double HTMLInputElement::valueAsDate() const return parseToDouble(value(), DateComponents::invalidMilliseconds()); case MONTH: { DateComponents date; - if (!formStringToDateComponents(inputType(), value(), &date)) + if (!parseToDateComponents(inputType(), value(), &date)) return DateComponents::invalidMilliseconds(); double msec = date.millisecondsSinceEpoch(); ASSERT(isfinite(msec)); @@ -1707,24 +1707,22 @@ double HTMLInputElement::valueAsDate() const void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec) { - DateComponents date; - bool success; switch (inputType()) { case DATE: - success = date.setMillisecondsSinceEpochForDate(value); - break; case DATETIME: - success = date.setMillisecondsSinceEpochForDateTime(value); - break; - case MONTH: - success = date.setMillisecondsSinceEpochForMonth(value); - break; case TIME: - success = date.setMillisecondsSinceMidnight(value); - break; case WEEK: - success = date.setMillisecondsSinceEpochForWeek(value); - break; + setValue(serializeForDateTimeTypes(value)); + return; + case MONTH: { + DateComponents date; + if (!date.setMillisecondsSinceEpochForMonth(value)) { + setValue(String()); + return; + } + setValue(date.toString()); + return; + } case BUTTON: case CHECKBOX: case COLOR: @@ -1746,33 +1744,8 @@ void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec) case URL: ec = INVALID_STATE_ERR; return; - default: - ASSERT_NOT_REACHED(); - success = false; } - if (!success) { - setValue(String()); - return; - } - setDateValue(date); -} - -void HTMLInputElement::setDateValue(const DateComponents& date) -{ - double step; - if (!getAllowedValueStep(&step)) { - setValue(date.toString()); - return; - } - if (!fmod(step, msecPerMinute)) { - setValue(date.toString(DateComponents::None)); - return; - } - if (!fmod(step, msecPerSecond)) { - setValue(date.toString(DateComponents::Second)); - return; - } - setValue(date.toString(DateComponents::Millisecond)); + ASSERT_NOT_REACHED(); } double HTMLInputElement::valueAsNumber() const @@ -1820,32 +1793,109 @@ void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec) switch (inputType()) { case DATE: case DATETIME: + case DATETIMELOCAL: + case MONTH: + case NUMBER: + case RANGE: case TIME: case WEEK: - setValueAsDate(newValue, ec); + setValue(serialize(newValue)); return; - case MONTH: { - DateComponents date; - if (!date.setMonthsSinceEpoch(newValue)) { - setValue(String()); - return; - } - setValue(date.toString()); + + case BUTTON: + case CHECKBOX: + case COLOR: + case EMAIL: + case FILE: + case HIDDEN: + case IMAGE: + case ISINDEX: + case PASSWORD: + case RADIO: + case RESET: + case SEARCH: + case SUBMIT: + case TELEPHONE: + case TEXT: + case URL: + ec = INVALID_STATE_ERR; return; } - case DATETIMELOCAL: { - DateComponents date; - if (!date.setMillisecondsSinceEpochForDateTimeLocal(newValue)) { - setValue(String()); - return; - } - setDateValue(date); - return; + ASSERT_NOT_REACHED(); +} + +String HTMLInputElement::serializeForDateTimeTypes(double value) const +{ + bool success = false; + DateComponents date; + switch (inputType()) { + case DATE: + success = date.setMillisecondsSinceEpochForDate(value); + break; + case DATETIME: + success = date.setMillisecondsSinceEpochForDateTime(value); + break; + case DATETIMELOCAL: + success = date.setMillisecondsSinceEpochForDateTimeLocal(value); + break; + case MONTH: + success = date.setMonthsSinceEpoch(value); + break; + case TIME: + success = date.setMillisecondsSinceMidnight(value); + break; + case WEEK: + success = date.setMillisecondsSinceEpochForWeek(value); + break; + case NUMBER: + case RANGE: + case BUTTON: + case CHECKBOX: + case COLOR: + case EMAIL: + case FILE: + case HIDDEN: + case IMAGE: + case ISINDEX: + case PASSWORD: + case RADIO: + case RESET: + case SEARCH: + case SUBMIT: + case TELEPHONE: + case TEXT: + case URL: + ASSERT_NOT_REACHED(); + return String(); } + if (!success) + return String(); + + double step; + if (!getAllowedValueStep(&step)) + return date.toString(); + if (!fmod(step, msecPerMinute)) + return date.toString(DateComponents::None); + if (!fmod(step, msecPerSecond)) + return date.toString(DateComponents::Second); + return date.toString(DateComponents::Millisecond); +} + +String HTMLInputElement::serialize(double value) const +{ + if (!isfinite(value)) + return String(); + switch (inputType()) { + case DATE: + case DATETIME: + case DATETIMELOCAL: + case MONTH: + case TIME: + case WEEK: + return serializeForDateTimeTypes(value); case NUMBER: case RANGE: - setValue(formStringFromDouble(newValue)); - return; + return serializeForNumberType(value); case BUTTON: case CHECKBOX: @@ -1863,11 +1913,10 @@ void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec) case TELEPHONE: case TEXT: case URL: - ec = INVALID_STATE_ERR; - return; + break; } ASSERT_NOT_REACHED(); - return; + return String(); } String HTMLInputElement::placeholder() const @@ -2573,7 +2622,7 @@ bool HTMLInputElement::willValidate() const inputType() != BUTTON && inputType() != RESET; } -String HTMLInputElement::formStringFromDouble(double number) +String HTMLInputElement::serializeForNumberType(double number) { // According to HTML5, "the best representation of the number n as a floating // point number" is a string produced by applying ToString() to n. @@ -2583,7 +2632,7 @@ String HTMLInputElement::formStringFromDouble(double number) return String(buffer, length); } -bool HTMLInputElement::formStringToDouble(const String& src, double* out) +bool HTMLInputElement::parseToDoubleForNumberType(const String& src, double* out) { // See HTML5 2.4.4.3 `Real numbers.' @@ -2609,7 +2658,7 @@ bool HTMLInputElement::formStringToDouble(const String& src, double* out) return true; } -bool HTMLInputElement::formStringToDateComponents(InputType type, const String& formString, DateComponents* out) +bool HTMLInputElement::parseToDateComponents(InputType type, const String& formString, DateComponents* out) { if (formString.isEmpty()) return false; diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h index 4665437..40930ac 100644 --- a/WebCore/html/HTMLInputElement.h +++ b/WebCore/html/HTMLInputElement.h @@ -262,14 +262,14 @@ public: // Converts the specified string to a floating number. // If the conversion fails, the return value is false. Take care that leading or trailing unnecessary characters make failures. This returns false for an empty string input. // The double* parameter may be 0. - static bool formStringToDouble(const String&, double*); + static bool parseToDoubleForNumberType(const String&, double*); // Converts the specified number to a string. This is an implementation of // HTML5's "algorithm to convert a number to a string" for NUMBER/RANGE types. - static String formStringFromDouble(double); + static String serializeForNumberType(double); // Parses the specified string as the InputType, and returns true if it is successfully parsed. // An instance pointed by the DateComponents* parameter will have parsed values and be // modified even if the parsing fails. The DateComponents* parameter may be 0. - static bool formStringToDateComponents(InputType, const String&, DateComponents*); + static bool parseToDateComponents(InputType, const String&, DateComponents*); protected: virtual void willMoveToNewOwnerDocument(); @@ -305,11 +305,14 @@ private: // succeeds; Returns defaultValue otherwise. This function can // return NaN or Infinity only if defaultValue is NaN or Infinity. double parseToDouble(const String&, double defaultValue) const; - - // Generates a suitable string for the specified DateComponents and the - // step value, and calls setValue() with it. - void setDateValue(const DateComponents&); - + // Create a string representation of the specified double value for the + // current input type. If NaN or Infinity is specified, this returns an + // emtpy string. This should not be called for types without valueAsNumber. + String serialize(double) const; + // Create a string representation of the specified double value for the + // current input type. The type must be one of DATE, DATETIME, + // DATETIMELOCAL, MONTH, TIME, and WEEK. + String serializeForDateTimeTypes(double) const; #if ENABLE(DATALIST) HTMLDataListElement* dataList() const; diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp index 279aac7..12b93ef 100644 --- a/WebCore/html/HTMLMediaElement.cpp +++ b/WebCore/html/HTMLMediaElement.cpp @@ -664,8 +664,8 @@ void HTMLMediaElement::noneSupported() // 9 -Abort these steps. Until the load() method is invoked, the element won't attempt to load another resource. - if (isVideo()) - static_cast<HTMLVideoElement*>(this)->updatePosterImage(); + updatePosterImage(); + if (renderer()) renderer()->updateFromElement(); } @@ -743,9 +743,7 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state) else if (state == MediaPlayer::FormatError && m_loadState == LoadingFromSrcAttr) noneSupported(); - if (isVideo()) - static_cast<HTMLVideoElement*>(this)->updatePosterImage(); - + updatePosterImage(); return; } @@ -883,8 +881,8 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state) shouldUpdatePosterImage = true; } - if (shouldUpdatePosterImage && isVideo()) - static_cast<HTMLVideoElement*>(this)->updatePosterImage(); + if (shouldUpdatePosterImage) + updatePosterImage(); updatePlayState(); } @@ -1506,6 +1504,8 @@ void HTMLMediaElement::mediaPlayerRepaint(MediaPlayer*) beginProcessingMediaPlayerCallback(); if (renderer()) renderer()->repaint(); + + updatePosterImage(); endProcessingMediaPlayerCallback(); } @@ -1529,11 +1529,10 @@ bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*) return false; } -GraphicsLayer* HTMLMediaElement::mediaPlayerGraphicsLayer(MediaPlayer*) +void HTMLMediaElement::mediaPlayerRenderingModeChanged(MediaPlayer*) { - if (renderer() && renderer()->isVideo()) - return toRenderVideo(renderer())->videoGraphicsLayer(); - return 0; + // Kick off a fake recalcStyle that will update the compositing tree. + setNeedsStyleRecalc(SyntheticStyleChange); } #endif @@ -1878,6 +1877,13 @@ PlatformMedia HTMLMediaElement::platformMedia() const return m_player ? m_player->platformMedia() : NoPlatformMedia; } +#if USE(ACCELERATED_COMPOSITING) +PlatformLayer* HTMLMediaElement::platformLayer() const +{ + return m_player ? m_player->platformLayer() : 0; +} +#endif + bool HTMLMediaElement::hasClosedCaptions() const { return m_player && m_player->hasClosedCaptions(); diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h index 45a41c6..07801da 100644 --- a/WebCore/html/HTMLMediaElement.h +++ b/WebCore/html/HTMLMediaElement.h @@ -46,7 +46,6 @@ class TimeRanges; class HTMLMediaElement : public HTMLElement, public MediaPlayerClient { public: - HTMLMediaElement(const QualifiedName&, Document*); virtual ~HTMLMediaElement(); bool checkDTD(const Node* newChild); @@ -63,7 +62,7 @@ public: MediaPlayer* player() const { return m_player.get(); } - virtual bool isVideo() const { return false; } + virtual bool isVideo() const = 0; virtual bool hasVideo() const { return false; } virtual bool hasAudio() const; @@ -75,6 +74,9 @@ public: virtual bool supportsSave() const; PlatformMedia platformMedia() const; +#if USE(ACCELERATED_COMPOSITING) + PlatformLayer* platformLayer() const; +#endif void scheduleLoad(); @@ -174,12 +176,15 @@ public: bool processingUserGesture() const; protected: + HTMLMediaElement(const QualifiedName&, Document*); + float getTimeOffsetAttribute(const QualifiedName&, float valueOnError) const; void setTimeOffsetAttribute(const QualifiedName&, float value); virtual void documentWillBecomeInactive(); virtual void documentDidBecomeActive(); virtual void mediaVolumeDidChange(); + virtual void updatePosterImage() { } void setReadyState(MediaPlayer::ReadyState); void setNetworkState(MediaPlayer::NetworkState); @@ -200,7 +205,7 @@ private: // MediaPlayerClient virtual void mediaPlayerSizeChanged(MediaPlayer*); #if USE(ACCELERATED_COMPOSITING) virtual bool mediaPlayerRenderingCanBeAccelerated(MediaPlayer*); - virtual GraphicsLayer* mediaPlayerGraphicsLayer(MediaPlayer*); + virtual void mediaPlayerRenderingModeChanged(MediaPlayer*); #endif private: diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp index cab4e18..2752cbb 100644 --- a/WebCore/html/HTMLOptionElement.cpp +++ b/WebCore/html/HTMLOptionElement.cpp @@ -2,8 +2,9 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. * (C) 2006 Alexey Proskuryakov (ap@nypop.com) + * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -41,13 +42,33 @@ namespace WebCore { using namespace HTMLNames; -HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) - : HTMLFormControlElement(tagName, doc, f) +HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) + : HTMLFormControlElement(tagName, document, form) , m_style(0) { ASSERT(hasTagName(optionTag)); } +PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document* document, const String& data, const String& value, + bool defaultSelected, bool selected, ExceptionCode& ec) +{ + RefPtr<HTMLOptionElement> element = new HTMLOptionElement(optionTag, document); + + RefPtr<Text> text = Text::create(document, data.isNull() ? "" : data); + + ec = 0; + element->appendChild(text.release(), ec); + if (ec) + return 0; + + if (!value.isNull()) + element->setValue(value); + element->setDefaultSelected(defaultSelected); + element->setSelected(selected); + + return element.release(); +} + bool HTMLOptionElement::checkDTD(const Node* newChild) { return newChild->isTextNode() || newChild->hasTagName(scriptTag); @@ -178,7 +199,7 @@ HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const if (!select) return 0; - + return static_cast<HTMLSelectElement*>(select); } @@ -207,9 +228,9 @@ void HTMLOptionElement::setRenderStyle(PassRefPtr<RenderStyle> newStyle) m_style = newStyle; } -RenderStyle* HTMLOptionElement::nonRendererRenderStyle() const -{ - return m_style.get(); +RenderStyle* HTMLOptionElement::nonRendererRenderStyle() const +{ + return m_style.get(); } String HTMLOptionElement::textIndentedToRespectGroupLabel() const @@ -218,8 +239,8 @@ String HTMLOptionElement::textIndentedToRespectGroupLabel() const } bool HTMLOptionElement::disabled() const -{ - return ownElementDisabled() || (parentNode() && static_cast<HTMLFormControlElement*>(parentNode())->disabled()); +{ + return ownElementDisabled() || (parentNode() && static_cast<HTMLFormControlElement*>(parentNode())->disabled()); } void HTMLOptionElement::insertedIntoTree(bool deep) @@ -231,7 +252,7 @@ void HTMLOptionElement::insertedIntoTree(bool deep) select->setSelectedIndex(index(), false); select->scrollToSelection(); } - + HTMLFormControlElement::insertedIntoTree(deep); } diff --git a/WebCore/html/HTMLOptionElement.h b/WebCore/html/HTMLOptionElement.h index 7be9e9a..4255f25 100644 --- a/WebCore/html/HTMLOptionElement.h +++ b/WebCore/html/HTMLOptionElement.h @@ -3,6 +3,7 @@ * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Dirk Mueller (mueller@kde.org) * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -39,6 +40,9 @@ class HTMLOptionElement : public HTMLFormControlElement, public OptionElement { public: HTMLOptionElement(const QualifiedName&, Document*, HTMLFormElement* = 0); + static PassRefPtr<HTMLOptionElement> createForJSConstructor(Document*, const String& data, const String& value, + bool defaultSelected, bool selected, ExceptionCode&); + virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } virtual int tagPriority() const { return 2; } virtual bool checkDTD(const Node* newChild); @@ -48,7 +52,7 @@ public: virtual void attach(); virtual void detach(); virtual void setRenderStyle(PassRefPtr<RenderStyle>); - + virtual const AtomicString& formControlType() const; virtual String text() const; @@ -78,10 +82,10 @@ public: bool ownElementDisabled() const { return HTMLFormControlElement::disabled(); } virtual bool disabled() const; - + virtual void insertedIntoTree(bool); virtual void accessKeyAction(bool); - + private: virtual RenderStyle* nonRendererRenderStyle() const; diff --git a/WebCore/html/HTMLPlugInElement.cpp b/WebCore/html/HTMLPlugInElement.cpp index 9319034..51db115 100644 --- a/WebCore/html/HTMLPlugInElement.cpp +++ b/WebCore/html/HTMLPlugInElement.cpp @@ -151,6 +151,12 @@ bool HTMLPlugInElement::checkDTD(const Node* newChild) void HTMLPlugInElement::defaultEventHandler(Event* event) { + // Firefox seems to use a fake event listener to dispatch events to plug-in (tested with mouse events only). + // This is observable via different order of events - in Firefox, event listeners specified in HTML attributes fires first, then an event + // gets dispatched to plug-in, and only then other event listeners fire. Hopefully, this difference does not matter in practice. + + // FIXME: Mouse down and scroll events are passed down to plug-in via custom code in EventHandler; these code paths should be united. + RenderObject* r = renderer(); if (!r || !r->isWidget()) return; diff --git a/WebCore/html/HTMLVideoElement.h b/WebCore/html/HTMLVideoElement.h index a5c005c..d12667e 100644 --- a/WebCore/html/HTMLVideoElement.h +++ b/WebCore/html/HTMLVideoElement.h @@ -70,7 +70,6 @@ public: bool webkitSupportsFullscreen(); bool webkitDisplayingFullscreen(); - void updatePosterImage(); bool shouldDisplayPosterImage() const { return m_shouldDisplayPosterImage; } void paint(GraphicsContext*, const IntRect&); @@ -79,6 +78,7 @@ public: private: virtual bool hasAvailableVideoFrame() const; + virtual void updatePosterImage(); OwnPtr<HTMLImageLoader> m_imageLoader; KURL m_posterURL; diff --git a/WebCore/html/ValidityState.cpp b/WebCore/html/ValidityState.cpp index 1e0a07b..c6c58a5 100644 --- a/WebCore/html/ValidityState.cpp +++ b/WebCore/html/ValidityState.cpp @@ -80,7 +80,7 @@ bool ValidityState::typeMismatch() const case HTMLInputElement::COLOR: return !isValidColorString(value); case HTMLInputElement::NUMBER: - return !HTMLInputElement::formStringToDouble(value, 0); + return !HTMLInputElement::parseToDoubleForNumberType(value, 0); case HTMLInputElement::URL: return !KURL(KURL(), value).isValid(); case HTMLInputElement::EMAIL: { @@ -100,7 +100,7 @@ bool ValidityState::typeMismatch() const case HTMLInputElement::MONTH: case HTMLInputElement::TIME: case HTMLInputElement::WEEK: - return !HTMLInputElement::formStringToDateComponents(input->inputType(), value, 0); + return !HTMLInputElement::parseToDateComponents(input->inputType(), value, 0); case HTMLInputElement::BUTTON: case HTMLInputElement::CHECKBOX: case HTMLInputElement::FILE: |