HRESULT STDMETHODCALLTYPE DOMElement::font(WebFontDescription* webFontDescription) { if (!webFontDescription) { ASSERT_NOT_REACHED(); return E_POINTER; } ASSERT(m_element); WebCore::RenderElement* renderer = m_element->renderer(); if (!renderer) return E_FAIL; FontDescription fontDescription = renderer->style().fontCascade().fontDescription(); AtomicString family = fontDescription.firstFamily(); // FIXME: This leaks. Delete this whole function to get rid of the leak. UChar* familyCharactersBuffer = new UChar[family.length()]; StringView(family.string()).getCharactersWithUpconvert(familyCharactersBuffer); webFontDescription->family = familyCharactersBuffer; webFontDescription->familyLength = family.length(); webFontDescription->size = fontDescription.computedSize(); webFontDescription->bold = fontDescription.weight() >= WebCore::FontWeight600; webFontDescription->italic = fontDescription.italic(); return S_OK; }
HRESULT STDMETHODCALLTYPE DOMElement::font(WebFontDescription* webFontDescription) { if (!webFontDescription) { ASSERT_NOT_REACHED(); return E_POINTER; } ASSERT(m_element); WebCore::RenderElement* renderer = m_element->renderer(); if (!renderer) return E_FAIL; FontDescription fontDescription = renderer->style().font().fontDescription(); AtomicString family = fontDescription.firstFamily(); webFontDescription->family = family.characters(); webFontDescription->familyLength = family.length(); webFontDescription->size = fontDescription.computedSize(); webFontDescription->bold = fontDescription.weight() >= WebCore::FontWeight600; webFontDescription->italic = fontDescription.italic(); return S_OK; }