Title: [175778] trunk/Source/WebCore
- Revision
- 175778
- Author
- cdu...@apple.com
- Date
- 2014-11-08 10:07:28 -0800 (Sat, 08 Nov 2014)
Log Message
Speed up HTMLInputElement::isEmptyValue()
https://bugs.webkit.org/show_bug.cgi?id=138515
Reviewed by Geoffrey Garen.
HTMLInputElement::isEmptyValue() was calling
HTMLTextFormControlElement::innerTextValue() which causes a full
subtree traversal to construct a string representation of that subtree
using a StringBuilder. In the case of HTMLInputElement::isEmptyValue(),
we don't have to do all this: We don't need to construct a String
and we can return false as soon as we find a non-empty descendant.
No new tests, no behavior change.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isEmptyValue):
* html/HTMLInputElement.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (175777 => 175778)
--- trunk/Source/WebCore/ChangeLog 2014-11-08 17:17:32 UTC (rev 175777)
+++ trunk/Source/WebCore/ChangeLog 2014-11-08 18:07:28 UTC (rev 175778)
@@ -1,3 +1,23 @@
+2014-11-08 Chris Dumez <cdu...@apple.com>
+
+ Speed up HTMLInputElement::isEmptyValue()
+ https://bugs.webkit.org/show_bug.cgi?id=138515
+
+ Reviewed by Geoffrey Garen.
+
+ HTMLInputElement::isEmptyValue() was calling
+ HTMLTextFormControlElement::innerTextValue() which causes a full
+ subtree traversal to construct a string representation of that subtree
+ using a StringBuilder. In the case of HTMLInputElement::isEmptyValue(),
+ we don't have to do all this: We don't need to construct a String
+ and we can return false as soon as we find a non-empty descendant.
+
+ No new tests, no behavior change.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::isEmptyValue):
+ * html/HTMLInputElement.h:
+
2014-11-07 Eric Carlson <eric.carl...@apple.com>
[iOS] video is sometimes allowed to play from the background
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (175777 => 175778)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2014-11-08 17:17:32 UTC (rev 175777)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2014-11-08 18:07:28 UTC (rev 175778)
@@ -62,6 +62,8 @@
#include "SearchInputType.h"
#include "StyleResolver.h"
#include "TextBreakIterator.h"
+#include "TextControlInnerElements.h"
+#include "TextNodeTraversal.h"
#include <wtf/MathExtras.h>
#include <wtf/Ref.h>
@@ -1676,6 +1678,21 @@
return m_inputType->updatePlaceholderText();
}
+bool HTMLInputElement::isEmptyValue() const
+{
+ if (!isTextField())
+ return true;
+
+ TextControlInnerTextElement* innerText = innerTextElement();
+ ASSERT(innerText);
+
+ for (Text* text = TextNodeTraversal::firstWithin(innerText); text; text = TextNodeTraversal::next(text, innerText)) {
+ if (text->length())
+ return false;
+ }
+ return true;
+}
+
void HTMLInputElement::parseMaxLengthAttribute(const AtomicString& value)
{
int maxLength;
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (175777 => 175778)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2014-11-08 17:17:32 UTC (rev 175777)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2014-11-08 18:07:28 UTC (rev 175778)
@@ -144,7 +144,7 @@
#endif
HTMLElement* containerElement() const;
- virtual TextControlInnerTextElement* innerTextElement() const override;
+ virtual TextControlInnerTextElement* innerTextElement() const override final;
HTMLElement* innerBlockElement() const;
HTMLElement* innerSpinButtonElement() const;
HTMLElement* resultsButtonElement() const;
@@ -341,7 +341,7 @@
virtual void updateFocusAppearance(bool restorePreviousSelection) override;
virtual bool shouldUseInputMethod() override final;
- virtual bool isTextFormControl() const override { return isTextField(); }
+ virtual bool isTextFormControl() const override final { return isTextField(); }
virtual bool canTriggerImplicitSubmission() const override { return isTextField(); }
@@ -389,7 +389,7 @@
virtual bool supportsPlaceholder() const override;
virtual void updatePlaceholderText() override;
- virtual bool isEmptyValue() const override { return innerTextValue().isEmpty(); }
+ virtual bool isEmptyValue() const override final;
virtual void handleFocusEvent(Node* oldFocusedNode, FocusDirection) override;
virtual void handleBlurEvent() override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes