- Revision
- 175380
- Author
- [email protected]
- Date
- 2014-10-30 14:25:30 -0700 (Thu, 30 Oct 2014)
Log Message
Optimize HTMLVideoElement / HTMLAudioElement type checks a bit
https://bugs.webkit.org/show_bug.cgi?id=138202
Reviewed by Benjamin Poulain.
Optimize HTMLVideoElement / HTMLAudioElement type checks a bit by:
1. Using is<HTMLMediaElement>() instead of
(is<HTMLVideoElement>() || is<HTMLAudioElement>()) if the caller is
interested in both video and audio elements. This is faster because
it ends up doing:
- virtual call to Element::isMediaElement()
instead of
- Node::isHTMLElement() +
virtual call to HTMLElement::isHTMLUnknownElement() +
2 * HTMLElement::hasTagName()
2. Updating HTMLVideoElement / HTMLAudioElement type traits
specializations to:
- Avoid doing any virtual function call if the input type is an
HTMLMediaElement (which is common in the code base).
- Speed up check if the input is an Element by doing:
- virtual call to Element::isMediaElement() +
HTMLElement::hasTagName()
instead of
- Node::isHTMLElement() +
virtual call to !HTMLElement::isHTMLUnknownElement() +
HTMLElement::hasTagName()
The speed stays the same if the input is a Node or an HTMLElement.
No new tests, no behavior change.
* css/CSSDefaultStyleSheets.cpp:
(WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
* dom/make_names.pl:
(defaultTagPropertyHash):
(printTypeHelpers):
* html/HTMLAudioElement.h:
(isType):
* html/HTMLImageLoader.cpp:
* html/HTMLTagNames.in:
* html/HTMLVideoElement.h:
(isType):
* page/ChromeClient.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (175379 => 175380)
--- trunk/Source/WebCore/ChangeLog 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/ChangeLog 2014-10-30 21:25:30 UTC (rev 175380)
@@ -1,3 +1,48 @@
+2014-10-30 Chris Dumez <[email protected]>
+
+ Optimize HTMLVideoElement / HTMLAudioElement type checks a bit
+ https://bugs.webkit.org/show_bug.cgi?id=138202
+
+ Reviewed by Benjamin Poulain.
+
+ Optimize HTMLVideoElement / HTMLAudioElement type checks a bit by:
+ 1. Using is<HTMLMediaElement>() instead of
+ (is<HTMLVideoElement>() || is<HTMLAudioElement>()) if the caller is
+ interested in both video and audio elements. This is faster because
+ it ends up doing:
+ - virtual call to Element::isMediaElement()
+ instead of
+ - Node::isHTMLElement() +
+ virtual call to HTMLElement::isHTMLUnknownElement() +
+ 2 * HTMLElement::hasTagName()
+ 2. Updating HTMLVideoElement / HTMLAudioElement type traits
+ specializations to:
+ - Avoid doing any virtual function call if the input type is an
+ HTMLMediaElement (which is common in the code base).
+ - Speed up check if the input is an Element by doing:
+ - virtual call to Element::isMediaElement() +
+ HTMLElement::hasTagName()
+ instead of
+ - Node::isHTMLElement() +
+ virtual call to !HTMLElement::isHTMLUnknownElement() +
+ HTMLElement::hasTagName()
+ The speed stays the same if the input is a Node or an HTMLElement.
+
+ No new tests, no behavior change.
+
+ * css/CSSDefaultStyleSheets.cpp:
+ (WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
+ * dom/make_names.pl:
+ (defaultTagPropertyHash):
+ (printTypeHelpers):
+ * html/HTMLAudioElement.h:
+ (isType):
+ * html/HTMLImageLoader.cpp:
+ * html/HTMLTagNames.in:
+ * html/HTMLVideoElement.h:
+ (isType):
+ * page/ChromeClient.h:
+
2014-10-30 Myles C. Maxfield <[email protected]>
Migrate ComplexTextControllerCoreText to use SPI instead of WKSI
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (175379 => 175380)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-10-30 21:25:30 UTC (rev 175380)
@@ -44,6 +44,7 @@
#include "FrameLoader.h"
#include "FrameSelection.h"
#include "HTMLAreaElement.h"
+#include "HTMLAudioElement.h"
#include "HTMLFormElement.h"
#include "HTMLFrameElementBase.h"
#include "HTMLImageElement.h"
@@ -57,6 +58,7 @@
#include "HTMLSelectElement.h"
#include "HTMLTableElement.h"
#include "HTMLTextAreaElement.h"
+#include "HTMLVideoElement.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
#include "Image.h"
Modified: trunk/Source/WebCore/css/CSSDefaultStyleSheets.cpp (175379 => 175380)
--- trunk/Source/WebCore/css/CSSDefaultStyleSheets.cpp 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/css/CSSDefaultStyleSheets.cpp 2014-10-30 21:25:30 UTC (rev 175380)
@@ -177,7 +177,7 @@
#endif
#if ENABLE(VIDEO)
- if (!mediaControlsStyleSheet && (is<HTMLVideoElement>(element) || is<HTMLAudioElement>(element))) {
+ if (!mediaControlsStyleSheet && is<HTMLMediaElement>(element)) {
String mediaRules = RenderTheme::themeForPage(element.document().page())->mediaControlsStyleSheet();
if (mediaRules.isEmpty())
mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(mediaControlsUserAgentStyleSheet)) + RenderTheme::themeForPage(element.document().page())->extraMediaControlsStyleSheet();
Modified: trunk/Source/WebCore/dom/make_names.pl (175379 => 175380)
--- trunk/Source/WebCore/dom/make_names.pl 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/dom/make_names.pl 2014-10-30 21:25:30 UTC (rev 175380)
@@ -194,6 +194,7 @@
'wrapperOnlyIfMediaIsAvailable' => 0,
'conditional' => 0,
'runtimeConditional' => 0,
+ 'customTypeHelper' => 0,
);
}
@@ -634,10 +635,12 @@
}
for my $class (sort keys %classToTags) {
+ my $name = $classToTags{$class}[0];
+ next if $parsedTags{$name}{customTypeHelper};
# Skip classes that map to more than 1 tag.
my $tagCount = scalar @{$classToTags{$class}};
next if $tagCount > 1;
- my $name = $classToTags{$class}[0];
+
print F <<END
namespace WebCore {
class $class;
Modified: trunk/Source/WebCore/html/HTMLAudioElement.h (175379 => 175380)
--- trunk/Source/WebCore/html/HTMLAudioElement.h 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/html/HTMLAudioElement.h 2014-10-30 21:25:30 UTC (rev 175380)
@@ -45,7 +45,13 @@
virtual MediaSession::MediaType presentationType() const override { return MediaSession::Audio; }
};
-} //namespace
+} // namespace WebCore
-#endif
-#endif
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLAudioElement)
+ static bool isType(const WebCore::HTMLMediaElement& element) { return element.hasTagName(WebCore::HTMLNames::audioTag); }
+ static bool isType(const WebCore::Element& element) { return is<WebCore::HTMLMediaElement>(element) && isType(downcast<WebCore::HTMLMediaElement>(element)); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLMediaElement>(node) && isType(downcast<WebCore::HTMLMediaElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // ENABLE(VIDEO)
+#endif // HTMLAudioElement_h
Modified: trunk/Source/WebCore/html/HTMLImageLoader.cpp (175379 => 175380)
--- trunk/Source/WebCore/html/HTMLImageLoader.cpp 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/html/HTMLImageLoader.cpp 2014-10-30 21:25:30 UTC (rev 175380)
@@ -29,6 +29,7 @@
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "HTMLParserIdioms.h"
+#include "HTMLVideoElement.h"
#include "Settings.h"
#include "JSDOMWindowBase.h"
Modified: trunk/Source/WebCore/html/HTMLTagNames.in (175379 => 175380)
--- trunk/Source/WebCore/html/HTMLTagNames.in 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/html/HTMLTagNames.in 2014-10-30 21:25:30 UTC (rev 175380)
@@ -11,7 +11,7 @@
area
article interfaceName=HTMLElement
aside interfaceName=HTMLElement
-audio wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedByParser
+audio wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedByParser, customTypeHelper
b interfaceName=HTMLElement
base
basefont interfaceName=HTMLBaseFontElement
@@ -134,7 +134,7 @@
u interfaceName=HTMLElement
ul interfaceName=HTMLUListElement
var interfaceName=HTMLElement
-video wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedByParser
+video wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedByParser, customTypeHelper
wbr interfaceName=HTMLElement
xmp interfaceName=HTMLPreElement
noscript interfaceName=HTMLElement
Modified: trunk/Source/WebCore/html/HTMLVideoElement.h (175379 => 175380)
--- trunk/Source/WebCore/html/HTMLVideoElement.h 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/html/HTMLVideoElement.h 2014-10-30 21:25:30 UTC (rev 175380)
@@ -104,7 +104,13 @@
AtomicString m_defaultPosterURL;
};
-} //namespace
+} // namespace WebCore
-#endif
-#endif
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLVideoElement)
+ static bool isType(const WebCore::HTMLMediaElement& element) { return element.hasTagName(WebCore::HTMLNames::videoTag); }
+ static bool isType(const WebCore::Element& element) { return is<WebCore::HTMLMediaElement>(element) && isType(downcast<WebCore::HTMLMediaElement>(element)); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLMediaElement>(node) && isType(downcast<WebCore::HTMLMediaElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // ENABLE(VIDEO)
+#endif // HTMLVideoElement_h
Modified: trunk/Source/WebCore/page/ChromeClient.h (175379 => 175380)
--- trunk/Source/WebCore/page/ChromeClient.h 2014-10-30 21:17:30 UTC (rev 175379)
+++ trunk/Source/WebCore/page/ChromeClient.h 2014-10-30 21:25:30 UTC (rev 175380)
@@ -75,6 +75,7 @@
class GraphicsLayer;
class GraphicsLayerFactory;
class HTMLInputElement;
+class HTMLVideoElement;
class HitTestResult;
class IntRect;
class NavigationAction;