| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 double contentsScaleFactor = 1.0; | 41 double contentsScaleFactor = 1.0; |
| 42 NPN_GetValue(NPNVcontentsScaleFactor, &contentsScaleFactor); | 42 NPN_GetValue(NPNVcontentsScaleFactor, &contentsScaleFactor); |
| 43 return contentsScaleFactor; | 43 return contentsScaleFactor; |
| 44 } | 44 } |
| 45 | 45 |
| 46 double cachedContentsScaleFactor() | 46 double cachedContentsScaleFactor() |
| 47 { | 47 { |
| 48 return m_cachedContentsScaleFactor; | 48 return m_cachedContentsScaleFactor; |
| 49 } | 49 } |
| 50 | 50 |
| 51 class ScriptableObject : public Object<ScriptableObject> { | 51 class ScriptableObject : public Object<ScriptableObject> { |
| 52 public: | 52 public: |
| 53 bool hasProperty(NPIdentifier propertyName) | 53 bool hasProperty(NPIdentifier propertyName) |
| 54 { | 54 { |
| 55 return identifierIs(propertyName, "contentsScaleFactor") | 55 return identifierIs(propertyName, "contentsScaleFactor") |
| 56 || identifierIs(propertyName, "cachedContentsScaleFactor"); | 56 || identifierIs(propertyName, "cachedContentsScaleFactor"); |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool getProperty(NPIdentifier propertyName, NPVariant* result) | 59 bool getProperty(NPIdentifier propertyName, NPVariant* result) |
| 60 { | 60 { |
| 61 if (identifierIs(propertyName, "contentsScaleFactor")) { | 61 if (identifierIs(propertyName, "contentsScaleFactor")) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 virtual NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc,
char* argn[], char* argv[], NPSavedData *saved) | 78 virtual NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc,
char* argn[], char* argv[], NPSavedData *saved) |
| 79 { | 79 { |
| 80 m_cachedContentsScaleFactor = contentsScaleFactor(); | 80 m_cachedContentsScaleFactor = contentsScaleFactor(); |
| 81 return NPERR_NO_ERROR; | 81 return NPERR_NO_ERROR; |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual NPError NPP_GetValue(NPPVariable variable, void* value) | 84 virtual NPError NPP_GetValue(NPPVariable variable, void* value) |
| 85 { | 85 { |
| 86 if (variable != NPPVpluginScriptableNPObject) | 86 if (variable != NPPVpluginScriptableNPObject) |
| 87 return NPERR_GENERIC_ERROR; | 87 return NPERR_GENERIC_ERROR; |
| 88 | 88 |
| 89 *(NPObject**)value = ScriptableObject::create(this); | 89 *(NPObject**)value = ScriptableObject::create(this); |
| 90 | 90 |
| 91 return NPERR_NO_ERROR; | 91 return NPERR_NO_ERROR; |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual NPError NPP_SetValue(NPNVariable variable, void* value) | 94 virtual NPError NPP_SetValue(NPNVariable variable, void* value) |
| 95 { | 95 { |
| 96 switch (variable) { | 96 switch (variable) { |
| 97 case NPNVcontentsScaleFactor: | 97 case NPNVcontentsScaleFactor: |
| 98 m_cachedContentsScaleFactor = *(double*)value; | 98 m_cachedContentsScaleFactor = *(double*)value; |
| 99 return NPERR_NO_ERROR; | 99 return NPERR_NO_ERROR; |
| 100 default: | 100 default: |
| 101 return NPERR_GENERIC_ERROR; | 101 return NPERR_GENERIC_ERROR; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 double m_cachedContentsScaleFactor; | 104 double m_cachedContentsScaleFactor; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 static PluginTest::Register<ContentsScaleFactor> contentsScaleFactor("contents-s
cale-factor"); | 107 static PluginTest::Register<ContentsScaleFactor> contentsScaleFactor("contents-s
cale-factor"); |
| OLD | NEW |