Index: webkit/port/platform/graphics/UniscribeHelperTextRun.cpp |
=================================================================== |
--- webkit/port/platform/graphics/UniscribeHelperTextRun.cpp (revision 5490) |
+++ webkit/port/platform/graphics/UniscribeHelperTextRun.cpp (working copy) |
@@ -20,109 +20,116 @@ |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include "config.h" |
+#include "UniscribeHelperTextRun.h" |
-#include "UniscribeStateTextRun.h" |
- |
#include "ChromiumBridge.h" |
#include "Font.h" |
#include "SimpleFontData.h" |
-UniscribeStateTextRun::UniscribeStateTextRun(const WebCore::TextRun& run, |
- const WebCore::Font& font) |
- : UniscribeState(run.characters(), run.length(), run.rtl(), |
- font.primaryFont()->platformData().hfont(), |
- font.primaryFont()->platformData().scriptCache(), |
- font.primaryFont()->platformData().scriptFontProperties()), |
- font_(&font), |
- font_index_(0) { |
- set_directional_override(run.directionalOverride()); |
- set_letter_spacing(font.letterSpacing()); |
- set_space_width(font.spaceWidth()); |
- set_word_spacing(font.wordSpacing()); |
- set_ascent(font.primaryFont()->ascent()); |
+namespace WebCore { |
+UniscribeHelperTextRun::UniscribeHelperTextRun(const WebCore::TextRun& run, |
+ const WebCore::Font& font) |
+ : UniscribeHelper(run.characters(), run.length(), run.rtl(), |
+ font.primaryFont()->platformData().hfont(), |
+ font.primaryFont()->platformData().scriptCache(), |
+ font.primaryFont()->platformData().scriptFontProperties()) |
+ , m_font(&font) |
+ , m_fontIndex(0) |
+{ |
+ setDirectionalOverride(run.directionalOverride()); |
+ setLetterSpacing(font.letterSpacing()); |
+ setSpaceWidth(font.spaceWidth()); |
+ setWordSpacing(font.wordSpacing()); |
+ setAscent(font.primaryFont()->ascent()); |
+ |
Init(); |
// Padding is the amount to add to make justification happen. This |
// should be done after Init() so all the runs are already measured. |
if (run.padding() > 0) |
- Justify(run.padding()); |
+ Justify(run.padding()); |
} |
-UniscribeStateTextRun::UniscribeStateTextRun( |
+UniscribeHelperTextRun::UniscribeHelperTextRun( |
const wchar_t* input, |
- int input_length, |
- bool is_rtl, |
+ int inputLength, |
+ bool isRtl, |
HFONT hfont, |
- SCRIPT_CACHE* script_cache, |
- SCRIPT_FONTPROPERTIES* font_properties) |
- : UniscribeState(input, input_length, is_rtl, hfont, |
- script_cache, font_properties), |
- font_(NULL), |
- font_index_(-1) { |
+ SCRIPT_CACHE* scriptCache, |
+ SCRIPT_FONTPROPERTIES* fontProperties) |
+ : UniscribeHelper(input, inputLength, isRtl, hfont, |
+ scriptCache, fontProperties) |
+ , m_font(NULL) |
+ , m_fontIndex(-1) |
+{ |
} |
-void UniscribeStateTextRun::TryToPreloadFont(HFONT font) { |
- // Ask the browser to get the font metrics for this font. |
- // That will preload the font and it should now be accessible |
- // from the renderer. |
- WebCore::ChromiumBridge::ensureFontLoaded(font); |
+void UniscribeHelperTextRun::TryToPreloadFont(HFONT font) |
+{ |
+ // Ask the browser to get the font metrics for this font. |
+ // That will preload the font and it should now be accessible |
+ // from the renderer. |
+ WebCore::ChromiumBridge::ensureFontLoaded(font); |
} |
-bool UniscribeStateTextRun::NextWinFontData( |
+bool UniscribeHelperTextRun::NextWinFontData( |
HFONT* hfont, |
- SCRIPT_CACHE** script_cache, |
- SCRIPT_FONTPROPERTIES** font_properties, |
- int* ascent) { |
- // This check is necessary because NextWinFontData can be |
- // called again after we already ran out of fonts. fontDataAt |
- // behaves in a strange manner when the difference between |
- // param passed and # of fonts stored in WebKit::Font is |
- // larger than one. We can avoid this check by setting |
- // font_index_ to # of elements in hfonts_ when we run out |
- // of font. In that case, we'd have to go through a couple of |
- // more checks before returning false. |
- if (font_index_ == -1 || !font_) |
- return false; |
+ SCRIPT_CACHE** scriptCache, |
+ SCRIPT_FONTPROPERTIES** fontProperties, |
+ int* ascent) |
+{ |
+ // This check is necessary because NextWinFontData can be called again |
+ // after we already ran out of fonts. fontDataAt behaves in a strange |
+ // manner when the difference between param passed and # of fonts stored in |
+ // WebKit::Font is larger than one. We can avoid this check by setting |
+ // font_index_ to # of elements in hfonts_ when we run out of font. In that |
+ // case, we'd have to go through a couple of more checks before returning |
+ // false. |
+ if (m_fontIndex == -1 || !m_font) |
+ return false; |
- // If the font data for a fallback font requested is not |
- // yet retrieved, add them to our vectors. Note that '>' rather |
- // than '>=' is used to test that condition. primaryFont is not |
- // stored in hfonts_, and friends so that indices for fontDataAt |
- // and our vectors for font data are 1 off from each other. |
- // That is, when fully populated, hfonts_ and friends have |
- // one font fewer than what's contained in font_. |
- if (static_cast<size_t>(++font_index_) > hfonts_->size()) { |
- const WebCore::FontData *font_data; |
- font_data = font_->fontDataAt(font_index_); |
- if (!font_data) { |
- // run out of fonts |
- font_index_ = -1; |
- return false; |
- } |
+ // If the font data for a fallback font requested is not yet retrieved, add |
+ // them to our vectors. Note that '>' rather than '>=' is used to test that |
+ // condition. primaryFont is not stored in hfonts_, and friends so that |
+ // indices for fontDataAt and our vectors for font data are 1 off from each |
+ // other. That is, when fully populated, hfonts_ and friends have one font |
+ // fewer than what's contained in font_. |
+ if (static_cast<size_t>(++m_fontIndex) > m_hfonts.size()) { |
+ const WebCore::FontData *fontData = m_font->fontDataAt(m_fontIndex); |
+ if (!fontData) { |
+ // Ran out of fonts. |
+ m_fontIndex = -1; |
+ return false; |
+ } |
- // TODO(ericroman): this won't work for SegmentedFontData |
- // http://b/issue?id=1007335 |
- const WebCore::SimpleFontData* simple_font_data = |
- font_data->fontDataForCharacter(' '); |
+ // TODO(ericroman): this won't work for SegmentedFontData |
+ // http://b/issue?id=1007335 |
+ const WebCore::SimpleFontData* simpleFontData = |
+ fontData->fontDataForCharacter(' '); |
- hfonts_->push_back(simple_font_data->platformData().hfont()); |
- script_caches_->push_back(simple_font_data->platformData().scriptCache()); |
- font_properties_->push_back(simple_font_data->platformData().scriptFontProperties()); |
- ascents_->push_back(simple_font_data->ascent()); |
- } |
+ m_hfonts.append(simpleFontData->platformData().hfont()); |
+ m_scriptCaches.append( |
+ simpleFontData->platformData().scriptCache()); |
+ m_fontProperties.append( |
+ simpleFontData->platformData().scriptFontProperties()); |
+ m_ascents.append(simpleFontData->ascent()); |
+ } |
- *hfont = hfonts_[font_index_ - 1]; |
- *script_cache = script_caches_[font_index_ - 1]; |
- *font_properties = font_properties_[font_index_ - 1]; |
- *ascent = ascents_[font_index_ - 1]; |
- return true; |
+ *hfont = m_hfonts[m_fontIndex - 1]; |
+ *scriptCache = m_scriptCaches[m_fontIndex - 1]; |
+ *fontProperties = m_fontProperties[m_fontIndex - 1]; |
+ *ascent = m_ascents[m_fontIndex - 1]; |
+ return true; |
} |
-void UniscribeStateTextRun::ResetFontIndex() { |
- font_index_ = 0; |
+void UniscribeHelperTextRun::ResetFontIndex() |
+{ |
+ m_fontIndex = 0; |
} |
+ |
+} // namespace WebCore |
Property changes on: webkit\port\platform\graphics\UniscribeHelperTextRun.cpp |
___________________________________________________________________ |
Added: svn:mergeinfo |
Merged /branches/chrome_webkit_merge_branch/src/webkit/port/platform/UniscribeStateTextRun.cpp:r3734-4217,4606-5108,5177-5263 |