| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/html/MediaDocument.h" | 26 #include "core/html/MediaDocument.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 28 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "core/dom/ElementTraversal.h" | 30 #include "core/dom/ElementTraversal.h" |
| 31 #include "core/dom/RawDataDocumentParser.h" | 31 #include "core/dom/RawDataDocumentParser.h" |
| 32 #include "core/events/KeyboardEvent.h" | 32 #include "core/events/KeyboardEvent.h" |
| 33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 34 #include "core/html/HTMLAnchorElement.h" |
| 34 #include "core/html/HTMLBodyElement.h" | 35 #include "core/html/HTMLBodyElement.h" |
| 36 #include "core/html/HTMLDivElement.h" |
| 35 #include "core/html/HTMLHeadElement.h" | 37 #include "core/html/HTMLHeadElement.h" |
| 36 #include "core/html/HTMLHtmlElement.h" | 38 #include "core/html/HTMLHtmlElement.h" |
| 37 #include "core/html/HTMLMetaElement.h" | 39 #include "core/html/HTMLMetaElement.h" |
| 38 #include "core/html/HTMLSourceElement.h" | 40 #include "core/html/HTMLSourceElement.h" |
| 39 #include "core/html/HTMLVideoElement.h" | 41 #include "core/html/HTMLVideoElement.h" |
| 40 #include "core/loader/DocumentLoader.h" | 42 #include "core/loader/DocumentLoader.h" |
| 41 #include "core/loader/FrameLoader.h" | 43 #include "core/loader/FrameLoader.h" |
| 42 #include "core/loader/FrameLoaderClient.h" | 44 #include "core/loader/FrameLoaderClient.h" |
| 43 #include "platform/KeyboardCodes.h" | 45 #include "platform/KeyboardCodes.h" |
| 46 #include "platform/text/PlatformLocale.h" |
| 44 | 47 |
| 45 namespace blink { | 48 namespace blink { |
| 46 | 49 |
| 47 using namespace HTMLNames; | 50 using namespace HTMLNames; |
| 48 | 51 |
| 49 // FIXME: Share more code with PluginDocumentParser. | 52 // FIXME: Share more code with PluginDocumentParser. |
| 50 class MediaDocumentParser : public RawDataDocumentParser { | 53 class MediaDocumentParser : public RawDataDocumentParser { |
| 51 public: | 54 public: |
| 52 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc
ument) | 55 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc
ument) |
| 53 { | 56 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 94 |
| 92 RefPtrWillBeRawPtr<HTMLSourceElement> source = HTMLSourceElement::create(*do
cument()); | 95 RefPtrWillBeRawPtr<HTMLSourceElement> source = HTMLSourceElement::create(*do
cument()); |
| 93 source->setSrc(document()->url()); | 96 source->setSrc(document()->url()); |
| 94 | 97 |
| 95 if (DocumentLoader* loader = document()->loader()) | 98 if (DocumentLoader* loader = document()->loader()) |
| 96 source->setType(loader->responseMIMEType()); | 99 source->setType(loader->responseMIMEType()); |
| 97 | 100 |
| 98 media->appendChild(source.release()); | 101 media->appendChild(source.release()); |
| 99 | 102 |
| 100 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document
()); | 103 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document
()); |
| 101 body->appendChild(media.release()); | |
| 102 | 104 |
| 105 RefPtrWillBeRawPtr<HTMLDivElement> div = HTMLDivElement::create(*document())
; |
| 106 if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) { |
| 107 // Padding is used to compensate for the height of the download button s
o that the media element can still be centered. |
| 108 RefPtrWillBeRawPtr<HTMLDivElement> padding = HTMLDivElement::create(*doc
ument()); |
| 109 padding->setAttribute(heightAttr, "68px;"); |
| 110 div->appendChild(padding.release()); |
| 111 } |
| 112 |
| 113 div->appendChild(media.release()); |
| 114 |
| 115 if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) { |
| 116 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create
(*document()); |
| 117 anchor->setAttribute(downloadAttr, ""); |
| 118 anchor->setURL(document()->url()); |
| 119 anchor->setTextContent(document()->getCachedLocale(document()->contentLa
nguage()).queryString(WebLocalizedString::DownloadButtonLabel)); |
| 120 div->appendChild(anchor.release()); |
| 121 } |
| 122 |
| 123 body->appendChild(div.release()); |
| 103 rootElement->appendChild(head.release()); | 124 rootElement->appendChild(head.release()); |
| 104 rootElement->appendChild(body.release()); | 125 rootElement->appendChild(body.release()); |
| 105 | 126 |
| 106 m_didBuildDocumentStructure = true; | 127 m_didBuildDocumentStructure = true; |
| 107 } | 128 } |
| 108 | 129 |
| 109 void MediaDocumentParser::appendBytes(const char*, size_t) | 130 void MediaDocumentParser::appendBytes(const char*, size_t) |
| 110 { | 131 { |
| 111 if (m_didBuildDocumentStructure) | 132 if (m_didBuildDocumentStructure) |
| 112 return; | 133 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); | 166 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); |
| 146 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode
() == VKEY_MEDIA_PLAY_PAUSE) { | 167 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode
() == VKEY_MEDIA_PLAY_PAUSE) { |
| 147 // space or media key (play/pause) | 168 // space or media key (play/pause) |
| 148 video->togglePlayState(); | 169 video->togglePlayState(); |
| 149 event->setDefaultHandled(); | 170 event->setDefaultHandled(); |
| 150 } | 171 } |
| 151 } | 172 } |
| 152 } | 173 } |
| 153 | 174 |
| 154 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |