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

Unified Diff: Source/core/dom/Element.cpp

Issue 1285393003: Element should check inActiveDocument before forcing layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 04d7e8fce0c9f31e9161920b8de3170e22aafe06..867994d7436361809eae0a4b2ccf62a810a3fd3e 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -444,6 +444,9 @@ bool Element::shouldIgnoreAttributeCase() const
void Element::scrollIntoView(bool alignToTop)
{
+ if (!inActiveDocument())
+ return;
+
document().updateLayoutIgnorePendingStylesheets();
if (!layoutObject())
@@ -459,6 +462,9 @@ void Element::scrollIntoView(bool alignToTop)
void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
{
+ if (!inActiveDocument())
+ return;
+
document().updateLayoutIgnorePendingStylesheets();
if (!layoutObject())
@@ -578,6 +584,8 @@ static double adjustForLocalZoom(LayoutUnit value, LayoutObject& layoutObject)
int Element::offsetLeft()
{
+ if (inActiveDocument())
+ return 0;
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
return lroundf(adjustForLocalZoom(layoutObject->offsetLeft(), *layoutObject));
@@ -586,6 +594,8 @@ int Element::offsetLeft()
int Element::offsetTop()
{
+ if (inActiveDocument())
+ return 0;
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
return lroundf(adjustForLocalZoom(layoutObject->pixelSnappedOffsetTop(), *layoutObject));
@@ -594,6 +604,8 @@ int Element::offsetTop()
int Element::offsetWidth()
{
+ if (inActiveDocument())
+ return 0;
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetWidth(), *layoutObject).round();
@@ -602,6 +614,8 @@ int Element::offsetWidth()
int Element::offsetHeight()
{
+ if (inActiveDocument())
+ return 0;
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetHeight(), *layoutObject).round();
@@ -610,6 +624,9 @@ int Element::offsetHeight()
Element* Element::offsetParent()
{
+ if (inActiveDocument())
+ return nullptr;
+
document().updateLayoutIgnorePendingStylesheets();
LayoutObject* layoutObject = this->layoutObject();
@@ -628,6 +645,9 @@ Element* Element::offsetParent()
int Element::clientLeft()
{
+ if (inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBox* layoutObject = layoutBox())
@@ -637,6 +657,9 @@ int Element::clientLeft()
int Element::clientTop()
{
+ if (inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBox* layoutObject = layoutBox())
@@ -646,6 +669,9 @@ int Element::clientTop()
int Element::clientWidth()
{
+ if (inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
// When in strict mode, clientWidth for the document element should return the width of the containing frame.
@@ -669,6 +695,9 @@ int Element::clientWidth()
int Element::clientHeight()
{
+ if (inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
// When in strict mode, clientHeight for the document element should return the height of the containing frame.
@@ -693,6 +722,9 @@ int Element::clientHeight()
double Element::scrollLeft()
{
+ if (inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
if (document().scrollingElement() == this) {
@@ -709,6 +741,9 @@ double Element::scrollLeft()
double Element::scrollTop()
{
+ if (inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
if (document().scrollingElement() == this) {
@@ -725,6 +760,9 @@ double Element::scrollTop()
void Element::setScrollLeft(double newLeft)
{
+ if (!inActiveDocument())
+ return;
+
document().updateLayoutIgnorePendingStylesheets();
newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft);
@@ -741,6 +779,9 @@ void Element::setScrollLeft(double newLeft)
void Element::setScrollTop(double newTop)
{
+ if (!inActiveDocument())
+ return;
+
document().updateLayoutIgnorePendingStylesheets();
newTop = ScrollableArea::normalizeNonFiniteScroll(newTop);
@@ -757,6 +798,9 @@ void Element::setScrollTop(double newTop)
int Element::scrollWidth()
{
+ if (!inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
if (document().scrollingElement() == this) {
@@ -772,6 +816,9 @@ int Element::scrollWidth()
int Element::scrollHeight()
{
+ if (!inActiveDocument())
+ return 0;
+
document().updateLayoutIgnorePendingStylesheets();
if (document().scrollingElement() == this) {
@@ -795,6 +842,9 @@ void Element::scrollBy(double x, double y)
void Element::scrollBy(const ScrollToOptions& scrollToOptions)
{
+ if (!inActiveDocument())
+ return;
+
// FIXME: This should be removed once scroll updates are processed only after
// the compositing update. See http://crbug.com/420741.
document().updateLayoutIgnorePendingStylesheets();
@@ -816,6 +866,9 @@ void Element::scrollTo(double x, double y)
void Element::scrollTo(const ScrollToOptions& scrollToOptions)
{
+ if (!inActiveDocument())
+ return;
+
// FIXME: This should be removed once scroll updates are processed only after
// the compositing update. See http://crbug.com/420741.
document().updateLayoutIgnorePendingStylesheets();
@@ -914,6 +967,9 @@ void Element::decrementProxyCount()
bool Element::hasNonEmptyLayoutSize() const
{
+ if (!inActiveDocument())
+ return false;
+
document().updateLayoutIgnorePendingStylesheets();
if (LayoutBoxModelObject* box = layoutBoxModelObject())
@@ -923,6 +979,9 @@ bool Element::hasNonEmptyLayoutSize() const
IntRect Element::boundsInViewportSpace()
{
+ if (!inActiveDocument())
+ return IntRect();
+
document().updateLayoutIgnorePendingStylesheets();
FrameView* view = document().view();
@@ -954,6 +1013,9 @@ IntRect Element::boundsInViewportSpace()
ClientRectList* Element::getClientRects()
{
+ if (!inActiveDocument())
+ return ClientRectList::create();
+
document().updateLayoutIgnorePendingStylesheets();
LayoutObject* elementLayoutObject = layoutObject();
@@ -971,6 +1033,9 @@ ClientRectList* Element::getClientRects()
ClientRect* Element::getBoundingClientRect()
{
+ if (!inActiveDocument())
+ return ClientRect::create();
+
document().updateLayoutIgnorePendingStylesheets();
Vector<FloatQuad> quads;
@@ -1009,14 +1074,16 @@ IntRect Element::screenRect() const
const AtomicString& Element::computedRole()
{
- document().updateLayoutIgnorePendingStylesheets();
+ if (inActiveDocument())
+ document().updateLayoutIgnorePendingStylesheets();
OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document());
return cache->get()->computedRoleForNode(this);
}
String Element::computedName()
{
- document().updateLayoutIgnorePendingStylesheets();
+ if (inActiveDocument())
+ document().updateLayoutIgnorePendingStylesheets();
OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document());
return cache->get()->computedNameForNode(this);
}
@@ -2270,15 +2337,12 @@ bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicStrin
void Element::focus(bool restorePreviousSelection, WebFocusType type, InputDeviceCapabilities* sourceCapabilities)
{
- if (!inDocument())
+ if (!inActiveDocument())
return;
if (document().focusedElement() == this)
return;
- if (!document().isActive())
- return;
-
document().updateLayoutIgnorePendingStylesheets();
if (!isFocusable())
return;
@@ -2557,7 +2621,8 @@ void Element::insertAdjacentHTML(const String& where, const String& markup, Exce
String Element::innerText()
{
// We need to update layout, since plainText uses line boxes in the layout tree.
- document().updateLayoutIgnorePendingStylesheets();
+ if (inActiveDocument())
+ document().updateLayoutIgnorePendingStylesheets();
if (!layoutObject())
return textContent(true);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698