void VTTRegion::displayLastVTTCueBox() { WTF_LOG(Media, "VTTRegion::displayLastVTTCueBox"); ASSERT(m_cueContainer); // FIXME: This should not be causing recalc styles in a loop to set the "top" css // property to move elements. We should just scroll the text track cues on the // compositor with an animation. if (m_scrollTimer.isActive()) return; // If it's a scrolling region, add the scrolling class. if (isScrollingRegion()) m_cueContainer->classList().add(textTrackCueContainerScrollingClass(), ASSERT_NO_EXCEPTION); float regionBottom = m_regionDisplayTree->getBoundingClientRect()->bottom(); // Find first cue that is not entirely displayed and scroll it upwards. for (Element* child = ElementTraversal::firstChild(*m_cueContainer); child && !m_scrollTimer.isActive(); child = ElementTraversal::nextSibling(*child)) { ClientRect* clientRect = child->getBoundingClientRect(); float childTop = clientRect->top(); float childBottom = clientRect->bottom(); if (regionBottom >= childBottom) continue; float height = childBottom - childTop; m_currentTop -= std::min(height, childBottom - regionBottom); m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrimitiveValue::UnitType::Pixels); startTimer(); } }
static Element* elementFromCenter(Element& element) { ClientRect* clientRect = element.getBoundingClientRect(); int centerX = static_cast<int>((clientRect->left() + clientRect->right()) / 2); int centerY = static_cast<int>((clientRect->top() + clientRect->bottom()) / 2); return element.document().elementFromPoint(centerX , centerY); }
JSValue jsClientRectTop(ExecState* exec, JSValue slotBase, const Identifier&) { JSClientRect* castedThis = static_cast<JSClientRect*>(asObject(slotBase)); UNUSED_PARAM(exec); ClientRect* imp = static_cast<ClientRect*>(castedThis->impl()); JSValue result = jsNumber(exec, imp->top()); return result; }
static v8::Handle<v8::Value> topAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.ClientRect.top._get"); ClientRect* imp = V8ClientRect::toNative(info.Holder()); return v8::Number::New(imp->top()); }