Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: Source/core/html/shadow/MediaControlElementTypes.cpp

Issue 195473002: Let MediaControls use the parent HTMLMediaElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 18 matching lines...) Expand all
29 29
30 #include "config.h" 30 #include "config.h"
31 31
32 #include "core/html/shadow/MediaControlElementTypes.h" 32 #include "core/html/shadow/MediaControlElementTypes.h"
33 33
34 #include "CSSValueKeywords.h" 34 #include "CSSValueKeywords.h"
35 #include "HTMLNames.h" 35 #include "HTMLNames.h"
36 #include "bindings/v8/ExceptionStatePlaceholder.h" 36 #include "bindings/v8/ExceptionStatePlaceholder.h"
37 #include "core/css/StylePropertySet.h" 37 #include "core/css/StylePropertySet.h"
38 #include "core/events/MouseEvent.h" 38 #include "core/events/MouseEvent.h"
39 #include "core/html/HTMLMediaElement.h"
40 #include "core/html/MediaController.h"
39 41
40 namespace WebCore { 42 namespace WebCore {
41 43
42 using namespace HTMLNames; 44 using namespace HTMLNames;
43 45
44 class Event; 46 class Event;
45 47
46 HTMLMediaElement* toParentMediaElement(Node* node) 48 HTMLMediaElement* toParentMediaElement(Node* node)
47 { 49 {
48 if (!node) 50 if (!node)
49 return 0; 51 return 0;
50 Node* mediaNode = node->shadowHost(); 52 Node* mediaNode = node->shadowHost();
51 if (!mediaNode) 53 if (!mediaNode)
52 mediaNode = node; 54 mediaNode = node;
53 if (!mediaNode || !mediaNode->isElementNode() || !toElement(mediaNode)->isMe diaElement()) 55 if (!mediaNode || !mediaNode->isElementNode() || !toElement(mediaNode)->isMe diaElement())
54 return 0; 56 return 0;
55 57
56 return toHTMLMediaElement(mediaNode); 58 return toHTMLMediaElement(mediaNode);
57 } 59 }
58 60
59 MediaControlElementType mediaControlElementType(Node* node) 61 MediaControlElementType mediaControlElementType(Node* node)
60 { 62 {
61 ASSERT_WITH_SECURITY_IMPLICATION(node->isMediaControlElement()); 63 ASSERT_WITH_SECURITY_IMPLICATION(node->isMediaControlElement());
62 HTMLElement* element = toHTMLElement(node); 64 HTMLElement* element = toHTMLElement(node);
63 if (element->hasTagName(inputTag)) 65 if (element->hasTagName(inputTag))
64 return static_cast<MediaControlInputElement*>(element)->displayType(); 66 return static_cast<MediaControlInputElement*>(element)->displayType();
65 return static_cast<MediaControlDivElement*>(element)->displayType(); 67 return static_cast<MediaControlDivElement*>(element)->displayType();
66 } 68 }
67 69
68 MediaControlElement::MediaControlElement(MediaControlElementType displayType, HT MLElement* element) 70 MediaControlElement::MediaControlElement(HTMLMediaElement& mediaElement, MediaCo ntrolElementType displayType, HTMLElement* element)
acolwell GONE FROM CHROMIUM 2014/03/12 00:22:32 WDYT about handing in MediaControls into these bas
philipj_slow 2014/03/12 04:30:11 I started writing this patch before merging MediaC
69 : m_mediaController(0) 71 : m_mediaElement(mediaElement)
70 , m_displayType(displayType) 72 , m_displayType(displayType)
71 , m_element(element) 73 , m_element(element)
72 { 74 {
73 } 75 }
74 76
77 MediaControllerInterface& MediaControlElement::mediaControllerInterface() const
78 {
79 if (m_mediaElement.controller())
80 return *m_mediaElement.controller();
81 return m_mediaElement;
82 }
83
75 void MediaControlElement::hide() 84 void MediaControlElement::hide()
76 { 85 {
77 m_element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); 86 m_element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
78 } 87 }
79 88
80 void MediaControlElement::show() 89 void MediaControlElement::show()
81 { 90 {
82 m_element->removeInlineStyleProperty(CSSPropertyDisplay); 91 m_element->removeInlineStyleProperty(CSSPropertyDisplay);
83 } 92 }
84 93
85 void MediaControlElement::setDisplayType(MediaControlElementType displayType) 94 void MediaControlElement::setDisplayType(MediaControlElementType displayType)
86 { 95 {
87 if (displayType == m_displayType) 96 if (displayType == m_displayType)
88 return; 97 return;
89 98
90 m_displayType = displayType; 99 m_displayType = displayType;
91 if (RenderObject* object = m_element->renderer()) 100 if (RenderObject* object = m_element->renderer())
92 object->repaint(); 101 object->repaint();
93 } 102 }
94 103
95 // ---------------------------- 104 // ----------------------------
96 105
97 MediaControlDivElement::MediaControlDivElement(Document& document, MediaControlE lementType displayType) 106 MediaControlDivElement::MediaControlDivElement(HTMLMediaElement& mediaElement, M ediaControlElementType displayType)
98 : HTMLDivElement(document) 107 : HTMLDivElement(mediaElement.document())
99 , MediaControlElement(displayType, this) 108 , MediaControlElement(mediaElement, displayType, this)
100 { 109 {
101 } 110 }
102 111
103 // ---------------------------- 112 // ----------------------------
104 113
105 MediaControlInputElement::MediaControlInputElement(Document& document, MediaCont rolElementType displayType) 114 MediaControlInputElement::MediaControlInputElement(HTMLMediaElement& mediaElemen t, MediaControlElementType displayType)
106 : HTMLInputElement(document, 0, false) 115 : HTMLInputElement(mediaElement.document(), 0, false)
107 , MediaControlElement(displayType, this) 116 , MediaControlElement(mediaElement, displayType, this)
108 { 117 {
109 } 118 }
110 119
111 bool MediaControlInputElement::isMouseFocusable() const 120 bool MediaControlInputElement::isMouseFocusable() const
112 { 121 {
113 return false; 122 return false;
114 } 123 }
115 124
116 // ---------------------------- 125 // ----------------------------
117 126
118 MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(Document& documen t, MediaControlElementType displayType) 127 MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(HTMLMediaElement& mediaElement, MediaControlElementType displayType)
119 : MediaControlDivElement(document, displayType) 128 : MediaControlDivElement(mediaElement, displayType)
120 , m_currentValue(0) 129 , m_currentValue(0)
121 { 130 {
122 } 131 }
123 132
124 void MediaControlTimeDisplayElement::setCurrentValue(double time) 133 void MediaControlTimeDisplayElement::setCurrentValue(double time)
125 { 134 {
126 m_currentValue = time; 135 m_currentValue = time;
127 } 136 }
128 137
129 } // namespace WebCore 138 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698